Example usage for org.apache.commons.configuration Configuration setProperty

List of usage examples for org.apache.commons.configuration Configuration setProperty

Introduction

In this page you can find the example usage for org.apache.commons.configuration Configuration setProperty.

Prototype

void setProperty(String key, Object value);

Source Link

Document

Set a property, this will replace any previously set values.

Usage

From source file:org.ambraproject.service.xml.XMLServiceTest.java

@BeforeClass
protected void setUp() throws Exception {

    DocumentBuilderFactory documentBuilderfactory = DocumentBuilderFactory
            .newInstance("org.apache.xerces.jaxp.DocumentBuilderFactoryImpl", getClass().getClassLoader());
    documentBuilderfactory.setNamespaceAware(true);
    documentBuilderfactory.setValidating(false);
    documentBuilderfactory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
    Map<String, String> xmlFactoryProperties = new HashMap<String, String>();
    xmlFactoryProperties.put("javax.xml.transform.TransformerFactory", "net.sf.saxon.TransformerFactoryImpl");
    xmlFactoryProperties.put("javax.xml.transform.Transformer", "net.sf.saxon.Controller");

    XMLUnit.setControlDocumentBuilderFactory(documentBuilderfactory);
    XMLUnit.setTestDocumentBuilderFactory(documentBuilderfactory);
    XMLUnit.setIgnoreComments(true);// w  w w .ja  v  a  2s.c  o  m
    XMLUnit.setIgnoreWhitespace(true);
    XMLUnit.setIgnoreAttributeOrder(true);
    XMLUnit.setTransformerFactory("net.sf.saxon.TransformerFactoryImpl");
    XMLUnit.setXSLTVersion("2.0");

    Configuration configiration = new BaseConfiguration();
    configiration.setProperty("ambra.platform.appContext", "test-context");

}

From source file:org.ambud.marauder.sink.MarauderTitanSink.java

@Override
public void configure(Context context) {
    Configuration conf = new BaseConfiguration();
    conf.setProperty("storage.backend", "hbase");
    conf.setProperty("storage.hostname", context.getString("servers", "192.168.1.20"));
    //      conf.setProperty("storage.index.t.backend", "lucene");
    //      conf.setProperty("storage.index.t.directory", "/tmp/index");
    conf.setProperty("storage.batch-loading", "true");
    batchSize = context.getInteger("batchSize", 1000);
    g = TitanFactory.open(conf);//from   w  w  w .  j av  a2  s. c o m
    g.makeKey("t").dataType(String.class).indexed(Vertex.class).make();
    g.makeKey("o").dataType(Integer.class).indexed(Vertex.class).make();
    g.makeKey("s").dataType(Long.class).indexed(Vertex.class).make();
    g.makeKey("n").dataType(String.class).indexed(Vertex.class).make();
    g.makeLabel("dil").unidirected().manyToMany().make();
    g.makeLabel("sil").unidirected().manyToMany().make();
    g.makeLabel("dpl").unidirected().manyToMany().make();
    g.makeLabel("spl").unidirected().manyToMany().make();
    g.makeLabel("isl").unidirected().manyToMany().make();
    g.makeLabel("hl").unidirected().manyToMany().make();
    g.makeLabel("evl").unidirected().manyToMany().make();
    g.makeLabel("il").unidirected().manyToMany().make();
    g.makeLabel("tl").unidirected().manyToMany().make();
    g.makeLabel("gil").unidirected().manyToMany().make();
    g.commit();
}

From source file:org.apache.atlas.Atlas.java

public static void main(String[] args) throws Exception {
    CommandLine cmd = parseArgs(args);/*from   w  w  w.  j a va 2  s  .  com*/
    PropertiesConfiguration buildConfiguration = new PropertiesConfiguration("atlas-buildinfo.properties");
    String appPath = "webapp/target/atlas-webapp-" + getProjectVersion(buildConfiguration);

    if (cmd.hasOption(APP_PATH)) {
        appPath = cmd.getOptionValue(APP_PATH);
    }

    setApplicationHome();
    Configuration configuration = ApplicationProperties.get();
    final String enableTLSFlag = configuration.getString(SecurityProperties.TLS_ENABLED);
    final int appPort = getApplicationPort(cmd, enableTLSFlag, configuration);
    System.setProperty(AtlasConstants.SYSTEM_PROPERTY_APP_PORT, String.valueOf(appPort));
    final boolean enableTLS = isTLSEnabled(enableTLSFlag, appPort);
    configuration.setProperty(SecurityProperties.TLS_ENABLED, String.valueOf(enableTLS));

    runSetupIfRequired(configuration);
    showStartupInfo(buildConfiguration, enableTLS, appPort);

    server = EmbeddedServer.newServer(appPort, appPath, enableTLS);
    server.start();
}

From source file:org.apache.atlas.graph.GraphSandboxUtil.java

