List of usage examples for org.apache.commons.configuration BaseConfiguration BaseConfiguration
BaseConfiguration
From source file:com.feedzai.fos.impl.r.RandomForestPMMLProducerConsumerTest.java
private RManager setupManager() throws FOSException { BaseConfiguration configuration = new BaseConfiguration(); configuration.setProperty(FosConfig.FACTORY_NAME, RManagerFactory.class.getName()); FosConfig config = new FosConfig(configuration); RManagerConfig rManagerConfig = new RManagerConfig(config); return new RManager(rManagerConfig); }
From source file:com.comcast.viper.flume2storm.connection.KryoNetConnectionParametersTest.java
/** * Test {@link KryoNetConnectionParameters} with a full configuration * /* w w w. j a v a2 s . co m*/ * @throws F2SConfigurationException * If the configuration is invalid */ @Test public void testFromConfiguration() throws F2SConfigurationException { String hostname = RandomStringUtils.randomAlphabetic(10); int port = TestUtils.getRandomPositiveInt(65000); int objectBufferSize = TestUtils.getRandomPositiveInt(100000); int writeBufferSize = TestUtils.getRandomPositiveInt(100000); Configuration config = new BaseConfiguration(); config.addProperty(KryoNetConnectionParameters.ADDRESS, hostname); config.addProperty(KryoNetConnectionParameters.PORT, port); config.addProperty(KryoNetConnectionParameters.OBJECT_BUFFER_SZ, objectBufferSize); config.addProperty(KryoNetConnectionParameters.WRITE_BUFFER_SZ, writeBufferSize); KryoNetConnectionParameters params = KryoNetConnectionParameters.from(config); Assert.assertEquals(hostname, params.getAddress()); Assert.assertEquals(port, params.getPort()); Assert.assertEquals(objectBufferSize, params.getObjectBufferSize()); Assert.assertEquals(writeBufferSize, params.getWriteBufferSize()); }
From source file:com.feedzai.fos.impl.weka.WekaScorerTest.java
@Test public void passthroughCreationTest() throws FOSException { BaseConfiguration configuration = new BaseConfiguration(); configuration.setProperty(GenericObjectPoolConfig.class.getName() + ".minIdle", 10); configuration.setProperty(GenericObjectPoolConfig.class.getName() + ".maxActive", 10); configuration.setProperty(FosConfig.HEADER_LOCATION, "target/test-classes/models/threadunsafe"); configuration.setProperty(FosConfig.FACTORY_NAME, WekaManagerFactory.class.getName()); WekaManagerConfig wekaManagerConfig = new WekaManagerConfig(new FosConfig(configuration)); WekaManager wekaManager = new WekaManager(wekaManagerConfig); WekaScorer wekaScorer = wekaManager.getScorer(); double[] score = wekaScorer.score(Lists.newArrayList(testUUID), new Object[] { 1.5, 0, "gray", "positive" }) .get(0);/*ww w. jav a2s .c om*/ assertEquals(2, score.length); assertEquals(1.0, score[0] + score[1], 0.001); Assert.assertTrue(((Map<Integer, WekaThreadSafeScorer>) Whitebox.getInternalState(wekaScorer, "wekaThreadSafeScorers")).get(testUUID) instanceof WekaThreadSafeScorerPassthrough); }
From source file:com.netflix.config.PollingSourceTest.java
@Test public void testDeletingPollingSource() throws Exception { BaseConfiguration config = new BaseConfiguration(); config.addProperty("prop1", "original"); DummyPollingSource source = new DummyPollingSource(false); source.setFull("prop1=changed"); FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 10, false); ConfigurationWithPollingSource pollingConfig = new ConfigurationWithPollingSource(config, source, scheduler);/*from w ww . j a va 2 s .c om*/ Thread.sleep(200); assertEquals("changed", pollingConfig.getProperty("prop1")); source.setFull(""); Thread.sleep(200); assertFalse(pollingConfig.containsKey("prop1")); source.setFull("prop1=changedagain,prop2=new"); Thread.sleep(200); assertEquals("changedagain", pollingConfig.getProperty("prop1")); assertEquals("new", pollingConfig.getProperty("prop2")); source.setFull("prop3=new"); Thread.sleep(200); assertFalse(pollingConfig.containsKey("prop1")); assertFalse(pollingConfig.containsKey("prop2")); assertEquals("new", pollingConfig.getProperty("prop3")); }
From source file:edu.cwru.sepia.model.SimplePlannerTest.java
@BeforeClass public static void loadTemplates() throws Exception { State.StateBuilder builder = new State.StateBuilder(); builder.setSize(15, 15);/*from www. jav a 2 s . c o m*/ state = builder.build(); templates = TypeLoader.loadFromFile("data/unit_templates", player, state); System.out.println("Sucessfully loaded templates"); planner = new SimplePlanner(state); for (Template<?> t : templates) { if (!(t instanceof UnitTemplate)) continue; builder.addTemplate(t); } { Unit u = ((UnitTemplate) builder.getTemplate(player, "Peasant")).produceInstance(state); builder.addUnit(u, 10, 10); } { Unit u = ((UnitTemplate) builder.getTemplate(player, "Barracks")).produceInstance(state); builder.addUnit(u, 0, 0); } { Unit u = ((UnitTemplate) builder.getTemplate(player, "Blacksmith")).produceInstance(state); builder.addUnit(u, 0, 1); } { Unit u = ((UnitTemplate) builder.getTemplate(player, "Blacksmith")).produceInstance(state); builder.addUnit(u, 0, 2); } ResourceNodeType tree = new ResourceNodeType("TREE", new ResourceType("WOOD")); for (int i = 0; i <= 12; i++) { ResourceNode t = new ResourceNode(tree, i, 8, 100, state.nextTargetId()); builder.addResource(t); } ResourceNode t = new ResourceNode(tree, 7, 2, 100, state.nextTargetId()); builder.addResource(t); t = new ResourceNode(tree, 7, 3, 100, state.nextTargetId()); builder.addResource(t); t = new ResourceNode(tree, 8, 3, 100, state.nextTargetId()); builder.addResource(t); t = new ResourceNode(tree, 8, 4, 100, state.nextTargetId()); builder.addResource(t); t = new ResourceNode(tree, 9, 4, 100, state.nextTargetId()); builder.addResource(t); t = new ResourceNode(tree, 10, 4, 100, state.nextTargetId()); builder.addResource(t); model = new SimpleDurativeModel(state, null, new BaseConfiguration()); }
From source file:com.runwaysdk.configuration.CommonsConfigurationTest.java
@Test public void testCommonsConfigOverrideSetVsAdd() { BaseConfiguration bc = new BaseConfiguration(); BaseConfiguration bc2 = new BaseConfiguration(); bc2.addProperty("test.prop", 52); CompositeConfiguration cconfig = new CompositeConfiguration(); cconfig.addConfiguration(bc);// w w w. j a v a 2 s .co m cconfig.addConfiguration(bc2); bc.setProperty("test.prop", 112); Assert.assertEquals(112, cconfig.getInt("test.prop")); }
From source file:co.turnus.generic.AbstractConfigurable.java
protected void setOption(String name, Object value) { if (configuration == null) { configuration = new BaseConfiguration(); }//from ww w .j av a 2s .co m configuration.setProperty(name, value); }
From source file:cz.cas.lib.proarc.common.catalog.Z3950CatalogTest.java
@Test public void testFind() throws Exception { String host = System.getProperty("Z3950CatalogTest.host"); String port = System.getProperty("Z3950CatalogTest.port"); String base = System.getProperty("Z3950CatalogTest.base"); String recordCharset = System.getProperty("Z3950CatalogTest.recordCharset"); Assume.assumeNotNull(host, port, base); String fieldName = "sys"; String value = "001704913"; Locale locale = null;/* www . ja va 2 s .co m*/ final String catalogId = "catalogId"; CatalogConfiguration c = new CatalogConfiguration(catalogId, "", new BaseConfiguration() { { addProperty(CatalogConfiguration.PROPERTY_FIELDS, "sys"); addProperty( CatalogConfiguration.FIELD_PREFIX + '.' + "sys" + '.' + Z3950Catalog.PROPERTY_FIELD_QUERY, "@attrset bib-1 @attr 1=12 @attr 4=1 \"%s\""); } }); Z3950Catalog instance = new Z3950Catalog(host, Integer.parseInt(port), base, recordCharset == null ? null : Charset.forName(recordCharset), Z3950Catalog.readFields(c)); List<MetadataItem> result = instance.find(fieldName, value, locale); assertFalse(result.isEmpty()); }
From source file:net.riccardocossu.autodoc.maven.AutodocMojo.java
@SuppressWarnings("unchecked") public void execute() throws MojoExecutionException { try {/*from www. j a va 2s . c o m*/ Set<URL> urls = new HashSet<URL>(); List<String> elements = project.getCompileClasspathElements(); for (String element : elements) { urls.add(new File(element).toURI().toURL()); } ClassLoader contextClassLoader = URLClassLoader.newInstance(urls.toArray(new URL[0]), Thread.currentThread().getContextClassLoader()); Thread.currentThread().setContextClassLoader(contextClassLoader); } catch (DependencyResolutionRequiredException e) { throw new MojoExecutionException("Error expanding classloader", e); } catch (MalformedURLException e) { throw new MojoExecutionException("Error expanding classloader", e); } File f = new File(outputDirectory.getAbsolutePath() + "/autodoc"); if (!f.exists()) { f.mkdirs(); } BaseConfiguration conf = new BaseConfiguration(); conf.addProperty(Engine.CONFIG_PACKAGES, packages); conf.addProperty(Engine.CONFIG_INPUT_PLUGINS, inputPlugins); conf.addProperty(Engine.CONFIG_OUTPUT_PLUGINS, outputPlugins); conf.addProperty(Engine.CONFIG_BASE_OUTPUT_DIR, f.getAbsolutePath()); Engine eng = new Engine(conf); List<PackageContainer> parsedPackages = eng.execute(); getLog().info(String.format("Parsed %d packages", parsedPackages.size())); }
From source file:dk.dma.ais.abnormal.stat.AbnormalStatBuilderAppTestModule.java
@Provides
@Singleton
Configuration provideConfiguration() {
return new BaseConfiguration();
}