Exemplo n.º 1
0
  @Before
  public void setUp() throws Exception {
    indexer = new Indexer(new File(TEST_RESOURCES_OBJECTS));
    indexer.init();

    indexer.setCreateIndex(true);
    indexer.prepareIndex();
    indexer.getIndexingReport().clear();

    LocationHelper.getLocation("escidoc_persistent22");
  }
Exemplo n.º 2
0
  // Tests index append mode
  @Test
  public void testIndexWriteMode() throws Exception {
    indexer.indexItemsStart(new File(TEST_RESOURCES_OBJECTS + "escidoc_2120373"));
    indexer.finalizeIndex();

    Properties properties = new Properties();
    InputStream s = getClass().getClassLoader().getResourceAsStream("indexer.properties");

    if (s != null) {
      properties.load(s);
    } else {
      throw new FileNotFoundException("Properties not found ");
    }

    assertTrue(indexer.getIndexWriter().maxDoc() == 1);

    // add one index document more
    indexer = new Indexer(new File(TEST_RESOURCES_OBJECTS));
    indexer.init();
    indexer.setCreateIndex(false);
    indexer.prepareIndex();
    indexer.indexItemsStart(new File(TEST_RESOURCES_OBJECTS + "escidoc_2111711"));
    indexer.finalizeIndex();
    assertTrue(
        "Found " + indexer.getIndexWriter().maxDoc(), indexer.getIndexWriter().maxDoc() == 2);

    // and again
    indexer = new Indexer(new File(TEST_RESOURCES_OBJECTS));
    indexer.init();
    indexer.setCreateIndex(false);
    indexer.prepareIndex();
    indexer.indexItemsStart(new File(TEST_RESOURCES_OBJECTS + "escidoc_2110486"));
    indexer.finalizeIndex();
    assertTrue(
        "Found " + indexer.getIndexWriter().maxDoc(), indexer.getIndexWriter().maxDoc() == 3);
  }