Repository: incubator-tamaya
Updated Branches:
  refs/heads/master 8cf583436 -> c97b5e713


TAMAYA-335: Add bugfix with test for wrong builder var

* Add test and bugfix by renaming variable properly in builder.


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

Branch: refs/heads/master
Commit: c97b5e71381df0c3d1c6f04b4a7a770336693656
Parents: 8cf5834
Author: Phil Ottlinger <[email protected]>
Authored: Mon Apr 30 00:17:09 2018 +0200
Committer: Phil Ottlinger <[email protected]>
Committed: Mon Apr 30 00:17:09 2018 +0200

----------------------------------------------------------------------
 .../propertysource/SimplePropertySource.java         |  7 ++-----
 .../propertysource/SimplePropertySourceTest.java     | 15 ++++++++++++++-
 2 files changed, 16 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c97b5e71/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySource.java
----------------------------------------------------------------------
diff --git 
a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySource.java
 
b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySource.java
index 6dc41a7..3eb9d58 100644
--- 
a/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySource.java
+++ 
b/code/spi-support/src/main/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySource.java
@@ -31,7 +31,6 @@ import java.util.Map;
 import java.util.Objects;
 import java.util.Properties;
 import java.util.UUID;
-import java.util.logging.Logger;
 
 /**
  * Simple implementation of a {@link org.apache.tamaya.spi.PropertySource} for
@@ -39,8 +38,6 @@ import java.util.logging.Logger;
  */
 public class SimplePropertySource extends BasePropertySource {
 
-    private static final Logger LOG = 
Logger.getLogger(SimplePropertySource.class.getName());
-
     /**
      * The current properties.
      */
@@ -188,10 +185,10 @@ public class SimplePropertySource extends 
BasePropertySource {
          * Sets the {@code name} and returns a reference to this Builder so 
that the methods
          * can be chained together.
          *
-         * @param val the {@code name} to set, not null.
+         * @param name the {@code name} to set, not null.
          * @return a reference to this Builder
          */
-        public Builder withName(String val) {
+        public Builder withName(String name) {
             this.name = Objects.requireNonNull(name);
             return this;
         }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/c97b5e71/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySourceTest.java
----------------------------------------------------------------------
diff --git 
a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySourceTest.java
 
b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySourceTest.java
index 343e51a..3b53b32 100644
--- 
a/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySourceTest.java
+++ 
b/code/spi-support/src/test/java/org/apache/tamaya/spisupport/propertysource/SimplePropertySourceTest.java
@@ -21,6 +21,7 @@ package org.apache.tamaya.spisupport.propertysource;
 import java.io.File;
 import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.spi.PropertyValue;
+import 
org.apache.tamaya.spisupport.propertysource.SimplePropertySource.Builder;
 import org.junit.Test;
 
 import java.net.URL;
@@ -42,7 +43,6 @@ public class SimplePropertySourceTest {
         assertThat(source.getProperties()).hasSize(2); // double the size for 
.source values.
         assertThat(source.getProperties()).contains(entry("a", 
PropertyValue.of("a", "b", resource.toString())));
         assertThat(source.getProperties()).contains(entry("b", 
PropertyValue.of("b", "1", resource.toString())));
-
     }
 
     @Test
@@ -181,4 +181,17 @@ public class SimplePropertySourceTest {
         assertThat(sps.getProperties()).contains(entry("a", 
PropertyValue.of("a", "b", resource.toString())));
         assertThat(sps.getProperties()).contains(entry("b", 
PropertyValue.of("b", "1", resource.toString())));
     }
+    
+    @Test
+    public void buildingWithValidName() {
+       final String KEY = "myTestKey"; 
+       Builder builder = SimplePropertySource.newBuilder().withName(KEY);
+       assertThat(builder.build().getName()).isEqualTo(KEY);
+    }
+    
+    @Test(expected = NullPointerException.class)
+    public void buildingWithInvalidNameYieldsNPE() {
+       SimplePropertySource.newBuilder().withName(null);
+    }
+    
 }

Reply via email to