tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [1/4] incubator-tamaya git commit: TAMAYA-3: - Renamed PropertyProvider to PropertySource. - Factored out PropertyProviderBuilder (now to PropertySourceBuilder) into core implemntation (was API). - Removed SPI in favor of harcoded PropertySourceFactory.
Date Sat, 13 Dec 2014 00:41:03 GMT
Repository: incubator-tamaya
Updated Branches:
  refs/heads/master ff1f5917d -> 80bce9ec9


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/80bce9ec/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java b/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
index 8ee32cb..54e1491 100644
--- a/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
+++ b/core/src/test/java/org/apache/tamaya/ucs/UC1ReadProperties.java
@@ -20,6 +20,7 @@ package org.apache.tamaya.ucs;
 
 import org.apache.tamaya.*;
 import org.apache.tamaya.core.config.ConfigFunctions;
+import org.apache.tamaya.core.properties.PropertySourceBuilder;
 import org.junit.Test;
 
 import java.math.BigDecimal;
@@ -59,7 +60,7 @@ public class UC1ReadProperties {
 
     @Test
     public void example() {
-        Configuration config = PropertyProviderBuilder.create("test")
+        Configuration config = PropertySourceBuilder.create("test")
                 .addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build().toConfiguration();
         String name = config.get("name").orElse("Anatole");
         BigDecimal bigNum = config.get("num.BD", BigDecimal.class).orElseThrow(() -> new
IllegalStateException("Sorry"));
@@ -74,13 +75,13 @@ public class UC1ReadProperties {
         Map<String, String> areaMap = config.toMap().entrySet().stream()
                 .filter((e) -> e.getKey().startsWith("num."))
                 .collect(Collectors.toMap((e) -> e.getKey().substring("num.".length()),
Map.Entry::getValue));
-        Configuration areaConfig = PropertyProviderBuilder.create("Test").addMap(areaMap).build().toConfiguration();
+        Configuration areaConfig = PropertySourceBuilder.create("Test").addMap(areaMap).build().toConfiguration();
         System.out.println(areaConfig);
     }
 
     @Test
     public void getConfigurationTest() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:barFoo.properties").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:barFoo.properties").build();
         Configuration config = provider.toConfiguration();
         assertNotNull(config);
         assertTrue(config.isEmpty());
@@ -90,7 +91,7 @@ public class UC1ReadProperties {
 
     @Test
     public void readBadPropertiesTest() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:barFoo.properties").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:barFoo.properties").build();
         assertNotNull(provider);
         assertTrue(provider.isEmpty());
         assertTrue(provider.keySet().isEmpty());
@@ -99,7 +100,7 @@ public class UC1ReadProperties {
 
     @Test
     public void readPropertiesTest() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
         assertNotNull(provider);
         assertEquals(provider.get("a").get(), "aValue");
         assertEquals(provider.get("b").get(), "bValue");
@@ -123,7 +124,7 @@ public class UC1ReadProperties {
 
     @Test
     public void readXmlPropertiesTest() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.xml").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.xml").build();
         assertNotNull(provider);
         assertEquals(provider.get("a-xml").get(), "aFromXml");
         assertEquals(provider.get("b-xml").get(), "bFromXml");
@@ -132,7 +133,7 @@ public class UC1ReadProperties {
 
     @Test
     public void readIniPropertiesTest() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.ini").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.ini").build();
         assertNotNull(provider);
         assertEquals(provider.get("a.b.c").get(), "abcValue-fromIni");
         assertEquals(provider.get("a.b.b").get(), "abbValue-fromIni");
@@ -144,7 +145,7 @@ public class UC1ReadProperties {
 
     @Test
     public void readAllPropertiesTest() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").withAggregationPolicy(AggregationPolicy.IGNORE_DUPLICATES)
+        PropertySource provider = PropertySourceBuilder.create("Test").withAggregationPolicy(AggregationPolicy.IGNORE_DUPLICATES)
                 .addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.*").build();
         assertNotNull(provider);
         // fromMap ini file
@@ -160,7 +161,7 @@ public class UC1ReadProperties {
 
     @Test
     public void checkForAValue() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
         assertFalse(provider.containsKey("blabla"));
         assertTrue(provider.containsKey("num.BD"));
         assertFalse(provider.get("blabla").isPresent());
@@ -169,7 +170,7 @@ public class UC1ReadProperties {
 
     @Test
     public void checkKeys() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
         assertEquals(provider.keySet().size(), 16);
         assertTrue(provider.keySet().contains("boolean"));
         assertFalse(provider.keySet().contains("blabla"));
@@ -177,7 +178,7 @@ public class UC1ReadProperties {
 
     @Test
     public void checkToMap() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
         Map<String, String> map = provider.toMap();
         assertNotNull(map);
         assertEquals(map.size(), 16);
@@ -188,34 +189,34 @@ public class UC1ReadProperties {
 
     @Test
     public void checkMetaInfo() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
         MetaInfo meta = provider.getMetaInfo();
         assertNotNull(meta);
     }
 
     @Test
     public void checkNeverNull() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
         assertNotNull(provider.get("blabla"));
         assertNotNull(provider.get("a.b.c"));
     }
 
     @Test
     public void checkUndefined() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
         assertFalse(provider.get("blabla").isPresent());
         assertTrue(provider.get("a.b.c").isPresent());
     }
 
     @Test
     public void checkPassDefaultValues() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
         assertEquals("myDefaultValue", provider.get("blabla").orElse("myDefaultValue"));
     }
 
     @Test(expected = IllegalStateException.class)
     public void checkThrowCustomException() {
-        PropertyProvider provider = PropertyProviderBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
+        PropertySource provider = PropertySourceBuilder.create("Test").addPaths("classpath:ucs/UC1ReadProperties/UC1ReadPropertiesTest.properties").build();
         provider.get("blabla").orElseThrow(() -> new IllegalStateException("checkThrowCustomException"));
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/80bce9ec/core/src/test/java/org/apache/tamaya/ucs/UC2CombineProperties.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/org/apache/tamaya/ucs/UC2CombineProperties.java b/core/src/test/java/org/apache/tamaya/ucs/UC2CombineProperties.java
index 824a470..a463c31 100644
--- a/core/src/test/java/org/apache/tamaya/ucs/UC2CombineProperties.java
+++ b/core/src/test/java/org/apache/tamaya/ucs/UC2CombineProperties.java
@@ -19,6 +19,7 @@
 package org.apache.tamaya.ucs;
 
 import org.apache.tamaya.*;
+import org.apache.tamaya.core.properties.PropertySourceBuilder;
 import org.junit.Test;
 
 import static junit.framework.TestCase.assertTrue;
@@ -37,16 +38,16 @@ public class UC2CombineProperties {
      */
     @Test
     public void simpleAggregationTests() {
-        PropertyProvider props1 = PropertyProviderBuilder.create().addPaths("classpath:ucs/UC2CombineProperties/props1.properties").build();
-        PropertyProvider props2 = PropertyProviderBuilder.create().addPaths("classpath:ucs/UC2CombineProperties/props2.properties").build();
-        PropertyProvider unionOverriding = PropertyProviderBuilder.create(props1).withAggregationPolicy(AggregationPolicy.OVERRIDE).addProviders(props2).build();
+        PropertySource props1 = PropertySourceBuilder.create().addPaths("classpath:ucs/UC2CombineProperties/props1.properties").build();
+        PropertySource props2 = PropertySourceBuilder.create().addPaths("classpath:ucs/UC2CombineProperties/props2.properties").build();
+        PropertySource unionOverriding = PropertySourceBuilder.create(props1).withAggregationPolicy(AggregationPolicy.OVERRIDE).addProviders(props2).build();
         System.out.println("unionOverriding: " + unionOverriding);
-        PropertyProvider unionIgnoringDuplicates = PropertyProviderBuilder.create(props1).withAggregationPolicy(AggregationPolicy.IGNORE_DUPLICATES).addProviders(props2).build();
+        PropertySource unionIgnoringDuplicates = PropertySourceBuilder.create(props1).withAggregationPolicy(AggregationPolicy.IGNORE_DUPLICATES).addProviders(props2).build();
         System.out.println("unionIgnoringDuplicates: " + unionIgnoringDuplicates);
-        PropertyProvider unionCombined = PropertyProviderBuilder.create(props1).withAggregationPolicy(AggregationPolicy.COMBINE).addProviders(props2).build();
+        PropertySource unionCombined = PropertySourceBuilder.create(props1).withAggregationPolicy(AggregationPolicy.COMBINE).addProviders(props2).build();
         System.out.println("unionCombined: " + unionCombined);
         try{
-            PropertyProviderBuilder.create(props1).withAggregationPolicy(AggregationPolicy.EXCEPTION).addProviders(props2).build();
+            PropertySourceBuilder.create(props1).withAggregationPolicy(AggregationPolicy.EXCEPTION).addProviders(props2).build();
         }
         catch(ConfigException e){
             // expected!
@@ -58,9 +59,9 @@ public class UC2CombineProperties {
      */
     @Test
     public void dynamicAggregationTests() {
-        PropertyProvider props1 = PropertyProviderBuilder.create().addPaths("classpath:ucs/UC2CombineProperties/props1.properties").build();
-        PropertyProvider props2 = PropertyProviderBuilder.create().addPaths("classpath:ucs/UC2CombineProperties/props2.properties").build();
-        PropertyProvider props = PropertyProviderBuilder.create().withAggregationPolicy((k,
v1, v2) -> (v1 != null ? v1 : "") + '[' + v2 + "]").withMetaInfo(MetaInfo.of("dynamicAggregationTests"))
+        PropertySource props1 = PropertySourceBuilder.create().addPaths("classpath:ucs/UC2CombineProperties/props1.properties").build();
+        PropertySource props2 = PropertySourceBuilder.create().addPaths("classpath:ucs/UC2CombineProperties/props2.properties").build();
+        PropertySource props = PropertySourceBuilder.create().withAggregationPolicy((k, v1,
v2) -> (v1 != null ? v1 : "") + '[' + v2 + "]").withMetaInfo(MetaInfo.of("dynamicAggregationTests"))
                 .aggregate(props1, props2).build();
         System.out.println(props);
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/80bce9ec/modules/integration/cdi/src/test/java/main/java/metamodel/ext/cdi/ConfiguredClass.java
----------------------------------------------------------------------
diff --git a/modules/integration/cdi/src/test/java/main/java/metamodel/ext/cdi/ConfiguredClass.java
b/modules/integration/cdi/src/test/java/main/java/metamodel/ext/cdi/ConfiguredClass.java
index e610085..823b472 100644
--- a/modules/integration/cdi/src/test/java/main/java/metamodel/ext/cdi/ConfiguredClass.java
+++ b/modules/integration/cdi/src/test/java/main/java/metamodel/ext/cdi/ConfiguredClass.java
@@ -20,7 +20,7 @@
  */
 package main.java.metamodel.ext.cdi;
 
-import org.apache.tamaya.annotation.ConfigChangeListener;
+import org.apache.tamaya.annotation.ObservesConfigChange;
 import org.apache.tamaya.annotation.ConfiguredProperty;
 import org.apache.tamaya.annotation.DefaultValue;
 import org.apache.tamaya.annotation.WithConfig;
@@ -78,7 +78,7 @@ public class ConfiguredClass{
     @ConfiguredProperty("double1")
     private double doubleValue;
 
-    @ConfigChangeListener
+    @ObservesConfigChange
     public void changeListener1(PropertyChangeEvent configChange){
         // will be called
     }


Mime
View raw message