@Test
public void testIndexesWork() throws Exception {
// Index should be added the descriptor and thus end up in the CAS generated from the
// analysis engine.
AnalysisEngine desc = createEngine(IndexTestComponent.class);
JCas jcas = desc.newJCas();
Token token1 = new Token(jcas, 1, 2);
token1.addToIndexes();
// index1 is a sorted index, so when adding a token twice, both remain in the index
Token token2 = new Token(jcas, 3, 4);
token2.addToIndexes();
token2.addToIndexes();
Sentence sentence1 = new Sentence(jcas, 1, 2);
sentence1.addToIndexes();
// index2 is a set index, so even when adding a sentence twice, only one remains in the index
Sentence sentence2 = new Sentence(jcas, 3, 4);
sentence2.addToIndexes();
sentence2.addToIndexes();
FSIndex<FeatureStructure> index1 = jcas.getFSIndexRepository().getIndex("index1");
FSIndex<FeatureStructure> index2 = jcas.getFSIndexRepository().getIndex("index2");
assertEquals(3, index1.size());
assertEquals(2, index2.size());
// AnalysisEngine dumpWriter = createPrimitive(CASDumpWriter.class);