@Test public void testParameterOfNothing() throws IOException, SAXException { try { ConfigLoader.load("classpath:config-no-object.xml"); fail("Config file setting parameters of nothing was accepted"); } catch (DukeConfigException e) { // this configuration is bad, so this is what we wanted to test } }
@Test public void testSingleGroup() throws IOException, SAXException { try { ConfigLoader.load("classpath:config-single-group.xml"); fail("Config file with a single group was accepted"); } catch (DukeConfigException e) { // this configuration is bad, so this is what we wanted to test } }
@Test public void testCustomComparator() throws IOException, SAXException { Configuration config = ConfigLoader.load("classpath:config-custom-comparator.xml"); List<Comparator> comparators = config.getCustomComparators(); assertEquals(1, comparators.size()); }
@Test public void testDatabaseDefault() throws IOException, SAXException { Configuration config = ConfigLoader.load("classpath:config-database.xml"); Database db = config.getDatabase(false); assertTrue(db instanceof InMemoryDatabase); } }
@Test public void testCustomEstimator() throws IOException, SAXException { Configuration config = ConfigLoader.load("classpath:config-custom-estimator.xml"); List<Comparator> comparators = config.getCustomComparators(); assertEquals(1, comparators.size()); WeightedLevenshtein wl = (WeightedLevenshtein) comparators.get(0); DefaultWeightEstimator est = (DefaultWeightEstimator) wl.getEstimator(); assertEquals(3.8, est.getDigitWeight()); }
@Test public void testEmpty() throws IOException, SAXException { Configuration config = ConfigLoader.load("classpath:config-empty.xml"); assertTrue(config.getDataSources().isEmpty()); assertTrue(config.getDataSources(1).isEmpty()); assertTrue(config.getDataSources(2).isEmpty()); assertEquals(config.getThreshold(), 0.4); assertEquals(config.getMaybeThreshold(), 0.0); assertTrue(config.getProperties().isEmpty()); }
@Test public void testDefaultComparator() throws IOException, SAXException { Configuration config = ConfigLoader.load("classpath:config-no-comparator.xml"); Property prop = config.getPropertyByName("LASTNAME"); assertEquals(null, prop.getComparator()); assertEquals(Property.Lookup.DEFAULT, prop.getLookupBehaviour()); }
@Test public void testEmpty() throws IOException, SAXException { Configuration config = ConfigLoader.load("classpath:config-empty.xml"); assertTrue(config.getDataSources().isEmpty()); assertTrue(config.getDataSources(1).isEmpty()); assertTrue(config.getDataSources(2).isEmpty()); assertEquals(config.getThreshold(), 0.4); assertEquals(config.getMaybeThreshold(), 0.0); assertTrue(config.getProperties().isEmpty()); File outfile = tmpdir.newFile("config.xml"); ConfigWriter writer = new ConfigWriter(new FileOutputStream(outfile.getAbsolutePath())); writer.write(config); config = ConfigLoader.load(outfile.getAbsolutePath()); assertTrue(config.getDataSources().isEmpty()); assertTrue(config.getDataSources(1).isEmpty()); assertTrue(config.getDataSources(2).isEmpty()); assertEquals(config.getThreshold(), 0.4); assertEquals(config.getMaybeThreshold(), 0.0); assertTrue(config.getProperties().isEmpty()); }
@Test public void testDefaultProbs() throws IOException, SAXException { Configuration config = ConfigLoader.load("classpath:config-default-probs.xml"); Property prop = config.getPropertyByName("FIRSTNAME"); assertEquals(0.5, prop.getHighProbability()); assertEquals(0.5, prop.getLowProbability()); assertEquals(Property.Lookup.DEFAULT, prop.getLookupBehaviour()); }
@Test public void testLookup() throws IOException, SAXException { Configuration config = ConfigLoader.load("classpath:config-lookup.xml"); Property prop = config.getPropertyByName("FIRSTNAME"); assertEquals(Property.Lookup.REQUIRED, prop.getLookupBehaviour()); prop = config.getPropertyByName("LASTNAME"); assertEquals(Property.Lookup.DEFAULT, prop.getLookupBehaviour()); }
ConfigWriter writer = new ConfigWriter(new FileOutputStream(outfile.getAbsolutePath())); writer.write(config); config = ConfigLoader.load(outfile.getAbsolutePath());
config = ConfigLoader.load(argv[0]);
ConfigWriter writer = new ConfigWriter(new FileOutputStream(outfile.getAbsolutePath())); writer.write(config); config = ConfigLoader.load(outfile.getAbsolutePath());
ConfigWriter writer = new ConfigWriter(new FileOutputStream(outfile.getAbsolutePath())); writer.write(config); config = ConfigLoader.load(outfile.getAbsolutePath());
ConfigWriter writer = new ConfigWriter(new FileOutputStream(outfile.getAbsolutePath())); writer.write(config); config = ConfigLoader.load(outfile.getAbsolutePath());
config = ConfigLoader.load(argv[0]); } catch (FileNotFoundException e) { System.err.println("ERROR: Config file '" + argv[0] + "' not found!");
Configuration config = ConfigLoader.load(configfile); this.processor = new Processor(config, false); this.linkdb = makeLinkDatabase(props);
Configuration config = ConfigLoader.load(argv[0]); GeneticAlgorithm genetic = new GeneticAlgorithm(config, testfile,
config = ConfigLoader.load(argv[0]);
Configuration config = ConfigLoader.load(configfile); this.processor = new Processor(config, false); this.linkdb = makeLinkDatabase(props);