List of usage examples for org.apache.commons.configuration ConfigurationException printStackTrace
public void printStackTrace()
From source file:org.valabs.odisp.standart.ConfigurationManager.java
private void loadConfigFile(String element) { try {//from w w w . j av a 2s . c o m // compConf.addConfiguration(); XMLConfiguration conf = new XMLConfiguration(element); // try { // // override // compConf.addConfiguration(new XMLConfiguration(element + ".local")); // } catch (ConfigurationException ex) { // // } log.info("Loaded " + element); loadConfiguration(conf); } catch (ConfigurationException ex) { ex.printStackTrace(); } }
From source file:org.valabs.odisp.standart5.ConfigurationManager5.java
private void loadConfigFile(String element) { try {// w w w.j a v a 2s .c o m XMLConfiguration conf = new XMLConfiguration(element); log.info("Loaded " + element); loadConfiguration(conf); } catch (ConfigurationException ex) { ex.printStackTrace(); } }
From source file:org.wso2.andes.configuration.qpid.plugins.ConfigurationPluginTest.java
@Override public void setUp() throws Exception { // Test does not directly use the AppRegistry but the configured broker // is required for the correct ConfigurationPlugin processing super.setUp(); XMLConfiguration xmlconfig = new XMLConfiguration(); xmlconfig.addProperty("base.element[@property]", "property"); xmlconfig.addProperty("base.element.name", "name"); // We make these strings as that is how they will be read from the file. xmlconfig.addProperty("base.element.positiveLong", String.valueOf(POSITIVE_LONG)); xmlconfig.addProperty("base.element.negativeLong", String.valueOf(NEGATIVE_LONG)); xmlconfig.addProperty("base.element.boolean", String.valueOf(true)); xmlconfig.addProperty("base.element.double", String.valueOf(DOUBLE)); for (int i = 0; i < LIST_SIZE; i++) { xmlconfig.addProperty("base.element.list", i); }//from ww w.j a v a2 s . c om //Use a composite configuration as this is what our broker code uses. CompositeConfiguration composite = new CompositeConfiguration(); composite.addConfiguration(xmlconfig); _plugin = new ConfigPlugin(); try { _plugin.setConfiguration("base.element", composite.subset("base.element")); } catch (ConfigurationException e) { e.printStackTrace(); fail(e.toString()); } }
From source file:org.wso2.andes.server.virtualhost.plugins.SlowConsumerDetectionConfigurationTest.java
/** * Default Testing:/*from w ww . j a v a 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 . java 2s. c o m * * 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 w w w. j a v a2s . c o 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.SlowConsumerDetectionPolicyConfigurationTest.java
/** * Input Testing:/* w w w . j a v a 2 s. co 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 ww w . jav a 2 s .c om*/ * * 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.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 v a2 s . c o m*/ } 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:pagelyzer.JPagelyzer.java
public JPagelyzer(String[] args, boolean isTrain) { // this.isTrain = isTrain; // no need any more cpath browser etc. they are all in config file // not to change the usage of options I am adding display options to send to usage. displayoptions.addOption("get", true, "The functionality to run: " + SCREENSHOT + ", " + SOURCE + " or " + SEGMENTATION + " or " + MIRROR); displayoptions.addOption("url", true, "The URL to process"); // displayoptions.addOption("url2",true,"Second URL to compare"); displayoptions.addOption("config", true, "Global configuration file for an example of file: https://github.com/openplanets/pagelyzer/blob/master/config.xml"); // displayoptions.addOption("mode",true,"hybrid/content/image it can be also set in config file"); CommandLineParser parser = new BasicParser(); CommandLine cmd;//from w w w . j av a 2 s .co m /* Parsing comandline parameters*/ try { cmd = parser.parse(displayoptions, args); } catch (ParseException pe) { usage(displayoptions); return; } if (!cmd.hasOption("config")) { usage(displayoptions); System.exit(0); } try { config = new XMLConfiguration(cmd.getOptionValue("config")); } catch (ConfigurationException e) { // TODO Auto-generated catch block e.printStackTrace(); } // if(displayoptions.getOption("mode").getValue()!=null) // // comparemode= displayoptions.getOption("mode").getValue(); // else // // comparemode = this.config.getString("pagelyzer.run.default.comparison.mode"); // cfile = config.getString("pagelyzer.run.default.comparison.subdir")+ "ex_" + config.getString("pagelyzer.run.default.comparison.mode") +".xml"; isDebugActive = config.getBoolean("pagelyzer.debug.screenshots.active"); debugfilePattern = config.getString("pagelyzer.debug.screenshots.filepattern"); debugPathtoSave = config.getString("pagelyzer.debug.screenshots.path"); outputfile = config.getString("pagelyzer.run.default.parameter.outputfile"); browser = config.getString("pagelyzer.run.default.parameter.browser"); // browser2 = config.getString("pagelyzer.run.default.parameter.browser2"); // this.config.setProperty("pagelyzer.run.default.comparison.file","ex_"+comparemode+".xml"); // if(isTrain) // { // sc = new ScapeTrain(); // try { // sc.init(new File(cfile)); // } catch (Exception ex) { // System.err.println("Marcalize could not be initialized"); // System.exit(0); // } // // } // else // { // url1 = displayoptions.getOption("url1").getValue(); // url2 = displayoptions.getOption("url2").getValue(); // } /* Validate program intrinsic input parameters and configuration */ if (cmd.hasOption("get")) { target = cmd.getOptionValue("get"); } else { if (this.config.getString("pagelyzer.run.default.parameter.get") == null) { usage(displayoptions); System.exit(0); } else { target = this.config.getString("pagelyzer.run.default.parameter.get"); } } if (this.config.getString("selenium.run.mode").equals(LOCAL)) { System.out.println("Selenium: local WebDriver"); } else { System.out.println("Selenium: remote " + this.config.getString("selenium.server.url")); } if ((this.config.getBoolean("pagelyzer.debug.screenshots.active")) && (this.config.getString("pagelyzer.debug.screenshots.path") == null)) { System.out.println( "Debug was activated, but no path is specified to put the files. Use -debugpath path or change the configuration file"); System.exit(0); } if (!cmd.hasOption("url")) { System.out.println("URL parameter missing"); System.exit(0); } else url = cmd.getOptionValue("url"); }