AnalysisEngineDescription primitiveDesc = new AnalysisEngineDescription_impl();
primitiveDesc.setPrimitive(true);
primitiveDesc.getMetaData().setName("Test Primitive TAE");
primitiveDesc
.setAnnotatorImplementationName("org.apache.uima.analysis_engine.impl.TestAnnotator");
ConfigurationParameter p1 = new ConfigurationParameter_impl();
p1.setName("StringParam");
p1.setDescription("parameter with String data type");
p1.setType(ConfigurationParameter.TYPE_STRING);
primitiveDesc.getMetaData().getConfigurationParameterDeclarations()
.setConfigurationParameters(new ConfigurationParameter[] { p1 });
primitiveDesc.getMetaData().getConfigurationParameterSettings().setParameterSettings(
new NameValuePair[] { new NameValuePair_impl("StringParam", "Test1") });
// instantiate TextAnalysisEngine
PrimitiveAnalysisEngine_impl ae = new PrimitiveAnalysisEngine_impl();
ae.initialize(primitiveDesc, null);
// check value of string param (TestAnnotator saves it in a static field)
assertEquals("Test1", TestAnnotator.stringParamValue);
// reconfigure
ae.setConfigParameterValue("StringParam", "Test2");
ae.reconfigure();
// test again
assertEquals("Test2", TestAnnotator.stringParamValue);
// test aggregate TAE
AnalysisEngineDescription aggDesc = new AnalysisEngineDescription_impl();
aggDesc.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
aggDesc.setPrimitive(false);
aggDesc.getMetaData().setName("Test Aggregate TAE");
aggDesc.getDelegateAnalysisEngineSpecifiersWithImports().put("Test", primitiveDesc);
FixedFlow_impl flow = new FixedFlow_impl();
flow.setFixedFlow(new String[] { "Test" });
aggDesc.getAnalysisEngineMetaData().setFlowConstraints(flow);
ConfigurationParameter p2 = new ConfigurationParameter_impl();
p2.setName("StringParam");
p2.setDescription("parameter with String data type");
p2.setType(ConfigurationParameter.TYPE_STRING);
aggDesc.getMetaData().getConfigurationParameterDeclarations().setConfigurationParameters(
new ConfigurationParameter[] { p2 });
aggDesc.getMetaData().getConfigurationParameterSettings().setParameterSettings(
new NameValuePair[] { new NameValuePair_impl("StringParam", "Test3") });
// instantiate TextAnalysisEngine
AggregateAnalysisEngine_impl aggAe = new AggregateAnalysisEngine_impl();
aggAe.initialize(aggDesc, null);
assertEquals("Test3", TestAnnotator.stringParamValue);
// reconfigure
aggAe.setConfigParameterValue("StringParam", "Test4");
aggAe.reconfigure();
// test again
assertEquals("Test4", TestAnnotator.stringParamValue);
// reconfigure WITHOUT setting that parameter
aggAe.reconfigure();
// test again
assertEquals("Test4", TestAnnotator.stringParamValue);
// test aggregate TAE that does NOT override parameter
primitiveDesc.getMetaData().getConfigurationParameterSettings().setParameterSettings(
new NameValuePair[] { new NameValuePair_impl("StringParam", "Test1") });
AnalysisEngineDescription aggDesc2 = new AnalysisEngineDescription_impl();
aggDesc2.setFrameworkImplementation(Constants.JAVA_FRAMEWORK_NAME);
aggDesc2.setPrimitive(false);
aggDesc2.getMetaData().setName("Test Aggregate TAE");
aggDesc2.getDelegateAnalysisEngineSpecifiersWithImports().put("Test", primitiveDesc);
FixedFlow_impl flow2 = new FixedFlow_impl();
flow2.setFixedFlow(new String[] { "Test" });
aggDesc2.getAnalysisEngineMetaData().setFlowConstraints(flow2);
ConfigurationParameter p3 = new ConfigurationParameter_impl();
p3.setName("IntParam");
p3.setDescription("parameter with Integer data type");
p3.setType(ConfigurationParameter.TYPE_INTEGER);
aggDesc2.getMetaData().getConfigurationParameterDeclarations().setConfigurationParameters(
new ConfigurationParameter[] { p3 });
aggDesc2.getMetaData().getConfigurationParameterSettings().setParameterSettings(
new NameValuePair[] { new NameValuePair_impl("IntParam", Integer.valueOf(42)) });
// instantiate TextAnalysisEngine