Example usage for org.apache.commons.configuration ConfigurationException getMessage

List of usage examples for org.apache.commons.configuration ConfigurationException getMessage

Introduction

In this page you can find the example usage for org.apache.commons.configuration ConfigurationException getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.wso2.andes.server.security.access.plugins.PlainConfigurationTest.java

public void testACLFileSyntaxNotEnough() throws Exception {
    try {//ww w.  j  ava  2  s.  co  m
        writeACLConfig("INVALID");
        fail("fail");
    } catch (ConfigurationException ce) {
        assertEquals(String.format(PlainConfiguration.NOT_ENOUGH_TOKENS_MSG, 1), ce.getMessage());
    }
}

From source file:org.wso2.andes.server.security.access.plugins.PlainConfigurationTest.java

public void testACLFileSyntaxPropertyKeyOnly() throws Exception {
    try {/* w  w w . j  av  a  2  s .  c  om*/
        writeACLConfig("ACL ALLOW adk CREATE QUEUE name");
        fail("fail");
    } catch (ConfigurationException ce) {
        assertEquals(String.format(PlainConfiguration.PROPERTY_KEY_ONLY_MSG, 1), ce.getMessage());
    }
}

From source file:org.wso2.andes.server.security.access.plugins.PlainConfigurationTest.java

public void testACLFileSyntaxPropertyNoEquals() throws Exception {
    try {/*from  www.jav  a  2s . c om*/
        writeACLConfig("ACL ALLOW adk CREATE QUEUE name test");
        fail("fail");
    } catch (ConfigurationException ce) {
        assertEquals(String.format(PlainConfiguration.PROPERTY_NO_EQUALS_MSG, 1), ce.getMessage());
    }
}

From source file:org.wso2.andes.server.security.access.plugins.PlainConfigurationTest.java

public void testACLFileSyntaxPropertyNoValue() throws Exception {
    try {//from  w  w w .  j  a  va 2 s.com
        writeACLConfig("ACL ALLOW adk CREATE QUEUE name =");
        fail("fail");
    } catch (ConfigurationException ce) {
        assertEquals(String.format(PlainConfiguration.PROPERTY_NO_VALUE_MSG, 1), ce.getMessage());
    }
}

From source file:org.wso2.andes.server.virtualhost.plugins.policies.TopicDeletePolicyConfigurationTest.java

/**
 * Test that with the correct configuration the deletePersistent option can
 * be enabled./*from w  ww . j  av a2 s . com*/
 *
 * Test creates a new Configuration object and passes in the xml snippet
 * that the ConfigurationPlugin would receive during normal execution.
 * This is the XML that would be matched for this plugin:
 * <topicdelete>
 *   <delete-persistent>
 * <topicdelete>
 *
 * So it would be subset and passed in as just:
 *   <delete-persistent>
 *
 *
 * The property should therefore be enabled. 
 *
 */
public void testConfigDeletePersistent() {
    TopicDeletePolicyConfiguration config = new TopicDeletePolicyConfiguration();

    XMLConfiguration xmlconfig = new XMLConfiguration();

    xmlconfig.addProperty("delete-persistent", "");

    // Create a CompositeConfiguration as this is what the broker uses
    CompositeConfiguration composite = new CompositeConfiguration();
    composite.addConfiguration(xmlconfig);

    try {
        config.setConfiguration("", composite);
    } catch (ConfigurationException e) {
        fail(e.getMessage());
    }

    assertTrue("A configured TopicDelete should delete persistent queues.", config.deletePersistent());
}

From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionConfigurationTest.java

/**
 * Default Testing:/*from  www  . j  ava  2  s . c o  m*/
 *
 * Provide a fully complete and valid configuration specifying 'delay' and
 * 'timeunit' and ensure that it is correctly processed.
 *
 * Ensure no exceptions are thrown and that we get the same values back that
 * were put into the configuration.
 */
public void testConfigLoadingValidConfig() {
    SlowConsumerDetectionConfiguration config = new SlowConsumerDetectionConfiguration();

    XMLConfiguration xmlconfig = new XMLConfiguration();

    long DELAY = 10;
    String TIMEUNIT = TimeUnit.MICROSECONDS.toString();
    xmlconfig.addProperty("delay", String.valueOf(DELAY));
    xmlconfig.addProperty("timeunit", TIMEUNIT);

    // Create a CompositeConfiguration as this is what the broker uses
    CompositeConfiguration composite = new CompositeConfiguration();
    composite.addConfiguration(xmlconfig);

    try {
        config.setConfiguration("", composite);
    } catch (ConfigurationException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }

    assertEquals("Delay not correctly returned.", DELAY, config.getDelay());
    assertEquals("TimeUnit not correctly returned.", TIMEUNIT, String.valueOf(config.getTimeUnit()));
}

From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionConfigurationTest.java

