当前位置: 首页>>代码示例>>Java>>正文


Java DIHConfiguration类代码示例

本文整理汇总了Java中org.apache.solr.handler.dataimport.config.DIHConfiguration的典型用法代码示例。如果您正苦于以下问题:Java DIHConfiguration类的具体用法?Java DIHConfiguration怎么用?Java DIHConfiguration使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DIHConfiguration类属于org.apache.solr.handler.dataimport.config包,在下文中一共展示了DIHConfiguration类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: singleEntityNoRows

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void singleEntityNoRows() {
  DataImporter di = new DataImporter();
  di.loadAndInit(dc_singleEntity);
  DIHConfiguration cfg = di.getConfig();
  Entity ent = cfg.getEntities().get(0);
  MockDataSource.setIterator("select * from x", new ArrayList<Map<String, Object>>().iterator());
  RequestInfo rp = new RequestInfo(null, createMap("command", "full-import"), null);
  SolrWriterImpl swi = new SolrWriterImpl();
  di.runCmd(rp, swi);
  assertEquals(Boolean.TRUE, swi.deleteAllCalled);
  assertEquals(Boolean.TRUE, 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());
}
 
开发者ID:europeana,项目名称:search,代码行数:19,代码来源:TestDocBuilder.java

示例2: testDeltaImportNoRows_MustNotCommit

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void testDeltaImportNoRows_MustNotCommit() {
  DataImporter di = new DataImporter();
  di.loadAndInit(dc_deltaConfig);
  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());
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:TestDocBuilder.java

示例3: testCheckScript

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void testCheckScript() throws Exception {
  try {
    DocumentBuilder builder = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(xml)));
    DataImporter di = new DataImporter();
    DIHConfiguration dc = di.readFromXml(document);
    Context c = getContext("checkNextToken", dc.getScript().getText());

    Map map = new HashMap();
    map.put("nextToken", "hello");
    EntityProcessorWrapper sep = new EntityProcessorWrapper(new SqlEntityProcessor(), null, null);
    sep.init(c);
    sep.applyTransformer(map);
    assertEquals("true", map.get("$hasMore"));
    map = new HashMap();
    map.put("nextToken", "");
    sep.applyTransformer(map);
    assertNull(map.get("$hasMore"));
  } catch (DataImportHandlerException e) {    
    assumeFalse("This JVM does not have JavaScript installed.  Test Skipped.", e
        .getMessage().startsWith("Cannot load Script Engine for language"));
    throw e;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:27,代码来源:TestScriptTransformer.java

示例4: singleEntityNoRows

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void singleEntityNoRows() {
  DataImporter di = new DataImporter();
  di.loadAndInit(dc_singleEntity);
  DIHConfiguration cfg = di.getConfig();
  Entity ent = cfg.getEntities().get(0);
  MockDataSource.setIterator("select * from x", new ArrayList<Map<String, Object>>().iterator());
  RequestInfo rp = new RequestInfo(createMap("command", "full-import"), null);
  SolrWriterImpl swi = new SolrWriterImpl();
  di.runCmd(rp, swi);
  assertEquals(Boolean.TRUE, swi.deleteAllCalled);
  assertEquals(Boolean.TRUE, 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());
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:19,代码来源:TestDocBuilder.java

示例5: testDeltaImportNoRows_MustNotCommit

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void testDeltaImportNoRows_MustNotCommit() {
  DataImporter di = new DataImporter();
  di.loadAndInit(dc_deltaConfig);
  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(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());
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:20,代码来源:TestDocBuilder.java

示例6: testCheckScript

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void testCheckScript() throws Exception {
  try {
    DocumentBuilder builder = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(xml)));
    DataImporter di = new DataImporter();
    DIHConfiguration dc = di.readFromXml(document);
    Context c = getContext("checkNextToken", dc.getScript().getText());

    Map map = new HashMap();
    map.put("nextToken", "hello");
    EntityProcessorWrapper sep = new EntityProcessorWrapper(new SqlEntityProcessor(), null, null);
    sep.init(c);
    sep.applyTransformer(map);
    assertEquals("true", map.get("$hasMore"));
    map = new HashMap();
    map.put("nextToken", "");
    sep.applyTransformer(map);
    assertNull(map.get("$hasMore"));
  } catch (DataImportHandlerException e) {    
    assumeFalse("This JVM does not have Rhino installed.  Test Skipped.", e
        .getMessage().startsWith("Cannot load Script Engine for language"));
    throw e;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:27,代码来源:TestScriptTransformer.java

示例7: singleEntityOneRow

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void singleEntityOneRow() {
  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", "full-import"), null);
  SolrWriterImpl swi = new SolrWriterImpl();
  di.runCmd(rp, swi);
  assertEquals(Boolean.TRUE, 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 = l.get(i);
    SolrInputDocument doc = swi.docs.get(i);
    for (Map.Entry<String, Object> entry : map.entrySet()) {
      assertEquals(entry.getValue(), doc.getFieldValue(entry.getKey()));
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:TestDocBuilder.java

示例8: testImportCommand

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@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()));
    }
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:29,代码来源:TestDocBuilder.java

示例9: singleEntityMultipleRows

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void singleEntityMultipleRows() {
  DataImporter di = new DataImporter();
  di.loadAndInit(dc_singleEntity);
  DIHConfiguration cfg = di.getConfig();
  Entity ent = cfg.getEntities().get(0);
  RequestInfo rp = new RequestInfo(null, createMap("command", "full-import"), null);
  List<Map<String, Object>> l = new ArrayList<>();
  l.add(createMap("id", 1, "desc", "one"));
  l.add(createMap("id", 2, "desc", "two"));
  l.add(createMap("id", 3, "desc", "three"));

  MockDataSource.setIterator("select * from x", l.iterator());
  SolrWriterImpl swi = new SolrWriterImpl();
  di.runCmd(rp, swi);
  assertEquals(Boolean.TRUE, swi.deleteAllCalled);
  assertEquals(Boolean.TRUE, swi.commitCalled);
  assertEquals(Boolean.TRUE, swi.finishCalled);
  assertEquals(3, swi.docs.size());
  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()));
    }
    assertEquals(map.get("desc"), doc.getFieldValue("desc_s"));
  }
  assertEquals(1, di.getDocBuilder().importStatistics.queryCount.get());
  assertEquals(3, di.getDocBuilder().importStatistics.docCount.get());
  assertEquals(3, di.getDocBuilder().importStatistics.rowsCount.get());
}
 
