TAMAYA-274 Using Configuration as main API entry point only.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/8745dd24 Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/8745dd24 Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/8745dd24 Branch: refs/heads/master Commit: 8745dd246caab08d0a7a6b608cd0fbdf450ae825 Parents: 5f3f86b Author: Anatole Tresch <[email protected]> Authored: Sun Nov 18 22:16:24 2018 +0100 Committer: Anatole Tresch <[email protected]> Committed: Sun Nov 18 22:16:24 2018 +0100 ---------------------------------------------------------------------- .../org/apache/tamaya/core/OSGIActivator.java | 5 +- .../tamaya/core/internal/BannerManager.java | 4 +- .../core/internal/OSGIServiceContext.java | 3 +- .../tamaya/core/internal/OSGIServiceLoader.java | 2 +- .../tamaya/core/ConfigurationBuilderTest.java | 65 ++++++++++---------- .../apache/tamaya/core/OSGIActivatorTest.java | 3 +- .../apache/tamaya/core/TestPropertySource.java | 4 -- .../internal/CoreConfigurationBuilderTest.java | 18 ++---- .../internal/DefaultJavaConfigurationTest.java | 14 ++--- .../testdata/TestPropertyDefaultSource.java | 9 +-- .../testdata/TestPropertySourceProvider.java | 12 ++-- 11 files changed, 58 insertions(+), 81 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8745dd24/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java b/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java index 2ca51db..3a44c66 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java +++ b/code/core/src/main/java/org/apache/tamaya/core/OSGIActivator.java @@ -20,10 +20,9 @@ package org.apache.tamaya.core; -import org.apache.tamaya.ConfigurationProvider; +import org.apache.tamaya.Configuration; import org.apache.tamaya.core.internal.*; import org.apache.tamaya.spi.ServiceContextManager; -import org.apache.tamaya.spisupport.DefaultConfiguration; import org.apache.tamaya.spisupport.PropertyFilterComparator; import org.apache.tamaya.spisupport.PropertySourceComparator; import org.osgi.framework.BundleActivator; @@ -47,7 +46,7 @@ public class OSGIActivator implements BundleActivator { context.addBundleListener(serviceLoader); ServiceContextManager.set(new OSGIServiceContext(serviceLoader)); LOG.info("Registered Tamaya OSGI ServiceContext..."); - ConfigurationProvider.setConfiguration( + Configuration.setCurrent( new CoreConfigurationBuilder() .addDefaultPropertyConverters() .addDefaultPropertyFilters() http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8745dd24/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java b/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java index 3293153..5477fde 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/BannerManager.java @@ -18,7 +18,7 @@ */ package org.apache.tamaya.core.internal; -import org.apache.tamaya.ConfigurationProvider; +import org.apache.tamaya.Configuration; import java.io.BufferedReader; import java.io.InputStream; @@ -103,7 +103,7 @@ abstract class AbstractBannerPrinter implements BannerPrinter { @Override public void outputBanner() { - try (InputStream in = ConfigurationProvider.class.getResourceAsStream(BANNER_RESOURCE_PATH)) { + try (InputStream in = Configuration.class.getResourceAsStream(BANNER_RESOURCE_PATH)) { BufferedReader reader = new BufferedReader(new InputStreamReader(in)); String line; http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8745dd24/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java index c0645b1..207dfd8 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceContext.java @@ -104,7 +104,8 @@ public class OSGIServiceContext implements ServiceContext{ ServiceReference<T> ref = this.osgiServiceLoader.getBundleContext().getServiceReference(serviceType); if(ref!=null){ try { - return (T)this.osgiServiceLoader.getBundleContext().getService(ref).getClass().newInstance(); + return (T)this.osgiServiceLoader.getBundleContext().getService(ref).getClass().getConstructor() + .newInstance(); } catch (Exception e) { if(supplier!=null){ return supplier.get(); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8745dd24/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java ---------------------------------------------------------------------- diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java index dc7c0d4..19dd104 100644 --- a/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java +++ b/code/core/src/main/java/org/apache/tamaya/core/internal/OSGIServiceLoader.java @@ -240,7 +240,7 @@ public class OSGIServiceLoader implements BundleListener { public Object getService(Bundle bundle, ServiceRegistration registration) { try { log.fine("Creating Service...:" + serviceClass.getName()); - return serviceClass.newInstance(); + return serviceClass.getConstructor().newInstance(); } catch (Exception ex) { ex.printStackTrace(); throw new IllegalStateException("Failed to createObject service: " + serviceClass.getName(), ex); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8745dd24/code/core/src/test/java/org/apache/tamaya/core/ConfigurationBuilderTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/ConfigurationBuilderTest.java b/code/core/src/test/java/org/apache/tamaya/core/ConfigurationBuilderTest.java index 8a687d7..cf1adf7 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/ConfigurationBuilderTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/ConfigurationBuilderTest.java @@ -19,7 +19,6 @@ package org.apache.tamaya.core; import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.TypeLiteral; import org.apache.tamaya.core.internal.CoreConfigurationBuilder; import org.apache.tamaya.spi.*; @@ -40,7 +39,7 @@ public class ConfigurationBuilderTest { @Test public void setContext() throws Exception { Configuration cfg = Configuration.current(); - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() + ConfigurationBuilder b = Configuration.createConfigurationBuilder() .setConfiguration(cfg); assertThat(b.build()).isEqualTo(cfg); } @@ -56,7 +55,7 @@ public class ConfigurationBuilderTest { assertThat(cfg.getContext().getPropertySources().contains(testPS2)).isTrue(); // Ensure no sorting happens during add, so switch ordinals! testPS2 = new TestPropertySource("addPropertySources_Array", 1); - b = ConfigurationProvider.getConfigurationBuilder() + b = Configuration.createConfigurationBuilder() .addPropertySources(testPS2, testPropertySource); cfg = b.build(); assertThat(cfg.getContext().getPropertySources()).hasSize(2); @@ -79,7 +78,7 @@ public class ConfigurationBuilderTest { assertThat("addPropertySources_Collection").isEqualTo(cfg.getContext().getPropertySources().get(1).getName()); // Ensure no sorting happens during add, so switch ordinals! testPS2 = new TestPropertySource("addPropertySources_Collection", 1); - b = ConfigurationProvider.getConfigurationBuilder() + b = Configuration.createConfigurationBuilder() .addPropertySources(Arrays.asList(new PropertySource[]{testPS2, testPropertySource})); cfg = b.build(); assertThat(cfg.getContext().getPropertySources()).hasSize(2); @@ -92,13 +91,13 @@ public class ConfigurationBuilderTest { @Test public void removePropertySources_Array() throws Exception { PropertySource testPS2 = new TestPropertySource("removePropertySources_Array", 1); - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() + ConfigurationBuilder b = Configuration.createConfigurationBuilder() .addPropertySources(testPropertySource, testPS2); Configuration cfg = b.build(); assertThat(cfg.getContext().getPropertySources()).hasSize(2); assertThat(cfg.getContext().getPropertySources().contains(testPropertySource)).isTrue(); assertThat(cfg.getContext().getPropertySources().contains(testPS2)).isTrue(); - b = ConfigurationProvider.getConfigurationBuilder() + b = Configuration.createConfigurationBuilder() .addPropertySources(testPropertySource, testPS2); b.removePropertySources(testPropertySource); cfg = b.build(); @@ -110,13 +109,13 @@ public class ConfigurationBuilderTest { @Test public void removePropertySources_Collection() throws Exception { PropertySource testPS2 = new TestPropertySource("removePropertySources_Array", 1); - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() + ConfigurationBuilder b = Configuration.createConfigurationBuilder() .addPropertySources(testPropertySource, testPS2); Configuration cfg = b.build(); assertThat(cfg.getContext().getPropertySources()).hasSize(2); assertThat(cfg.getContext().getPropertySources().contains(testPropertySource)).isTrue(); assertThat(cfg.getContext().getPropertySources().contains(testPS2)).isTrue(); - b = ConfigurationProvider.getConfigurationBuilder() + b = Configuration.createConfigurationBuilder() .addPropertySources(testPropertySource, testPS2); b.removePropertySources(testPropertySource); cfg = b.build(); @@ -129,14 +128,14 @@ public class ConfigurationBuilderTest { public void addPropertyFilters_Array() throws Exception { PropertyFilter filter1 = (value, ctx) -> value; PropertyFilter filter2 = (value, ctx) -> value; - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder b = Configuration.createConfigurationBuilder(); b.addPropertyFilters(filter1, filter2); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); assertThat(ctx.getPropertyFilters().contains(filter1)).isTrue(); assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); assertThat(ctx.getPropertyFilters()).hasSize(2); - b = ConfigurationProvider.getConfigurationBuilder(); + b = Configuration.createConfigurationBuilder(); b.addPropertyFilters(filter1, filter2); b.addPropertyFilters(filter1, filter2); assertThat(ctx.getPropertyFilters()).hasSize(2); @@ -146,14 +145,14 @@ public class ConfigurationBuilderTest { public void addPropertyFilters_Collection() throws Exception { PropertyFilter filter1 = (value, ctx) -> value; PropertyFilter filter2 = (value, ctx) -> value; - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder b = Configuration.createConfigurationBuilder(); b.addPropertyFilters(Arrays.asList(new PropertyFilter[]{filter1, filter2})); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); assertThat(ctx.getPropertyFilters().contains(filter1)).isTrue(); assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); assertThat(ctx.getPropertyFilters()).hasSize(2); - b = ConfigurationProvider.getConfigurationBuilder(); + b = Configuration.createConfigurationBuilder(); b.addPropertyFilters(filter1, filter2); b.addPropertyFilters(filter1, filter2); assertThat(ctx.getPropertyFilters()).hasSize(2); @@ -163,14 +162,14 @@ public class ConfigurationBuilderTest { public void removePropertyFilters_Array() throws Exception { PropertyFilter filter1 = (value, ctx) -> value; PropertyFilter filter2 = (value, ctx) -> value; - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() + ConfigurationBuilder b = Configuration.createConfigurationBuilder() .addPropertyFilters(filter1, filter2); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); assertThat(ctx.getPropertyFilters().contains(filter1)).isTrue(); assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); assertThat(ctx.getPropertyFilters()).hasSize(2); - b = ConfigurationProvider.getConfigurationBuilder() + b = Configuration.createConfigurationBuilder() .addPropertyFilters(filter1, filter2); b.removePropertyFilters(filter1); cfg = b.build(); @@ -184,14 +183,14 @@ public class ConfigurationBuilderTest { public void removePropertyFilters_Collection() throws Exception { PropertyFilter filter1 = (value, ctx) -> value; PropertyFilter filter2 = (value, ctx) -> value; - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() + ConfigurationBuilder b = Configuration.createConfigurationBuilder() .addPropertyFilters(Arrays.asList(new PropertyFilter[]{filter1, filter2})); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); assertThat(ctx.getPropertyFilters().contains(filter1)).isTrue(); assertThat(ctx.getPropertyFilters().contains(filter2)).isTrue(); assertThat(ctx.getPropertyFilters()).hasSize(2); - b = ConfigurationProvider.getConfigurationBuilder() + b = Configuration.createConfigurationBuilder() .addPropertyFilters(Arrays.asList(new PropertyFilter[]{filter1, filter2})); b.removePropertyFilters(filter1); cfg = b.build(); @@ -205,13 +204,13 @@ public class ConfigurationBuilderTest { @SuppressWarnings({ "rawtypes", "unchecked" }) public void addPropertyConverters_Array() throws Exception { PropertyConverter converter = (value, ctx) -> value.toLowerCase(); - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() + ConfigurationBuilder b = Configuration.createConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isTrue(); assertThat(ctx.getPropertyConverters()).hasSize(1); - b = ConfigurationProvider.getConfigurationBuilder() + b = Configuration.createConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter); b.addPropertyConverters(TypeLiteral.of(String.class), converter); assertThat(ctx.getPropertyConverters()).hasSize(1); @@ -221,14 +220,14 @@ public class ConfigurationBuilderTest { @SuppressWarnings({ "rawtypes", "unchecked" }) public void addPropertyConverters_Collection() throws Exception { PropertyConverter converter = (value, ctx) -> value.toLowerCase(); - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() + ConfigurationBuilder b = Configuration.createConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isTrue(); assertThat(1).isEqualTo(ctx.getPropertyConverters().size()); - b = ConfigurationProvider.getConfigurationBuilder() + b = Configuration.createConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); b.addPropertyConverters(TypeLiteral.of(String.class), converter); @@ -239,13 +238,13 @@ public class ConfigurationBuilderTest { @SuppressWarnings({ "rawtypes", "unchecked" }) public void removePropertyConverters_Array() throws Exception { PropertyConverter converter = (value, ctx) -> value.toLowerCase(); - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() + ConfigurationBuilder b = Configuration.createConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isTrue(); assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class))).hasSize(1); - b = ConfigurationProvider.getConfigurationBuilder() + b = Configuration.createConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), converter); b.removePropertyConverters(TypeLiteral.of(String.class), converter); cfg = b.build(); @@ -259,13 +258,13 @@ public class ConfigurationBuilderTest { @Test public void removePropertyConverters_Collection() throws Exception { PropertyConverter converter = (value, ctx) -> value.toLowerCase(); - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder() + ConfigurationBuilder b = Configuration.createConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(converter)).isTrue(); assertThat(ctx.getPropertyConverters(TypeLiteral.of(String.class))).hasSize(1); - b = ConfigurationProvider.getConfigurationBuilder() + b = Configuration.createConfigurationBuilder() .addPropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); b.removePropertyConverters(TypeLiteral.of(String.class), Arrays.<PropertyConverter<Object>>asList(new PropertyConverter[]{converter})); cfg = b.build(); @@ -276,7 +275,7 @@ public class ConfigurationBuilderTest { @Test public void increasePriority(){ - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder b = Configuration.createConfigurationBuilder(); TestPropertySource[] propertySources = new TestPropertySource[10]; for(int i=0;i<propertySources.length;i++){ propertySources[i] = new TestPropertySource("ps"+i,i); @@ -296,7 +295,7 @@ public class ConfigurationBuilderTest { @Test public void decreasePriority(){ - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder b = Configuration.createConfigurationBuilder(); TestPropertySource[] propertySources = new TestPropertySource[10]; for(int i=0;i<propertySources.length;i++){ propertySources[i] = new TestPropertySource("ps"+i,i); @@ -317,7 +316,7 @@ public class ConfigurationBuilderTest { @Test public void lowestPriority(){ // setup - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder b = Configuration.createConfigurationBuilder(); TestPropertySource[] propertySources = new TestPropertySource[10]; for(int i=0;i<propertySources.length;i++){ propertySources[i] = new TestPropertySource("ps"+i,i); @@ -341,7 +340,7 @@ public class ConfigurationBuilderTest { @Test public void highestPriority(){ // setup - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder b = Configuration.createConfigurationBuilder(); TestPropertySource[] propertySources = new TestPropertySource[10]; for(int i=0;i<propertySources.length;i++){ propertySources[i] = new TestPropertySource("ps"+i,i); @@ -365,7 +364,7 @@ public class ConfigurationBuilderTest { @Test public void sortPropertySources(){ // setup - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder b = Configuration.createConfigurationBuilder(); TestPropertySource[] propertySources = new TestPropertySource[10]; for(int i=0;i<propertySources.length;i++){ propertySources[i] = new TestPropertySource("ps"+i,i); @@ -383,7 +382,7 @@ public class ConfigurationBuilderTest { @Test public void sortPropertyFilter(){ // setup - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder b = Configuration.createConfigurationBuilder(); PropertyFilter[] propertyFilters = new PropertyFilter[10]; for(int i=0;i<propertyFilters.length;i++){ propertyFilters[i] = (value, ctx) -> value.setValue(toString() + " - "); @@ -400,7 +399,7 @@ public class ConfigurationBuilderTest { @Test public void build() throws Exception { - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder b = Configuration.createConfigurationBuilder(); Configuration cfg = b.build(); ConfigurationContext ctx = cfg.getContext(); assertThat(ctx).isNotNull(); @@ -410,7 +409,7 @@ public class ConfigurationBuilderTest { @Test public void testRemoveAllFilters() throws Exception { - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder b = Configuration.createConfigurationBuilder(); b.addPropertyFilters((value, ctx) -> value.setValue(toString() + " - ")); assertThat(b.getPropertyFilters().isEmpty()).isFalse(); b.removePropertyFilters(b.getPropertyFilters()); @@ -419,7 +418,7 @@ public class ConfigurationBuilderTest { @Test public void testRemoveAllSources() throws Exception { - ConfigurationBuilder b = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder b = Configuration.createConfigurationBuilder(); b.addPropertySources(new TestPropertySource()); assertThat(b.getPropertySources().isEmpty()).isFalse(); b.removePropertySources(b.getPropertySources()); http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8745dd24/code/core/src/test/java/org/apache/tamaya/core/OSGIActivatorTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/OSGIActivatorTest.java b/code/core/src/test/java/org/apache/tamaya/core/OSGIActivatorTest.java index f9cbbdb..e92fe5b 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/OSGIActivatorTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/OSGIActivatorTest.java @@ -19,7 +19,6 @@ package org.apache.tamaya.core; import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.core.internal.MockBundle; import org.apache.tamaya.core.internal.MockBundleContext; import org.apache.tamaya.spi.ServiceContext; @@ -48,7 +47,7 @@ public class OSGIActivatorTest { @After public void tearDown() throws Exception { ServiceContextManager.set(prevServiceContext); - ConfigurationProvider.setConfiguration(prevConfiguration); + Configuration.setCurrent(prevConfiguration); } /** http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8745dd24/code/core/src/test/java/org/apache/tamaya/core/TestPropertySource.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/TestPropertySource.java b/code/core/src/test/java/org/apache/tamaya/core/TestPropertySource.java index da5a557..6cb79aa 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/TestPropertySource.java +++ b/code/core/src/test/java/org/apache/tamaya/core/TestPropertySource.java @@ -65,8 +65,4 @@ public class TestPropertySource implements PropertySource { return Collections.emptyMap(); } - @Override - public boolean isScannable() { - return false; - } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8745dd24/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationBuilderTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationBuilderTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationBuilderTest.java index caba173..246fe4a 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationBuilderTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/CoreConfigurationBuilderTest.java @@ -24,17 +24,13 @@ import java.math.BigInteger; import java.net.URI; import java.net.URL; import java.nio.file.Path; -import java.util.Collection; +import java.util.*; + import org.apache.tamaya.Configuration; -import org.apache.tamaya.ConfigurationProvider; import org.apache.tamaya.TypeLiteral; import org.apache.tamaya.spi.*; import org.junit.Test; -import java.util.Collections; -import java.util.Currency; -import java.util.Map; - import static org.assertj.core.api.Assertions.*; /** @@ -173,7 +169,7 @@ public class CoreConfigurationBuilderTest { @Test public void addDefaultPropertyConverters() throws Exception { - ConfigurationBuilder builder = ConfigurationProvider.getConfigurationBuilder(); + ConfigurationBuilder builder = Configuration.createConfigurationBuilder(); builder.addDefaultPropertyConverters(); } @@ -181,7 +177,7 @@ public class CoreConfigurationBuilderTest { public void addCorePropertyConverters() throws Exception { CoreConfigurationBuilder b = new CoreConfigurationBuilder(); b.addCorePropertyConverters(); - Map<TypeLiteral<?>, Collection<PropertyConverter<?>>> converters = b.getPropertyConverter(); + Map<TypeLiteral<?>, List<PropertyConverter<?>>> converters = b.getPropertyConverter(); assertThat(converters.containsKey(TypeLiteral.<BigDecimal>of(BigDecimal.class))).isTrue(); assertThat(converters.containsKey(TypeLiteral.<BigInteger>of(BigInteger.class))).isTrue(); assertThat(converters.containsKey(TypeLiteral.<Boolean>of(Boolean.class))).isTrue(); @@ -225,7 +221,7 @@ public class CoreConfigurationBuilderTest { @Override public PropertyValue get(String key) { - return PropertyValue.of(key, key + "Value", getName()); + return PropertyValue.createValue(key, key + "Value"); } @Override @@ -233,10 +229,6 @@ public class CoreConfigurationBuilderTest { return Collections.emptyMap(); } - @Override - public boolean isScannable() { - return false; - } } } \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8745dd24/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java index 54310ae..d0b83c7 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java +++ b/code/core/src/test/java/org/apache/tamaya/core/internal/DefaultJavaConfigurationTest.java @@ -18,9 +18,9 @@ */ package org.apache.tamaya.core.internal; +import org.apache.tamaya.Configuration; import org.junit.Test; -import static org.apache.tamaya.ConfigurationProvider.getConfiguration; import static org.assertj.core.api.Assertions.*; public class DefaultJavaConfigurationTest { @@ -34,14 +34,14 @@ public class DefaultJavaConfigurationTest { String key = "confkey" + i; String value = "javaconf-value" + i; // check if we had our key in configuration.current - assertThat(getConfiguration().getProperties().containsKey(key)).isTrue(); - assertThat(value).isEqualTo(getConfiguration().get(key)); + assertThat(Configuration.current().getProperties().containsKey(key)).isTrue(); + assertThat(value).isEqualTo(Configuration.current().get(key)); } - assertThat(getConfiguration().getProperties().containsKey("aaeehh")).isTrue(); - assertThat(getConfiguration().getProperties().get("aaeehh")).isEqualTo(A_UMLAUT); + assertThat(Configuration.current().getProperties().containsKey("aaeehh")).isTrue(); + assertThat(Configuration.current().getProperties().get("aaeehh")).isEqualTo(A_UMLAUT); - assertThat(getConfiguration().getProperties().containsKey(O_UMLAUT)).isTrue(); - assertThat(getConfiguration().getProperties().get(O_UMLAUT)).isEqualTo("o"); + assertThat(Configuration.current().getProperties().containsKey(O_UMLAUT)).isTrue(); + assertThat(Configuration.current().getProperties().get(O_UMLAUT)).isEqualTo("o"); } } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8745dd24/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSource.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSource.java b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSource.java index 65d69dd..f630fb8 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSource.java +++ b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyDefaultSource.java @@ -34,8 +34,8 @@ public class TestPropertyDefaultSource extends BasePropertySource{ public TestPropertyDefaultSource() { super(100); - properties.put("name", PropertyValue.of("name", "Anatole", "test")); - properties.put("name2",PropertyValue.of("name2", "Sabine", "test")); + properties.put("name", PropertyValue.createValue("name", "Anatole")); + properties.put("name2",PropertyValue.createValue("name2", "Sabine")); properties = Collections.unmodifiableMap(properties); } @@ -49,9 +49,4 @@ public class TestPropertyDefaultSource extends BasePropertySource{ return properties; } - @Override - public boolean isScannable() { - return true; - } - } http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8745dd24/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java ---------------------------------------------------------------------- diff --git a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java index 5a427e0..c5b3084 100644 --- a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java +++ b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertySourceProvider.java @@ -53,10 +53,10 @@ public class TestPropertySourceProvider implements PropertySourceProvider { public MyPropertySource() { super(200); - properties.put("name", PropertyValue.of("name", "Robin", "test")); - properties.put("name3", PropertyValue.of("name3", "Lukas", "test")); - properties.put("name4", PropertyValue.of("name4", "Sereina", "test")); - properties.put("name5", PropertyValue.of("name5", "Benjamin", "test")); + properties.put("name", PropertyValue.createValue("name", "Robin")); + properties.put("name3", PropertyValue.createValue("name3", "Lukas")); + properties.put("name4", PropertyValue.createValue("name4", "Sereina")); + properties.put("name5", PropertyValue.createValue("name5", "Benjamin")); properties = Collections.unmodifiableMap(properties); } @@ -70,10 +70,6 @@ public class TestPropertySourceProvider implements PropertySourceProvider { return properties; } - @Override - public boolean isScannable() { - return true; - } } }
