List of usage examples for org.apache.commons.configuration ConfigurationException getCause
public Throwable getCause()
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionConfigurationTest.java
/** * Failure Testing:/*from ww w. ja va 2s . c om*/ * * Test that delay must be long not a string value. * Provide a delay as a written value not a long. 'ten'. * * This should throw a configuration exception which is being trapped and * verified to be the right exception, a NumberFormatException. * */ public void testConfigLoadingInValidDelayString() { SlowConsumerDetectionConfiguration config = new SlowConsumerDetectionConfiguration(); XMLConfiguration xmlconfig = new XMLConfiguration(); xmlconfig.addProperty("delay", "ten"); xmlconfig.addProperty("timeunit", TimeUnit.MICROSECONDS.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) { Throwable cause = e.getCause(); assertEquals("Cause not correct", NumberFormatException.class, cause.getClass()); } }
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionConfigurationTest.java
/** * Failure Testing:/* www.java2 s. c om*/ * * Test that negative delays are invalid. * * Delay must be a positive value as negative delay means doesn't make sense. * * Configuration exception with a useful message should be thrown here. * */ public void testConfigLoadingInValidDelayNegative() { SlowConsumerDetectionConfiguration config = new SlowConsumerDetectionConfiguration(); XMLConfiguration xmlconfig = new XMLConfiguration(); xmlconfig.addProperty("delay", "-10"); xmlconfig.addProperty("timeunit", TimeUnit.MICROSECONDS.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) { Throwable cause = e.getCause(); assertNotNull("Configuration Exception must not be null.", cause); assertEquals("Cause not correct", ConfigurationException.class, cause.getClass()); assertEquals("Incorrect message.", "SlowConsumerDetectionConfiguration: 'delay' must be a Positive Long value.", cause.getMessage()); } }
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionConfigurationTest.java
/** * Failure Testing:/* w w w.j a va2 s . co m*/ * * Test that delay cannot be 0. * * A zero delay means run constantly. This is not how VirtualHostTasks * are designed to be run so we dis-allow the use of 0 delay. * * Same test as 'testConfigLoadingInValidDelayNegative' but with a 0 value. * */ public void testConfigLoadingInValidDelayZero() { SlowConsumerDetectionConfiguration config = new SlowConsumerDetectionConfiguration(); XMLConfiguration xmlconfig = new XMLConfiguration(); xmlconfig.addProperty("delay", "0"); xmlconfig.addProperty("timeunit", TimeUnit.MICROSECONDS.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) { Throwable cause = e.getCause(); assertNotNull("Configuration Exception must not be null.", cause); assertEquals("Cause not correct", ConfigurationException.class, cause.getClass()); assertEquals("Incorrect message.", "SlowConsumerDetectionConfiguration: 'delay' must be a Positive Long value.", cause.getMessage()); } }