tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [5/8] incubator-tamaya git commit: TAMAYA-136: Adding PropertyValue for PropertySource SPI.
Date Tue, 02 Feb 2016 16:16:14 GMT
TAMAYA-136: Adding PropertyValue for PropertySource SPI.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/0be037b8
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/0be037b8
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/0be037b8

Branch: refs/heads/master
Commit: 0be037b844450e30ab58a78cab9ddd9bd07585c1
Parents: 80432ae
Author: anatole <anatole@apache.org>
Authored: Tue Feb 2 15:24:18 2016 +0100
Committer: anatole <anatole@apache.org>
Committed: Tue Feb 2 15:24:18 2016 +0100

----------------------------------------------------------------------
 .../core/internal/DefaultConfiguration.java     |  17 +-
 .../tamaya/core/internal/PropertyFiltering.java |  40 ++--
 .../core/propertysource/BasePropertySource.java |  30 ++-
 .../EnvironmentPropertySource.java              |   5 +-
 .../propertysource/SystemPropertySource.java    |   6 +-
 .../ConverterTestsPropertySource.java           | 189 ++++++++++---------
 .../propertysource/BasePropertySourceTest.java  |   7 +-
 .../EnvironmentPropertySourceTest.java          |   2 +-
 .../PropertiesFilePropertySourceTest.java       |   9 +-
 .../SystemPropertySourceTest.java               |   6 +-
 .../provider/JavaConfigurationProviderTest.java |   2 +-
 .../core/testdata/TestPropertyFilter.java       |   5 +-
 .../testdata/TestRemovingPropertyFilter.java    |   7 +-
 13 files changed, 187 insertions(+), 138 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
index f7c363c..0f74628 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/DefaultConfiguration.java
@@ -23,7 +23,12 @@ import org.apache.tamaya.ConfigOperator;
 import org.apache.tamaya.ConfigQuery;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.spi.*;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+import org.apache.tamaya.spi.PropertyFilter;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
 
 import java.util.ArrayList;
 import java.util.Collections;
