List of usage examples for org.apache.commons.configuration Configuration addProperty
void addProperty(String key, Object value);
From source file:org.bhave.experiment.data.TestKafkaConsumer.java
@Test public void testConfigureKafkaConsumer() throws InterruptedException { KafkaDataConsumer consumer = new KafkaDataConsumer(); Configuration config = new PropertiesConfiguration(); config.addProperty(KafkaDataConsumer.HOST_CFG, "localhost"); config.addProperty(KafkaDataConsumer.PORT_CFG, KafkaDataConsumer.DEFAULT_PORT_CFG); config.addProperty(KafkaDataConsumer.TOPIC_CFG, "test"); config.addProperty(KafkaDataConsumer.P_PRODUCER_ID, 0); consumer.loadConfiguration(config);/*from w w w . j a v a 2 s. c o m*/ Configuration configuration = consumer.getConfiguration(); assertNotNull(configuration); consumer.addExporter(new StdOutDataExporter()); Thread consumerThread = new Thread(consumer); consumerThread.setName("Consumer Thread"); consumerThread.start(); assertTrue(consumerThread.isAlive()); //this should terminate the thread in which it is running consumer.finish(); Thread.sleep(1000); assertFalse(consumerThread.isAlive()); System.out.println("Kafka Consumer Thread terminated"); }
From source file:org.bhave.sweeper.impl.ConfigurationTranformer.java
@Override public Configuration transform(Object value) { Configuration config = new PropertiesConfiguration(); config.addProperty(paramName, value); return config; }
From source file:org.jpac.configuration.Property.java
public Property(Object owningObject, String key, Object defaultValue, String comment, boolean classProperty) throws ConfigurationException { this.classProperty = classProperty; Configuration configuration = Configuration.getInstance(); //compute key if (classProperty) { //if it is a class property, prefix its key with the canonical name of the class this.key = owningObject.getClass().getCanonicalName().replace(".", "..").concat(".").concat(key); } else if (owningObject instanceof AbstractModule) { //if it is a module, prefix its key with the qualified name of the module this.key = ((AbstractModule) owningObject).getQualifiedName().concat(".").concat(key); } else {//from ww w. java2 s. c o m //otherwise, take the given key itself this.key = key; } //add property, if not already part of the configuration if (!configuration.containsKey(this.key)) { configuration.addProperty(this.key, defaultValue == null ? "" : defaultValue); } if (comment != null) { String commentKey = this.key + "[@comment]"; if (!configuration.containsKey(commentKey)) { //add it to the property configuration.addProperty(commentKey, comment); } //mark this comment as been touched during actual session configuration.getTouchedProperties().add(commentKey); } //mark this property as been touched during actual session configuration.getTouchedProperties().add(this.key); }
From source file:org.lable.oss.dynamicconfig.configutil.ConfigUtilTest.java
@Test public void testChildMapReturnsMap() { Configuration input = new HierarchicalConfiguration(); input.addProperty("prop1", "XXX"); input.addProperty("prop2.l1", "XXX"); input.addProperty("prop2.l2", "XXX"); input.addProperty("prop3.deeper", "XXX"); final Map<String, Configuration> output = childMap(input); assertThat(output.size(), is(3));/* ww w . j av a2 s. c om*/ assertThat(output.get("prop3").getString("deeper"), is("XXX")); }
From source file:org.lable.oss.dynamicconfig.configutil.ConfigUtilTest.java
@Test public void testChildMapReturnsSubsetMap() { Configuration input = new HierarchicalConfiguration(); input.addProperty("prop1", "XXX"); input.addProperty("prop2.l1", "XXX"); input.addProperty("prop2.l2", "XXX"); input.addProperty("prop3.deeper", "XXX"); final Map<String, Configuration> output = childMap(input.subset("prop2")); assertThat(output.size(), is(2));//from w w w . ja v a 2 s. c o m assertThat(output.containsKey("l1"), is(true)); assertThat(output.containsKey("l2"), is(true)); }
From source file:org.lable.oss.dynamicconfig.configutil.ConfigUtilTest.java
@Test public void testChildMapReturnsSubsetMapWithPath() { Configuration input = new HierarchicalConfiguration(); input.addProperty("prop1", "XXX"); input.addProperty("prop2.l1", "XXX"); input.addProperty("prop2.l2", "XXX"); input.addProperty("prop3.deeper", "XXX"); final Map<String, Configuration> output = childMap(input, "prop2"); assertThat(output.size(), is(2));//from w w w .j ava 2 s .com assertThat(output.containsKey("l1"), is(true)); assertThat(output.containsKey("l2"), is(true)); }
From source file:org.lable.oss.dynamicconfig.configutil.ConfigUtilTest.java
@Test public void testChildMapEmptyPath() { Configuration input = new HierarchicalConfiguration(); input.addProperty("prop1", "XXX"); final Map<String, Configuration> output = childMap(input, ""); assertThat(output.containsKey("prop1"), is(true)); }
From source file:org.lable.oss.dynamicconfig.configutil.ConfigUtilTest.java
@Test public void testChildKeys() { Configuration input = new HierarchicalConfiguration(); input.addProperty("prop1", "XXX"); input.addProperty("prop2", "XXX"); input.addProperty("prop3.deeper", "XXX"); input.addProperty("prop3.deeperest", "XXX"); final Set<String> result = childKeys(input); assertThat(result.size(), is(3));//from ww w . j av a 2 s. com assertThat(result.contains("prop1"), is(true)); assertThat(result.contains("prop2"), is(true)); assertThat(result.contains("prop3"), is(true)); }
From source file:org.lable.oss.dynamicconfig.configutil.ConfigUtilTest.java
@Test public void testChildKeysSubList() { Configuration input = new HierarchicalConfiguration(); input.addProperty("prop1", "XXX"); input.addProperty("prop2", "XXX"); input.addProperty("prop3.deeper", "XXX"); final Set<String> result = childKeys(input, "prop3"); assertThat(result.size(), is(1));/* w w w . ja v a 2s . co m*/ assertThat(result.contains("deeper"), is(true)); }
From source file:org.lable.oss.dynamicconfig.configutil.ConfigUtilTest.java
@Test public void testChildKeysEmptyPath() { Configuration input = new HierarchicalConfiguration(); input.addProperty("prop1", "XXX"); final Set<String> result = childKeys(input, ""); assertThat(result.contains("prop1"), is(true)); }