lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jan...@apache.org
Subject svn commit: r1171138 - in /lucene/dev/trunk/solr: contrib/extraction/src/test/org/apache/solr/handler/extraction/ core/src/test/org/apache/solr/handler/
Date Thu, 15 Sep 2011 15:29:35 GMT
Author: janhoy
Date: Thu Sep 15 15:29:35 2011
New Revision: 1171138

URL: http://svn.apache.org/viewvc?rev=1171138&view=rev
Log:
SOLR-2540: Fixing commitWithin tests which timed out

Added:
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/BufferingRequestProcessor.java
  (with props)
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java
  (with props)
Modified:
    lucene/dev/trunk/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java
    lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java

Modified: lucene/dev/trunk/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java?rev=1171138&r1=1171137&r2=1171138&view=diff
==============================================================================
--- lucene/dev/trunk/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java
(original)
+++ lucene/dev/trunk/solr/contrib/extraction/src/test/org/apache/solr/handler/extraction/ExtractingRequestHandlerTest.java
Thu Sep 15 15:29:35 2011
@@ -28,7 +28,10 @@ import org.apache.solr.handler.extractio
 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 @@ import org.junit.Test;
  *
  **/
 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 class ExtractingRequestHandlerTes
   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

Added: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/BufferingRequestProcessor.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/BufferingRequestProcessor.java?rev=1171138&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/BufferingRequestProcessor.java
(added)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/BufferingRequestProcessor.java
Thu Sep 15 15:29:35 2011
@@ -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?    
+  }
+}

Added: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java?rev=1171138&view=auto
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java
(added)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/CSVRequestHandlerTest.java
Thu Sep 15 15:29:35 2011
@@ -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();
+  }
+}

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java?rev=1171138&r1=1171137&r2=1171138&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/JsonLoaderTest.java Thu Sep
15 15:29:35 2011
@@ -17,11 +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.solr.SolrTestCaseJ4;
 import org.apache.solr.common.SolrInputDocument;
 import org.apache.solr.common.SolrInputField;
@@ -31,8 +26,6 @@ import org.apache.solr.response.SolrQuer
 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;
 
@@ -199,43 +192,4 @@ public class JsonLoaderTest extends Solr
     );
   }
 
-}
-
-
-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?    
-  }
-}
+}
\ No newline at end of file

Modified: lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java
URL: http://svn.apache.org/viewvc/lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java?rev=1171138&r1=1171137&r2=1171138&view=diff
==============================================================================
--- lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java (original)
+++ lucene/dev/trunk/solr/core/src/test/org/apache/solr/handler/TestCSVLoader.java Thu Sep
15 15:29:35 2011
@@ -114,15 +114,6 @@ public class TestCSVLoader extends SolrT
   }
 
   @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");



Mime
View raw message