Search in sources :

Example 6 with ConfigFilter

use of org.apache.deltaspike.core.spi.config.ConfigFilter in project deltaspike by apache.

the class ConfigResolverTest method testConfigFilter.

@Test
public void testConfigFilter() {
    ConfigFilter configFilter = new TestConfigFilter();
    Assert.assertEquals("shouldGetDecrypted: value", configFilter.filterValue("somekey.encrypted", "value"));
    Assert.assertEquals("**********", configFilter.filterValueForLog("somekey.password", "value"));
    ConfigResolver.addConfigFilter(configFilter);
    Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getPropertyValue("testkey4.encrypted"));
    Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getProjectStageAwarePropertyValue("testkey4.encrypted"));
    Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getProjectStageAwarePropertyValue("testkey4.encrypted", null));
    Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getPropertyAwarePropertyValue("testkey4.encrypted", "dbvendor"));
    Assert.assertEquals("shouldGetDecrypted: value", ConfigResolver.getPropertyAwarePropertyValue("testkey4.encrypted", "dbvendor", null));
    List<String> allPropertyValues = ConfigResolver.getAllPropertyValues("testkey4.encrypted");
    Assert.assertNotNull(allPropertyValues);
    Assert.assertEquals(1, allPropertyValues.size());
    Assert.assertEquals("shouldGetDecrypted: value", allPropertyValues.get(0));
}
Also used : ConfigFilter(org.apache.deltaspike.core.spi.config.ConfigFilter) Test(org.junit.Test)

Aggregations

ConfigFilter (org.apache.deltaspike.core.spi.config.ConfigFilter)6 ConfigSource (org.apache.deltaspike.core.spi.config.ConfigSource)2 ConfigSourceProvider (org.apache.deltaspike.core.spi.config.ConfigSourceProvider)2 Test (org.junit.Test)2