List of usage examples for org.apache.commons.configuration Configuration addProperty
void addProperty(String key, Object value);
From source file:maltcms.ui.fileHandles.properties.tools.SceneParser.java
/** * Supports both absolute and relative paths and also arbitrary combinations * of the two. In case of relative paths, the location of the file * containing the pipeline configuration is used as basedir to resolve the * relative path./*from w w w. j a v a 2s . c o m*/ * * Example for relative path: * <pre>pipelines.properties = fragmentCommands/myClassName.properties</pre> * Example for absolute path: * <pre>pipelines.properties = /home/juser/myFunkyDir/myClassName.properties</pre> * * <pre>pipeline.properties</pre> accepts multiple entries, separated by a * ',' (comma) character. Example: * <pre>pipeline.properties = fragmentCommands/myClassName.properties,/home/juser/myFunkyDir/myClassName.properties</pre> * * @param filename the filename of the base configuration, which contains * the pipeline= and pipeline.properties keys. * @param cfg the configuration object resembling the content of filename. * @param scene the graph scene into which to load the configuration. */ public static void parseIntoScene(String filename, Configuration cfg, PipelineGraphScene scene) { Logger.getLogger(SceneParser.class.getName()) .info("###################################################################"); Logger.getLogger(SceneParser.class.getName()).info("Creating graph scene from file"); File f = new File(filename); //Get pipeline from configuration cfg.addProperty("config.basedir", f.getParentFile().getAbsoluteFile().toURI().getPath()); String pipelineXml = cfg.getString("pipeline.xml"); FileSystemXmlApplicationContext fsxmac = new FileSystemXmlApplicationContext(new String[] { pipelineXml }, true); ICommandSequence commandSequence = fsxmac.getBean("commandPipeline", cross.datastructures.pipeline.CommandPipeline.class); // String[] pipes = pipeline.toArray(new String[]{}); Logger.getLogger(SceneParser.class.getName()).log(Level.INFO, "Pipeline elements: {0}", commandSequence.getCommands()); PipelineGeneralConfigWidget pgcw = (PipelineGeneralConfigWidget) scene.createGeneralWidget(); pgcw.setProperties(cfg); String lastNode = null; String edge; int edgeCounter = 0; int nodeCounter = 0; Configuration pipeHash = new PropertiesConfiguration(); for (IFragmentCommand command : commandSequence.getCommands()) { Collection<String> configKeys = cross.annotations.AnnotationInspector .getRequiredConfigKeys(command.getClass()); // for (String pipe : pipes) { String nodeId = command.getClass().getCanonicalName() + "" + nodeCounter; PipelineElementWidget node = (PipelineElementWidget) scene.addNode(nodeId); // node.setPropertyFile(); // System.out.println("Parsing pipeline element " + pipeCfg.getAbsolutePath()); node.setBean(command); node.setLabel(command.getClass().getSimpleName()); node.setCurrentClassProperties(); Configuration prop = node.getProperties(); // pipeHash = PropertyLoader.getHash(pipeCfg.getAbsolutePath()); // node.setPropertyFile(pipeCfg.getAbsolutePath()); Iterator iter = pipeHash.getKeys(); while (iter.hasNext()) { String key = (String) iter.next(); prop.setProperty(key, pipeHash.getProperty(key)); } node.setProperties(prop); if (lastNode != null) { edge = "Ledge" + edgeCounter++; scene.addEdge(edge); Logger.getLogger(SceneParser.class.getName()).log(Level.INFO, "Adding edge between lastNode {0} and {1}", new Object[] { lastNode, nodeId }); scene.setEdgeSource(edge, lastNode); scene.setEdgeTarget(edge, nodeId); scene.validate(); } // x += dx; // y += dy; scene.validate(); lastNode = nodeId; nodeCounter++; } scene.validate(); SceneLayouter.layoutVertical(scene); }
From source file:co.indexia.antiquity.graph.TitanTxLongVersionedGraphTest.java
@Override protected ActiveVersionedGraph<?, Long> generateGraph() { File f = new File("/tmp/testgraph"); if (f.exists()) { if (f.isDirectory()) { try { FileUtils.deleteDirectory(f); } catch (IOException e) { throw new IllegalStateException(e); }/*from w ww. j a v a 2 s .co m*/ } else { f.delete(); } } Configuration c = new BaseConfiguration(); c.addProperty("storage.directory", "/tmp/testgraph"); TitanGraph g = TitanFactory.open(c); return new ActiveVersionedGraph.ActiveVersionedTransactionalGraphBuilder<TitanGraph, Long>(g, new LongGraphIdentifierBehavior()).init(true).conf(null).build(); }
From source file:com.comcast.viper.flume2storm.zookeeper.ZkClientConfigurationTest.java
@Test public void testFromConfiguration() throws F2SConfigurationException { String connectionStr = "host1.whatever.org"; int sessionTimeout = 1111; int connectionTimeout = 2222; int reconnectionDelay = 3333; int terminationTimeout = 4444; Configuration config = new BaseConfiguration(); config.addProperty(ZkClientConfiguration.CONNECTION_STRING, connectionStr); config.addProperty(ZkClientConfiguration.SESSION_TIMEOUT, sessionTimeout); config.addProperty(ZkClientConfiguration.CONNECTION_TIMEOUT, connectionTimeout); config.addProperty(ZkClientConfiguration.RECONNECTION_DELAY, reconnectionDelay); config.addProperty(ZkClientConfiguration.TERMINATION_TIMEOUT, terminationTimeout); ZkClientConfiguration zkClientConfiguration = ZkClientConfiguration.from(config); Assert.assertEquals(connectionStr, zkClientConfiguration.getConnectionStr()); Assert.assertEquals(sessionTimeout, zkClientConfiguration.getSessionTimeout()); Assert.assertEquals(connectionTimeout, zkClientConfiguration.getConnectionTimeout()); Assert.assertEquals(reconnectionDelay, zkClientConfiguration.getReconnectionDelay()); Assert.assertEquals(terminationTimeout, zkClientConfiguration.getTerminationTimeout()); }
From source file:com.comcast.viper.flume2storm.location.StaticLocationServiceConfigurationTest.java
/** * Test invalid argument for//w w w . j ava2 s . c om * {@link StaticLocationServiceConfiguration#setConfigurationLoaderClassName(String)} * * @throws F2SConfigurationException * If value is invalid */ @Test(expected = F2SConfigurationException.class) public void testConfigurationLoaderClassName3() throws F2SConfigurationException { Configuration config = new BaseConfiguration(); config.addProperty(StaticLocationServiceConfiguration.CONFIGURATION_LOADER_CLASS, "not-a-class"); StaticLocationServiceConfiguration.from(config); }
From source file:com.comcast.viper.flume2storm.location.StaticLocationServiceConfigurationTest.java
/** * Test {@link StaticLocationServiceConfiguration#from(Configuration)} * * @throws F2SConfigurationException/*ww w . j ava2s . c o m*/ * If the configuration is invalid */ @Test public void testFromConfiguration() throws F2SConfigurationException { String configurationLoaderClassName = SimpleServiceProviderConfigurationLoader.class.getCanonicalName(); String serviceProviderBase = "whatever"; Configuration config = new BaseConfiguration(); config.addProperty(StaticLocationServiceConfiguration.CONFIGURATION_LOADER_CLASS, configurationLoaderClassName); config.addProperty(StaticLocationServiceConfiguration.SERVICE_PROVIDER_BASE, serviceProviderBase); StaticLocationServiceConfiguration staticLocationServiceConfiguration = StaticLocationServiceConfiguration .from(config); Assert.assertEquals(configurationLoaderClassName, staticLocationServiceConfiguration.getConfigurationLoaderClassName()); Assert.assertEquals(serviceProviderBase, staticLocationServiceConfiguration.getServiceProviderBase()); }
From source file:com.comcast.viper.flume2storm.connection.KryoNetParametersTest.java
@Test public void testFromConfiguration() throws Exception { int connectionTo = TestUtils.getRandomPositiveInt(100000); int retrySleepDelay = TestUtils.getRandomPositiveInt(100000); int reconnectionDelay = TestUtils.getRandomPositiveInt(100000); int terminationTo = TestUtils.getRandomPositiveInt(100000); Configuration config = new BaseConfiguration(); config.addProperty(KryoNetParameters.CONNECTION_TIMEOUT, connectionTo); config.addProperty(KryoNetParameters.RETRY_SLEEP_DELAY, retrySleepDelay); config.addProperty(KryoNetParameters.RECONNECTION_DELAY, reconnectionDelay); config.addProperty(KryoNetParameters.TERMINATION_TO, terminationTo); KryoNetParameters params = KryoNetParameters.from(config); Assert.assertEquals(connectionTo, params.getConnectionTimeout()); Assert.assertEquals(retrySleepDelay, params.getRetrySleepDelay()); Assert.assertEquals(reconnectionDelay, params.getReconnectionDelay()); Assert.assertEquals(terminationTo, params.getTerminationTimeout()); }
From source file:it.geosolutions.opensdi2.configurations.OSDIConfigurationConverterTest.java
@Test public void propertiesValues2OSDIconfPositiveTest() { OSDIConfigConverter builder = new PropertiesConfigurationConverter(); Configuration config = new PropertiesConfiguration(); config.addProperty("key1", "value1"); config.addProperty("key2", "value2"); config.addProperty("key3", "value3"); OSDIConfiguration conf = builder.buildConfig(config, "scopeIDtest", "instanceIDtest"); assertTrue(conf instanceof OSDIConfigurationKVP); assertEquals(3, ((OSDIConfigurationKVP) conf).getNumberOfProperties()); assertEquals("value1", ((OSDIConfigurationKVP) conf).getValue("key1")); assertEquals("value2", ((OSDIConfigurationKVP) conf).getValue("key2")); assertEquals("value3", ((OSDIConfigurationKVP) conf).getValue("key3")); }
From source file:io.servicecomb.serviceregistry.config.TestServiceRegistryConfig.java
@Test public void getMicroserviceVersionFactory() { DynamicPropertyFactory.getInstance(); Configuration config = (Configuration) DynamicPropertyFactory.getBackingConfigurationSource(); config.addProperty(ServiceRegistryConfig.MICROSERVICE_VERSION_FACTORY, "test"); Assert.assertEquals("test", ServiceRegistryConfig.INSTANCE.getMicroserviceVersionFactory()); config.clearProperty(ServiceRegistryConfig.MICROSERVICE_VERSION_FACTORY); }
From source file:fr.inria.atlanmod.neoemf.data.blueprints.neo4j.config.InternalBlueprintsNeo4jConfiguration.java
@Override public void putDefaultConfiguration(Configuration currentConfiguration, File dbLocation) { if (isNull(currentConfiguration.getString(DIRECTORY))) { currentConfiguration.addProperty(DIRECTORY, dbLocation.getAbsolutePath()); }/*from w w w . ja v a 2 s . co m*/ }
From source file:com.linkedin.pinot.common.segment.fetcher.SegmentFetcherFactoryTest.java
License:asdf
@Test public void testCustomizedSegmentFetcherFactory() throws Exception { Configuration config = new PropertiesConfiguration(); config.addProperty("something", "abc"); config.addProperty("protocols", Arrays.asList("http", "https", "test")); config.addProperty("http.other", "some config"); config.addProperty("https.class", NoOpFetcher.class.getName()); config.addProperty("test.class", TestSegmentFetcher.class.getName()); _segmentFetcherFactory.init(config); Assert.assertTrue(_segmentFetcherFactory.containsProtocol("http")); Assert.assertTrue(_segmentFetcherFactory.containsProtocol("https")); Assert.assertTrue(_segmentFetcherFactory.containsProtocol("test")); SegmentFetcher testSegmentFetcher = _segmentFetcherFactory.getSegmentFetcherBasedOnURI("test://something"); Assert.assertTrue(testSegmentFetcher instanceof TestSegmentFetcher); Assert.assertEquals(((TestSegmentFetcher) testSegmentFetcher).getInitCalled(), 1); }