Example usage for org.apache.commons.configuration2 ImmutableConfiguration getKeys

List of usage examples for org.apache.commons.configuration2 ImmutableConfiguration getKeys

Introduction

In this page you can find the example usage for org.apache.commons.configuration2 ImmutableConfiguration getKeys.

Prototype

Iterator<String> getKeys();

Source Link

Document

Get the list of the keys contained in the configuration.

Usage

From source file:org.mitre.mpf.wfm.util.TestPropertiesUtil.java

@Test
public void testBuilderGetConfiguration() {
    ImmutableConfiguration mpfPropertiesconfig = mpfPropertiesConfigurationBuilder.getCompleteConfiguration();

    Assert.assertEquals(1, mpfPropertiesconfig.getInt(FRAME_INTERVAL_KEY));

    String mpfHome = System.getenv(MPF_HOME_ENV_VAR);
    Assert.assertNotNull(mpfHome);//from  www. j a  va 2  s  . c  o  m

    // ensure "${mpf.share.path}" and $MPF_HOME are interpolated
    Assert.assertEquals(mpfHome + "/share/models/", mpfPropertiesconfig.getString(MODELS_DIR_KEY));

    // attempt to resolve every property value
    Iterator<String> keyIterator = mpfPropertiesconfig.getKeys();
    while (keyIterator.hasNext()) {
        String key = keyIterator.next();

        // this call does interpolation
        String value = mpfPropertiesconfig.getString(key);

        System.out.println(key + " = " + value); // DEBUG

        // NOTE: mpf.version.timestamp is set via maven filtering, so the next assert will fail if this test is run
        // through IntelliJ unless "mvn compile" is run first. That can be done on the command line, or by adding a
        // "Run Maven Goal" to the "Before launch" section of the IntelliJ test configuration and setting the
        // "Command line" to "compile".

        Assert.assertFalse(
                key + " has a value of \"" + value + "\", which contains \"${\". Failed interpolation?",
                value.contains("${"));
    }
}