use of org.apache.solr.handler.dataimport.config.Entity in project lucene-solr by apache.
the class TestMailEntityProcessor method testFetchTimeSince.
@Test
@Ignore("Needs a Mock Mail Server to work")
public void testFetchTimeSince() throws ParseException {
paramMap.put("folders", "top1/child11");
paramMap.put("recurse", "true");
paramMap.put("processAttachement", "false");
paramMap.put("fetchMailsSince", "2008-12-26 00:00:00");
DataImporter di = new DataImporter();
di.loadAndInit(getConfigFromMap(paramMap));
Entity ent = di.getConfig().getEntities().get(0);
RequestInfo rp = new RequestInfo(null, createMap("command", "full-import"), null);
SolrWriterImpl swi = new SolrWriterImpl();
di.runCmd(rp, swi);
assertEquals("top2 and its direct children did not return 3 messages", swi.docs.size(), 3);
}
use of org.apache.solr.handler.dataimport.config.Entity in project lucene-solr by apache.
the class TestMailEntityProcessor method testConnection.
@Test
@Ignore("Needs a Mock Mail Server to work")
public void testConnection() {
// also tests recurse = false and default settings
paramMap.put("folders", "top2");
paramMap.put("recurse", "false");
paramMap.put("processAttachement", "false");
DataImporter di = new DataImporter();
di.loadAndInit(getConfigFromMap(paramMap));
Entity ent = di.getConfig().getEntities().get(0);
RequestInfo rp = new RequestInfo(null, createMap("command", "full-import"), null);
SolrWriterImpl swi = new SolrWriterImpl();
di.runCmd(rp, swi);
assertEquals("top1 did not return 2 messages", swi.docs.size(), 2);
}
use of org.apache.solr.handler.dataimport.config.Entity in project lucene-solr by apache.
the class TestMailEntityProcessor method testInclude.
@Test
@Ignore("Needs a Mock Mail Server to work")
public void testInclude() {
paramMap.put("folders", "top2");
paramMap.put("recurse", "true");
paramMap.put("processAttachement", "false");
paramMap.put("include", ".*grandchild.*");
DataImporter di = new DataImporter();
di.loadAndInit(getConfigFromMap(paramMap));
Entity ent = di.getConfig().getEntities().get(0);
RequestInfo rp = new RequestInfo(null, createMap("command", "full-import"), null);
SolrWriterImpl swi = new SolrWriterImpl();
di.runCmd(rp, swi);
assertEquals("top2 and its direct children did not return 3 messages", swi.docs.size(), 3);
}
use of org.apache.solr.handler.dataimport.config.Entity in project lucene-solr by apache.
the class TestDocBuilder method testImportCommand.
@Test
public void testImportCommand() {
DataImporter di = new DataImporter();
di.loadAndInit(dc_singleEntity);
DIHConfiguration cfg = di.getConfig();
Entity ent = cfg.getEntities().get(0);
List<Map<String, Object>> l = new ArrayList<>();
l.add(createMap("id", 1, "desc", "one"));
MockDataSource.setIterator("select * from x", l.iterator());
RequestInfo rp = new RequestInfo(null, createMap("command", "import"), null);
SolrWriterImpl swi = new SolrWriterImpl();
di.runCmd(rp, swi);
assertEquals(Boolean.FALSE, swi.deleteAllCalled);
assertEquals(Boolean.TRUE, swi.commitCalled);
assertEquals(Boolean.TRUE, swi.finishCalled);
assertEquals(1, swi.docs.size());
assertEquals(1, di.getDocBuilder().importStatistics.queryCount.get());
assertEquals(1, di.getDocBuilder().importStatistics.docCount.get());
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()) {
assertEquals(entry.getValue(), doc.getFieldValue(entry.getKey()));
}
}
}
use of org.apache.solr.handler.dataimport.config.Entity in project lucene-solr by apache.
the class TestDocBuilder method testDeltaImportNoRows_MustNotCommit.
@Test
public void testDeltaImportNoRows_MustNotCommit() {
DataImporter di = new DataImporter();
di.loadAndInit(dc_deltaConfig);
redirectTempProperties(di);
DIHConfiguration cfg = di.getConfig();
Entity ent = cfg.getEntities().get(0);
MockDataSource.setIterator("select * from x", new ArrayList<Map<String, Object>>().iterator());
MockDataSource.setIterator("select id from x", new ArrayList<Map<String, Object>>().iterator());
RequestInfo rp = new RequestInfo(null, createMap("command", "delta-import"), null);
SolrWriterImpl swi = new SolrWriterImpl();
di.runCmd(rp, swi);
assertEquals(Boolean.FALSE, swi.deleteAllCalled);
assertEquals(Boolean.FALSE, swi.commitCalled);
assertEquals(Boolean.TRUE, swi.finishCalled);
assertEquals(0, swi.docs.size());
assertEquals(1, di.getDocBuilder().importStatistics.queryCount.get());
assertEquals(0, di.getDocBuilder().importStatistics.docCount.get());
assertEquals(0, di.getDocBuilder().importStatistics.rowsCount.get());
}
Aggregations