Search in sources :

Example 6 with MapConfiguration

use of org.apache.commons.configuration.MapConfiguration in project pinot by linkedin.

the class MetricsHelperTest method testMetricsHelperRegistration.

@Test
public void testMetricsHelperRegistration() {
    listenerOneOkay = false;
    listenerTwoOkay = false;
    Map<String, String> configKeys = new HashMap<String, String>();
    configKeys.put("pinot.broker.metrics.metricsRegistryRegistrationListeners", ListenerOne.class.getName() + "," + ListenerTwo.class.getName());
    Configuration configuration = new MapConfiguration(configKeys);
    MetricsRegistry registry = new MetricsRegistry();
    // Initialize the MetricsHelper and create a new timer
    MetricsHelper.initializeMetrics(configuration.subset("pinot.broker.metrics"));
    MetricsHelper.registerMetricsRegistry(registry);
    MetricsHelper.newTimer(registry, new MetricName(MetricsHelperTest.class, "dummy"), TimeUnit.MILLISECONDS, TimeUnit.MILLISECONDS);
    // Check that the two listeners fired
    assertTrue(listenerOneOkay);
    assertTrue(listenerTwoOkay);
}
Also used : MetricName(com.yammer.metrics.core.MetricName) MetricsRegistry(com.yammer.metrics.core.MetricsRegistry) Configuration(org.apache.commons.configuration.Configuration) MapConfiguration(org.apache.commons.configuration.MapConfiguration) HashMap(java.util.HashMap) MapConfiguration(org.apache.commons.configuration.MapConfiguration) Test(org.testng.annotations.Test)

Example 7 with MapConfiguration

use of org.apache.commons.configuration.MapConfiguration in project OpenAttestation by OpenAttestation.

the class ConfigurationUtil method fromInputStream.

/**
     * Does NOT close the InputStream
     * 
     * @param properties
     * @return
     * @throws IOException 
     */
public static Configuration fromInputStream(InputStream properties) throws IOException {
    Properties p = new Properties();
    p.load(properties);
    return new MapConfiguration(p);
}
Also used : MapConfiguration(org.apache.commons.configuration.MapConfiguration) Properties(java.util.Properties)

Example 8 with MapConfiguration

use of org.apache.commons.configuration.MapConfiguration in project OpenAttestation by OpenAttestation.

the class TagCreateCaKey method main.

public static void main(String[] args) {
    TagCreateCaKey cmd = new TagCreateCaKey();
    cmd.setOptions(new MapConfiguration(new Properties()));
    try {
        //Removing to facilitate args passing
        //cmd.execute(new String[] { "CN=Asset CA,OU=Datacenter,C=US" });
        cmd.execute(args);
    } catch (Exception ex) {
        java.util.logging.Logger.getLogger(TagCreateCaKey.class.getName()).log(Level.SEVERE, null, ex);
    }
}
Also used : MapConfiguration(org.apache.commons.configuration.MapConfiguration) Properties(java.util.Properties)

Example 9 with MapConfiguration

use of org.apache.commons.configuration.MapConfiguration in project OpenAttestation by OpenAttestation.

the class TAConfig method readPropertiesFile.

private void readPropertiesFile(String propertiesFilename, CompositeConfiguration composite) throws IOException {
    InputStream in = getClass().getResourceAsStream(propertiesFilename);
    log.info("Reading property file " + propertiesFilename);
    if (in != null) {
        try {
            Properties properties = new Properties();
            properties.load(in);
            MapConfiguration classpath = new MapConfiguration(properties);
            dumpConfiguration(classpath, "classpath:/" + propertiesFilename);
            composite.addConfiguration(classpath);
        } finally {
            in.close();
        }
    }
}
Also used : InputStream(java.io.InputStream) MapConfiguration(org.apache.commons.configuration.MapConfiguration) Properties(java.util.Properties)

Example 10 with MapConfiguration

use of org.apache.commons.configuration.MapConfiguration in project chassis by Kixeye.

the class ZookeeperConfigurationWriterTest method basePathExists_overwrite.

@Test
public void basePathExists_overwrite() throws Exception {
    Assert.assertNull(curatorFramework.checkExists().forPath(base));
    try (CuratorFramework zkCurator = createCuratorFramework()) {
        ZookeeperConfigurationWriter writer = new ZookeeperConfigurationWriter(applicationName, environmentName, version, zkCurator, true);
        writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
        Assert.assertEquals(val1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
        Assert.assertEquals(val2, new String(curatorFramework.getData().forPath(base + "/" + key2)));
        String key3 = RandomUtils.nextInt() + "";
        String val3 = RandomUtils.nextInt() + "";
        String newVal1 = RandomUtils.nextInt() + "";
        props.clear();
        //updates key1
        props.put(key1, newVal1);
        //adds key3
        props.put(key3, val3);
        //key2 should be deleted
        writer.write(new MapConfiguration(props), new DefaultPropertyFilter());
        Assert.assertEquals(newVal1, new String(curatorFramework.getData().forPath(base + "/" + key1)));
        Assert.assertEquals(val3, new String(curatorFramework.getData().forPath(base + "/" + key3)));
        Assert.assertNull(curatorFramework.checkExists().forPath(base + "/" + key2));
    }
}
Also used : CuratorFramework(org.apache.curator.framework.CuratorFramework) MapConfiguration(org.apache.commons.configuration.MapConfiguration) DefaultPropertyFilter(com.kixeye.chassis.bootstrap.configuration.DefaultPropertyFilter) ZookeeperConfigurationWriter(com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationWriter) Test(org.junit.Test)

Aggregations

MapConfiguration (org.apache.commons.configuration.MapConfiguration)12 CuratorFramework (org.apache.curator.framework.CuratorFramework)5 Test (org.junit.Test)5 DefaultPropertyFilter (com.kixeye.chassis.bootstrap.configuration.DefaultPropertyFilter)4 ZookeeperConfigurationWriter (com.kixeye.chassis.bootstrap.configuration.zookeeper.ZookeeperConfigurationWriter)4 Properties (java.util.Properties)4 HashMap (java.util.HashMap)3 File (java.io.File)2 ApiClient (com.intel.mtwilson.ApiClient)1 SimpleKeystore (com.intel.mtwilson.util.crypto.SimpleKeystore)1 CuratorFrameworkBuilder (com.kixeye.chassis.bootstrap.configuration.zookeeper.CuratorFrameworkBuilder)1 ConcurrentCompositeConfiguration (com.netflix.config.ConcurrentCompositeConfiguration)1 MetricName (com.yammer.metrics.core.MetricName)1 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 URL (java.net.URL)1 X509Certificate (java.security.cert.X509Certificate)1 ArrayList (java.util.ArrayList)1 HttpSession (javax.servlet.http.HttpSession)1