Search in sources :

Example 1 with PropertiesConfigurationSource

use of com.sabre.oss.conf4j.source.PropertiesConfigurationSource in project open-kilda by telstra.

the class ValidatingConfigurationProviderTest method shouldPassValidationForValidConfig.

@Test
public void shouldPassValidationForValidConfig() {
    // given
    Properties source = new Properties();
    source.setProperty(TEST_KEY, String.valueOf(VALID_TEST_VALUE));
    ValidatingConfigurationProvider provider = new ValidatingConfigurationProvider(new PropertiesConfigurationSource(source), new JdkProxyStaticConfigurationFactory());
    // when
    TestConfig config = provider.getConfiguration(TestConfig.class);
    // then
    assertEquals(VALID_TEST_VALUE, config.getTestProperty());
}
Also used : PropertiesConfigurationSource(com.sabre.oss.conf4j.source.PropertiesConfigurationSource) JdkProxyStaticConfigurationFactory(com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory) Properties(java.util.Properties) Test(org.junit.Test)

Example 2 with PropertiesConfigurationSource

use of com.sabre.oss.conf4j.source.PropertiesConfigurationSource in project open-kilda by telstra.

the class ValidatingConfigurationProviderTest method shouldFailValidationForInvalidConfig.

@Test
public void shouldFailValidationForInvalidConfig() {
    // given
    Properties source = new Properties();
    source.setProperty(TEST_KEY, String.valueOf(INVALID_TEST_VALUE));
    ValidatingConfigurationProvider provider = new ValidatingConfigurationProvider(new PropertiesConfigurationSource(source), new JdkProxyStaticConfigurationFactory());
    // when
    expectedException.expect(ConfigurationException.class);
    provider.getConfiguration(TestConfig.class);
// then ConfigurationException is thrown
}
Also used : PropertiesConfigurationSource(com.sabre.oss.conf4j.source.PropertiesConfigurationSource) JdkProxyStaticConfigurationFactory(com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory) Properties(java.util.Properties) Test(org.junit.Test)

Aggregations

JdkProxyStaticConfigurationFactory (com.sabre.oss.conf4j.factory.jdkproxy.JdkProxyStaticConfigurationFactory)2 PropertiesConfigurationSource (com.sabre.oss.conf4j.source.PropertiesConfigurationSource)2 Properties (java.util.Properties)2 Test (org.junit.Test)2