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

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

Introduction

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

Prototype

public byte getByte(String key) 

Source Link

Document

Get a byte associated with the given configuration key.

Usage

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

/**
 * Runs the test./* ww  w . j  a  v  a 2 s  .co  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./*from   w w  w .  j a va  2s  .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.");
    }
}