* parsing of configuration files
*/
@Test
public void loadSimpleConfigDir() throws IOException {
String name = CONFIG_ROOT+"simple";
IndexingConfig config = new IndexingConfig(name,name){};
//assert that this directory exists (is created)
File expectedRoot = new File(testRoot,name);
expectedRoot = new File(expectedRoot,"indexing");
assertTrue("Root Dir not created",expectedRoot.isDirectory());
assertEquals("Root dir other the expected ",
expectedRoot.getCanonicalPath(),config.getIndexingFolder().getCanonicalPath());
assertTrue(config.getConfigFolder().isDirectory());
assertTrue(config.getSourceFolder().isDirectory());
assertTrue(config.getDestinationFolder().isDirectory());
assertTrue(config.getDistributionFolder().isDirectory());
//test the name
assertEquals(config.getName(),"simple");
assertEquals(config.getDescription(), "Simple Configuration");
//test if the normaliser configuration was parsed correctly!
final ScoreNormaliser normaliser = config.getNormaliser();
//test if the config files where copied form the classpath to the
//config directory.
assertTrue("Config File for the RangeNormaliser not copied",
new File(config.getConfigFolder(),"range.properties").isFile());
assertTrue("Config File for the MinScoreNormalizer not copied",
new File(config.getConfigFolder(),"minscore.properties").isFile());
//now test if the configuration was parsed correctly
ScoreNormaliser testNormaliser = normaliser;
assertNotNull(testNormaliser);
assertEquals(testNormaliser.getClass(), RangeNormaliser.class);
testNormaliser = testNormaliser.getChained();
assertNotNull(testNormaliser);
assertEquals(testNormaliser.getClass(), NaturalLogNormaliser.class);
testNormaliser = testNormaliser.getChained();
assertNotNull(testNormaliser);
assertEquals(testNormaliser.getClass(), MinScoreNormalizer.class);
EntityIterator entityIterator = config.getEntityIdIterator();
assertNotNull(entityIterator);
assertEquals(entityIterator.getClass(), LineBasedEntityIterator.class);
if(entityIterator.needsInitialisation()){
entityIterator.initialise();
}
Map<String,Float> entityIds = new HashMap<String,Float>();
//the values test if the normaliser configuration was readed correctly
//the keys if the configured entiyScore file was configured correctly
float boost = 10f/(float)Math.log1p(100);
entityIds.put("http://www.example.org/entity/test", Float.valueOf(10));
entityIds.put("http://www.example.org/entity/test2", Float.valueOf((float)(Math.log1p(10)*boost)));
entityIds.put("http://www.example.org/entity/test3", Float.valueOf(-1));
while(entityIterator.hasNext()){
EntityIterator.EntityScore entityScore = entityIterator.next();
Float expectedScore = entityIds.remove(entityScore.id);
assertNotNull("Entity with ID "+entityScore.id+" not found!",expectedScore);
Float score = normaliser.normalise(entityScore.score);
assertTrue("Entity score "+score+" is not the expected "+expectedScore,expectedScore.compareTo(score)==0);
}
assertTrue(entityIds.isEmpty());
List<EntityProcessor> processors = config.getEntityProcessors();
assertNotNull(processors);
}