lucene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jd...@apache.org
Subject svn commit: r1407549 - in /lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport: AbstractDIHJdbcTestCase.java TestSqlEntityProcessorDelta.java
Date Fri, 09 Nov 2012 17:22:51 GMT
Author: jdyer
Date: Fri Nov  9 17:22:51 2012
New Revision: 1407549

URL: http://svn.apache.org/viewvc?rev=1407549&view=rev
Log:
SOLR-3856: Improve tests for SqlEntityProcessor

Modified:
    lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/AbstractDIHJdbcTestCase.java
    lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java

Modified: lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/AbstractDIHJdbcTestCase.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/AbstractDIHJdbcTestCase.java?rev=1407549&r1=1407548&r2=1407549&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/AbstractDIHJdbcTestCase.java
(original)
+++ lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/AbstractDIHJdbcTestCase.java
Fri Nov  9 17:22:51 2012
@@ -37,7 +37,7 @@ import org.junit.AfterClass;
 import org.junit.Before;
 import org.junit.BeforeClass;
 /**
- * This sets up an in-memory Derby Sql database with a little sample data.
+ * This sets up an in-memory Sql database with a little sample data.
  */
 public abstract class AbstractDIHJdbcTestCase extends AbstractDataImportHandlerTestCase {
   //Start with "true" so the first test run will populate the data.
@@ -99,14 +99,20 @@ public abstract class AbstractDIHJdbcTes
   }
   protected void singleEntity(int numToExpect) throws Exception {
     h.query("/dataimport", generateRequest());
-    assertQ(req("*:*"), "//*[@numFound='" + totalPeople() + "']");    
-    Assert.assertTrue(totalDatabaseRequests() == numToExpect);
+    assertQ("There should be 1 document per person in the database: "
+        + totalPeople(), req("*:*"), "//*[@numFound='" + totalPeople() + "']");
+    Assert.assertTrue("Expecting " + numToExpect
+        + " database calls, but DIH reported " + totalDatabaseRequests(),
+        totalDatabaseRequests() == numToExpect);
   }
   protected void simpleTransform(int numToExpect) throws Exception {
     rootTransformerName = "AddAColumnTransformer";
     h.query("/dataimport", generateRequest());
-    assertQ(req("AddAColumn_s:Added"), "//*[@numFound='" + totalPeople() + "']");
-    Assert.assertTrue(totalDatabaseRequests() == numToExpect);
+    assertQ("There should be 1 document with a transformer-added column per person is the
database: "
+        + totalPeople(), req("AddAColumn_s:Added"), "//*[@numFound='" + totalPeople() + "']");
+    Assert.assertTrue("Expecting " + numToExpect
+        + " database calls, but DIH reported " + totalDatabaseRequests(),
+        totalDatabaseRequests() == numToExpect);
   }
   /**
    * A delta update will not clean up documents added by a transformer
@@ -116,16 +122,19 @@ public abstract class AbstractDIHJdbcTes
   protected void complexTransform(int numToExpect, int numDeleted) throws Exception {
     rootTransformerName = "TripleThreatTransformer";
     h.query("/dataimport", generateRequest());
-    assertQ(req("q", "*:*", "rows", "" + (totalPeople() * 3), "sort", "id asc"), "//*[@numFound='"
+ ((totalPeople() * 3) + (numDeleted * 2)) + "']");
-    assertQ(req("id:TripleThreat-1-*"), "//*[@numFound='" + (totalPeople() + numDeleted)
+ "']");
-    assertQ(req("id:TripleThreat-2-*"), "//*[@numFound='" + (totalPeople() + numDeleted)
+ "']");
-    if(personNameExists("Michael") && countryCodeExists("NR") && countryCodeExists("RN"))
+    int totalDocs = ((totalPeople() * 3) + (numDeleted * 2));
+    int totalAddedDocs = (totalPeople() + numDeleted);
+    assertQ(req("q", "*:*", "rows", "" + (totalPeople() * 3), "sort", "id asc"), "//*[@numFound='"
+ totalDocs + "']");
+    assertQ(req("id:TripleThreat-1-*"), "//*[@numFound='" + totalAddedDocs + "']");
+    assertQ(req("id:TripleThreat-2-*"), "//*[@numFound='" + totalAddedDocs + "']");
+    if(personNameExists("Michael") && countryCodeExists("NR"))
     {
       assertQ(
+          "Michael and NR are assured to be in the database.  Therefore the transformer should
have added leahciM and RN on the same document as id:TripleThreat-1-3",
           req("+id:TripleThreat-1-3 +NAME_mult_s:Michael +NAME_mult_s:leahciM  +COUNTRY_CODES_mult_s:NR
+COUNTRY_CODES_mult_s:RN"),
           "//*[@numFound='1']");
     }
-    assertQ(req("AddAColumn_s:Added"), "//*[@numFound='" + (totalPeople() + numDeleted) +
"']");
+    assertQ(req("AddAColumn_s:Added"), "//*[@numFound='" + totalAddedDocs + "']");
     Assert.assertTrue("Expecting " + numToExpect
         + " database calls, but DIH reported " + totalDatabaseRequests(),
         totalDatabaseRequests() == numToExpect);
@@ -177,9 +186,11 @@ public abstract class AbstractDIHJdbcTes
     }
     h.query("/dataimport", generateRequest());
     
-    assertQ(req("*:*"), "//*[@numFound='" + (totalPeople()) + "']");
+    assertQ("There should be 1 document per person in the database: "
+        + totalPeople(), req("*:*"), "//*[@numFound='" + (totalPeople()) + "']");
     if(!underlyingDataModified && "AddAColumnTransformer".equals(rootTransformerName))
{
-      assertQ(req("AddAColumn_s:Added"), "//*[@numFound='" + (totalPeople()) + "']");
+      assertQ("There should be 1 document with a transformer-added column per person is the
database: "
+          + totalPeople(), req("AddAColumn_s:Added"), "//*[@numFound='" + (totalPeople())
+ "']");
     }
     if(countryEntity) {
       if(personNameExists("Jayden"))

Modified: lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java
URL: http://svn.apache.org/viewvc/lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java?rev=1407549&r1=1407548&r2=1407549&view=diff
==============================================================================
--- lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java
(original)
+++ lucene/dev/branches/branch_4x/solr/contrib/dataimporthandler/src/test/org/apache/solr/handler/dataimport/TestSqlEntityProcessorDelta.java
Fri Nov  9 17:22:51 2012
@@ -1,6 +1,11 @@
 package org.apache.solr.handler.dataimport;
 
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Locale;
+
 import org.apache.solr.request.LocalSolrQueryRequest;
+import org.junit.Assume;
 import org.junit.Before;
 import org.junit.Ignore;
 import org.junit.Test;
@@ -25,13 +30,20 @@ import org.junit.Test;
 /**
  * Test with various combinations of parameters, child entites, transformers.
  */
