@Test
public void test() throws ResourceInitializationException, IOException, InvalidXMLException,
AnalysisEngineProcessException, ResourceConfigurationException {
final String name = getClass().getSimpleName();
final String namespace = getClass().getPackage().getName();
final AnalysisEngine ae = createAE(namespace + "." + name);
List<ResourceMetaData> metaData = new ArrayList<ResourceMetaData>();
metaData.add(ae.getMetaData());
String input = "This is a test.";
Type t1 = null;
// create a cas and apply rules
final CAS cas = CasCreationUtils.createCas(metaData);
cas.setDocumentText(input);
SimplePipeline.runPipeline(cas, ae);
t1 = cas.getTypeSystem().getType(TEST_TYPE);
assertEquals(1, cas.getAnnotationIndex(t1).size());
// reset the cas and do it again
cas.reset();
cas.setDocumentText(input);
SimplePipeline.runPipeline(cas, ae);
t1 = cas.getTypeSystem().getType(TEST_TYPE);
assertEquals(1, cas.getAnnotationIndex(t1).size());
// create a new cas and force the ae to update its types
ae.setConfigParameterValue(RutaEngine.PARAM_RELOAD_SCRIPT, true);
ae.reconfigure();
final CAS cas2 = CasCreationUtils.createCas(metaData);
cas2.setDocumentText(input);
SimplePipeline.runPipeline(cas2, ae);
t1 = cas2.getTypeSystem().getType(TEST_TYPE);
assertEquals(1, cas2.getAnnotationIndex(t1).size());
// create a new cas and do not force the ae to update its types
ae.setConfigParameterValue(RutaEngine.PARAM_RELOAD_SCRIPT, false);
ae.reconfigure();
final CAS cas3 = CasCreationUtils.createCas(metaData);
cas3.setDocumentText(input);
SimplePipeline.runPipeline(cas3, ae);
t1 = cas3.getTypeSystem().getType(TEST_TYPE);
assertEquals(1, cas3.getAnnotationIndex(t1).size());
// create a new cas and do not reconfigure the engine
final CAS cas4 = CasCreationUtils.createCas(metaData);
cas4.setDocumentText(input);
SimplePipeline.runPipeline(cas4, ae);
t1 = cas4.getTypeSystem().getType(TEST_TYPE);
assertEquals(1, cas4.getAnnotationIndex(t1).size());
if (ae != null) {
ae.destroy();
}
if (cas != null) {
cas.release();
}
if (cas2 != null) {