lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From sha...@apache.org
Subject svn commit: r819170 - in /lucene/solr/trunk/contrib/dataimporthandler/src: main/java/org/apache/solr/handler/dataimport/DataImporter.java test/java/org/apache/solr/handler/dataimport/TestDocBuilder.java
Date Sat, 26 Sep 2009 16:47:36 GMT
Author: shalin
Date: Sat Sep 26 16:47:35 2009
New Revision: 819170

URL: http://svn.apache.org/viewvc?rev=819170&view=rev
Log:
SOLR-1092 followup -- Import never happened at all

Modified:
    lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java
    lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder.java

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java?rev=819170&r1=819169&r2=819170&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/main/java/org/apache/solr/handler/dataimport/DataImporter.java
Sat Sep 26 16:47:35 2009
@@ -389,7 +389,7 @@
     try {
       Date lastModified = sw.loadIndexStartTime();
       setLastIndexTime(lastModified);
-      if (command.equals("full-import")) {
+      if (FULL_IMPORT_CMD.equals(command) || IMPORT_CMD.equals(command)) {
         doFullImport(sw, reqParams);
       } else if (command.equals(DELTA_IMPORT_CMD)) {
         doDeltaImport(sw, reqParams);

Modified: lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder.java
URL: http://svn.apache.org/viewvc/lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder.java?rev=819170&r1=819169&r2=819170&view=diff
==============================================================================
--- lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder.java
(original)
+++ lucene/solr/trunk/contrib/dataimporthandler/src/test/java/org/apache/solr/handler/dataimport/TestDocBuilder.java
Sat Sep 26 16:47:35 2009
@@ -132,6 +132,44 @@
   }
 
   @Test
+  public void testImportCommand() {
+    try {
+      DataImporter di = new DataImporter();
+      di.loadDataConfig(dc_singleEntity);
+      DataConfig cfg = di.getConfig();
+      DataConfig.Entity ent = cfg.document.entities.get(0);
+      List l = new ArrayList();
+      l.add(createMap("id", 1, "desc", "one"));
+      MockDataSource.setIterator("select * from x", l.iterator());
+      ent.dataSrc = new MockDataSource();
+      ent.isDocRoot = true;
+      DataImporter.RequestParams rp = new DataImporter.RequestParams(createMap("command",
"import"));
+      SolrWriterImpl swi = new SolrWriterImpl();
+      di.runCmd(rp, swi);
+      Assert.assertEquals(Boolean.FALSE, swi.deleteAllCalled);
+      Assert.assertEquals(Boolean.TRUE, swi.commitCalled);
+      Assert.assertEquals(1, swi.docs.size());
+      Assert.assertEquals(1, di.getDocBuilder().importStatistics.queryCount
+              .get());
+      Assert
+              .assertEquals(1, di.getDocBuilder().importStatistics.docCount.get());
+      Assert.assertEquals(1, di.getDocBuilder().importStatistics.rowsCount
+              .get());
+
+      for (int i = 0; i < l.size(); i++) {
+        Map<String, Object> map = (Map<String, Object>) l.get(i);
+        SolrInputDocument doc = swi.docs.get(i);
+        for (Map.Entry<String, Object> entry : map.entrySet()) {
+          Assert.assertEquals(entry.getValue(), doc.getFieldValue(entry
+                  .getKey()));
+        }
+      }
+    } finally {
+      MockDataSource.clearCache();
+    }
+  }
+
+  @Test
   public void singleEntityMultipleRows() {
     try {
       DataImporter di = new DataImporter();



Mime
View raw message