public static void create() {
    Configuration configuration;
    try {// w  w  w  .j  a v  a 2s .  com
        configuration = ApplicationProperties.get();
        // Append a suffix to isolate the database for each instance
        long currentMillisecs = System.currentTimeMillis();

        String newStorageDir = System.getProperty("atlas.data") + File.pathSeparator + "storage"
                + File.pathSeparator + currentMillisecs;
        configuration.setProperty("atlas.graph.storage.directory", newStorageDir);

        String newIndexerDir = System.getProperty("atlas.data") + File.pathSeparator + "index"
                + File.pathSeparator + currentMillisecs;
        configuration.setProperty("atlas.graph.index.search.directory", newIndexerDir);

        LOG.debug("New Storage dir : {}", newStorageDir);
        LOG.debug("New Indexer dir : {}", newIndexerDir);
    } catch (AtlasException ignored) {
    }
}

From source file:org.apache.atlas.kafka.KafkaNotificationTest.java

@BeforeClass
public void setup() throws Exception {
    Configuration properties = ApplicationProperties.get();
    properties.setProperty("atlas.kafka.data", "target/" + RandomStringUtils.randomAlphanumeric(5));

    kafkaNotification = new KafkaNotification(properties);
    kafkaNotification.start();//from ww  w  . j a  v a 2 s.c  om
}

From source file:org.apache.atlas.Main.java

public static void main(String[] args) throws Exception {
    CommandLine cmd = parseArgs(args);//from w  w w.jav a  2  s. c  o  m
    PropertiesConfiguration buildConfiguration = new PropertiesConfiguration("atlas-buildinfo.properties");
    String appPath = "webapp/target/atlas-webapp-" + getProjectVersion(buildConfiguration);

    if (cmd.hasOption(APP_PATH)) {
        appPath = cmd.getOptionValue(APP_PATH);
    }

    setApplicationHome();
    Configuration configuration = ApplicationProperties.get();
    final String enableTLSFlag = configuration.getString("atlas.enableTLS");
    final int appPort = getApplicationPort(cmd, enableTLSFlag, configuration);
    final boolean enableTLS = isTLSEnabled(enableTLSFlag, appPort);
    configuration.setProperty("atlas.enableTLS", String.valueOf(enableTLS));

    showStartupInfo(buildConfiguration, enableTLS, appPort);

    server = EmbeddedServer.newServer(appPort, appPath, enableTLS);
    server.start();
}

From source file:org.apache.atlas.repository.typestore.StoreBackedTypeCacheTestModule.java

@Override
protected Configuration getConfiguration() {
    try {//from   w  w w  .j  av  a  2s.c  o  m
        Configuration configuration = ApplicationProperties.get();
        configuration.setProperty(AtlasRepositoryConfiguration.TYPE_CACHE_IMPLEMENTATION_PROPERTY,
                StoreBackedTypeCache.class.getName());
        return configuration;
    } catch (AtlasException e) {
        throw new RuntimeException(e);
    }
}

From source file:org.apache.bookkeeper.common.conf.ConfigKey.java

/**
 * Update the setting <tt>name</tt> in the configuration <tt>conf</tt> with the provided <tt>value</tt>.
 *
 * @param conf configuration to set//from   ww  w .ja  v a  2 s. c  o  m
 * @param value value of the setting
 */
public void set(Configuration conf, Object value) {
    if (!type().validator().validate(name(), value)) {
        throw new IllegalArgumentException(
                "Invalid value '" + value + "' to set on setting '" + name() + "': expected type = " + type);
    }

    if (null != validator() && !validator().validate(name(), value)) {
        throw new IllegalArgumentException("Invalid value '" + value + "' to set on setting '" + name()
                + "': required '" + validator() + "'");
    }

    if (value instanceof Class) {
        conf.setProperty(name(), ((Class) value).getName());
    } else {
        conf.setProperty(name(), value);
    }
}

From source file:org.apache.bookkeeper.common.conf.ConfigKeyTest.java

@Test
public void testValidateFieldSuccess() throws ConfigException {
    String keyName = runtime.getMethodName();
    Validator validator = mock(Validator.class);
    when(validator.validate(anyString(), any())).thenReturn(true);
    Configuration conf = new ConcurrentConfiguration();
    conf.setProperty(keyName, "test-value");
    ConfigKey key = ConfigKey.builder(keyName).validator(validator).build();

    key.validate(conf);//from  ww  w.j  a  v  a  2s .c om
    verify(validator, times(1)).validate(eq(keyName), eq("test-value"));
}

From source file:org.apache.bookkeeper.common.conf.ConfigKeyTest.java

@Test
public void testValidateFieldFailure() {
    String keyName = runtime.getMethodName();
    Validator validator = mock(Validator.class);
    when(validator.validate(anyString(), any())).thenReturn(false);
    Configuration conf = new ConcurrentConfiguration();
    conf.setProperty(keyName, "test-value");
    ConfigKey key = ConfigKey.builder(keyName).validator(validator).build();

    try {/*from   ww w  . ja v  a  2  s.  c o m*/
        key.validate(conf);
        fail("Should fail validation if validator#validate returns false");
    } catch (ConfigException ce) {
        // expected
    }
    verify(validator, times(1)).validate(eq(keyName), eq("test-value"));
}