You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by an...@apache.org on 2016/04/04 01:30:07 UTC

[2/3] incubator-tamaya git commit: Fixed tests due to additional metadata included.

Fixed tests due to additional metadata included.


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

Branch: refs/heads/master
Commit: 076730a43ba021ad5875fe79556086027270dd6c
Parents: 8945515
Author: anatole <an...@apache.org>
Authored: Sun Apr 3 23:20:11 2016 +0200
Committer: anatole <an...@apache.org>
Committed: Sun Apr 3 23:20:11 2016 +0200

----------------------------------------------------------------------
 .../java/org/apache/tamaya/spi/PropertyValueBuilder.java     | 2 +-
 .../tamaya/core/propertysource/BasePropertySource.java       | 2 +-
 .../core/propertysource/EnvironmentPropertySourceTest.java   | 8 +++++++-
 .../propertysource/PropertiesFilePropertySourceTest.java     | 2 +-
 .../tamaya/core/propertysource/SystemPropertySourceTest.java | 6 ++++--
 .../tamaya/core/provider/JavaConfigurationProviderTest.java  | 2 +-
 6 files changed, 15 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/076730a4/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueBuilder.java
----------------------------------------------------------------------
diff --git a/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueBuilder.java b/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueBuilder.java
index 883e5c5..7eaeb94 100644
--- a/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueBuilder.java
+++ b/code/api/src/main/java/org/apache/tamaya/spi/PropertyValueBuilder.java
@@ -80,7 +80,7 @@ public class PropertyValueBuilder {
      * @return the builder for chaining.
      */
     public PropertyValueBuilder addContextData(String key, Object value) {
-        this.contextData.put("_"+this.key+'.'+key, String.valueOf(Objects.requireNonNull(value)));
+        this.contextData.put("_"+this.key+'.'+key, String.valueOf(Objects.requireNonNull(value, "Meta value is null.")));
         return this;
     }
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/076730a4/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 b5c7378..3745537 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
@@ -87,7 +87,7 @@ public abstract class BasePropertySource implements PropertySource{
         PropertyValueBuilder b = new PropertyValueBuilder(key, val, getName());
         String metaKeyStart = "_" + key + ".";
         for(Map.Entry<String,String> en:properties.entrySet()) {
-            if(en.getKey().startsWith(metaKeyStart)){
+            if(en.getKey().startsWith(metaKeyStart) && en.getValue()!=null){
                 b.addContextData(en.getKey().substring(metaKeyStart.length()), en.getValue());
             }
         }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/076730a4/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 a0f1093..05883f8 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
@@ -52,7 +52,13 @@ public class EnvironmentPropertySourceTest {
     @Test
     public void testGetProperties() throws Exception {
         Map<String, String> props = envPropertySource.getProperties();
-        assertEquals(System.getenv(), props);
+        for(Map.Entry<String,String> en: props.entrySet()){
+            if(en.getKey().startsWith("_")){
+                assertEquals(envPropertySource.getName(), en.getValue());
+            }else{
+                assertEquals(System.getenv(en.getKey()), en.getValue());
+            }
+        }
     }
 
     @Test

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/076730a4/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 745feeb..1d2139b 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
@@ -49,7 +49,7 @@ public class PropertiesFilePropertySourceTest {
 
     @Test
     public void testGetProperties() throws Exception {
-        Assert.assertEquals(5, testfilePropertySource.getProperties().size());
+        Assert.assertEquals(10, testfilePropertySource.getProperties().size());
         Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key1"));
         Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key2"));
         Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key3"));

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/076730a4/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 4848ab7..e6dd5bd 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
@@ -87,10 +87,12 @@ public class SystemPropertySourceTest {
         Properties systemEntries = System.getProperties();
 
         Assert.assertEquals("size of System.getProperties().entrySet() must be the same as SystemPropertySrouce.getProperties().entrySet()",
-                            systemEntries.entrySet().size(), toCheck.size());
+                            systemEntries.size(), toCheck.size()/2);
 
         for (Map.Entry<String, String> propertySourceEntry : toCheck.entrySet()) {
-
+            if(propertySourceEntry.getKey().startsWith("_")){
+                continue; // meta entry
+            }
             Assert.assertEquals("Entry values for key '" + propertySourceEntry.getKey() + "' do not match",
                                 systemEntries.getProperty(propertySourceEntry.getKey()), propertySourceEntry.getValue());
         }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/076730a4/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 c81ae32..4d9346f 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
@@ -42,7 +42,7 @@ public class JavaConfigurationProviderTest {
 
         PropertySource propertySource = propertySources.iterator().next();
 
-        assertThat(propertySource.getProperties().keySet(), hasSize(5));
+        assertThat(propertySource.getProperties().keySet(), hasSize(10));  // 5 entries + 5 metaentries
 
         for (int i = 1; i < 6; i++) {
             String key = "confkey" + i;