SOLR-2540: Fixing commitWithin tests which timed out (branch3x)

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/branches/branch_3x@1171139 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java b/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java
index 3acc9ba..b2dd1bb 100644
--- a/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java
+++ b/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java
@@ -28,7 +28,10 @@
 import org.apache.solr.handler.extraction.ExtractingParams;
 import org.apache.solr.handler.extraction.ExtractingRequestHandler;
 import org.apache.solr.request.LocalSolrQueryRequest;
+import org.apache.solr.handler.BufferingRequestProcessor;
+import org.apache.solr.request.SolrQueryRequest;
 import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.update.AddUpdateCommand;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Test;
@@ -39,6 +42,7 @@
  *
  **/
 public class ExtractingRequestHandlerTest extends SolrTestCaseJ4 {
+
   @BeforeClass
   public static void beforeClass() throws Exception {
     initCore("solrconfig.xml", "schema.xml", getFile("extraction/solr").getAbsolutePath());
@@ -289,21 +293,21 @@
   public void testCommitWithin() throws Exception {
     ExtractingRequestHandler handler = (ExtractingRequestHandler) h.getCore().getRequestHandler("/update/extract");
     assertTrue("handler is null and it shouldn't be", handler != null);
+    
+    SolrQueryRequest req = req("literal.id", "one",
+                               ExtractingParams.RESOURCE_NAME, "extraction/version_control.txt",
+                               "commitWithin", "200"
+                               );
+    SolrQueryResponse rsp = new SolrQueryResponse();
+    BufferingRequestProcessor p = new BufferingRequestProcessor(null);
 
-    // Load plain text specifying filename
-    loadLocal("extraction/version_control.txt", "fmap.created", "extractedDate", "fmap.producer", "extractedProducer",
-            "fmap.creator", "extractedCreator", "fmap.Keywords", "extractedKeywords",
-            "fmap.Author", "extractedAuthor",
-            "literal.id", "one",
-            "fmap.language", "extractedLanguage",
-            "fmap.content", "extractedContent",
-            ExtractingParams.RESOURCE_NAME, "extraction/version_control.txt",
-            "commitWithin", "200"
-    );
-    assertQ(req("id:one"), "//*[@numFound='0']");
-    // TODO: Find better way of testing commitWithin without sleeping?
-    Thread.sleep(1000);
-    assertQ(req("id:one"), "//*[@numFound='1']");
+    ExtractingDocumentLoader loader = (ExtractingDocumentLoader) handler.newLoader(req, p);
+    loader.load(req, rsp, new ContentStreamBase.FileStream(getFile("extraction/version_control.txt")));
+
+    AddUpdateCommand add = p.addCommands.get(0);
+    assertEquals(200, add.commitWithin);
+
+    req.close();
   }
 
   // Note: If you load a plain text file specifying neither MIME type nor filename, extraction will silently fail. This is because Tika's
diff --git a/solr/core/src/test/org/apache/solr/handler/BufferingRequestProcessor.java b/solr/core/src/test/org/apache/solr/handler/BufferingRequestProcessor.java
new file mode 100644
index 0000000..e8d7083
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/handler/BufferingRequestProcessor.java
@@ -0,0 +1,66 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.solr.update.AddUpdateCommand;
+import org.apache.solr.update.CommitUpdateCommand;
+import org.apache.solr.update.DeleteUpdateCommand;
+import org.apache.solr.update.RollbackUpdateCommand;
+import org.apache.solr.update.processor.UpdateRequestProcessor;
+
+public class BufferingRequestProcessor extends UpdateRequestProcessor
+{
+  public List<AddUpdateCommand> addCommands = new ArrayList<AddUpdateCommand>();
+  public List<DeleteUpdateCommand> deleteCommands = new ArrayList<DeleteUpdateCommand>();
+  public List<CommitUpdateCommand> commitCommands = new ArrayList<CommitUpdateCommand>();
+  public List<RollbackUpdateCommand> rollbackCommands = new ArrayList<RollbackUpdateCommand>();
+  
+  public BufferingRequestProcessor(UpdateRequestProcessor next) {
+    super(next);
+  }
+  
+  @Override
+  public void processAdd(AddUpdateCommand cmd) throws IOException {
+    addCommands.add( cmd );
+  }
+
+  @Override
+  public void processDelete(DeleteUpdateCommand cmd) throws IOException {
+    deleteCommands.add( cmd );
+  }
+
+  @Override
+  public void processCommit(CommitUpdateCommand cmd) throws IOException {
+    commitCommands.add( cmd );
+  }
+  
+  @Override
+  public void processRollback(RollbackUpdateCommand cmd) throws IOException
+  {
+    rollbackCommands.add( cmd );
+  }
+
+  @Override
+  public void finish() throws IOException {
+    // nothing?    
+  }
+}
diff --git a/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java b/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java
new file mode 100644
index 0000000..9ac4fc2
--- /dev/null
+++ b/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java
@@ -0,0 +1,54 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.solr.handler;
+
+import org.apache.solr.SolrTestCaseJ4;
+import org.apache.solr.common.util.ContentStreamBase;
+import org.apache.solr.request.SolrQueryRequest;
+import org.apache.solr.response.SolrQueryResponse;
+import org.apache.solr.update.AddUpdateCommand;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+
+public class CSVRequestHandlerTest extends SolrTestCaseJ4 {
+
+  @BeforeClass
+  public static void beforeClass() throws Exception {
+    initCore("solrconfig.xml", "schema.xml");
+  }
+
+  @Test
+  public void testCommitWithin() throws Exception {
+    CSVRequestHandler handler = new CSVRequestHandler();
+
+    String csvString = "id;name\n123;hello";
+    SolrQueryRequest req = req("separator", ";",
+                               "commitWithin", "200");
+    SolrQueryResponse rsp = new SolrQueryResponse();
+    BufferingRequestProcessor p = new BufferingRequestProcessor(null);
+
+    CSVLoader loader = (CSVLoader) handler.newLoader(req, p);
+    loader.load(req, rsp, new ContentStreamBase.StringStream.StringStream(csvString));
+
+    AddUpdateCommand add = p.addCommands.get(0);
+    assertEquals(200, add.commitWithin);
+
+    req.close();
+  }
+}
diff --git a/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java b/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java
index 0dab4df..c526a86 100644
--- a/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java
+++ b/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java
@@ -17,12 +17,6 @@
 
 package org.apache.solr.handler;
 
-import java.io.*;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.noggit.JSONParser;
-import org.apache.lucene.util.LuceneTestCase;
 import org.apache.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.SolrInputField;
@@ -32,8 +26,6 @@
 import org.apache.solr.update.AddUpdateCommand;
 import org.apache.solr.update.CommitUpdateCommand;
 import org.apache.solr.update.DeleteUpdateCommand;
-import org.apache.solr.update.RollbackUpdateCommand;
-import org.apache.solr.update.processor.UpdateRequestProcessor;
 import org.junit.BeforeClass;
 import org.junit.Test;
 
@@ -205,42 +197,3 @@
   }
 
 }