@@ -61,12 +66,16 @@ public class DefaultConfiguration implements Configuration {
 
 
     public String get(String key) {
-        return PropertyFiltering.applyFilter(key, evaluteRawValue(key), configurationContext);
+        Map<String,String> value = evaluteRawValue(key);
+        if(value==null || value.get(key)==null){
+            return null;
+        }
+        return PropertyFiltering.applyFilter(key, value, configurationContext);
     }
 
-    protected String evaluteRawValue(String key) {
+    protected Map<String,String> evaluteRawValue(String key) {
         List<PropertySource> propertySources = configurationContext.getPropertySources();
-        String unfilteredValue = null;
+        Map<String,String> unfilteredValue = null;
         PropertyValueCombinationPolicy combinationPolicy = this.configurationContext
                 .getPropertyValueCombinationPolicy();
         for (PropertySource propertySource : propertySources) {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFiltering.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFiltering.java
b/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFiltering.java
index 9f84e7c..f0d15bc 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFiltering.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/internal/PropertyFiltering.java
@@ -19,9 +19,11 @@
 package org.apache.tamaya.core.internal;
 
 import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.FilterContext;
 import org.apache.tamaya.spi.PropertyFilter;
 import org.apache.tamaya.spi.PropertySource;
 
+import java.util.Collections;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -38,6 +40,7 @@ public final class PropertyFiltering{
      * The logger.
      */
     private static final Logger LOG = Logger.getLogger(PropertyFiltering.class.getName());
+
     /**
      * The maximal number of filter cycles performed before aborting.
      */
@@ -48,25 +51,27 @@ public final class PropertyFiltering{
      */
     private PropertyFiltering(){}
 
-    public static String applyFilter(String key, String unfilteredValue, ConfigurationContext
configurationContext) {
+    public static String applyFilter(String key, Map<String,String> configData, ConfigurationContext
configurationContext) {
         // Apply filters to values, prevent values filtered to null!
+        String result = configData.get(key);
         for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
             boolean changed = false;
             // Apply filters to values, prevent values filtered to null!
+            FilterContext filterContext = new FilterContext(key, configData);
             for (PropertyFilter filter : configurationContext.getPropertyFilters()) {
-                String newValue = filter.filterProperty(key, unfilteredValue);
-                if (newValue != null && !newValue.equals(unfilteredValue)) {
+                String newValue = filter.filterProperty(result, filterContext);
+                if (newValue != null && !newValue.equals(result)) {
                     changed = true;
                     if (LOG.isLoggable(Level.FINEST)) {
-                        LOG.finest("Filter - " + key + ": " + unfilteredValue + " -> "
+ newValue + " by " + filter);
+                        LOG.finest("Filter - " + key + ": " + result + " -> " + newValue
+ " by " + filter);
                     }
-                } else if (unfilteredValue != null && !unfilteredValue.equals(newValue))
{
+                } else if (result != null && !result.equals(newValue)) {
                     changed = true;
                     if (LOG.isLoggable(Level.FINEST)) {
-                        LOG.finest("Filter - " + key + ": " + unfilteredValue + " -> "
+ newValue + " by " + filter);
+                        LOG.finest("Filter - " + key + ": " + result + " -> " + newValue
+ " by " + filter);
                     }
                 }
-                unfilteredValue = newValue;
+                result = newValue;
             }
             if (!changed) {
                 LOG.finest("Finishing filter loop, no changes detected.");
@@ -81,20 +86,21 @@ public final class PropertyFiltering{
                 }
             }
         }
-        return unfilteredValue;
+        return result;
     }
 
     public static Map<String, String> applyFilters(Map<String, String> inputMap,
ConfigurationContext configurationContext) {
         Map<String, String> resultMap = new HashMap<>(inputMap);
         // Apply filters to values, prevent values filtered to null!
+        Map<String, String> metaData = filterMetadata(inputMap);
         for (int i = 0; i < MAX_FILTER_LOOPS; i++) {
             AtomicInteger changes = new AtomicInteger();
-            for (PropertyFilter filter : configurationContext.getPropertyFilters()) {
-                for (Map.Entry<String, String> entry : inputMap.entrySet()) {
+            for (Map.Entry<String, String> entry : inputMap.entrySet()) {
+                FilterContext filterContext = new FilterContext(entry.getKey(), inputMap);
+                for (PropertyFilter filter : configurationContext.getPropertyFilters()) {
                     final String k = entry.getKey();
                     final String v = entry.getValue();
-
-                    String newValue = filter.filterProperty(k, v);
+                    String newValue = filter.filterProperty(v, filterContext);
                     if (newValue != null && !newValue.equals(v)) {
                         changes.incrementAndGet();
                         LOG.finest("Filter - " + k + ": " + v + " -> " + newValue + "
by " + filter);
@@ -128,4 +134,14 @@ public final class PropertyFiltering{
         return resultMap;
     }
 
+    private static Map<String, String> filterMetadata(Map<String, String> inputMap)
{
+        Map<String,String> result = new HashMap<>();
+        for(Map.Entry<String,String> en:inputMap.entrySet()){
+            if(en.getKey().startsWith("_")){
+                result.put(en.getKey(), en.getValue());
+            }
+        }
+        return Collections.unmodifiableMap(result);
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
b/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
index e9f53f9..b5c7378 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/propertysource/BasePropertySource.java
@@ -19,7 +19,10 @@
 package org.apache.tamaya.core.propertysource;
 
 import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spi.PropertyValueBuilder;
 
+import java.util.Map;
 import java.util.logging.Level;
 import java.util.logging.Logger;
 
@@ -53,13 +56,14 @@ public abstract class BasePropertySource implements PropertySource{
 
     @Override
     public int getOrdinal() {
-        String configuredOrdinal = get(TAMAYA_ORDINAL);
+        PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
+
         if(configuredOrdinal!=null){
-            try{
-                return Integer.parseInt(configuredOrdinal);
-            } catch(Exception e){
+            try {
+                return Integer.parseInt(configuredOrdinal.getValue());
+            } catch (Exception e) {
                 Logger.getLogger(getClass().getName()).log(Level.WARNING,
-                        "Configured Ordinal is not an int number: " + configuredOrdinal,
e);
+                        "Configured Ordinal is not an int number: " + configuredOrdinal.getValue(),
e);
             }
         }
         return getDefaultOrdinal();
@@ -74,8 +78,20 @@ public abstract class BasePropertySource implements PropertySource{
     }
 
     @Override
-    public String get(String key) {
-        return getProperties().get(key);
+    public PropertyValue get(String key) {
+        Map<String,String> properties = getProperties();
+        String val = properties.get(key);
+        if(val==null){
+            return null;
+        }
+        PropertyValueBuilder b = new PropertyValueBuilder(key, val, getName());
+        String metaKeyStart = "_" + key + ".";
+        for(Map.Entry<String,String> en:properties.entrySet()) {
+            if(en.getKey().startsWith(metaKeyStart)){
+                b.addContextData(en.getKey().substring(metaKeyStart.length()), en.getValue());
+            }
+        }
+        return b.build();
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
b/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
index c8c1aa3..841d432 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySource.java
@@ -19,6 +19,7 @@
 package org.apache.tamaya.core.propertysource;
 
 import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
 
 import java.util.Map;
 
@@ -46,8 +47,8 @@ public class EnvironmentPropertySource implements PropertySource {
     }
 
     @Override
-    public String get(String key) {
-        return getProperties().get(key);
+    public PropertyValue get(String key) {
+        return PropertyValue.of(key, System.getenv(key), getName());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
b/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
index 9093f25..80cd140 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/propertysource/SystemPropertySource.java
@@ -19,6 +19,8 @@
 package org.apache.tamaya.core.propertysource;
 
 import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spi.PropertyValueBuilder;
 
 import java.util.Collections;
 import java.util.HashMap;
@@ -69,8 +71,8 @@ public class SystemPropertySource implements PropertySource {
     }
 
     @Override
-    public String get(String key) {
-        return getProperties().get(key);
+    public PropertyValue get(String key) {
+        return PropertyValue.of(key, System.getProperty(key), getName());
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
index 26ad140..c2fe2d3 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/internal/converters/ConverterTestsPropertySource.java
@@ -19,6 +19,7 @@
 package org.apache.tamaya.core.internal.converters;
 
 import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
 
 import java.util.Collections;
 import java.util.Map;
@@ -38,204 +39,204 @@ public class ConverterTestsPropertySource implements PropertySource{
     }
 
     @Override
-    public String get(String key) {
+    public PropertyValue get(String key) {
         switch(key){
             // Bytes
             case "tests.converter.byte.decimal":
-                return "101";
+                return PropertyValue.of(key, "101", getName());
             case "tests.converter.byte.octal":
-                return "02";
+                return PropertyValue.of(key, "02", getName());
             case "tests.converter.byte.hex.lowerX":
-                return "0x2F";
+                return PropertyValue.of(key, "0x2F", getName());
             case "tests.converter.byte.hex.upperX":
-                return "0X3F";
+                return PropertyValue.of(key, "0X3F", getName());
             case "tests.converter.byte.min":
-                return "min";
+                return PropertyValue.of(key, "min", getName());
             case "tests.converter.byte.max":
-                return "MAX_Value";
+                return PropertyValue.of(key, "MAX_Value", getName());
             // Boolean
             case "tests.converter.boolean.y1":
-                return "y";
+                return PropertyValue.of(key, "y", getName());
             case "tests.converter.boolean.y2":
-                return "Y";
+                return PropertyValue.of(key, "Y", getName());
             case "tests.converter.boolean.yes1":
-                return "yes";
+                return PropertyValue.of(key, "yes", getName());
             case "tests.converter.boolean.yes2":
-                return "Yes";
+                return PropertyValue.of(key, "Yes", getName());
             case "tests.converter.boolean.yes3":
-                return "yeS";
+                return PropertyValue.of(key, "yeS", getName());
             case "tests.converter.boolean.true1":
-                return "true";
+                return PropertyValue.of(key, "true", getName());
             case "tests.converter.boolean.true2":
-                return "True";
+                return PropertyValue.of(key, "True", getName());
             case "tests.converter.boolean.true3":
-                return "trUe";
+                return PropertyValue.of(key, "trUe", getName());
             case "tests.converter.boolean.t1":
-                return "t";
+                return PropertyValue.of(key, "t", getName());
             case "tests.converter.boolean.t2":
-                return "T";
+                return PropertyValue.of(key, "T", getName());
             case "tests.converter.boolean.n1":
-                return "n";
+                return PropertyValue.of(key, "n", getName());
             case "tests.converter.boolean.n2":
-                return "N";
+                return PropertyValue.of(key, "N", getName());
             case "tests.converter.boolean.no1":
-                return "no";
+                return PropertyValue.of(key, "no", getName());
             case "tests.converter.boolean.no2":
-                return "No";
+                return PropertyValue.of(key, "No", getName());
             case "tests.converter.boolean.no3":
-                return "nO";
+                return PropertyValue.of(key, "nO", getName());
             case "tests.converter.boolean.false1":
-                return "false";
+                return PropertyValue.of(key, "false", getName());
             case "tests.converter.boolean.false2":
-                return "False";
+                return PropertyValue.of(key, "False", getName());
             case "tests.converter.boolean.false3":
-                return "falSe";
+                return PropertyValue.of(key, "falSe", getName());
             case "tests.converter.boolean.f1":
-                return "f";
+                return PropertyValue.of(key, "f", getName());
             case "tests.converter.boolean.f2":
-                return "F";
+                return PropertyValue.of(key, "F", getName());
             // Character
             case "tests.converter.char.f":
-                return "f";
+                return PropertyValue.of(key, "f", getName());
             case "tests.converter.char.d":
-                return "'d'";
+                return PropertyValue.of(key, "'d'", getName());
             case "tests.converter.char.f-before":
-                return "  f";
+                return PropertyValue.of(key, "  f", getName());
             case "tests.converter.char.f-after":
-                return "f   ";
+                return PropertyValue.of(key, "f   ", getName());
             case "tests.converter.char.f-around":
-                return "   f      ";
+                return PropertyValue.of(key, "   f      ", getName());
             case "tests.converter.char.f-numeric":
-                return "101";
+                return PropertyValue.of(key, "101", getName());
             // currency
             case "tests.converter.currency.code1":
-                return "CHF";
+                return PropertyValue.of(key, "CHF", getName());
             case "tests.converter.currency.code2":
-                return "cHf";
+                return PropertyValue.of(key, "cHf", getName());
             case "tests.converter.currency.code3":
-                return "  CHF";
+                return PropertyValue.of(key, "  CHF", getName());
             case "tests.converter.currency.code4":
-                return "CHF   ";
+                return PropertyValue.of(key, "CHF   ", getName());
             case "tests.converter.currency.code5":
-                return "  CHF   ";
+                return PropertyValue.of(key, "  CHF   ", getName());
             case "tests.converter.currency.code-numeric1":
-                return "100";
+                return PropertyValue.of(key, "100", getName());
             case "tests.converter.currency.code-numeric2":
-                return "  100";
+                return PropertyValue.of(key, "  100", getName());
             case "tests.converter.currency.code-numeric3":
-                return "100  ";
+                return PropertyValue.of(key, "100  ", getName());
             case "tests.converter.currency.code-numeric4":
-                return "  100  ";
+                return PropertyValue.of(key, "  100  ", getName());
             case "tests.converter.currency.code-locale1":
-                return "DE";
+                return PropertyValue.of(key, "DE", getName());
             case "tests.converter.currency.code-locale2":
-                return "  DE";
+                return PropertyValue.of(key, "  DE", getName());
             case "tests.converter.currency.code-locale3":
-                return "DE  ";
+                return PropertyValue.of(key, "DE  ", getName());
             case "tests.converter.currency.code-locale4":
-                return "  DE  ";
+                return PropertyValue.of(key, "  DE  ", getName());
             //double
             case "tests.converter.double.decimal":
-                return "1.23456789";
+                return PropertyValue.of(key, "1.23456789", getName());
             case "tests.converter.double.decimalNegative":
-                return "-1.23456789";
+                return PropertyValue.of(key, "-1.23456789", getName());
             case "tests.converter.double.integer":
-                return "  100";
+                return PropertyValue.of(key, "  100", getName());
             case "tests.converter.double.hex1":
-                return " 0XFF";
+                return PropertyValue.of(key, " 0XFF", getName());
             case "tests.converter.double.hex2":
-                return "-0xFF  ";
+                return PropertyValue.of(key, "-0xFF  ", getName());
             case "tests.converter.double.hex3":
-                return "#FF";
+                return PropertyValue.of(key, "#FF", getName());
             case "tests.converter.double.octal":
-                return "0013";
+                return PropertyValue.of(key, "0013", getName());
             case "tests.converter.double.min":
-                return "MIN_Value";
+                return PropertyValue.of(key, "MIN_Value", getName());
             case "tests.converter.double.max":
-                return "max";
+                return PropertyValue.of(key, "max", getName());
             case "tests.converter.double.nan":
-                return "NAN";
+                return PropertyValue.of(key, "NAN", getName());
             case "tests.converter.double.pi":
-                return "positive_infinity";
+                return PropertyValue.of(key, "positive_infinity", getName());
             case "tests.converter.double.ni":
-                return "Negative_Infinity";
+                return PropertyValue.of(key, "Negative_Infinity", getName());
             //float
             case "tests.converter.float.decimal":
-                return "1.23456789";
+                return PropertyValue.of(key, "1.23456789", getName());
             case "tests.converter.float.decimalNegative":
-                return "-1.23456789";
+                return PropertyValue.of(key, "-1.23456789", getName());
             case "tests.converter.float.integer":
-                return "  100";
+                return PropertyValue.of(key, "  100", getName());
             case "tests.converter.float.hex1":
-                return " 0XFF";
+                return PropertyValue.of(key, " 0XFF", getName());
             case "tests.converter.float.hex2":
-                return "-0xFF  ";
+                return PropertyValue.of(key, "-0xFF  ", getName());
             case "tests.converter.float.hex3":
-                return "#FF";
+                return PropertyValue.of(key, "#FF", getName());
             case "tests.converter.float.octal":
-                return "0013";
+                return PropertyValue.of(key, "0013", getName());
             case "tests.converter.float.min":
-                return "MIN_Value";
+                return PropertyValue.of(key, "MIN_Value", getName());
             case "tests.converter.float.max":
-                return "max";
+                return PropertyValue.of(key, "max", getName());
             case "tests.converter.float.nan":
-                return "NAN";
+                return PropertyValue.of(key, "NAN", getName());
             case "tests.converter.float.pi":
-                return "positive_infinity";
+                return PropertyValue.of(key, "positive_infinity", getName());
             case "tests.converter.float.ni":
-                return "Negative_Infinity";
+                return PropertyValue.of(key, "Negative_Infinity", getName());
             // Integer
             case "tests.converter.integer.decimal":
-                return "101";
+                return PropertyValue.of(key, "101", getName());
             case "tests.converter.integer.octal":
-                return "02";
+                return PropertyValue.of(key, "02", getName());
             case "tests.converter.integer.hex.lowerX":
-                return "0x2F";
+                return PropertyValue.of(key, "0x2F", getName());
             case "tests.converter.integer.hex.upperX":
-                return "0X3F";
+                return PropertyValue.of(key, "0X3F", getName());
             case "tests.converter.integer.min":
-                return "min";
+                return PropertyValue.of(key, "min", getName());
             case "tests.converter.integer.max":
-                return "MAX_Value";
+                return PropertyValue.of(key, "MAX_Value", getName());
             // Long
             case "tests.converter.long.decimal":
-                return "101";
+                return PropertyValue.of(key, "101", getName());
             case "tests.converter.long.octal":
-                return "02";
+                return PropertyValue.of(key, "02", getName());
             case "tests.converter.long.hex.lowerX":
-                return "0x2F";
+                return PropertyValue.of(key, "0x2F", getName());
             case "tests.converter.long.hex.upperX":
-                return "0X3F";
+                return PropertyValue.of(key, "0X3F", getName());
             case "tests.converter.long.min":
-                return "min";
+                return PropertyValue.of(key, "min", getName());
             case "tests.converter.long.max":
-                return "MAX_Value";
+                return PropertyValue.of(key, "MAX_Value", getName());
             // Short
             case "tests.converter.short.decimal":
-                return "101";
+                return PropertyValue.of(key, "101", getName());
             case "tests.converter.short.octal":
-                return "02";
+                return PropertyValue.of(key, "02", getName());
             case "tests.converter.short.hex.lowerX":
-                return "0x2F";
+                return PropertyValue.of(key, "0x2F", getName());
             case "tests.converter.short.hex.upperX":
-                return "0X3F";
+                return PropertyValue.of(key, "0X3F", getName());
             case "tests.converter.short.min":
-                return "min";
+                return PropertyValue.of(key, "min", getName());
             case "tests.converter.short.max":
-                return "MAX_Value";
+                return PropertyValue.of(key, "MAX_Value", getName());
             // BigDecimal
             case "tests.converter.bd.decimal":
-                return "101";
+                return PropertyValue.of(key, "101", getName());
             case "tests.converter.bd.float":
-                return "101.36438746";
+                return PropertyValue.of(key, "101.36438746", getName());
             case "tests.converter.bd.big":
-                return "101666666666666662333337263723628763821638923628193612983618293628763";
+                return PropertyValue.of(key, "101666666666666662333337263723628763821638923628193612983618293628763",
getName());
             case "tests.converter.bd.bigFloat":
-                return "1016666666666666623333372637236287638216389293628763.101666666666666662333337263723628763821638923628193612983618293628763";
+                return PropertyValue.of(key, "1016666666666666623333372637236287638216389293628763.101666666666666662333337263723628763821638923628193612983618293628763",
getName());
             case "tests.converter.bd.hex.lowerX":
-                return "0x2F";
+                return PropertyValue.of(key, "0x2F", getName());
             case "tests.converter.bd.hex.upperX":
-                return "0X3F";
+                return PropertyValue.of(key, "0X3F", getName());
         }
         return null;
     }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java
b/code/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java
index 8d3f086..8ab1baf 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/propertysource/BasePropertySourceTest.java
@@ -18,8 +18,9 @@
  */
 package org.apache.tamaya.core.propertysource;
 
-import org.apache.tamaya.core.propertysource.BasePropertySource;
 import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spi.PropertyValueBuilder;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -40,7 +41,7 @@ public class BasePropertySourceTest {
             }
 
             @Override
-            public String get(String key) {
+            public PropertyValue get(String key) {
                 return null;
             }
 
@@ -59,7 +60,7 @@ public class BasePropertySourceTest {
 
     @Test
     public void testGet() {
-        Assert.assertEquals("1000", new OverriddenOrdinalPropertySource().get(PropertySource.TAMAYA_ORDINAL));
+        Assert.assertEquals("1000", new OverriddenOrdinalPropertySource().get(PropertySource.TAMAYA_ORDINAL).get(PropertySource.TAMAYA_ORDINAL));
     }
 
     private static class OverriddenOrdinalPropertySource extends BasePropertySource {

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java
b/code/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java
index f9feb4b..a0f1093 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/propertysource/EnvironmentPropertySourceTest.java
@@ -45,7 +45,7 @@ public class EnvironmentPropertySourceTest {
     @Test
     public void testGet() throws Exception {
         for (Map.Entry<String, String> envEntry : System.getenv().entrySet()) {
-            assertEquals(envPropertySource.get(envEntry.getKey()), envEntry.getValue());
+            assertEquals(envPropertySource.get(envEntry.getKey()).get(envEntry.getKey()),
envEntry.getValue());
         }
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java
b/code/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java
index 2028ceb..745feeb 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/propertysource/PropertiesFilePropertySourceTest.java
@@ -18,7 +18,6 @@
  */
 package org.apache.tamaya.core.propertysource;
 
-import org.apache.tamaya.core.propertysource.SimplePropertySource;
 import org.apache.tamaya.spi.PropertySource;
 import org.junit.Assert;
 import org.junit.Test;
@@ -34,14 +33,16 @@ public class PropertiesFilePropertySourceTest {
     @Test
     public void testGetOrdinal() {
         Assert.assertEquals(0, testfilePropertySource.getOrdinal());
-        Assert.assertEquals(Integer.parseInt(overrideOrdinalPropertySource.get(PropertySource.TAMAYA_ORDINAL)),
overrideOrdinalPropertySource.getOrdinal());
+        Assert.assertEquals(Integer.parseInt(overrideOrdinalPropertySource.get(PropertySource.TAMAYA_ORDINAL)
+                .get(PropertySource.TAMAYA_ORDINAL)),
+                overrideOrdinalPropertySource.getOrdinal());
     }
 
 
     @Test
     public void testGet() {
-        Assert.assertEquals("val3", testfilePropertySource.get("key3"));
-        Assert.assertEquals("myval5", overrideOrdinalPropertySource.get("mykey5"));
+        Assert.assertEquals("val3", testfilePropertySource.get("key3").get("key3"));
+        Assert.assertEquals("myval5", overrideOrdinalPropertySource.get("mykey5").get("mykey5"));
         Assert.assertNull(testfilePropertySource.get("nonpresentkey"));
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/test/java/org/apache/tamaya/core/propertysource/SystemPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/propertysource/SystemPropertySourceTest.java
b/code/core/src/test/java/org/apache/tamaya/core/propertysource/SystemPropertySourceTest.java
index f0eaf68..4848ab7 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/propertysource/SystemPropertySourceTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/propertysource/SystemPropertySourceTest.java
@@ -18,8 +18,8 @@
  */
 package org.apache.tamaya.core.propertysource;
 
-import org.apache.tamaya.core.propertysource.SystemPropertySource;
 import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
 import org.junit.Assert;
 import org.junit.Test;
 
@@ -55,10 +55,10 @@ public class SystemPropertySourceTest {
     public void testGet() throws Exception {
         String propertyKeyToCheck = System.getProperties().stringPropertyNames().iterator().next();
 
-        String property = testPropertySource.get(propertyKeyToCheck);
+        PropertyValue property = testPropertySource.get(propertyKeyToCheck);
         Assert.assertNotNull("Property '" + propertyKeyToCheck + "' is not present in " +
                 SystemPropertySource.class.getSimpleName(), property);
-        Assert.assertEquals(System.getProperty(propertyKeyToCheck), property);
+        Assert.assertEquals(System.getProperty(propertyKeyToCheck), property.getValue());
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
b/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
index f099da4..c81ae32 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/provider/JavaConfigurationProviderTest.java
@@ -48,7 +48,7 @@ public class JavaConfigurationProviderTest {
             String key = "confkey" + i;
             String value = "javaconf-value" + i;
 
-            Assert.assertEquals(value, propertySource.get(key));
+            Assert.assertEquals(value, propertySource.get(key).get(key));
 
             // check if we had our key in configuration.current
             Assert.assertTrue(ConfigurationProvider.getConfiguration().getProperties().containsKey(key));

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java
b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java
index 6faa831..071cbb1 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestPropertyFilter.java
@@ -18,6 +18,7 @@
  */
 package org.apache.tamaya.core.testdata;
 
+import org.apache.tamaya.spi.FilterContext;
 import org.apache.tamaya.spi.PropertyFilter;
 
 import javax.annotation.Priority;
@@ -28,8 +29,8 @@ import javax.annotation.Priority;
 @Priority(100)
 public class TestPropertyFilter implements PropertyFilter{
     @Override
-    public String filterProperty(String key, String valueToBeFiltered) {
-        if("name4".equals(key)){
+    public String filterProperty(String valueToBeFiltered, FilterContext context) {
+        if("name4".equals(context.getKey())){
             return valueToBeFiltered + "(filtered)";
         }
         return valueToBeFiltered;

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/0be037b8/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java
b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java
index 5a57ad1..7a5b7a8 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/testdata/TestRemovingPropertyFilter.java
@@ -19,6 +19,7 @@
 package org.apache.tamaya.core.testdata;
 
 import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.spi.FilterContext;
 import org.apache.tamaya.spi.PropertyFilter;
 
 import javax.annotation.Priority;
@@ -29,11 +30,11 @@ import javax.annotation.Priority;
 @Priority(200)
 public class TestRemovingPropertyFilter implements PropertyFilter{
     @Override
-    public String filterProperty(String key, String valueToBeFiltered) {
-        if("name5".equals(key)){
+    public String filterProperty(String valueToBeFiltered, FilterContext context) {
+        if("name5".equals(context.getKey())){
             return null;
         }
-        else if("name3".equals(key)){
+        else if("name3".equals(context.getKey())){
             return "Mapped to name: " + ConfigurationProvider.getConfiguration().get("name");
         }
         return valueToBeFiltered;



Mime
View raw message