Repository: incubator-tamaya-extensions
Updated Branches:
  refs/heads/master 8b9306074 -> 396f1a738


TAMAYA-340 Environment properties vs PropertySourceChangeTest

On looking for the System property "java.home" in the Environment, we
are now also looking for "JAVA_HOME".  The Environment variable is often
a symlink while the System property is often the resolution of that
symlink.  That causes a surprising update event.  Test both sides of the
surprise.


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

Branch: refs/heads/master
Commit: 97c5630e5747ffeea2b7a60f1bb03577ee8ca449
Parents: 8b93060
Author: William Lieurance <[email protected]>
Authored: Sun Jun 10 21:38:39 2018 -0500
Committer: William Lieurance <[email protected]>
Committed: Sun Jun 10 21:38:39 2018 -0500

----------------------------------------------------------------------
 .../tamaya/events/PropertySourceChangeTest.java | 41 ++++++++++++++++----
 1 file changed, 34 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/97c5630e/modules/events/src/test/java/org/apache/tamaya/events/PropertySourceChangeTest.java
----------------------------------------------------------------------
diff --git 
a/modules/events/src/test/java/org/apache/tamaya/events/PropertySourceChangeTest.java
 
b/modules/events/src/test/java/org/apache/tamaya/events/PropertySourceChangeTest.java
index a1a9200..0fb577e 100644
--- 
a/modules/events/src/test/java/org/apache/tamaya/events/PropertySourceChangeTest.java
+++ 
b/modules/events/src/test/java/org/apache/tamaya/events/PropertySourceChangeTest.java
@@ -21,6 +21,7 @@ package org.apache.tamaya.events;
 import org.apache.tamaya.spisupport.propertysource.EnvironmentPropertySource;
 import org.apache.tamaya.spisupport.propertysource.SimplePropertySource;
 import org.apache.tamaya.spisupport.propertysource.SystemPropertySource;
+import org.apache.tamaya.spisupport.propertysource.MapPropertySource;
 import org.apache.tamaya.spi.PropertySource;
 import org.junit.Test;
 
@@ -62,7 +63,7 @@ public class PropertySourceChangeTest {
                 .addChanges(
                         new EnvironmentPropertySource()
                 ).build();
-        assertTrue(change.getChanges().size()>0);
+        assertTrue(change.getChanges().size() > 0);
     }
 
     @Test
@@ -71,7 +72,7 @@ public class PropertySourceChangeTest {
                 .addChanges(
                         new EnvironmentPropertySource()
                 ).build();
-        assertTrue(change.getRemovedSize()>0);
+        assertTrue(change.getRemovedSize() > 0);
     }
 
     @Test
@@ -80,16 +81,42 @@ public class PropertySourceChangeTest {
                 .addChanges(
                         new EnvironmentPropertySource()
                 ).build();
-        assertTrue(change.getAddedSize()>0);
+        assertTrue(change.getAddedSize() > 0);
     }
 
     @Test
-    public void testGetUpdatedSize() throws Exception {
+    public void testGetUpdatedSizeNoUpdates() throws Exception {
+        Map<String, String> addableMap = new HashMap<>();
+        
+        addableMap.put("NonOverridingValue", "someValue");
+
+        PropertySourceChange change = PropertySourceChangeBuilder.of(myPS)
+                .addChanges(
+                        //java.home and JAVA_HOME will often override each
+                        //  other, so stay away from EnvironmentPropertySource
+                        new SystemPropertySource()
+                )
+                .addChanges(
+                        new MapPropertySource("addableMap", addableMap)
+                )
+                .build();
+        assertTrue(change.getUpdatedSize() == 0);
+    }
+
+    @Test
+    public void testGetUpdatedSizeWithUpdates() throws Exception {
+        Map<String, String> addableMap = new HashMap<>();
+        addableMap.put("java.home", "/new/java/home/value");
+
         PropertySourceChange change = PropertySourceChangeBuilder.of(myPS)
                 .addChanges(
                         new EnvironmentPropertySource()
-                ).build();
-        assertTrue(change.getUpdatedSize()==0);
+                )
+                .addChanges(
+                        new MapPropertySource("addableMap", addableMap)
+                )
+                .build();
+        assertTrue(change.getUpdatedSize() > 0);
     }
 
     @Test
@@ -177,4 +204,4 @@ public class PropertySourceChangeTest {
         assertNotNull(toString);
         assertTrue(toString.contains(myPS.getName()));
     }
-}
\ No newline at end of file
+}

Reply via email to