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

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

Introduction

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

Prototype

String getString(String key);

Source Link

Document

Get a string associated with the given configuration key.

Usage

From source file:funnycats.TestUtils.java

@Test
public void testGettingFunnyCatsFromDirectoryReturnsAListOfCats() throws ConfigurationException {
    Configuration configuration = new PropertiesConfiguration("funnycats.properties");
    String path = configuration.getString("cats.pictures");
    URL url = getClass().getClassLoader().getResource(path);
    File directory = new File(url.getFile());
    List<FunnyCat> funnyCats = Utils.getFunnyCats(directory);
    Assert.assertTrue(funnyCats.size() > 0);
}

From source file:ch.epfl.eagle.daemon.nodemonitor.ConfigNodeMonitorState.java

@Override
public void initialize(Configuration conf) {
    nodeMonitors = ConfigUtil.parseBackends(conf);
    staticAppId = conf.getString(EagleConf.STATIC_APP_NAME);
}

From source file:com.cloudera.whirr.cm.CmServerClusterInstance.java

@SuppressWarnings("unchecked")
public static SortedSet<String> getMounts(ClusterSpec specification, Set<Instance> instances)
        throws IOException {
    Configuration configuration = getConfiguration(specification);
    SortedSet<String> mounts = new TreeSet<String>();
    Set<String> deviceMappings = CmServerClusterInstance.getDeviceMappings(specification, instances).keySet();
    if (!configuration.getList(CONFIG_WHIRR_DATA_DIRS_ROOT).isEmpty()) {
        mounts.addAll(configuration.getList(CONFIG_WHIRR_DATA_DIRS_ROOT));
    } else if (!deviceMappings.isEmpty()) {
        mounts.addAll(deviceMappings);/*www .  j  a v  a 2s.c o m*/
    } else {
        mounts.add(configuration.getString(CONFIG_WHIRR_INTERNAL_DATA_DIRS_DEFAULT));
    }
    return mounts;
}

From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.AddMetadataBoltTest.java

@Test
public void testConfigure(@Injectable Configuration conf) {
    new Expectations() {
        {//from   w  w w .j  av a  2 s.c o m
            conf.getString("field");
            result = "field0";
            conf.getString("value");
            result = "value0";
        }
    };
    bolt.configure(conf);
    assertThat(bolt.field, is("field0"));
    assertThat(bolt.value, is("value0"));
}

From source file:br.gov.frameworkdemoiselle.internal.implementation.ConfigurationEnumValueExtractor.java

@Override
public Object getValue(String prefix, String key, Field field, Configuration configuration) throws Exception {
    String value = configuration.getString(prefix + key);

    if (value != null && !value.trim().equals("")) {
        Object enums[] = field.getType().getEnumConstants();

        for (int i = 0; i < enums.length; i++) {
            if (((Enum<?>) enums[i]).name().equals(value)) {
                return enums[i];
            }/*from   www  .  j  a v a 2s  . c  om*/
        }
    } else {
        return null;
    }

    throw new ConversionException(getBundle().getString("configuration-not-conversion", value,
            field.getDeclaringClass().getCanonicalName()));
}

From source file:fr.inria.atlanmod.neoemf.data.blueprints.tg.config.InternalBlueprintsTgConfiguration.java

@Override
public void putDefaultConfiguration(Configuration currentConfiguration, File dbLocation)
        throws IllegalArgumentException {
    if (isNull(currentConfiguration.getString(DIRECTORY))) {
        currentConfiguration.addProperty(DIRECTORY, dbLocation.getAbsolutePath());
    }//from w w w . j a  v a  2 s.  com
    if (isNull(currentConfiguration.getString(FILE_TYPE))) {
        currentConfiguration.addProperty(FILE_TYPE, "GRAPHML");
    }
}

From source file:com.appeligo.amazon.AmazonIndexer.java

private AmazonIndexer() {
    Configuration config = ConfigUtils.getAmazonConfig();
    String index = config.getString("productIndex");
    queue = null;//new IndexerQueue(index, new StandardAnalyzer());
    service = AmazonService.getInstance();
}

From source file:com.appeligo.captions.LuceneInitializer.java

/**
 * Expected to initialize n servlet initializaton.
 *///w w w  .j  a  va2s  .  c  o m
public void contextInitialized(ServletContextEvent event) {

    Configuration config = ConfigUtils.getSystemConfig();
    String programIndex = config.getString("luceneIndex");
    String compositeIndex = config.getString("compositeIndex");
    String spellIndex = config.getString("spellIndex");
    String liveIndex = config.getString("luceneLiveIndex");
    String productIndex = config.getString("luceneProductIndex");
    unlockIndex(programIndex);
    unlockIndex(compositeIndex);
    unlockIndex(spellIndex);
    unlockIndex(liveIndex);
    unlockIndex(productIndex);
}

From source file:com.thalesgroup.sonar.plugins.tusar.metrics.NewMetrics.java

public NewMetrics(Configuration configuration) {
    csvFilePath = configuration.getString(Constants.TUSAR_INI_FILE_PATH_KEY);
}

From source file:com.boozallen.cognition.ingest.storm.bolt.enrich.DecomposeObjectArrayBoltTest.java

@Test
public void testConfigure(@Injectable Configuration conf) {
    new Expectations() {
        {/*from ww w .j a v a  2  s  .co  m*/
            conf.getString(DecomposeObjectArrayBolt.ARRAY_FIELD);
            result = "field0";
            conf.getString(DecomposeObjectArrayBolt.OBJECT_FIELD);
            result = "field1";
            conf.getString(DecomposeObjectArrayBolt.DEST_FIELD);
            result = "field2";
        }
    };
    bolt.configure(conf);
    assertThat(bolt.arrayField, is("field0"));
    assertThat(bolt.objectField, is("field1"));
    assertThat(bolt.destField, is("field2"));
}