-
-
-class BufferingRequestProcessor extends UpdateRequestProcessor
-{
-  List<AddUpdateCommand> addCommands = new ArrayList<AddUpdateCommand>();
-  List<DeleteUpdateCommand> deleteCommands = new ArrayList<DeleteUpdateCommand>();
-  List<CommitUpdateCommand> commitCommands = new ArrayList<CommitUpdateCommand>();
-  List<RollbackUpdateCommand> rollbackCommands = new ArrayList<RollbackUpdateCommand>();
-  
-  public BufferingRequestProcessor(UpdateRequestProcessor next) {
-    super(next);
-  }
-  
-  @Override
-  public void processAdd(AddUpdateCommand cmd) throws IOException {
-    addCommands.add( cmd );
-  }
-
-  @Override
-  public void processDelete(DeleteUpdateCommand cmd) throws IOException {
-    deleteCommands.add( cmd );
-  }
-
-  @Override
-  public void processCommit(CommitUpdateCommand cmd) throws IOException {
-    commitCommands.add( cmd );
-  }
-  
-  @Override
-  public void processRollback(RollbackUpdateCommand cmd) throws IOException
-  {
-    rollbackCommands.add( cmd );
-  }
-
-  @Override
-  public void finish() throws IOException {
-    // nothing?    
-  }
-}
diff --git a/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java b/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java
index 48a1c90..fd48401 100755
--- a/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java
+++ b/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java
@@ -113,15 +113,6 @@
   }
 
   @Test
-  public void testCommitWithin() throws Exception {
-    makeFile("id\n100\n101\n102");
-    loadLocal("stream.file",filename,"commitWithin","200");
-    assertQ(req("id:[100 TO 110]"),"//*[@numFound='0']");
-    Thread.sleep(1000);
-    assertQ(req("id:[100 TO 110]"),"//*[@numFound='3']");
-  }
-
-  @Test
   public void testCommitTrue() throws Exception {
     makeFile("id\n100\n101\n102");
     loadLocal("stream.file",filename,"commit","true");