You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2015/03/05 19:20:00 UTC
[1/5] incubator-tamaya git commit: Added a unit test.
Repository: incubator-tamaya
Updated Branches:
refs/heads/master a5420d61e -> 1b413201e
Added a unit test.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/1b413201
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/1b413201
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/1b413201
Branch: refs/heads/master
Commit: 1b413201e6af10c807db31a1bb60e1ca79e898a7
Parents: 8130dd0
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Thu Mar 5 22:39:22 2015 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Thu Mar 5 19:19:49 2015 +0100
----------------------------------------------------------------------
.../converters/LocalDateConverterTest.java | 41 ++++++++++++++++++++
1 file changed, 41 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/1b413201/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java
----------------------------------------------------------------------
diff --git a/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java
new file mode 100644
index 0000000..936aaa4
--- /dev/null
+++ b/java8/core/src/test/java/org/apache/tamaya/core/internal/converters/LocalDateConverterTest.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.tamaya.core.internal.converters;
+
+import org.junit.Test;
+
+import java.time.LocalDate;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.Matchers.notNullValue;
+
+public class LocalDateConverterTest {
+ public static final LocalDate REF_LOCAL_DATE = LocalDate.of(2007, 4, 1);
+
+ @Test
+ public void canConvertStringToLocalDate() throws Exception {
+ LocalDateConverter converter = new LocalDateConverter();
+
+ LocalDate date = converter.convert(" 2007-04-01\t");
+
+ assertThat(date, notNullValue());
+ assertThat(date, equalTo(REF_LOCAL_DATE));
+ }
+}
\ No newline at end of file
[2/5] incubator-tamaya git commit: TAMAYA-60 Updated todo list for
TAMAYA-60.
Posted by pl...@apache.org.
TAMAYA-60 Updated todo list for TAMAYA-60.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/411c438e
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/411c438e
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/411c438e
Branch: refs/heads/master
Commit: 411c438e35aec4cabbecfb4a720f6c68c34c8ada
Parents: dc984ef
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Thu Mar 5 19:22:43 2015 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Thu Mar 5 19:19:49 2015 +0100
----------------------------------------------------------------------
.../org/apache/tamaya/modules/builder/ConfigurationBuilder.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/411c438e/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java b/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
index 8c314e1..3774976 100644
--- a/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
+++ b/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
@@ -55,7 +55,7 @@ import static java.lang.String.format;
* - Rethink the default behaviour for SPI loading
* - Work on all TODOs for TAMAYA-60
* - Write JavaDoc
- * - adding sources via URL IN PROGRESS
+ * - adding sources via URL DONE
*
*
*
[4/5] incubator-tamaya git commit: TAMAYA-60 Added JavaDoc.
Posted by pl...@apache.org.
TAMAYA-60 Added JavaDoc.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/8130dd02
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/8130dd02
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/8130dd02
Branch: refs/heads/master
Commit: 8130dd023c2a2678febea025ca3b4e2065e70e1f
Parents: 411c438
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Thu Mar 5 20:48:10 2015 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Thu Mar 5 19:19:49 2015 +0100
----------------------------------------------------------------------
.../modules/builder/ConfigurationBuilder.java | 22 ++++++++++++++++++++
1 file changed, 22 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/8130dd02/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java b/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
index 3774976..e739282 100644
--- a/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
+++ b/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
@@ -125,6 +125,28 @@ public class ConfigurationBuilder {
return data;
}
+ /**
+ * Adds one or more resources with properties in an arbitrary format
+ * to the configuration to be build.
+ *
+ * <p>If a specific format is supported depends on the available
+ * {@link org.apache.tamaya.format.ConfigurationFormat} implementations.</p>
+ *
+ *<pre>
+ * URL first = new URL("file:/etc/service/config.json");
+ * URL second = new URL(file:/etc/defaults/values.properties");
+ *
+ * builder.addPropertySources(first, second);
+ *</pre>
+ *
+ * @param url first resource with properties for the the configuration to be build.
+ * @param urls list additional of resources with properties for the configuration to be
+ * build.
+ * @return the builder instance currently used
+ *
+ * @see org.apache.tamaya.format.ConfigurationFormat
+ * @see org.apache.tamaya.format.ConfigurationFormats#getFormats()
+ */
public ConfigurationBuilder addPropertySource(URL url, URL... urls) {
Stream.of(Collections.singletonList(url), Arrays.asList(urls))
.flatMap(Collection::stream)
[5/5] incubator-tamaya git commit: TAMAYA-60 A ConfigException will
be thrown if there is no configuration format able to handle the given
property resource.
Posted by pl...@apache.org.
TAMAYA-60 A ConfigException will be thrown if there is no configuration format able to handle the given property resource.
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/dc984efc
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/dc984efc
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/dc984efc
Branch: refs/heads/master
Commit: dc984efc9a6c4873e0cf3c91713ac677df90faca
Parents: 51d893a
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Thu Mar 5 19:20:31 2015 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Thu Mar 5 19:19:49 2015 +0100
----------------------------------------------------------------------
.../modules/builder/ConfigurationBuilder.java | 18 +++++++++++++++++-
.../builder/ConfigurationBuilderTest.java | 11 +++++++++++
.../test/resources/configfiles/other/simple.oml | 19 +++++++++++++++++++
3 files changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dc984efc/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java b/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
index 465b180..8c314e1 100644
--- a/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
+++ b/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
@@ -43,6 +43,8 @@ import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
+import static java.lang.String.format;
+
/* TODO LIST FOR TAMAYA-60
*
* - configurable loading of provided PropertyConverter DONE
@@ -99,7 +101,8 @@ public class ConfigurationBuilder {
public ConfigurationBuilder addPropertySource(URL url) {
try {
- ConfigurationData data = ConfigurationFormats.readConfigurationData(url);
+ ConfigurationData data = getConfigurationDataFromURL(url);
+
FlattenedDefaultPropertySource propertySource = new FlattenedDefaultPropertySource(data);
addPropertySources(propertySource);
} catch (IOException e) {
@@ -109,6 +112,19 @@ public class ConfigurationBuilder {
return this;
}
+ private ConfigurationData getConfigurationDataFromURL(URL url) throws IOException {
+ ConfigurationData data = ConfigurationFormats.readConfigurationData(url);
+
+ if (null == data) {
+ String mesg = format("No configuration format found which is able " +
+ "to read properties from %s.", url.toString());
+
+ throw new ConfigException(mesg);
+ }
+
+ return data;
+ }
+
public ConfigurationBuilder addPropertySource(URL url, URL... urls) {
Stream.of(Collections.singletonList(url), Arrays.asList(urls))
.flatMap(Collection::stream)
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dc984efc/modules/builder/src/test/java/org/apache/tamaya/modules/builder/ConfigurationBuilderTest.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/modules/builder/ConfigurationBuilderTest.java b/modules/builder/src/test/java/org/apache/tamaya/modules/builder/ConfigurationBuilderTest.java
index 5997aeb..1ddce26 100644
--- a/modules/builder/src/test/java/org/apache/tamaya/modules/builder/ConfigurationBuilderTest.java
+++ b/modules/builder/src/test/java/org/apache/tamaya/modules/builder/ConfigurationBuilderTest.java
@@ -766,6 +766,17 @@ public class ConfigurationBuilderTest {
* Tests for loading resources via URL (as String)
*/
+ @Test(expected = ConfigException.class)
+ public void tryToLoadOneUnsupportedPropertySourceViaStringURL() {
+ URL resource = this.getClass().getResource("/configfiles/other/simple.oml");
+
+ assertThat(resource, CoreMatchers.notNullValue());
+
+ ConfigurationBuilder builder = new ConfigurationBuilder();
+
+ builder.addPropertySource(resource.toString()).build();
+ }
+
@Test
public void loadOneJSONPropertySourceViaStringURL() {
URL resource = this.getClass().getResource("/configfiles/json/simple.json");
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/dc984efc/modules/builder/src/test/resources/configfiles/other/simple.oml
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/configfiles/other/simple.oml b/modules/builder/src/test/resources/configfiles/other/simple.oml
new file mode 100644
index 0000000..494dba3
--- /dev/null
+++ b/modules/builder/src/test/resources/configfiles/other/simple.oml
@@ -0,0 +1,19 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy current the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+Key:=Value
[3/5] incubator-tamaya git commit: TAMAYA-60 Property sources can now
also added via URL (String/URL).
Posted by pl...@apache.org.
TAMAYA-60 Property sources can now also added via URL (String/URL).
Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/51d893a4
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/51d893a4
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/51d893a4
Branch: refs/heads/master
Commit: 51d893a480c3f0cc9d036285946974d575dc70a3
Parents: a5420d6
Author: Oliver B. Fischer <pl...@apache.org>
Authored: Wed Mar 4 19:45:34 2015 +0100
Committer: Oliver B. Fischer <pl...@apache.org>
Committed: Thu Mar 5 19:19:49 2015 +0100
----------------------------------------------------------------------
modules/builder/pom.xml | 14 +++
.../modules/builder/ConfigurationBuilder.java | 61 ++++++++++-
.../builder/ConfigurationBuilderTest.java | 106 +++++++++++++++++++
.../test/resources/configfiles/json/first.json | 4 +
.../test/resources/configfiles/json/second.json | 4 +
.../test/resources/configfiles/json/simple.json | 4 +
.../test/resources/configfiles/json/third.json | 4 +
7 files changed, 196 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51d893a4/modules/builder/pom.xml
----------------------------------------------------------------------
diff --git a/modules/builder/pom.xml b/modules/builder/pom.xml
index 6ec1891..97d42b7 100644
--- a/modules/builder/pom.xml
+++ b/modules/builder/pom.xml
@@ -42,12 +42,26 @@ under the License.
</dependency>
<dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-formats</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
<groupId>org.apache.tamaya</groupId>
<artifactId>tamaya-core</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
+ <groupId>org.apache.tamaya.ext</groupId>
+ <artifactId>tamaya-json</artifactId>
+ <version>${project.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+
+ <dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
</dependency>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51d893a4/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java b/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
index c9a8fed..465b180 100644
--- a/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
+++ b/modules/builder/src/main/java/org/apache/tamaya/modules/builder/ConfigurationBuilder.java
@@ -18,17 +18,30 @@
*/
package org.apache.tamaya.modules.builder;
+import org.apache.tamaya.ConfigException;
import org.apache.tamaya.Configuration;
import org.apache.tamaya.PropertyConverter;
import org.apache.tamaya.TypeLiteral;
import org.apache.tamaya.core.internal.DefaultConfiguration;
+import org.apache.tamaya.format.ConfigurationData;
+import org.apache.tamaya.format.ConfigurationFormats;
+import org.apache.tamaya.format.FlattenedDefaultPropertySource;
import org.apache.tamaya.spi.ConfigurationContext;
import org.apache.tamaya.spi.PropertyFilter;
import org.apache.tamaya.spi.PropertySource;
import org.apache.tamaya.spi.PropertySourceProvider;
import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
import java.util.Objects;
+import java.util.function.Function;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/* TODO LIST FOR TAMAYA-60
*
@@ -40,7 +53,7 @@ import java.util.Objects;
* - Rethink the default behaviour for SPI loading
* - Work on all TODOs for TAMAYA-60
* - Write JavaDoc
- * - adding sources via URL
+ * - adding sources via URL IN PROGRESS
*
*
*
@@ -84,6 +97,39 @@ public class ConfigurationBuilder {
return this;
}
+ public ConfigurationBuilder addPropertySource(URL url) {
+ try {
+ ConfigurationData data = ConfigurationFormats.readConfigurationData(url);
+ FlattenedDefaultPropertySource propertySource = new FlattenedDefaultPropertySource(data);
+ addPropertySources(propertySource);
+ } catch (IOException e) {
+ throw new ConfigException("Failed to read " + url.toString(), e);
+ }
+
+ return this;
+ }
+
+ public ConfigurationBuilder addPropertySource(URL url, URL... urls) {
+ Stream.of(Collections.singletonList(url), Arrays.asList(urls))
+ .flatMap(Collection::stream)
+ .filter(entry -> entry != null)
+ .collect(Collectors.toList())
+ .forEach(this::addPropertySource);
+
+ return this;
+ }
+
+ public ConfigurationBuilder addPropertySource(String url, String... urls) {
+ Stream.of(Collections.singletonList(url), Arrays.asList(urls))
+ .flatMap(Collection::stream)
+ .filter(entry -> entry != null)
+ .map(new StringToURLMapper())
+ .collect(Collectors.toList())
+ .forEach(this::addPropertySource);
+
+ return this;
+ }
+
public ConfigurationBuilder addPropertySources(PropertySource... sources){
checkBuilderState();
@@ -248,4 +294,17 @@ public class ConfigurationBuilder {
return new DefaultConfiguration(contextBuilder.build());
}
+ /**
+ * Mapper to map a URL given as string to an URL instance.
+ */
+ private static class StringToURLMapper implements Function<String, URL> {
+ @Override
+ public URL apply(String u) {
+ try {
+ return new URL(u);
+ } catch (MalformedURLException e) {
+ throw new ConfigException(u + " is not a valid URL", e);
+ }
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51d893a4/modules/builder/src/test/java/org/apache/tamaya/modules/builder/ConfigurationBuilderTest.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/modules/builder/ConfigurationBuilderTest.java b/modules/builder/src/test/java/org/apache/tamaya/modules/builder/ConfigurationBuilderTest.java
index fa134e5..5997aeb 100644
--- a/modules/builder/src/test/java/org/apache/tamaya/modules/builder/ConfigurationBuilderTest.java
+++ b/modules/builder/src/test/java/org/apache/tamaya/modules/builder/ConfigurationBuilderTest.java
@@ -33,6 +33,8 @@ import org.junit.Ignore;
import org.junit.Test;
+import java.net.URL;
+
import static java.util.Arrays.asList;
import static org.apache.tamaya.modules.builder.util.mockito.NotMockedAnswer.NOT_MOCKED_ANSWER;
import static org.hamcrest.CoreMatchers.equalTo;
@@ -759,4 +761,108 @@ public class ConfigurationBuilderTest {
assertThat(config.get("tpsp_x"), nullValue());
assertThat(config.get("tpsp_x"), nullValue());
}
+
+ /*********************************************************************
+ * Tests for loading resources via URL (as String)
+ */
+
+ @Test
+ public void loadOneJSONPropertySourceViaStringURL() {
+ URL resource = this.getClass().getResource("/configfiles/json/simple.json");
+
+ assertThat(resource, CoreMatchers.notNullValue());
+
+ ConfigurationBuilder builder = new ConfigurationBuilder();
+
+ Configuration config = builder.addPropertySource(resource.toString())
+ .build();
+
+ assertThat(config, CoreMatchers.notNullValue());
+ assertThat(config.get("a"), equalTo("A"));
+ assertThat(config.get("b"), equalTo("B"));
+ }
+
+ @Test
+ public void loadMultipleJSONPropertySourceViaStringURL() {
+ URL first = this.getClass().getResource("/configfiles/json/first.json");
+ URL second = this.getClass().getResource("/configfiles/json/second.json");
+ URL third = this.getClass().getResource("/configfiles/json/third.json");
+
+ assertThat(first, CoreMatchers.notNullValue());
+ assertThat(second, CoreMatchers.notNullValue());
+ assertThat(third, CoreMatchers.notNullValue());
+
+ ConfigurationBuilder builder = new ConfigurationBuilder();
+
+ Configuration config = builder.addPropertySource(first.toString(), second.toString(),
+ null, third.toString())
+ .build();
+
+ assertThat(config, CoreMatchers.notNullValue());
+
+ // from first.json
+ assertThat(config.get("d"), equalTo("D"));
+ assertThat(config.get("e"), equalTo("E"));
+
+ // from second.json
+ assertThat(config.get("m"), equalTo("M"));
+ assertThat(config.get("n"), equalTo("N"));
+
+ // from thrid.json
+ assertThat(config.get("p"), equalTo("P"));
+ assertThat(config.get("q"), equalTo("Q"));
+ }
+
+ /**
+ * ******************************************************************
+ * Tests for loading resources via URL (as URL object)
+ */
+
+ @Test
+ public void loadOneJSONPropertySourceViaURL() {
+ URL resource = this.getClass().getResource("/configfiles/json/simple.json");
+
+ assertThat(resource, CoreMatchers.notNullValue());
+
+ ConfigurationBuilder builder = new ConfigurationBuilder();
+
+ Configuration config = builder.addPropertySource(resource)
+ .build();
+
+ assertThat(config, CoreMatchers.notNullValue());
+ assertThat(config.get("a"), equalTo("A"));
+ assertThat(config.get("b"), equalTo("B"));
+ }
+
+ @Test
+ public void loadMultipleJSONPropertySourceViaURL() {
+ URL first = this.getClass().getResource("/configfiles/json/first.json");
+ URL second = this.getClass().getResource("/configfiles/json/second.json");
+ URL third = this.getClass().getResource("/configfiles/json/third.json");
+
+ assertThat(first, CoreMatchers.notNullValue());
+ assertThat(second, CoreMatchers.notNullValue());
+ assertThat(third, CoreMatchers.notNullValue());
+
+ ConfigurationBuilder builder = new ConfigurationBuilder();
+
+ Configuration config = builder.addPropertySource(first, second,
+ null, third)
+ .build();
+
+ assertThat(config, CoreMatchers.notNullValue());
+
+ // from first.json
+ assertThat(config.get("d"), equalTo("D"));
+ assertThat(config.get("e"), equalTo("E"));
+
+ // from second.json
+ assertThat(config.get("m"), equalTo("M"));
+ assertThat(config.get("n"), equalTo("N"));
+
+ // from thrid.json
+ assertThat(config.get("p"), equalTo("P"));
+ assertThat(config.get("q"), equalTo("Q"));
+ }
+
}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51d893a4/modules/builder/src/test/resources/configfiles/json/first.json
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/configfiles/json/first.json b/modules/builder/src/test/resources/configfiles/json/first.json
new file mode 100644
index 0000000..822cf6e
--- /dev/null
+++ b/modules/builder/src/test/resources/configfiles/json/first.json
@@ -0,0 +1,4 @@
+{
+ "d": "D",
+ "e": "E"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51d893a4/modules/builder/src/test/resources/configfiles/json/second.json
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/configfiles/json/second.json b/modules/builder/src/test/resources/configfiles/json/second.json
new file mode 100644
index 0000000..e2c7778
--- /dev/null
+++ b/modules/builder/src/test/resources/configfiles/json/second.json
@@ -0,0 +1,4 @@
+{
+ "m": "M",
+ "n": "N"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51d893a4/modules/builder/src/test/resources/configfiles/json/simple.json
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/configfiles/json/simple.json b/modules/builder/src/test/resources/configfiles/json/simple.json
new file mode 100644
index 0000000..0cab2ae
--- /dev/null
+++ b/modules/builder/src/test/resources/configfiles/json/simple.json
@@ -0,0 +1,4 @@
+{
+ "a": "A",
+ "b": "B"
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/51d893a4/modules/builder/src/test/resources/configfiles/json/third.json
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/resources/configfiles/json/third.json b/modules/builder/src/test/resources/configfiles/json/third.json
new file mode 100644
index 0000000..6b62b96
--- /dev/null
+++ b/modules/builder/src/test/resources/configfiles/json/third.json
@@ -0,0 +1,4 @@
+{
+ "p": "P",
+ "q": "Q"
+}
\ No newline at end of file