List of usage examples for org.apache.commons.configuration ConfigurationException printStackTrace
public void printStackTrace()
From source file:jdbc.pool.JDBCPoolMySQLTest.java
/** * Tests the capacity increament of the pool. * /*from w w w .j a v a 2 s . c om*/ */ public void testCapacityIncreament() { testGetInstanceNull(); logger.debug("testCapacityIncreament Start"); try { CConnectionPoolManager manager = create(); // capacity increament MYSQL2 1 Connection conOracle1 = manager.getConnection("MYSQL2"); CPoolStatisticsBean bean = manager.getPoolStatistics("MYSQL2"); assertEquals("Pool Name", "MYSQL2", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 1, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 0, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 1, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); Connection conOracle2 = manager.getConnection("MYSQL2"); bean = manager.getPoolStatistics("MYSQL2"); assertEquals("Pool Name", "MYSQL2", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 2, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 0, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 2, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); conOracle2.close(); conOracle1.close(); // capacity increament MySQL 2 Connection conMysql1 = manager.getConnection("MYSQL"); Connection conMysql2 = manager.getConnection("MYSQL"); Connection conMysql3 = manager.getConnection("MYSQL"); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 3, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 0, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 3, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); Connection conMysql4 = manager.getConnection("MYSQL"); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 4, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 1, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 4, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); conMysql1.close(); conMysql2.close(); conMysql3.close(); conMysql4.close(); manager.destroy(true); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } logger.debug("testCapacityIncreament end."); }
From source file:jdbc.pool.JDBCPoolMySQLTest.java
public synchronized void testGetConnection() { testGetInstanceNull();/*www . j a va 2 s. com*/ logger.debug("testGetConnection Start."); CConnectionPoolManager manager = null; try { manager = create(); CPoolStatisticsBean bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 0, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 3, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 0, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); Connection con = manager.getConnection("MYSQL"); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 1, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 2, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 1, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); con.close(); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 1, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 3, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 0, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); Connection con1 = manager.getConnection("MYSQL"); Connection con2 = manager.getConnection("MYSQL"); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 2, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 1, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 2, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); con1.close(); con2.close(); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 2, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 3, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 0, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); manager.destroy(true); testGetInstanceNull(); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } finally { if (manager != null) manager.destroy(true); testGetInstanceNull(); } logger.debug("testGetConnection end."); }
From source file:jdbc.pool.JDBCPoolMySQLTest.java
public synchronized void testGetDataSource() { testGetInstanceNull();//from w ww . j a va 2 s .co m logger.debug("testGetDataSource Start."); CConnectionPoolManager manager = null; try { manager = create(); CPoolStatisticsBean bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 0, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 3, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 0, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); DataSource dataSource = manager.getDataSource("MYSQL"); Connection con = dataSource.getConnection(); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 1, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 2, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 1, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); con.close(); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 1, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 3, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 0, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); Connection con1 = dataSource.getConnection(); Connection con2 = dataSource.getConnection(); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 2, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 1, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 2, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); con1.close(); con2.close(); bean = manager.getPoolStatistics("MYSQL"); assertEquals("Pool Name", "MYSQL", bean.getPoolName()); assertEquals("Bad Connections Count", 0, bean.getBadConnectionCount()); assertEquals("Connections High Count", 2, bean.getConnectionsHighCount()); assertEquals("Current Free Connections", 3, bean.getCurrentFreeConnectionCount()); assertEquals("Current Used Connection count", 0, bean.getCurrentUsedConnectionCount()); assertEquals("Leaked Connection Count", 0, bean.getLeakedConnectionCount()); assertEquals("Leaked Statement Count", 0, bean.getLeakedStatementCount()); assertEquals("Leaked ResultSet Count", 0, bean.getLeakedResultSetCount()); manager.destroy(true); testGetInstanceNull(); } catch (ConfigurationException e) { e.printStackTrace(); fail("Caught ConfigurationException"); } catch (ParseException e) { e.printStackTrace(); fail("Caught ParseException"); } catch (IOException e) { e.printStackTrace(); fail("Caught IOException"); } catch (SQLException e) { e.printStackTrace(); fail("Caught SQLException"); } catch (ClassNotFoundException e) { e.printStackTrace(); fail("Caught ClassNotFoundException"); } catch (Throwable t) { t.printStackTrace(); } finally { if (manager != null) manager.destroy(true); testGetInstanceNull(); } logger.debug("testGetDataSource end."); }
From source file:nl.cyso.vsphere.client.Entry.java
/** * @param args/*from w w w . j av a2 s .c o m*/ */ public static void main(String[] args) { // Start out in ROOT ConfigMode CommandLine cli = null; // Initialize Formatter Formatter.setVersionInfo(Version.getVersion()); ConfigModes.init(); // Try to parse all ROOT cli options cli = Configuration.parseCli("ROOT", args); // Load the config if it was specified if (cli.hasOption("config")) { try { Configuration.loadFile(cli.getOptionValue("config")); } catch (ConfigurationException e) { e.printStackTrace(); System.exit(-1); } } // Load all options parsed for ROOT ConfigMode Configuration.load(cli); // Now we know which ConfigMode was selected // Display (specific) help if (Configuration.get("mode").equals("HELP")) { if (Configuration.has("help-type")) { ConfigModes.printConfigModeHelp(Configuration.get("help-type").toString()); } else { ConfigModes.printConfigModeHelp("ROOT"); } System.exit(0); } // From this point on we want a header displayed Formatter.printHeader(); // Display version information if (Configuration.get("mode").equals("VERSION")) { System.exit(0); } if (!Configuration.has("username") || !Configuration.has("password") || !Configuration.has("server")) { Formatter.usageError("No credentials were set, or server uri was missing", "ROOT", true); } try { String mode = Configuration.getString("mode"); if (mode.equals("ADDVM")) { Configuration.load("ADDVM", args); VsphereClient.createVirtualMachine(); } else if (mode.equals("REMOVEVM") || mode.equals("POWERONVM") || mode.equals("POWEROFFVM") || mode.equals("SHUTDOWNVM") || mode.equals("REBOOTVM") || mode.equals("MODIFYVM")) { Configuration.load(mode, args); Formatter.printInfoLine("Selecting root Virtual Machine folder"); ManagedObjectReference rootFolder; if (Configuration.has("folder") && !Configuration.getString("folder").equals("")) { rootFolder = VsphereQuery.findVirtualMachineFolder(Configuration.getString("dc"), Configuration.getString("folder"), 0); } else { rootFolder = VsphereQuery.getVMRootFolder(Configuration.getString("dc")); } if (rootFolder == null) { Formatter.printErrorLine("Could not select root Virtual Machine folder"); System.exit(-1); } Formatter.printInfoLine("Walking folder to find Virtual Machine"); ManagedObjectReference vm = VsphereQuery.findVirtualMachine(Configuration.getString("fqdn"), rootFolder); if (vm == null) { Formatter.printErrorLine("Could not find VM"); System.exit(-1); } if (mode.equals("REMOVEVM")) { Formatter.printInfoLine("Removing Virtual Machine: " + Configuration.getString("fqdn")); VsphereClient.deleteVirtualMachine(vm, Configuration.has("confirm")); } else if (mode.equals("POWERONVM")) { Formatter.printInfoLine("Powering on Virtual Machine: " + Configuration.getString("fqdn")); VsphereClient.powerOnVirtualMachine(vm); } else if (mode.equals("POWEROFFVM")) { Formatter.printInfoLine("Powering off Virtual Machine: " + Configuration.getString("fqdn")); VsphereClient.powerOffVirtualMachine(vm, Configuration.has("confirm")); } else if (mode.equals("SHUTDOWNVM")) { Formatter.printInfoLine( "Requesting shutdown of Virtual Machine: " + Configuration.getString("fqdn")); VsphereClient.shutdownVirtualMachine(vm, Configuration.has("confirm")); } else if (mode.equals("REBOOTVM")) { Formatter.printInfoLine( "Requesting reboot of Virtual Machine: " + Configuration.getString("fqdn")); VsphereClient.rebootVirtualMachine(vm, Configuration.has("confirm")); } else if (mode.equals("MODIFYVM")) { VsphereClient.modifyVirtualMachine(vm, Configuration.has("confirm")); } } else if (mode.equals("LIST")) { Configuration.load("LIST", args); ListModeType listType = null; try { listType = ListModeType.valueOf(Configuration.getString("list-type")); } catch (IllegalArgumentException e) { Formatter.usageError("Invalid List type selected", "LIST", true); } if (listType.equals(ListModeType.STORAGEFOLDER) && !Configuration.has("storage")) { Formatter.usageError("--storage must be specified when using storagefolder list mode", "LIST", true); } switch (listType) { case FOLDER: case VM: VsphereClient.VMFolderListMode(listType); break; case CLUSTER: case ESXNODE: case NETWORK: case STORAGE: VsphereClient.ComputeFolderListMode(listType); break; case STORAGEFOLDER: ManagedObjectReference dsref = VsphereQuery.getDatastoreReference( Configuration.getString("storage"), Configuration.getString("dc")); if (dsref == null) { Formatter.printErrorLine("Could not find specified datastore"); System.exit(-1); } VsphereClient.DatastoreListMode(dsref); break; default: throw new UnsupportedOperationException("List Mode not yet implemented"); } } else if (mode.equals("UPLOADTODATASTORE")) { Configuration.load("UPLOADTODATASTORE", args); URL server = new URL(Configuration.getString("server")); File file = new File(Configuration.getString("file")); String path = String.format("%s/%s", Configuration.getString("path"), file.getName()); if (path.charAt(0) != '/') { path = "/" + path; } String uri = String.format("%s://%s/folder%s?dcPath=%s&dsName=%s", server.getProtocol(), server.getHost(), path, URLEncoder.encode(Configuration.getString("dc"), "UTF-8"), URLEncoder.encode(Configuration.getString("storage"), "UTF-8")); Formatter.printInfoLine("Connecting to Datastore..."); HttpHelper http = new HttpHelper(new URL(uri), Configuration.getString("username"), Configuration.getString("password"), true); Formatter.printInfoLine("Uploading file..."); int response = http.putFile(file); switch (response) { case 200: Formatter.printInfoLine("File updated!"); break; case 201: Formatter.printInfoLine("File created!"); break; default: throw new RemoteException("Upload failed, HTTP error code: " + String.valueOf(response)); } Formatter.printInfoLine("Upload finished!"); } else { throw new UnsupportedOperationException("Mode not yet implemented"); } } catch (RemoteException re) { Formatter.printError("An error occured on vSphere: "); Formatter.printErrorLine(re); System.exit(-1); } catch (RuntimeException re) { Formatter.printError("Failed to execute action: "); Formatter.printErrorLine(re); Formatter.printStackTrace(re); System.exit(-1); } catch (Exception e) { Formatter.printErrorLine("An unexpected error occurred: "); Formatter.printStackTrace(e); System.exit(-1); } finally { VsphereManager.disconnect(); } }
From source file:nz.co.jsrsolutions.ds3.test.RetrieveTestData.java
public static void main(String[] args) { logger.info("Starting application [ rtd ] ..."); try {//from w w w. java2s . c o m config.addConfiguration( new XMLConfiguration(RetrieveTestData.class.getClassLoader().getResource(CONFIG_FILENAME))); HierarchicalConfiguration appConfig = config.configurationAt(APPLICATION_CONFIG_ROOT); EodDataProvider eodDataProvider = null; OutputStream out = new FileOutputStream(OUTPUT_FILENAME); XMLOutputFactory factory = XMLOutputFactory.newInstance(); XMLStreamWriter writer = factory.createXMLStreamWriter(out); eodDataProvider = EodDataProviderFactory.create(appConfig, EODDATA_PROVIDER_NAME); writer.writeStartDocument("utf-8", "1.0"); writer.writeCharacters(NEWLINE); writer.writeComment("Test data for running DataScraper unit tests against"); writer.writeCharacters(NEWLINE); writer.setPrefix(XML_PREFIX, XML_NAMESPACE_URI); writer.writeStartElement(XML_NAMESPACE_URI, TESTDATA_LOCALNAME); writer.writeNamespace(XML_PREFIX, XML_NAMESPACE_URI); writer.writeCharacters(NEWLINE); serializeExchanges(eodDataProvider, writer); serializeSymbols(eodDataProvider, writer); serializeQuotes(eodDataProvider, writer); writer.writeEndElement(); writer.writeCharacters(NEWLINE); writer.writeEndDocument(); writer.flush(); writer.close(); } catch (ConfigurationException ce) { logger.error(ce.toString()); ce.printStackTrace(); } catch (Exception e) { logger.error(e.toString()); logger.error(e); } logger.info("Exiting application [ rtd ] ..."); }
From source file:org.apache.ambari.view.hive.persistence.LocalKeyValueStorage.java
/** * Returns config instance/*ww w. j a v a 2 s . c o m*/ * @return config instance */ @Override protected synchronized PersistentConfiguration getConfig() { if (config == null) { String fileName = context.getProperties().get("dataworker.storagePath"); if (fileName == null) { String msg = "dataworker.storagePath is not configured!"; LOG.error(msg); throw new MisconfigurationFormattedException("dataworker.storagePath"); } try { config = new PersistentConfiguration(fileName); } catch (ConfigurationException e) { e.printStackTrace(); } } return config; }
From source file:org.apache.james.postage.Main.java
public static void main(String... args) { if (args == null || args.length == 0) { System.out.println("Please provide the configuration file"); return;/* ww w.ja va2 s . c o m*/ } String filename = args[0]; List<String> scenariosToRun = new ArrayList<String>(); for (int i = 1; i < args.length; i++) { scenariosToRun.add(args[i]); } // load all scenarios from configuration file ConfigurationLoader configurationLoader = new ConfigurationLoader(); Map<String, PostageConfiguration> configurations; try { // TODO allow different (non-xml) configs - as Common-Configuration supports it XMLConfiguration xmlConfiguration = new XMLConfiguration(filename); //xmlConfiguration.setThrowExceptionOnMissing(false); configurations = configurationLoader.create(xmlConfiguration); } catch (ConfigurationException e) { e.printStackTrace(); return; } // register shutdown hook if this app is terminated from outside Runtime.getRuntime().addShutdownHook(new Thread() { public void run() { shutdown(); } }); // run all scenarios runScenarios(configurations, scenariosToRun); }
From source file:org.apache.metron.AbstractConfigTest.java
protected void setUp(String configName) throws Exception { super.setUp(); this.setConfigPath("src/test/resources/config/" + getClass().getSimpleName() + ".config"); try {// ww w . ja v a2 s . c o m this.setConfig(new PropertiesConfiguration(this.getConfigPath())); Map configOptions = SettingsLoader.getConfigOptions((PropertiesConfiguration) this.config, configName + "="); this.setSettings( SettingsLoader.getConfigOptions((PropertiesConfiguration) this.config, configName + ".")); this.getSettings().put(configName, (String) configOptions.get(configName)); } catch (ConfigurationException e) { e.printStackTrace(); throw new Exception("Config not found !!" + e); } }
From source file:org.apache.qpid.server.configuration.plugins.AbstractConfigurationTest.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 w w w . j a v a 2 s . c om*/ //Use a composite configuration as this is what our broker code uses. CompositeConfiguration composite = new CompositeConfiguration(); composite.addConfiguration(xmlconfig); _plugin = new TestConfigPlugin(); try { _plugin.setConfiguration("base.element", composite.subset("base.element")); } catch (ConfigurationException e) { e.printStackTrace(); fail(e.toString()); } }
From source file:org.apache.s4.comm.DefaultCommModule.java
private void loadProperties(Binder binder) { try {//from w w w . j a v a2s.c o m config = new PropertiesConfiguration(); config.load(commConfigInputStream); // TODO - validate properties. /* Make all properties injectable. Do we need this? */ Names.bindProperties(binder, ConfigurationConverter.getProperties(config)); } catch (ConfigurationException e) { binder.addError(e); e.printStackTrace(); } }