SOLR-1092 followup -- Import never happened at all

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@819170 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Shalin Shekhar Mangar 2009-09-26 16:47:35 +00:00
parent 70fa2e4d0e
commit dc5f441fae
2 changed files with 39 additions and 1 deletions

View File

@ -389,7 +389,7 @@ public class DataImporter {
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);

View File

@ -131,6 +131,44 @@ public class TestDocBuilder {
}
}
@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 {