-@Ignore("Investigate failures on Policeman Jenkins Linux")
 public class TestSqlEntityProcessorDelta extends AbstractDIHJdbcTestCase {
   private boolean delta = false;
   private boolean useParentDeltaQueryParam = false;
   private IntChanges personChanges = null;
   private String[] countryChanges = null;
   
+  //TODO:  remove this on fixing SOLR-4051 / SOLR-1916
+  private void assumeIncomaptibleLocale() {
+    Date d = new Date();
+    String badDateFormat = DataImporter.DATE_TIME_FORMAT.get().format(d);
+    String betterDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss", Locale.ROOT).format(d);
+    Assume.assumeTrue(badDateFormat.equals(betterDateFormat));    
+  }
+  
   @Before
   public void setupDeltaTest() {
     delta = false;
@@ -40,6 +52,7 @@ public class TestSqlEntityProcessorDelta
   }
   @Test
   public void testSingleEntity() throws Exception {
+    assumeIncomaptibleLocale();
     singleEntity(1);
     changeStuff();
     int c = calculateDatabaseCalls();
@@ -48,6 +61,7 @@ public class TestSqlEntityProcessorDelta
   }
   @Test
   public void testWithSimpleTransformer() throws Exception {
+    assumeIncomaptibleLocale();
     simpleTransform(1);  
     changeStuff();
     simpleTransform(calculateDatabaseCalls());  
@@ -55,6 +69,7 @@ public class TestSqlEntityProcessorDelta
   }
   @Test
   public void testWithComplexTransformer() throws Exception {
+    assumeIncomaptibleLocale();
     complexTransform(1, 0);
     changeStuff();
     complexTransform(calculateDatabaseCalls(), personChanges.deletedKeys.length);
@@ -62,6 +77,7 @@ public class TestSqlEntityProcessorDelta
   }
   @Test
   public void testChildEntities() throws Exception {
+    assumeIncomaptibleLocale();
     useParentDeltaQueryParam = random().nextBoolean();
     withChildEntities(false, true);
     changeStuff();



Mime
View raw message