Example usage for org.apache.commons.collections ExtendedProperties getInt

List of usage examples for org.apache.commons.collections ExtendedProperties getInt

Introduction

In this page you can find the example usage for org.apache.commons.collections ExtendedProperties getInt.

Prototype

public int getInt(String name) 

Source Link

Document

The purpose of this method is to get the configuration resource with the given name as an integer.

Usage

From source file:org.apache.flex.forks.velocity.test.CommonsExtPropTestCase.java

/**
 * Runs the test.//  w ww. j  av  a 2  s  .  c o m
 */
public void runTest() {
    try {
        assureResultsDirectoryExists(RESULTS_DIR);

        ExtendedProperties c = new ExtendedProperties(TEST_CONFIG);

        FileWriter result = new FileWriter(getFileName(RESULTS_DIR, "output", "res"));

        message(result, "Testing order of keys ...");
        showIterator(result, c.getKeys());

        message(result, "Testing retrieval of CSV values ...");
        showVector(result, c.getVector("resource.loader"));

        message(result, "Testing subset(prefix).getKeys() ...");
        ExtendedProperties subset = c.subset("file.resource.loader");
        showIterator(result, subset.getKeys());

        message(result, "Testing getVector(prefix) ...");
        showVector(result, subset.getVector("path"));

        message(result, "Testing getString(key) ...");
        result.write(c.getString("config.string.value"));
        result.write("\n\n");

        message(result, "Testing getBoolean(key) ...");
        result.write(new Boolean(c.getBoolean("config.boolean.value")).toString());
        result.write("\n\n");

        message(result, "Testing getByte(key) ...");
        result.write(new Byte(c.getByte("config.byte.value")).toString());
        result.write("\n\n");

        message(result, "Testing getShort(key) ...");
        result.write(new Short(c.getShort("config.short.value")).toString());
        result.write("\n\n");

        message(result, "Testing getInt(key) ...");
        result.write(new Integer(c.getInt("config.int.value")).toString());
        result.write("\n\n");

        message(result, "Testing getLong(key) ...");
        result.write(new Long(c.getLong("config.long.value")).toString());
        result.write("\n\n");

        message(result, "Testing getFloat(key) ...");
        result.write(new Float(c.getFloat("config.float.value")).toString());
        result.write("\n\n");

        message(result, "Testing getDouble(key) ...");
        result.write(new Double(c.getDouble("config.double.value")).toString());
        result.write("\n\n");

        message(result, "Testing escaped-comma scalar...");
        result.write(c.getString("escape.comma1"));
        result.write("\n\n");

        message(result, "Testing escaped-comma vector...");
        showVector(result, c.getVector("escape.comma2"));
        result.write("\n\n");

        result.flush();
        result.close();

        if (!isMatch(RESULTS_DIR, COMPARE_DIR, "output", "res", "cmp")) {
            fail("Output incorrect.");
        }
    } catch (Exception e) {
        System.err.println("Cannot setup CommonsExtPropTestCase!");
        e.printStackTrace();
        System.exit(1);
    }
}

From source file:org.apache.velocity.test.CommonsExtPropTestCase.java

/**
 * Runs the test.//ww w .j a v a2s  .  c  o m
 */
public void testExtendedProperties() throws Exception {
    assureResultsDirectoryExists(RESULTS_DIR);

    ExtendedProperties c = new ExtendedProperties(TEST_CONFIG);

    FileWriter result = new FileWriter(getFileName(RESULTS_DIR, "output", "res"));

    message(result, "Testing order of keys ...");
    showIterator(result, c.getKeys());

    message(result, "Testing retrieval of CSV values ...");
    showVector(result, c.getVector("resource.loader"));

    message(result, "Testing subset(prefix).getKeys() ...");
    ExtendedProperties subset = c.subset("file.resource.loader");
    showIterator(result, subset.getKeys());

    message(result, "Testing getVector(prefix) ...");
    showVector(result, subset.getVector("path"));

    message(result, "Testing getString(key) ...");
    result.write(c.getString("config.string.value"));
    result.write("\n\n");

    message(result, "Testing getBoolean(key) ...");
    result.write(new Boolean(c.getBoolean("config.boolean.value")).toString());
    result.write("\n\n");

    message(result, "Testing getByte(key) ...");
    result.write(new Byte(c.getByte("config.byte.value")).toString());
    result.write("\n\n");

    message(result, "Testing getShort(key) ...");
    result.write(new Short(c.getShort("config.short.value")).toString());
    result.write("\n\n");

    message(result, "Testing getInt(key) ...");
    result.write(new Integer(c.getInt("config.int.value")).toString());
    result.write("\n\n");

    message(result, "Testing getLong(key) ...");
    result.write(new Long(c.getLong("config.long.value")).toString());
    result.write("\n\n");

    message(result, "Testing getFloat(key) ...");
    result.write(new Float(c.getFloat("config.float.value")).toString());
    result.write("\n\n");

    message(result, "Testing getDouble(key) ...");
    result.write(new Double(c.getDouble("config.double.value")).toString());
    result.write("\n\n");

    message(result, "Testing escaped-comma scalar...");
    result.write(c.getString("escape.comma1"));
    result.write("\n\n");

    message(result, "Testing escaped-comma vector...");
    showVector(result, c.getVector("escape.comma2"));
    result.write("\n\n");

    result.flush();
    result.close();

    if (!isMatch(RESULTS_DIR, COMPARE_DIR, "output", "res", "cmp")) {
        fail("Output incorrect.");
    }
}