@Override public String parseProperty(String key, String value, Properties properties) { return ConfigResolver.getPropertyValue(key); } }
public ConnectionPoolConfiguration(String poolName) { username = ConfigResolver.getPropertyValue("dw." + poolName + ".accumulo.userName"); password = ConfigResolver.getPropertyValue("dw." + poolName + ".accumulo.password"); instance = ConfigResolver.getPropertyValue("dw." + poolName + ".instanceName"); zookeepers = ConfigResolver.getPropertyValue("dw." + poolName + ".zookeepers"); lowPriorityPoolSize = Integer.parseInt(ConfigResolver.getPropertyValue("dw." + poolName + ".pool.low.size", "25")); normalPriorityPoolSize = Integer.parseInt(ConfigResolver.getPropertyValue("dw." + poolName + ".pool.normal.size", "50")); highPriorityPoolSize = Integer.parseInt(ConfigResolver.getPropertyValue("dw." + poolName + ".pool.high.size", "100")); adminPriorityPoolSize = Integer.parseInt(ConfigResolver.getPropertyValue("dw." + poolName + ".pool.admin.size", "200")); }
@ConfigEntry public Boolean getAlwaysTwoStepAuthentication() { Boolean result = null; if (twoStepAuthenticationProviderFound) { String value = ConfigResolver.getPropertyValue("2step.always", "true"); result = Boolean.valueOf(value); } return result; }
@ConfigEntry public String getNamedPermissionCheck() { return ConfigResolver.getPropertyValue("namedPermissionCheck.class", ""); }
@ConfigEntry public String getCustomCheck() { return ConfigResolver.getPropertyValue("customCheck.class", ""); }
@ConfigEntry public String getLocationSecuredURLProperties() { return ConfigResolver.getPropertyValue("securedURLs.file", "/WEB-INF/securedURLs.ini"); }
@ConfigEntry public String getPermissionVoterSuffix() { return ConfigResolver.getPropertyValue("voter.suffix.permission", "PermissionVoter"); }
@ConfigEntry public String getCustomCheckSuffix() { return ConfigResolver.getPropertyValue("voter.suffix.check", "AccessDecisionVoter"); }
@ConfigEntry public String getSSOApplication() { return ConfigResolver.getPropertyValue("SSO.application", ""); }
@ConfigEntry public HashEncoding getHashEncoding() { HashEncoding result = HashEncoding.fromValue(ConfigResolver.getPropertyValue("hashEncoding", "HEX")); if (result == null) { throw new OctopusConfigurationException( "The 'hashEncoding' parameter value " + ConfigResolver.getPropertyValue("hashEncoding", "HEX") + " isn't valid. Use 'HEX' or 'BASE64'."); } return result; }
/** * This method triggers freeing of the ConfigSources. */ @SuppressWarnings("UnusedDeclaration") public void freeConfigSources(@Observes BeforeShutdown bs) { String appName = ConfigResolver.getPropertyValue(ConfigResolver.DELTASPIKE_APP_NAME_CONFIG); unRegisterConfigMBean(appName); ConfigResolver.freeConfigSources(); detectedParentPropertyFileConfigs.remove(ClassUtils.getClassLoader(null)); }
@Test public void testStandaloneConfigSource() { Assert.assertNull(ConfigResolver.getPropertyValue("notexisting")); Assert.assertEquals("testvalue", ConfigResolver.getPropertyValue("testkey")); }
@Test public void testConfigVariableNotExisting() { { String url = ConfigResolver.getPropertyValue("deltaspike.test.nonexisting.variable", "", true); Assert.assertEquals("${does.not.exist}/someservice/myendpoint", url); } { String url = ConfigResolver.getPropertyValue("deltaspike.test.nonexisting.variable", true); Assert.assertEquals("${does.not.exist}/someservice/myendpoint", url); } }
@Test public void testConfigVariableReplacement() { { String url = ConfigResolver.getPropertyValue("deltaspike.test.someapp.soap.endpoint", "", true); Assert.assertEquals("http://localhost:12345/someservice/myendpoint", url); } { String url = ConfigResolver.getPropertyValue("deltaspike.test.someapp.soap.endpoint", true); Assert.assertEquals("http://localhost:12345/someservice/myendpoint", url); } }
@Test public void testOverruledValue() { String result = ConfigResolver.getPropertyValue("test"); Assert.assertEquals("test2", result); }
@Test public void testCustomPropertyConfigSources() throws Exception { Assert.assertTrue( Thread.currentThread().getContextClassLoader().getResources(CONFIG_FILE_NAME).hasMoreElements()); String value = ConfigResolver.getPropertyValue("some.propertykey"); Assert.assertNotNull(value); Assert.assertEquals("somevalue", value); String bootTimeValue = ConfigResolver.getPropertyValue("some.boottimekey"); Assert.assertNotNull(bootTimeValue); Assert.assertEquals("correctvalue", bootTimeValue); }
@Test public void testConfigViaMetaInfPropertyFile() { String key = "testProperty03"; String value = "test_value_03"; String configuredValue = ConfigResolver.getPropertyValue(key); Assert.assertEquals(value, configuredValue); }
@Test public void testConfigFilter() { String secretVal = ConfigResolver.getPropertyValue("my.very.secret"); Assert.assertNotNull(secretVal); Assert.assertEquals("a secret value: onlyIDoKnowIt", secretVal); }
@Test public void testConfig() { String val = ConfigResolver.getPropertyValue("deltaspike.test.config.from.file"); Assert.assertNotNull(val); Assert.assertEquals("it works", val); }
@Test public void testConfigVariableRecursiveDeclaration() { String url = ConfigResolver.getPropertyValue("deltaspike.test.recursive.variable1", "", true); Assert.assertEquals("pre-crazy-post/ohgosh/crazy", url); ConfigResolver.TypedResolver<String> tr = ConfigResolver.resolve("deltaspike.test.recursive.variable1") .evaluateVariables(true).logChanges(true); Assert.assertEquals("pre-crazy-post/ohgosh/crazy", tr.getValue()); }