/**
   * Default Testing://from  w w w .  j  a  v a 2 s  .com
   *
   * Test Missing TimeUnit value gets default.
   *
   * The TimeUnit value is optional and default to SECONDS.
   *
   * Test that if we do not specify a TimeUnit then we correctly get seconds.
   *
   * Also verify that relying on the default does not impact the setting of
   * the 'delay' value.
   *
   */
public void testConfigLoadingMissingTimeUnitDefaults() {
    SlowConsumerDetectionConfiguration config = new SlowConsumerDetectionConfiguration();

    XMLConfiguration xmlconfig = new XMLConfiguration();

    long DELAY = 10;
    xmlconfig.addProperty("delay", String.valueOf(DELAY));

    // Create a CompositeConfiguration as this is what the broker uses
    CompositeConfiguration composite = new CompositeConfiguration();
    composite.addConfiguration(xmlconfig);
    try {
        config.setConfiguration("", composite);
    } catch (ConfigurationException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }

    assertEquals("Delay not correctly returned.", DELAY, config.getDelay());
    assertEquals("Default TimeUnit incorrect", TimeUnit.SECONDS, config.getTimeUnit());
}

From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionConfigurationTest.java

/**
 * Input Testing:/*from ww w.  ja v a 2s  . co  m*/
 *
 * TimeUnit parsing requires the String value be in UpperCase.
 * Ensure we can handle when the user doesn't know this.
 *
 * Same test as 'testConfigLoadingValidConfig' but checking that
 * the timeunit field is not case sensitive.
 * i.e. the toUpper is being correctly applied.
 */
public void testConfigLoadingValidConfigStrangeTimeUnit() {
    SlowConsumerDetectionConfiguration config = new SlowConsumerDetectionConfiguration();

    XMLConfiguration xmlconfig = new XMLConfiguration();

    long DELAY = 10;

    xmlconfig.addProperty("delay", DELAY);
    xmlconfig.addProperty("timeunit", "MiCrOsEcOnDs");

    // Create a CompositeConfiguration as this is what the broker uses
    CompositeConfiguration composite = new CompositeConfiguration();
    composite.addConfiguration(xmlconfig);

    try {
        config.setConfiguration("", composite);
    } catch (ConfigurationException e) {
        e.printStackTrace();
        fail(e.getMessage());
    }

    assertEquals("Delay not correctly returned.", DELAY, config.getDelay());
    assertEquals("TimeUnit not correctly returned.", TimeUnit.MICROSECONDS.toString(),
            String.valueOf(config.getTimeUnit()));

}

From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionConfigurationTest.java

/**
 * Failure Testing:/*from  w ww  . java2s  . c  om*/
 *
 * Test that missing delay fails.
 * If we have no delay then we do not pick a default. So a Configuration
 * Exception is thrown.
 *
 * */
public void testConfigLoadingInValidMissingDelay() {
    SlowConsumerDetectionConfiguration config = new SlowConsumerDetectionConfiguration();

    XMLConfiguration xmlconfig = new XMLConfiguration();

    xmlconfig.addProperty("timeunit", TimeUnit.SECONDS.toString());

    // Create a CompositeConfiguration as this is what the broker uses
    CompositeConfiguration composite = new CompositeConfiguration();
    composite.addConfiguration(xmlconfig);
    try {
        config.setConfiguration("", composite);
        fail("Configuration should fail to validate");
    } catch (ConfigurationException e) {
        assertEquals("Incorrect message.",
                "SlowConsumerDetectionConfiguration: unable to configure invalid delay:null", e.getMessage());
    }
}

From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionConfigurationTest.java

/**
 * Failure Testing://from ww  w .  jav a 2  s .com
 *
 * Test that erroneous TimeUnit fails.
 *
 * Valid TimeUnit values vary based on the JVM version i.e. 1.6 added HOURS/DAYS etc.
 *
 * We don't test the values for TimeUnit are accepted other than MILLISECONDS in the
 * positive testing at the start.
 *
 * Here we ensure that an erroneous for TimeUnit correctly throws an exception.
 *
 * We test with 'foo', which will never be a TimeUnit
 *
 */
public void testConfigLoadingInValidTimeUnit() {
    SlowConsumerDetectionConfiguration config = new SlowConsumerDetectionConfiguration();

    String TIMEUNIT = "foo";
    XMLConfiguration xmlconfig = new XMLConfiguration();

    xmlconfig.addProperty("delay", "10");
    xmlconfig.addProperty("timeunit", TIMEUNIT);

    // Create a CompositeConfiguration as this is what the broker uses
    CompositeConfiguration composite = new CompositeConfiguration();
    composite.addConfiguration(xmlconfig);
    try {
        config.setConfiguration("", composite);
        fail("Configuration should fail to validate");
    } catch (ConfigurationException e) {
        assertEquals("Incorrect message.",
                "Unable to configure Slow Consumer Detection invalid TimeUnit:" + TIMEUNIT, e.getMessage());
    }
}