开发者ID:europeana,项目名称:search,代码行数:32,代码来源:TestDocBuilder.java

示例10: testReadScriptTag

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void testReadScriptTag() throws Exception {
  try {
    DocumentBuilder builder = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(xml)));
    DataImporter di = new DataImporter();
    DIHConfiguration dc = di.readFromXml(document);
    assertTrue(dc.getScript().getText().indexOf("checkNextToken") > -1);
  } catch (DataImportHandlerException e) {    
    assumeFalse("This JVM does not have JavaScript installed.  Test Skipped.", e
        .getMessage().startsWith("Cannot load Script Engine for language"));
    throw e;
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:16,代码来源:TestScriptTransformer.java

示例11: testBasic

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void testBasic() throws Exception {
  javax.xml.parsers.DocumentBuilder builder = DocumentBuilderFactory
          .newInstance().newDocumentBuilder();
  Document doc = builder.parse(new InputSource(new StringReader(xml)));
  DataImporter di = new DataImporter();
  DIHConfiguration dc = di.readFromXml(doc);
  assertEquals("atrimlisting", dc.getEntities().get(0).getName());
}
 
开发者ID:europeana,项目名称:search,代码行数:10,代码来源:TestDataConfig.java

示例12: singleEntityOneRow

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void singleEntityOneRow() {
  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<Map<String, Object>>();
  l.add(createMap("id", 1, "desc", "one"));
  MockDataSource.setIterator("select * from x", l.iterator());
  RequestInfo rp = new RequestInfo(createMap("command", "full-import"), null);
  SolrWriterImpl swi = new SolrWriterImpl();
  di.runCmd(rp, swi);
  assertEquals(Boolean.TRUE, 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 = l.get(i);
    SolrInputDocument doc = swi.docs.get(i);
    for (Map.Entry<String, Object> entry : map.entrySet()) {
      assertEquals(entry.getValue(), doc.getFieldValue(entry.getKey()));
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:29,代码来源:TestDocBuilder.java

示例13: testImportCommand

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@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<Map<String, Object>>();
  l.add(createMap("id", 1, "desc", "one"));
  MockDataSource.setIterator("select * from x", l.iterator());
  RequestInfo rp = new RequestInfo(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()));
    }
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:29,代码来源:TestDocBuilder.java

示例14: singleEntityMultipleRows

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void singleEntityMultipleRows() {
  DataImporter di = new DataImporter();
  di.loadAndInit(dc_singleEntity);
  DIHConfiguration cfg = di.getConfig();
  Entity ent = cfg.getEntities().get(0);
  RequestInfo rp = new RequestInfo(createMap("command", "full-import"), null);
  List<Map<String, Object>> l = new ArrayList<Map<String, Object>>();
  l.add(createMap("id", 1, "desc", "one"));
  l.add(createMap("id", 2, "desc", "two"));
  l.add(createMap("id", 3, "desc", "three"));

  MockDataSource.setIterator("select * from x", l.iterator());
  SolrWriterImpl swi = new SolrWriterImpl();
  di.runCmd(rp, swi);
  assertEquals(Boolean.TRUE, swi.deleteAllCalled);
  assertEquals(Boolean.TRUE, swi.commitCalled);
  assertEquals(Boolean.TRUE, swi.finishCalled);
  assertEquals(3, swi.docs.size());
  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()));
    }
    assertEquals(map.get("desc"), doc.getFieldValue("desc_s"));
  }
  assertEquals(1, di.getDocBuilder().importStatistics.queryCount.get());
  assertEquals(3, di.getDocBuilder().importStatistics.docCount.get());
  assertEquals(3, di.getDocBuilder().importStatistics.rowsCount.get());
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:32,代码来源:TestDocBuilder.java

示例15: testReadScriptTag

import org.apache.solr.handler.dataimport.config.DIHConfiguration; //导入依赖的package包/类
@Test
public void testReadScriptTag() throws Exception {
  try {
    DocumentBuilder builder = DocumentBuilderFactory.newInstance()
            .newDocumentBuilder();
    Document document = builder.parse(new InputSource(new StringReader(xml)));
    DataImporter di = new DataImporter();
    DIHConfiguration dc = di.readFromXml(document);
    assertTrue(dc.getScript().getText().indexOf("checkNextToken") > -1);
  } catch (DataImportHandlerException e) {    
    assumeFalse("This JVM does not have Rhino installed.  Test Skipped.", e
        .getMessage().startsWith("Cannot load Script Engine for language"));
    throw e;
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:16,代码来源:TestScriptTransformer.java


注:本文中的org.apache.solr.handler.dataimport.config.DIHConfiguration类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。