Hi all,
I have written a CollectionReader that reads from a database. I added
the database connection parameters as mandatory parameters to the
descriptor. They are initialized with the correct values for the
production database.
Now, I want to write some unit tests that connect to a (always
available) test database, as the production database might not be
available at testing time.
I tried it with the code below, but the the reader's initialize() method
is already called when
CollectionReader reader =
UIMAFramework.produceCollectionReader(specifier);
is executed. That means, the test will fail before it had the chance to
reconfigure the parameters.
Is there any way to set the configuration parameters of a collection
reader before it is actually initialized?
Thanks,
Torsten
<snip>
// a map that contains the configuration parameters
Map<String,Object> configParameters = new HashMap<String, Object>() {{
// fill the map with some parameters
...
try {
XMLInputSource xmlInput = new XMLInputSource(descriptorFileReader);
ResourceSpecifier specifier =
UIMAFramework.getXMLParser().parseResourceSpecifier(xmlInput);
CollectionReader reader =
UIMAFramework.produceCollectionReader(specifier);
for (String key : configParameters.keySet()) {
reader.setConfigParameterValue(key, configParameters.get(key));
}
reader.reconfigure();
// testing the reader
...
}
// a lot of catches
</snip>
|