You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by jo...@apache.org on 2016/10/23 13:50:53 UTC
incubator-tamaya git commit: TAMAYA-181 Ensure that name is always
set in SimplePropertySource so that source entries are maintained.
Repository: incubator-tamaya
Updated Branches:
refs/heads/master 36b437ae8 -> 747bae159
TAMAYA-181 Ensure that name is always set in SimplePropertySource so that source entries are maintained.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/747bae15
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/747bae15
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/747bae15
Branch: refs/heads/master
Commit: 747bae159add72f140199d8107ff0549f33671cb
Parents: 36b437a
Author: John D. Ament <jo...@apache.org>
Authored: Sun Oct 23 09:50:30 2016 -0400
Committer: John D. Ament <jo...@apache.org>
Committed: Sun Oct 23 09:50:30 2016 -0400
----------------------------------------------------------------------
.../propertysource/SimplePropertySource.java | 19 ++++++++++---------
.../PropertiesFilePropertySourceTest.java | 2 +-
.../propertysource/SimplePropertySourceTest.java | 4 ++--
.../provider/JavaConfigurationProviderTest.java | 2 +-
4 files changed, 14 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/747bae15/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java
----------------------------------------------------------------------
diff --git a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java b/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java
index e875d8c..4ad171e 100644
--- a/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java
+++ b/code/core/src/main/java/org/apache/tamaya/core/propertysource/SimplePropertySource.java
@@ -41,22 +41,26 @@ public class SimplePropertySource extends BasePropertySource {
/**
* The property source name.
*/
- private String name;
+ private final String name;
/**
* The current properties.
*/
private Map<String, String> properties;
+ private SimplePropertySource(String name) {
+ super(0);
+ this.name = Objects.requireNonNull(name);
+ }
+
/**
* Creates a new Properties based PropertySource based on the given URL.
*
* @param propertiesLocation the URL encoded location, not null.
*/
public SimplePropertySource(File propertiesLocation) {
- super(0);
+ this(propertiesLocation.toString());
try {
- this.name = propertiesLocation.toString();
this.properties = load(propertiesLocation.toURI().toURL());
} catch (IOException e) {
throw new ConfigException("Failed to load properties from " + propertiesLocation, e);
@@ -69,9 +73,8 @@ public class SimplePropertySource extends BasePropertySource {
* @param propertiesLocation the URL encoded location, not null.
*/
public SimplePropertySource(URL propertiesLocation) {
- super(0);
+ this(propertiesLocation.toString());
this.properties = load(propertiesLocation);
- this.name = propertiesLocation.toString();
}
/**
@@ -81,9 +84,8 @@ public class SimplePropertySource extends BasePropertySource {
* @param properties the properties, not null.
*/
public SimplePropertySource(String name, Map<String, String> properties) {
- super(0);
+ this(name);
this.properties = new HashMap<>(properties);
- this.name = Objects.requireNonNull(name);
}
/**
@@ -93,9 +95,8 @@ public class SimplePropertySource extends BasePropertySource {
* @param propertiesLocation the URL encoded location, not null.
*/
public SimplePropertySource(String name, URL propertiesLocation) {
- super(0);
+ this(name);
this.properties = load(propertiesLocation);
- this.name = Objects.requireNonNull(name);
}
@Override
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/747bae15/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..279403e 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()); // double the size for .source values.
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/747bae15/code/core/src/test/java/org/apache/tamaya/core/propertysource/SimplePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/code/core/src/test/java/org/apache/tamaya/core/propertysource/SimplePropertySourceTest.java b/code/core/src/test/java/org/apache/tamaya/core/propertysource/SimplePropertySourceTest.java
index 064611c..518ed18 100644
--- a/code/core/src/test/java/org/apache/tamaya/core/propertysource/SimplePropertySourceTest.java
+++ b/code/core/src/test/java/org/apache/tamaya/core/propertysource/SimplePropertySourceTest.java
@@ -39,7 +39,7 @@ public class SimplePropertySourceTest {
SimplePropertySource source = new SimplePropertySource(resource);
assertThat(source, notNullValue());
- assertThat(source.getProperties(), aMapWithSize(2));
+ assertThat(source.getProperties(), aMapWithSize(4)); // double the size for .source values.
assertThat(source.getProperties(), hasEntry("a", "b"));
assertThat(source.getProperties(), hasEntry("b", "1"));
@@ -83,6 +83,6 @@ public class SimplePropertySourceTest {
SimplePropertySource source = new SimplePropertySource(resource);
assertThat(source, notNullValue());
- assertThat(source.getProperties(), aMapWithSize(5));
+ assertThat(source.getProperties(), aMapWithSize(10)); // double the size for .source values.
}
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/747bae15/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 3ca3478..59b9e33 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
@@ -44,7 +44,7 @@ public class JavaConfigurationProviderTest {
PropertySource propertySource = propertySources.iterator().next();
- assertThat(propertySource.getProperties().keySet(), hasSize(5));
+ assertThat(propertySource.getProperties().keySet(), hasSize(10)); // double the size for .source values.
for (int i = 1; i < 6; i++) {
String key = "confkey" + i;