List of usage examples for org.apache.commons.configuration ConfigurationException getMessage
public String getMessage()
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionPolicyConfigurationTest.java
/** * Input Testing:/* w ww.jav a2s . c o m*/ * * Test that a given String can be set and retrieved through the configuration * * No validation is being performed to ensure that the policy exists. Only * that a value can be set for the policy. * */ public void testConfigLoadingValidConfig() { SlowConsumerDetectionPolicyConfiguration config = new SlowConsumerDetectionPolicyConfiguration(); XMLConfiguration xmlconfig = new XMLConfiguration(); String policyName = "TestPolicy"; xmlconfig.addProperty("name", policyName); // 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("Policy name not retrieved as expected.", policyName, config.getPolicyName()); }
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionPolicyConfigurationTest.java
/** * Failure Testing://from w ww .j a va 2s .co m * * Test that providing a configuration section without the 'name' field * causes an exception to be thrown. * * An empty configuration is provided and the thrown exception message * is checked to confirm the right reason. * */ public void testConfigLoadingInValidConfig() { SlowConsumerDetectionPolicyConfiguration config = new SlowConsumerDetectionPolicyConfiguration(); XMLConfiguration xmlconfig = new XMLConfiguration(); // Create a CompositeConfiguration as this is what the broker uses CompositeConfiguration composite = new CompositeConfiguration(); composite.addConfiguration(xmlconfig); try { config.setConfiguration("", composite); fail("Config is invalid so won't validate."); } catch (ConfigurationException e) { e.printStackTrace(); assertEquals("Exception message not as expected.", "No Slow consumer policy defined.", e.getMessage()); } }
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionQueueConfigurationTest.java
/** * Test a fully loaded configuration file. * * It is not an error to have all control values specified. * <p>/*from w ww . j a v a 2s.co m*/ * Here we need to catch the {@link ConfigurationException} that ensues due to lack * of a policy plugin. */ public void testConfigLoadingValidConfig() { SlowConsumerDetectionQueueConfiguration config = new SlowConsumerDetectionQueueConfiguration(); XMLConfiguration xmlconfig = new XMLConfiguration(); xmlconfig.addProperty("messageAge", "60000"); xmlconfig.addProperty("depth", "1024"); xmlconfig.addProperty("messageCount", "10"); // Create a CompositeConfiguration as this is what the broker uses CompositeConfiguration composite = new CompositeConfiguration(); composite.addConfiguration(xmlconfig); try { config.setConfiguration("", composite); fail("No Policies are avaialbe to load in a unit test"); } catch (ConfigurationException e) { assertTrue("Exception message incorrect, was: " + e.getMessage(), e.getMessage().startsWith("No Slow Consumer Policy specified. Known Policies:[")); } }
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionQueueConfigurationTest.java
/** * When we do not specify any control value then a {@link ConfigurationException} * must be thrown to remind us./* w w w . j a v a 2 s . c om*/ */ public void testConfigLoadingMissingConfig() { SlowConsumerDetectionQueueConfiguration config = new SlowConsumerDetectionQueueConfiguration(); XMLConfiguration xmlconfig = new XMLConfiguration(); // Create a CompositeConfiguration as this is what the broker uses CompositeConfiguration composite = new CompositeConfiguration(); composite.addConfiguration(xmlconfig); try { config.setConfiguration("", composite); fail("No Policies are avaialbe to load in a unit test"); } catch (ConfigurationException e) { assertEquals("At least one configuration property('messageAge','depth'" + " or 'messageCount') must be specified.", e.getMessage()); } }
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionQueueConfigurationTest.java
/** * Setting messageAge on its own is enough to have a valid configuration * * Here we need to catch the {@link ConfigurationException} that ensues due to lack * of a policy plugin.//from ww w. java 2 s.c om */ public void testConfigLoadingMessageAgeOk() { SlowConsumerDetectionQueueConfiguration config = new SlowConsumerDetectionQueueConfiguration(); XMLConfiguration xmlconfig = new XMLConfiguration(); xmlconfig.addProperty("messageAge", "60000"); // Create a CompositeConfiguration as this is what the broker uses CompositeConfiguration composite = new CompositeConfiguration(); composite.addConfiguration(xmlconfig); try { config.setConfiguration("", composite); fail("No Policies are avaialbe to load in a unit test"); } catch (ConfigurationException e) { assertTrue("Exception message incorrect, was: " + e.getMessage(), e.getMessage().startsWith("No Slow Consumer Policy specified. Known Policies:[")); } }
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionQueueConfigurationTest.java
/** * Setting depth on its own is enough to have a valid configuration. * * Here we need to catch the {@link ConfigurationException} that ensues due to lack * of a policy plugin.//from w ww.jav a 2 s . c om */ public void testConfigLoadingDepthOk() { SlowConsumerDetectionQueueConfiguration config = new SlowConsumerDetectionQueueConfiguration(); XMLConfiguration xmlconfig = new XMLConfiguration(); xmlconfig.addProperty("depth", "1024"); // Create a CompositeConfiguration as this is what the broker uses CompositeConfiguration composite = new CompositeConfiguration(); composite.addConfiguration(xmlconfig); try { config.setConfiguration("", composite); fail("No Policies are avaialbe to load in a unit test"); } catch (ConfigurationException e) { assertTrue("Exception message incorrect, was: " + e.getMessage(), e.getMessage().startsWith("No Slow Consumer Policy specified. Known Policies:[")); } }
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionQueueConfigurationTest.java
/** * Setting messageCount on its own is enough to have a valid configuration. * * Here we need to catch the {@link ConfigurationException} that ensues due to lack * of a policy plugin.//from w w w.j av a 2 s . c o m */ public void testConfigLoadingMessageCountOk() { SlowConsumerDetectionQueueConfiguration config = new SlowConsumerDetectionQueueConfiguration(); XMLConfiguration xmlconfig = new XMLConfiguration(); xmlconfig.addProperty("messageCount", "10"); // Create a CompositeConfiguration as this is what the broker uses CompositeConfiguration composite = new CompositeConfiguration(); composite.addConfiguration(xmlconfig); try { config.setConfiguration("", composite); fail("No Policies are avaialbe to load in a unit test"); } catch (ConfigurationException e) { assertTrue("Exception message incorrect, was: " + e.getMessage(), e.getMessage().startsWith("No Slow Consumer Policy specified. Known Policies:[")); } }
From source file:org.wso2.andes.tools.messagestore.MessageStoreTool.java
private void loadVirtualHosts(File configFile) { if (!configFile.exists()) { _devlog.error("Config file not found:" + configFile.getAbsolutePath()); return;// w w w . ja va 2 s. c om } else { _devlog.debug("using config file :" + configFile.getAbsolutePath()); } try { ConfigurationFileApplicationRegistry registry = new ConfigurationFileApplicationRegistry(configFile); ApplicationRegistry.remove(); ApplicationRegistry.initialise(registry); checkMessageStores(); _initialised = true; } catch (ConfigurationException e) { _console.println("Unable to load configuration due to configuration error: " + e.getMessage()); e.printStackTrace(); } catch (Exception e) { _console.println("Unable to load configuration due to: " + e.getMessage()); e.printStackTrace(); } }
From source file:org.wso2.carbon.device.mgt.iot.agent.kura.display.resource.IFrameResource.java
@Override public void run(Map<String, Object> args) { log.info("run()"); DisplayServiceContext displayServiceContext = (DisplayServiceContext) args.get("displayServiceContext"); try {//from w ww .j a v a 2 s . c o m displayServiceContext.setCurrentIFrameUrl(getNavigationUrl(), getPreScreenDelay(), getOnScreenDelay()); } catch (ConfigurationException e) { log.severe("Resource Run Error: " + e.getMessage()); } }
From source file:org.wso2.carbon.device.mgt.iot.agent.kura.display.resource.UrlResource.java
@Override public void run(Map<String, Object> args) { log.info("run()"); Browser browser = (Browser) args.get("browser"); try {/*from w w w . j av a 2 s . c om*/ browser.open(getNavigationUrl()); } catch (ConfigurationException e) { log.severe("Resource Run Error: " + e.getMessage()); } }