List of usage examples for org.apache.commons.configuration2 PropertiesConfiguration getProperty
@Override public final Object getProperty(final String key)
From source file:com.sikulix.core.SX.java
private static void mergeExtraOptions(PropertiesConfiguration baseOptions, PropertiesConfiguration extraOptions) { trace("loadOptions: have to merge extra Options"); if (isNull(extraOptions) || extraOptions.size() == 0) { return;// www.ja va 2s . c om } Iterator<String> allKeys = extraOptions.getKeys(); while (allKeys.hasNext()) { String key = allKeys.next(); if (isNull(baseOptions.getProperty(key))) { baseOptions.addProperty(key, extraOptions.getProperty(key)); trace("Option added: %s", key); } else { baseOptions.addProperty(key, extraOptions.getProperty(key)); trace("Option changed: %s", key); } } }
From source file:com.sikulix.core.SX.java
private static void setOptions(PropertiesConfiguration someOptions) { if (isNull(someOptions) || someOptions.size() == 0) { return;/* www.j a v a2s .com*/ } Iterator<String> allKeys = someOptions.getKeys(); List<String> sxSettings = new ArrayList<>(); while (allKeys.hasNext()) { String key = allKeys.next(); if (key.startsWith("Settings.")) { sxSettings.add(key); continue; } trace("!setOptions: %s = %s", key, someOptions.getProperty(key)); } if (sxSettings.size() > 0) { Class cClass = null; try { cClass = Class.forName("org.sikuli.basics.Settings"); } catch (ClassNotFoundException e) { error("!setOptions: %s", cClass); } if (!isNull(cClass)) { for (String sKey : sxSettings) { String sAttr = sKey.substring("Settings.".length()); Field cField = null; Class ccField = null; try { cField = cClass.getField(sAttr); ccField = cField.getType(); if (ccField.getName() == "boolean") { cField.setBoolean(null, someOptions.getBoolean(sKey)); } else if (ccField.getName() == "int") { cField.setInt(null, someOptions.getInt(sKey)); } else if (ccField.getName() == "float") { cField.setFloat(null, someOptions.getFloat(sKey)); } else if (ccField.getName() == "double") { cField.setDouble(null, someOptions.getDouble(sKey)); } else if (ccField.getName() == "String") { cField.set(null, someOptions.getString(sKey)); } trace("!setOptions: %s = %s", sAttr, someOptions.getProperty(sKey)); someOptions.clearProperty(sKey); } catch (Exception ex) { error("!setOptions: %s = %s", sKey, sxOptions.getProperty(sKey)); } } } } }
From source file:org.apache.activemq.cli.test.ArtemisTest.java
private void checkRole(String user, File roleFile, String... roles) throws Exception { Configurations configs = new Configurations(); FileBasedConfigurationBuilder<PropertiesConfiguration> roleBuilder = configs.propertiesBuilder(roleFile); PropertiesConfiguration roleConfig = roleBuilder.getConfiguration(); for (String r : roles) { String storedUsers = (String) roleConfig.getProperty(r); System.out.println("users in role: " + r + " ; " + storedUsers); List<String> userList = StringUtil.splitStringList(storedUsers, ","); assertTrue(userList.contains(user)); }//from w w w . j a v a 2 s . co m }
From source file:org.apache.activemq.cli.test.ArtemisTest.java
private boolean checkPassword(String user, String password, File userFile) throws Exception { Configurations configs = new Configurations(); FileBasedConfigurationBuilder<PropertiesConfiguration> userBuilder = configs.propertiesBuilder(userFile); PropertiesConfiguration userConfig = userBuilder.getConfiguration(); String storedPassword = (String) userConfig.getProperty(user); HashProcessor processor = PasswordMaskingUtil.getHashProcessor(storedPassword); return processor.compare(password.toCharArray(), storedPassword); }
From source file:org.jbb.lib.properties.FreshInstallPropertiesCreator.java
private static void addMissingProperties(PropertiesConfiguration reference, PropertiesConfiguration target) { Lists.newArrayList(reference.getKeys()).stream().filter(propertyKey -> !target.containsKey(propertyKey)) .forEach(missingKey -> target.setProperty(missingKey, reference.getProperty(missingKey))); }
From source file:uk.co.hadoopathome.kafkastreams.integration.StreamingDroolsIntegrationTest.java
@Test public void testApplication() throws Exception { PropertiesConfiguration properties = ConfigurationReader.getProperties("config.properties"); properties.setProperty("bootstrapServers", CLUSTER.bootstrapServers()); properties.setProperty("zookeeperServers", CLUSTER.zookeeperConnect()); String inputTopic = (String) properties.getProperty("inputTopic"); String outputTopic = (String) properties.getProperty("outputTopic"); CLUSTER.createTopic(inputTopic);/*from www . ja va 2 s . c o m*/ CLUSTER.createTopic(outputTopic); List<String> inputValues = Arrays.asList("Hello", "Canal", "Camel"); List<String> expectedOutput = Arrays.asList("0Hello", "Canal", "0Camel"); String statePath = (String) properties.getProperty(StreamsConfig.STATE_DIR_CONFIG); IntegrationTestUtils.purgeLocalStreamsState(statePath); KafkaStreams streams = KafkaStreamsRunner.runKafkaStream(properties); Properties producerConfig = createProducerConfig(); IntegrationTestUtils.produceValuesSynchronously(inputTopic, inputValues, producerConfig); Properties consumerConfig = createConsumerConfig(); List<String> actualOutput = IntegrationTestUtils.waitUntilMinValuesRecordsReceived(consumerConfig, outputTopic, expectedOutput.size()); assertThat(actualOutput).containsExactlyElementsOf(expectedOutput); streams.close(); }