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/11/26 00:14:10 UTC
incubator-tamaya-extensions git commit: TAMAYA-202: Use
bnd-maven-plugin. Minimize required config. Renamed invalid package in yaml
format module.
Repository: incubator-tamaya-extensions
Updated Branches:
refs/heads/master 26a5414e4 -> 85ae2a471
TAMAYA-202:
Use bnd-maven-plugin. Minimize required config.
Renamed invalid package in yaml format module.
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/85ae2a47
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/tree/85ae2a47
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/diff/85ae2a47
Branch: refs/heads/master
Commit: 85ae2a4719d617698c3863ab0fe2e7567f1e415d
Parents: 26a5414
Author: anatole <an...@apache.org>
Authored: Sat Nov 26 01:13:57 2016 +0100
Committer: anatole <an...@apache.org>
Committed: Sat Nov 26 01:13:57 2016 +0100
----------------------------------------------------------------------
modules/events/bnd.bnd | 3 +
modules/filter/bnd.bnd | 2 +
modules/formats/base/bnd.bnd | 3 +
modules/formats/json/bnd.bnd | 2 +
.../java/org/apache/tamaya/json/JSONFormat.java | 26 +--
.../apache/tamaya/json/JSONPropertySource.java | 26 +--
.../org/apache/tamaya/json/JSONVisitor.java | 26 +--
.../json/CommonJSONTestCaseCollection.java | 190 -------------------
.../org/apache/tamaya/json/JSONFormatIT.java | 48 -----
.../org/apache/tamaya/json/JSONFormatTest.java | 75 --------
.../tamaya/json/JSONPropertySourceTest.java | 56 ------
.../yaml/CommonJSONTestCaseCollection.java | 190 +++++++++++++++++++
.../org/apache/tamaya/yaml/JSONFormatIT.java | 49 +++++
.../org/apache/tamaya/yaml/JSONFormatTest.java | 76 ++++++++
.../tamaya/yaml/JSONPropertySourceTest.java | 57 ++++++
modules/formats/yaml/bnd.bnd | 2 +
.../java/org/apache/tamaya/json/YAMLFormat.java | 156 ---------------
.../apache/tamaya/json/YAMLPropertySource.java | 100 ----------
.../java/org/apache/tamaya/yaml/YAMLFormat.java | 156 +++++++++++++++
.../apache/tamaya/yaml/YAMLPropertySource.java | 100 ++++++++++
...org.apache.tamaya.format.ConfigurationFormat | 2 +-
.../org/apache/tamaya/json/YAMLFormatTest.java | 70 -------
.../tamaya/json/YAMLPropertySourceTest.java | 54 ------
.../org/apache/tamaya/yaml/YAMLFormatTest.java | 70 +++++++
.../tamaya/yaml/YAMLPropertySourceTest.java | 52 +++++
modules/functions/bnd.bnd | 2 +
modules/injection/injection-api/bnd.bnd | 3 +
modules/injection/standalone/bnd.bnd | 2 +
modules/mutable-config/bnd.bnd | 2 +
modules/optional/bnd.bnd | 2 +
modules/resolver/bnd.bnd | 3 +
modules/resources/bnd.bnd | 2 +
modules/spi-support/bnd.bnd | 2 +
modules/spring/bnd.bnd | 2 +
pom.xml | 38 ++--
35 files changed, 838 insertions(+), 811 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/events/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/events/bnd.bnd b/modules/events/bnd.bnd
new file mode 100644
index 0000000..95aebbc
--- /dev/null
+++ b/modules/events/bnd.bnd
@@ -0,0 +1,3 @@
+Export-Package: \
+ org.apache.tamaya.events,\
+ org.apache.tamaya.events.spi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/filter/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/filter/bnd.bnd b/modules/filter/bnd.bnd
new file mode 100644
index 0000000..4e2f0f8
--- /dev/null
+++ b/modules/filter/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+ org.apache.tamaya.filter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/base/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/formats/base/bnd.bnd b/modules/formats/base/bnd.bnd
new file mode 100644
index 0000000..2f8a324
--- /dev/null
+++ b/modules/formats/base/bnd.bnd
@@ -0,0 +1,3 @@
+Export-Package: \
+ org.apache.tamaya.format,\
+ org.apache.tamaya.format.formats
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/formats/json/bnd.bnd b/modules/formats/json/bnd.bnd
new file mode 100644
index 0000000..45ee7d7
--- /dev/null
+++ b/modules/formats/json/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+ org.apache.tamaya.json
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONFormat.java b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
index 30f9d68..66f684e 100644
--- a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
+++ b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONFormat.java
@@ -1,20 +1,20 @@
/*
* 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
+ * 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
+ * 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.
+ * 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.json;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
index 43cfa73..18d64ce 100644
--- a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
+++ b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONPropertySource.java
@@ -1,20 +1,20 @@
/*
* 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
+ * 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
+ * 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.
+ * 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.json;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java
index 2135ec5..e1516e5 100644
--- a/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java
+++ b/modules/formats/json/src/main/java/org/apache/tamaya/json/JSONVisitor.java
@@ -1,20 +1,20 @@
/*
* 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
+ * 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
+ * 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.
+ * 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.json;
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java b/modules/formats/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java
deleted file mode 100644
index cfd4be5..0000000
--- a/modules/formats/json/src/test/java/org/apache/tamaya/json/CommonJSONTestCaseCollection.java
+++ /dev/null
@@ -1,190 +0,0 @@
-/*
- * 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.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-import org.hamcrest.CoreMatchers;
-import org.hamcrest.Matchers;
-import org.junit.Test;
-
-import java.net.URL;
-
-import static org.hamcrest.CoreMatchers.equalTo;
-import static org.hamcrest.CoreMatchers.is;
-import static org.hamcrest.CoreMatchers.notNullValue;
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasSize;
-
-/**
- * Class with a collection of common test cases each JSON processing
- * class must be able to pass.
- */
-public abstract class CommonJSONTestCaseCollection {
-
- abstract PropertySource getPropertiesFrom(URL source) throws Exception;
-
- @Test
- public void canReadNonLatinCharacters() throws Exception {
- URL configURL = JSONPropertySourceTest.class
- .getResource("/configs/valid/cyrillic.json");
-
- assertThat(configURL, Matchers.notNullValue());
-
- PropertySource propertySource = getPropertiesFrom(configURL);
-
- assertThat(propertySource.get("name"), Matchers.notNullValue());
- assertThat(propertySource.get("name").getValue(), equalTo("\u041e\u043b\u0438\u0432\u0435\u0440"));
- assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f"), Matchers.notNullValue());
- assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f").getValue(), Matchers.equalTo("Fischer"));
- }
-
- @Test
- public void canReadNestedStringOnlyJSONConfigFile2() throws Exception {
- URL configURL = JSONPropertySourceTest.class
- .getResource("/configs/valid/simple-nested-string-only-config-1.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(5));
-
- PropertyValue keyB = properties.get("b");
- PropertyValue keyDO = properties.get("d.o");
- PropertyValue keyDP = properties.get("d.p");
-
- assertThat(keyB, notNullValue());
- assertThat(keyB.getValue(), equalTo("B"));
- assertThat(keyDO, notNullValue());
- assertThat(keyDO.getValue(), equalTo("O"));
- assertThat(keyDP, Matchers.notNullValue());
- assertThat(keyDP.getValue(), is("P"));
- }
-
- @Test
- public void canReadNestedStringOnlyJSONConfigFileWithObjectInTheMiddle()
- throws Exception {
- URL configURL = JSONPropertySourceTest.class
- .getResource("/configs/valid/simple-nested-string-only-config-2.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(4));
-
- PropertyValue keyA = properties.get("a");
- PropertyValue keyDO = properties.get("b.o");
- PropertyValue keyDP = properties.get("b.p");
- PropertyValue keyC = properties.get("c");
-
- assertThat(keyA, notNullValue());
- assertThat(keyA.getValue(), is("A"));
- assertThat(keyC, notNullValue());
- assertThat(keyC.getValue(), equalTo("C"));
- assertThat(keyDO, notNullValue());
- assertThat(keyDO.getValue(), equalTo("O"));
- assertThat(keyDP, notNullValue());
- assertThat(keyDP.getValue(), is("P"));
- }
-
- @Test(expected = ConfigException.class)
- public void canHandleIllegalJSONFileWhichContainsAnArray() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/with-array.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- getPropertiesFrom(configURL).getProperties();
- }
-
- @Test(expected = ConfigException.class)
- public void canHandleIllegalJSONFileConsistingOfOneOpeningBracket() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/only-opening-bracket.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- getPropertiesFrom(configURL).getProperties();
- }
-
- @Test(expected = ConfigException.class)
- public void canHandleIllegalJSONFileWhichIsEmpty() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- getPropertiesFrom(configURL).getProperties();
- }
-
- @Test
- public void priorityInConfigFileOverwriteExplicitlyGivenPriority() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/with-explicit-priority.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getOrdinal(), is(16784));
- }
-
- @Test
- public void canReadFlatStringOnlyJSONConfigFile() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/simple-flat-string-only-config.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(3));
-
- PropertyValue keyA = properties.get("a");
- PropertyValue keyB = properties.get("b");
- PropertyValue keyC = properties.get("c");
-
- assertThat(keyA, notNullValue());
- assertThat(keyA.getValue(), equalTo("A"));
- assertThat(keyB, notNullValue());
- assertThat(keyB.getValue(), is("B"));
- assertThat(keyC, notNullValue());
- assertThat(keyC.getValue(), is("C"));
- }
-
- @Test(expected = ConfigException.class)
- public void emptyJSONFileResultsInConfigException() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- properties.getProperties();
- }
-
- @Test
- public void canHandleEmptyJSONObject() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/empty-object-config.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- PropertySource properties = getPropertiesFrom(configURL);
-
- assertThat(properties.getProperties().keySet(), hasSize(0));
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java b/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java
deleted file mode 100644
index 851655e..0000000
--- a/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONFormatIT.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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.json;
-
-import org.apache.tamaya.format.ConfigurationFormat;
-import org.apache.tamaya.spi.ServiceContextManager;
-import org.junit.Test;
-
-import java.util.List;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.notNullValue;
-
-/**
- * Integration tests for {@link JSONFormat}.
- */
-public class JSONFormatIT {
- @Test
- public void jsonFormatCanBeFoundViaServiceLoader() throws Exception {
- List<ConfigurationFormat> formats = ServiceContextManager.getServiceContext()
- .getServices(ConfigurationFormat.class);
-
- ConfigurationFormat format = null;
- for (ConfigurationFormat f : formats) {
- if (f instanceof JSONFormat) {
- format = f;
- break;
- }
- }
- assertThat(format, notNullValue());
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java b/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java
deleted file mode 100644
index 513e1b0..0000000
--- a/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONFormatTest.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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.json;
-
-
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.MappedConfigurationDataPropertySource;
-import org.apache.tamaya.spi.PropertySource;
-import org.junit.Test;
-
-import java.io.InputStream;
-import java.net.URL;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-
-public class JSONFormatTest extends CommonJSONTestCaseCollection {
- private final JSONFormat format = new JSONFormat();
-
- @Test(expected = NullPointerException.class)
- public void acceptsNeedsNonNullParameter() throws Exception {
- format.accepts(null);
- }
-
- @Test
- public void aNonJSONFileBasedURLIsNotAccepted() throws Exception {
- URL url = new URL("file:///etc/service/conf.conf");
-
- assertThat(format.accepts(url), is(false));
- }
-
- @Test
- public void aJSONFileBasedURLIsAccepted() throws Exception {
- URL url = new URL("file:///etc/service/conf.json");
-
- assertThat(format.accepts(url), is(true));
- }
-
- @Test
- public void aHTTPBasedURLIsNotAccepted() throws Exception {
- URL url = new URL("http://nowhere.somewhere/conf.json");
- assertThat(format.accepts(url), is(true));
- }
-
- @Test
- public void aFTPBasedURLIsNotAccepted() throws Exception {
- URL url = new URL("ftp://nowhere.somewhere/a/b/c/d/conf.json");
-
- assertThat(format.accepts(url), is(true));
- }
-
- @Override
- PropertySource getPropertiesFrom(URL source) throws Exception {
- try (InputStream is = source.openStream()) {
- ConfigurationData data = format.readConfiguration(source.toString(), is);
- return new MappedConfigurationDataPropertySource(data);
- }
- }
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java b/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java
deleted file mode 100644
index 9892446..0000000
--- a/modules/formats/json/src/test/java/org/apache/tamaya/json/JSONPropertySourceTest.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * 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.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertySource;
-import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-
-import java.net.URL;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-
-public class JSONPropertySourceTest extends CommonJSONTestCaseCollection {
-
- @Test
- public void tamayaOrdinalKeywordIsNotPropagatedAsNormalProperty() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/with-explicit-priority.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- JSONPropertySource source = new JSONPropertySource(configURL, 4);
- assertEquals(source.get(PropertySource.TAMAYA_ORDINAL).getValue(), "16784");
- }
-
- @Test(expected=ConfigException.class)
- public void testDoNotAcceptJsonArrays() throws Exception {
- URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/array.json");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- new JSONPropertySource(configURL);
- }
-
- @Override
- PropertySource getPropertiesFrom(URL source) throws Exception {
- return new JSONPropertySource(source);
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/src/test/java/org/apache/tamaya/yaml/CommonJSONTestCaseCollection.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/test/java/org/apache/tamaya/yaml/CommonJSONTestCaseCollection.java b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/CommonJSONTestCaseCollection.java
new file mode 100644
index 0000000..21cd2f9
--- /dev/null
+++ b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/CommonJSONTestCaseCollection.java
@@ -0,0 +1,190 @@
+/*
+ * 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.yaml;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+import java.net.URL;
+
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.CoreMatchers.notNullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasSize;
+
+/**
+ * Class with a collection of common test cases each JSON processing
+ * class must be able to pass.
+ */
+public abstract class CommonJSONTestCaseCollection {
+
+ abstract PropertySource getPropertiesFrom(URL source) throws Exception;
+
+ @Test
+ public void canReadNonLatinCharacters() throws Exception {
+ URL configURL = JSONPropertySourceTest.class
+ .getResource("/configs/valid/cyrillic.json");
+
+ assertThat(configURL, Matchers.notNullValue());
+
+ PropertySource propertySource = getPropertiesFrom(configURL);
+
+ assertThat(propertySource.get("name"), Matchers.notNullValue());
+ assertThat(propertySource.get("name").getValue(), equalTo("\u041e\u043b\u0438\u0432\u0435\u0440"));
+ assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f"), Matchers.notNullValue());
+ assertThat(propertySource.get("\u0444\u0430\u043c\u0438\u043b\u0438\u044f").getValue(), Matchers.equalTo("Fischer"));
+ }
+
+ @Test
+ public void canReadNestedStringOnlyJSONConfigFile2() throws Exception {
+ URL configURL = JSONPropertySourceTest.class
+ .getResource("/configs/valid/simple-nested-string-only-config-1.json");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ PropertySource properties = getPropertiesFrom(configURL);
+
+ assertThat(properties.getProperties().keySet(), hasSize(5));
+
+ PropertyValue keyB = properties.get("b");
+ PropertyValue keyDO = properties.get("d.o");
+ PropertyValue keyDP = properties.get("d.p");
+
+ assertThat(keyB, notNullValue());
+ assertThat(keyB.getValue(), equalTo("B"));
+ assertThat(keyDO, notNullValue());
+ assertThat(keyDO.getValue(), equalTo("O"));
+ assertThat(keyDP, Matchers.notNullValue());
+ assertThat(keyDP.getValue(), is("P"));
+ }
+
+ @Test
+ public void canReadNestedStringOnlyJSONConfigFileWithObjectInTheMiddle()
+ throws Exception {
+ URL configURL = JSONPropertySourceTest.class
+ .getResource("/configs/valid/simple-nested-string-only-config-2.json");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ PropertySource properties = getPropertiesFrom(configURL);
+
+ assertThat(properties.getProperties().keySet(), hasSize(4));
+
+ PropertyValue keyA = properties.get("a");
+ PropertyValue keyDO = properties.get("b.o");
+ PropertyValue keyDP = properties.get("b.p");
+ PropertyValue keyC = properties.get("c");
+
+ assertThat(keyA, notNullValue());
+ assertThat(keyA.getValue(), is("A"));
+ assertThat(keyC, notNullValue());
+ assertThat(keyC.getValue(), equalTo("C"));
+ assertThat(keyDO, notNullValue());
+ assertThat(keyDO.getValue(), equalTo("O"));
+ assertThat(keyDP, notNullValue());
+ assertThat(keyDP.getValue(), is("P"));
+ }
+
+ @Test(expected = ConfigException.class)
+ public void canHandleIllegalJSONFileWhichContainsAnArray() throws Exception {
+ URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/with-array.json");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ getPropertiesFrom(configURL).getProperties();
+ }
+
+ @Test(expected = ConfigException.class)
+ public void canHandleIllegalJSONFileConsistingOfOneOpeningBracket() throws Exception {
+ URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/only-opening-bracket.json");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ getPropertiesFrom(configURL).getProperties();
+ }
+
+ @Test(expected = ConfigException.class)
+ public void canHandleIllegalJSONFileWhichIsEmpty() throws Exception {
+ URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ getPropertiesFrom(configURL).getProperties();
+ }
+
+ @Test
+ public void priorityInConfigFileOverwriteExplicitlyGivenPriority() throws Exception {
+ URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/with-explicit-priority.json");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ PropertySource properties = getPropertiesFrom(configURL);
+
+ assertThat(properties.getOrdinal(), is(16784));
+ }
+
+ @Test
+ public void canReadFlatStringOnlyJSONConfigFile() throws Exception {
+ URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/simple-flat-string-only-config.json");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ PropertySource properties = getPropertiesFrom(configURL);
+
+ assertThat(properties.getProperties().keySet(), hasSize(3));
+
+ PropertyValue keyA = properties.get("a");
+ PropertyValue keyB = properties.get("b");
+ PropertyValue keyC = properties.get("c");
+
+ assertThat(keyA, notNullValue());
+ assertThat(keyA.getValue(), equalTo("A"));
+ assertThat(keyB, notNullValue());
+ assertThat(keyB.getValue(), is("B"));
+ assertThat(keyC, notNullValue());
+ assertThat(keyC.getValue(), is("C"));
+ }
+
+ @Test(expected = ConfigException.class)
+ public void emptyJSONFileResultsInConfigException() throws Exception {
+ URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/empty-file.json");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ PropertySource properties = getPropertiesFrom(configURL);
+
+ properties.getProperties();
+ }
+
+ @Test
+ public void canHandleEmptyJSONObject() throws Exception {
+ URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/empty-object-config.json");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ PropertySource properties = getPropertiesFrom(configURL);
+
+ assertThat(properties.getProperties().keySet(), hasSize(0));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONFormatIT.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONFormatIT.java b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONFormatIT.java
new file mode 100644
index 0000000..a13810e
--- /dev/null
+++ b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONFormatIT.java
@@ -0,0 +1,49 @@
+/*
+ * 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.yaml;
+
+import org.apache.tamaya.format.ConfigurationFormat;
+import org.apache.tamaya.json.JSONFormat;
+import org.apache.tamaya.spi.ServiceContextManager;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.notNullValue;
+
+/**
+ * Integration tests for {@link JSONFormat}.
+ */
+public class JSONFormatIT {
+ @Test
+ public void jsonFormatCanBeFoundViaServiceLoader() throws Exception {
+ List<ConfigurationFormat> formats = ServiceContextManager.getServiceContext()
+ .getServices(ConfigurationFormat.class);
+
+ ConfigurationFormat format = null;
+ for (ConfigurationFormat f : formats) {
+ if (f instanceof JSONFormat) {
+ format = f;
+ break;
+ }
+ }
+ assertThat(format, notNullValue());
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONFormatTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONFormatTest.java b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONFormatTest.java
new file mode 100644
index 0000000..216573e
--- /dev/null
+++ b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONFormatTest.java
@@ -0,0 +1,76 @@
+/*
+ * 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.yaml;
+
+
+import org.apache.tamaya.format.ConfigurationData;
+import org.apache.tamaya.format.MappedConfigurationDataPropertySource;
+import org.apache.tamaya.json.JSONFormat;
+import org.apache.tamaya.spi.PropertySource;
+import org.junit.Test;
+
+import java.io.InputStream;
+import java.net.URL;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+
+public class JSONFormatTest extends CommonJSONTestCaseCollection {
+ private final JSONFormat format = new JSONFormat();
+
+ @Test(expected = NullPointerException.class)
+ public void acceptsNeedsNonNullParameter() throws Exception {
+ format.accepts(null);
+ }
+
+ @Test
+ public void aNonJSONFileBasedURLIsNotAccepted() throws Exception {
+ URL url = new URL("file:///etc/service/conf.conf");
+
+ assertThat(format.accepts(url), is(false));
+ }
+
+ @Test
+ public void aJSONFileBasedURLIsAccepted() throws Exception {
+ URL url = new URL("file:///etc/service/conf.json");
+
+ assertThat(format.accepts(url), is(true));
+ }
+
+ @Test
+ public void aHTTPBasedURLIsNotAccepted() throws Exception {
+ URL url = new URL("http://nowhere.somewhere/conf.json");
+ assertThat(format.accepts(url), is(true));
+ }
+
+ @Test
+ public void aFTPBasedURLIsNotAccepted() throws Exception {
+ URL url = new URL("ftp://nowhere.somewhere/a/b/c/d/conf.json");
+
+ assertThat(format.accepts(url), is(true));
+ }
+
+ @Override
+ PropertySource getPropertiesFrom(URL source) throws Exception {
+ try (InputStream is = source.openStream()) {
+ ConfigurationData data = format.readConfiguration(source.toString(), is);
+ return new MappedConfigurationDataPropertySource(data);
+ }
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONPropertySourceTest.java b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONPropertySourceTest.java
new file mode 100644
index 0000000..83944f5
--- /dev/null
+++ b/modules/formats/json/src/test/java/org/apache/tamaya/yaml/JSONPropertySourceTest.java
@@ -0,0 +1,57 @@
+/*
+ * 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.yaml;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.json.JSONPropertySource;
+import org.apache.tamaya.spi.PropertySource;
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+
+import java.net.URL;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+
+public class JSONPropertySourceTest extends CommonJSONTestCaseCollection {
+
+ @Test
+ public void tamayaOrdinalKeywordIsNotPropagatedAsNormalProperty() throws Exception {
+ URL configURL = JSONPropertySourceTest.class.getResource("/configs/valid/with-explicit-priority.json");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ JSONPropertySource source = new JSONPropertySource(configURL, 4);
+ assertEquals(source.get(PropertySource.TAMAYA_ORDINAL).getValue(), "16784");
+ }
+
+ @Test(expected=ConfigException.class)
+ public void testDoNotAcceptJsonArrays() throws Exception {
+ URL configURL = JSONPropertySourceTest.class.getResource("/configs/invalid/array.json");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ new JSONPropertySource(configURL);
+ }
+
+ @Override
+ PropertySource getPropertiesFrom(URL source) throws Exception {
+ return new JSONPropertySource(source);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/yaml/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/bnd.bnd b/modules/formats/yaml/bnd.bnd
new file mode 100644
index 0000000..325dbc7
--- /dev/null
+++ b/modules/formats/yaml/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+ org.apache.tamaya.yaml
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/yaml/src/main/java/org/apache/tamaya/json/YAMLFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/src/main/java/org/apache/tamaya/json/YAMLFormat.java b/modules/formats/yaml/src/main/java/org/apache/tamaya/json/YAMLFormat.java
deleted file mode 100644
index 06e431e..0000000
--- a/modules/formats/yaml/src/main/java/org/apache/tamaya/json/YAMLFormat.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * 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.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.format.ConfigurationData;
-import org.apache.tamaya.format.ConfigurationDataBuilder;
-import org.apache.tamaya.format.ConfigurationFormat;
-import org.yaml.snakeyaml.Yaml;
-
-import java.io.InputStream;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import static java.lang.String.format;
-
-
-/**
- * Implementation of the {@link org.apache.tamaya.format.ConfigurationFormat}
- * able to read configuration properties represented in JSON
- *
- * @see <a href="http://www.json.org">JSON format specification</a>
- */
-public class YAMLFormat implements ConfigurationFormat {
- /**
- * THe logger.
- */
- private static final Logger LOG = Logger.getLogger(YAMLFormat.class.getName());
-
- /**
- * Constructor, itniaitlizing zhe JSON reader factory.
- */
- public YAMLFormat(){
- }
-
- @Override
- public String getName() {
- return "yaml";
- }
-
- @Override
- public boolean accepts(URL url) {
- return Objects.requireNonNull(url).getPath().endsWith(".yaml");
- }
-
- @Override
- public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
- try( InputStream in = inputStream;) {
- Map<String, String> values = readConfig(resource, inputStream);
- return ConfigurationDataBuilder.of(resource, this).addProperties(values)
- .build();
- } catch (Exception e) {
- throw new ConfigException("Failed to read data from " + resource, e);
- }
- }
-
- /**
- * Reads the configuration.
- * @param inputStream the input stream, not null.
- * @param resource resource URI, not null.
- * @return the configuration read from the given resource URI.
- * @throws ConfigException if resource URI cannot be read.
- */
- protected Map<String, String> readConfig(String resource, InputStream inputStream) {
- try{
- Yaml yaml = new Yaml();
- HashMap<String, String> values = new HashMap<>();
- Object config = yaml.load(inputStream);
- mapYamlIntoProperties(config, values);
- if(LOG.isLoggable(Level.FINEST)){
- LOG.finest("Read data from " + resource + " : " + values);
- }
- return values;
- }catch (Throwable t) {
- throw new ConfigException(format("Failed to read properties from %s", resource), t);
- }
- }
- /**
- * Reads the configuration.
- * @param urlResource soure of the configuration.
- * @return the configuration read from the given resource URL.
- * @throws ConfigException if resource URL cannot be read.
- */
- protected Map<String, String> readConfig(URL urlResource) {
- try (InputStream is = urlResource.openStream()) {
- return readConfig(urlResource.toExternalForm(), is);
- }
- catch (Throwable t) {
- throw new ConfigException(format("Failed to read properties from %s", urlResource.toExternalForm()), t);
- }
- }
-
- private void mapYamlIntoProperties(Object config, HashMap<String, String> values) {
- mapYamlIntoProperties("", config, values);
- }
-
- /**
- * Maps the given config item (could be a String, a collection type or something else returned by the yaml parser
- * to a key/value pair and adds it to {@code values} (hereby honoring the prefix as a key to be used.).
- * Collection types are recursively to remapped hereby extending the given prefix as needed and recursively
- * delegate mapping of values contained.
- * @param prefix the prefix or key evaluated so far, never null (but can be empty for root entries).
- * @param config the config value. Could be a single value or a collection type.
- * @param values the properties where items identified must be written into. These properties are going to be
- * returned as result of the format reading operation ans integrated into the overall configuration
- * map.
- */
- protected void mapYamlIntoProperties(String prefix, Object config, HashMap<String, String> values) {
- // add further data types supported by yaml, e.g. date, ...
- if(config instanceof List){
- StringBuilder b = new StringBuilder();
- for(Object val:((List<Object>)config)){
- b.append(mapValueToString(val));
- b.append(",");
- }
- if(b.length()>0){
- b.setLength(b.length()-1);
- }
- values.put(prefix, b.toString());
- values.put("_"+prefix+".collection-type", "List");
- } else if(config instanceof Map){
- for(Map.Entry<String,Object> en:((Map<String,Object>)config).entrySet()){
- String newPrefix = prefix.isEmpty()?en.getKey():prefix +"."+en.getKey();
- mapYamlIntoProperties(newPrefix, en.getValue(), values);
- }
- } else{
- values.put(prefix, mapValueToString(config));
- }
- }
-
- protected String mapValueToString(Object val) {
- return String.valueOf(val);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/yaml/src/main/java/org/apache/tamaya/json/YAMLPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/src/main/java/org/apache/tamaya/json/YAMLPropertySource.java b/modules/formats/yaml/src/main/java/org/apache/tamaya/json/YAMLPropertySource.java
deleted file mode 100644
index e29d2e7..0000000
--- a/modules/formats/yaml/src/main/java/org/apache/tamaya/json/YAMLPropertySource.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * 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.json;
-
-import org.apache.tamaya.spi.PropertySource;
-import org.apache.tamaya.spi.PropertyValue;
-
-import java.net.URL;
-import java.util.*;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-
-
-/**
- * Property source based on a JSON file.
- */
-public class YAMLPropertySource implements PropertySource {
- /** The underlying resource. */
- private final URL urlResource;
- /** The values read. */
- private final Map<String, String> values;
- /** The evaluated ordinal. */
- private int ordinal;
- /** The format implementation used for parsing. */
- private YAMLFormat format = new YAMLFormat();
-
- /**
- * Constructor, hereby using 0 as the default ordinal.
- * @param resource the resource modelled as URL, not null.
- */
- public YAMLPropertySource(URL resource) {
- this(resource, 0);
- }
-
- /**
- * Constructor.
- * @param resource the resource modelled as URL, not null.
- * @param defaultOrdinal the defaultOrdinal to be used.
- */
- public YAMLPropertySource(URL resource, int defaultOrdinal) {
- urlResource = Objects.requireNonNull(resource);
- this.ordinal = defaultOrdinal; // may be overriden by read...
- this.values = format.readConfig(urlResource);
- if (this.values.containsKey(TAMAYA_ORDINAL)) {
- this.ordinal = Integer.parseInt(this.values.get(TAMAYA_ORDINAL));
- }
- }
-
- @Override
- public int getOrdinal() {
- PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
- if(configuredOrdinal!=null){
- try{
- return Integer.parseInt(configuredOrdinal.getValue());
- } catch(Exception e){
- Logger.getLogger(getClass().getName()).log(Level.WARNING,
- "Configured Ordinal is not an int number: " + configuredOrdinal, e);
- }
- }
- return ordinal;
- }
-
- @Override
- public String getName() {
- return urlResource.toExternalForm();
- }
-
- @Override
- public PropertyValue get(String key) {
- return PropertyValue.of(key, getProperties().get(key), getName());
- }
-
- @Override
- public Map<String, String> getProperties() {
- return Collections.unmodifiableMap(values);
- }
-
-
- @Override
- public boolean isScannable() {
- return true;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLFormat.java
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLFormat.java b/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLFormat.java
new file mode 100644
index 0000000..bdb83aa
--- /dev/null
+++ b/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLFormat.java
@@ -0,0 +1,156 @@
+/*
+ * 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.yaml;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.format.ConfigurationData;
+import org.apache.tamaya.format.ConfigurationDataBuilder;
+import org.apache.tamaya.format.ConfigurationFormat;
+import org.yaml.snakeyaml.Yaml;
+
+import java.io.InputStream;
+import java.net.URL;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import static java.lang.String.format;
+
+
+/**
+ * Implementation of the {@link org.apache.tamaya.format.ConfigurationFormat}
+ * able to read configuration properties represented in JSON
+ *
+ * @see <a href="http://www.json.org">JSON format specification</a>
+ */
+public class YAMLFormat implements ConfigurationFormat {
+ /**
+ * THe logger.
+ */
+ private static final Logger LOG = Logger.getLogger(YAMLFormat.class.getName());
+
+ /**
+ * Constructor, itniaitlizing zhe JSON reader factory.
+ */
+ public YAMLFormat(){
+ }
+
+ @Override
+ public String getName() {
+ return "yaml";
+ }
+
+ @Override
+ public boolean accepts(URL url) {
+ return Objects.requireNonNull(url).getPath().endsWith(".yaml");
+ }
+
+ @Override
+ public ConfigurationData readConfiguration(String resource, InputStream inputStream) {
+ try( InputStream in = inputStream;) {
+ Map<String, String> values = readConfig(resource, inputStream);
+ return ConfigurationDataBuilder.of(resource, this).addProperties(values)
+ .build();
+ } catch (Exception e) {
+ throw new ConfigException("Failed to read data from " + resource, e);
+ }
+ }
+
+ /**
+ * Reads the configuration.
+ * @param inputStream the input stream, not null.
+ * @param resource resource URI, not null.
+ * @return the configuration read from the given resource URI.
+ * @throws ConfigException if resource URI cannot be read.
+ */
+ protected Map<String, String> readConfig(String resource, InputStream inputStream) {
+ try{
+ Yaml yaml = new Yaml();
+ HashMap<String, String> values = new HashMap<>();
+ Object config = yaml.load(inputStream);
+ mapYamlIntoProperties(config, values);
+ if(LOG.isLoggable(Level.FINEST)){
+ LOG.finest("Read data from " + resource + " : " + values);
+ }
+ return values;
+ }catch (Throwable t) {
+ throw new ConfigException(format("Failed to read properties from %s", resource), t);
+ }
+ }
+ /**
+ * Reads the configuration.
+ * @param urlResource soure of the configuration.
+ * @return the configuration read from the given resource URL.
+ * @throws ConfigException if resource URL cannot be read.
+ */
+ protected Map<String, String> readConfig(URL urlResource) {
+ try (InputStream is = urlResource.openStream()) {
+ return readConfig(urlResource.toExternalForm(), is);
+ }
+ catch (Throwable t) {
+ throw new ConfigException(format("Failed to read properties from %s", urlResource.toExternalForm()), t);
+ }
+ }
+
+ private void mapYamlIntoProperties(Object config, HashMap<String, String> values) {
+ mapYamlIntoProperties("", config, values);
+ }
+
+ /**
+ * Maps the given config item (could be a String, a collection type or something else returned by the yaml parser
+ * to a key/value pair and adds it to {@code values} (hereby honoring the prefix as a key to be used.).
+ * Collection types are recursively to remapped hereby extending the given prefix as needed and recursively
+ * delegate mapping of values contained.
+ * @param prefix the prefix or key evaluated so far, never null (but can be empty for root entries).
+ * @param config the config value. Could be a single value or a collection type.
+ * @param values the properties where items identified must be written into. These properties are going to be
+ * returned as result of the format reading operation ans integrated into the overall configuration
+ * map.
+ */
+ protected void mapYamlIntoProperties(String prefix, Object config, HashMap<String, String> values) {
+ // add further data types supported by yaml, e.g. date, ...
+ if(config instanceof List){
+ StringBuilder b = new StringBuilder();
+ for(Object val:((List<Object>)config)){
+ b.append(mapValueToString(val));
+ b.append(",");
+ }
+ if(b.length()>0){
+ b.setLength(b.length()-1);
+ }
+ values.put(prefix, b.toString());
+ values.put("_"+prefix+".collection-type", "List");
+ } else if(config instanceof Map){
+ for(Map.Entry<String,Object> en:((Map<String,Object>)config).entrySet()){
+ String newPrefix = prefix.isEmpty()?en.getKey():prefix +"."+en.getKey();
+ mapYamlIntoProperties(newPrefix, en.getValue(), values);
+ }
+ } else{
+ values.put(prefix, mapValueToString(config));
+ }
+ }
+
+ protected String mapValueToString(Object val) {
+ return String.valueOf(val);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java b/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java
new file mode 100644
index 0000000..9edc15b
--- /dev/null
+++ b/modules/formats/yaml/src/main/java/org/apache/tamaya/yaml/YAMLPropertySource.java
@@ -0,0 +1,100 @@
+/*
+ * 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.yaml;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+
+import java.net.URL;
+import java.util.*;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+
+
+/**
+ * Property source based on a JSON file.
+ */
+public class YAMLPropertySource implements PropertySource {
+ /** The underlying resource. */
+ private final URL urlResource;
+ /** The values read. */
+ private final Map<String, String> values;
+ /** The evaluated ordinal. */
+ private int ordinal;
+ /** The format implementation used for parsing. */
+ private YAMLFormat format = new YAMLFormat();
+
+ /**
+ * Constructor, hereby using 0 as the default ordinal.
+ * @param resource the resource modelled as URL, not null.
+ */
+ public YAMLPropertySource(URL resource) {
+ this(resource, 0);
+ }
+
+ /**
+ * Constructor.
+ * @param resource the resource modelled as URL, not null.
+ * @param defaultOrdinal the defaultOrdinal to be used.
+ */
+ public YAMLPropertySource(URL resource, int defaultOrdinal) {
+ urlResource = Objects.requireNonNull(resource);
+ this.ordinal = defaultOrdinal; // may be overriden by read...
+ this.values = format.readConfig(urlResource);
+ if (this.values.containsKey(TAMAYA_ORDINAL)) {
+ this.ordinal = Integer.parseInt(this.values.get(TAMAYA_ORDINAL));
+ }
+ }
+
+ @Override
+ public int getOrdinal() {
+ PropertyValue configuredOrdinal = get(TAMAYA_ORDINAL);
+ if(configuredOrdinal!=null){
+ try{
+ return Integer.parseInt(configuredOrdinal.getValue());
+ } catch(Exception e){
+ Logger.getLogger(getClass().getName()).log(Level.WARNING,
+ "Configured Ordinal is not an int number: " + configuredOrdinal, e);
+ }
+ }
+ return ordinal;
+ }
+
+ @Override
+ public String getName() {
+ return urlResource.toExternalForm();
+ }
+
+ @Override
+ public PropertyValue get(String key) {
+ return PropertyValue.of(key, getProperties().get(key), getName());
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return Collections.unmodifiableMap(values);
+ }
+
+
+ @Override
+ public boolean isScannable() {
+ return true;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/yaml/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat b/modules/formats/yaml/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
index 1b5d57d..97bd1d8 100644
--- a/modules/formats/yaml/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
+++ b/modules/formats/yaml/src/main/resources/META-INF/services/org.apache.tamaya.format.ConfigurationFormat
@@ -16,4 +16,4 @@
# specific language governing permissions and limitations
# under the License.
#
-org.apache.tamaya.json.YAMLFormat
\ No newline at end of file
+org.apache.tamaya.yaml.YAMLFormat
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/yaml/src/test/java/org/apache/tamaya/json/YAMLFormatTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/src/test/java/org/apache/tamaya/json/YAMLFormatTest.java b/modules/formats/yaml/src/test/java/org/apache/tamaya/json/YAMLFormatTest.java
deleted file mode 100644
index adc170f..0000000
--- a/modules/formats/yaml/src/test/java/org/apache/tamaya/json/YAMLFormatTest.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * 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.json;
-
-
-import org.apache.tamaya.format.ConfigurationData;
-import org.junit.Test;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.util.Map;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.core.Is.is;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-
-public class YAMLFormatTest {
- private final YAMLFormat format = new YAMLFormat();
-
- @Test
- public void testAcceptURL() throws MalformedURLException {
- assertTrue(format.accepts(new URL("http://127.0.0.1/anyfile.yaml")));
- }
-
- @Test
- public void testAcceptURL_BC1() throws MalformedURLException {
- assertFalse(format.accepts(new URL("http://127.0.0.1/anyfile.YAML")));
- }
-
- @Test(expected = NullPointerException.class)
- public void testAcceptURL_BC2() throws MalformedURLException {
- assertFalse(format.accepts(null));
- }
-
- @Test
- public void testAcceptURL_BC3() throws MalformedURLException {
- assertFalse(format.accepts(new URL("http://127.0.0.1/anyfile.docx")));
- }
-
- @Test
- public void testRead() throws IOException {
- URL configURL = YAMLPropertySourceTest.class.getResource("/configs/valid/contact.yaml");
- assertTrue(format.accepts(configURL));
- ConfigurationData data = format.readConfiguration(configURL.toString(), configURL.openStream());
- assertNotNull(data);
- for(Map.Entry<String,String> en:data.getDefaultProperties().entrySet()) {
- System.out.println(en.getKey() + " -> " + en.getValue());
- }
- }
-
-}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/yaml/src/test/java/org/apache/tamaya/json/YAMLPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/src/test/java/org/apache/tamaya/json/YAMLPropertySourceTest.java b/modules/formats/yaml/src/test/java/org/apache/tamaya/json/YAMLPropertySourceTest.java
deleted file mode 100644
index 7f1c7a3..0000000
--- a/modules/formats/yaml/src/test/java/org/apache/tamaya/json/YAMLPropertySourceTest.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * 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.json;
-
-import org.apache.tamaya.ConfigException;
-import org.apache.tamaya.spi.PropertySource;
-import org.hamcrest.CoreMatchers;
-import org.junit.Test;
-
-import java.net.URL;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-
-public class YAMLPropertySourceTest {
-
- @Test
- public void testYamlWithOrdinal() throws Exception {
- URL configURL = YAMLPropertySourceTest.class.getResource("/configs/valid/test-with-prio.yaml");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- YAMLPropertySource source = new YAMLPropertySource(configURL, 4);
- assertEquals(source.getOrdinal(), 16784);
- }
-
- @Test
- public void testYamlDefaultOrdinal() throws Exception {
- URL configURL = YAMLPropertySourceTest.class.getResource("/configs/valid/test.yaml");
-
- assertThat(configURL, CoreMatchers.notNullValue());
-
- YAMLPropertySource source = new YAMLPropertySource(configURL, 4);
- assertEquals(source.getOrdinal(), 4);
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/yaml/src/test/java/org/apache/tamaya/yaml/YAMLFormatTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/src/test/java/org/apache/tamaya/yaml/YAMLFormatTest.java b/modules/formats/yaml/src/test/java/org/apache/tamaya/yaml/YAMLFormatTest.java
new file mode 100644
index 0000000..9f241f0
--- /dev/null
+++ b/modules/formats/yaml/src/test/java/org/apache/tamaya/yaml/YAMLFormatTest.java
@@ -0,0 +1,70 @@
+/*
+ * 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.yaml;
+
+
+import org.apache.tamaya.format.ConfigurationData;
+import org.junit.Test;
+
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.util.Map;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class YAMLFormatTest {
+ private final YAMLFormat format = new YAMLFormat();
+
+ @Test
+ public void testAcceptURL() throws MalformedURLException {
+ assertTrue(format.accepts(new URL("http://127.0.0.1/anyfile.yaml")));
+ }
+
+ @Test
+ public void testAcceptURL_BC1() throws MalformedURLException {
+ assertFalse(format.accepts(new URL("http://127.0.0.1/anyfile.YAML")));
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void testAcceptURL_BC2() throws MalformedURLException {
+ assertFalse(format.accepts(null));
+ }
+
+ @Test
+ public void testAcceptURL_BC3() throws MalformedURLException {
+ assertFalse(format.accepts(new URL("http://127.0.0.1/anyfile.docx")));
+ }
+
+ @Test
+ public void testRead() throws IOException {
+ URL configURL = YAMLPropertySourceTest.class.getResource("/configs/valid/contact.yaml");
+ assertTrue(format.accepts(configURL));
+ ConfigurationData data = format.readConfiguration(configURL.toString(), configURL.openStream());
+ assertNotNull(data);
+ for(Map.Entry<String,String> en:data.getDefaultProperties().entrySet()) {
+ System.out.println(en.getKey() + " -> " + en.getValue());
+ }
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/formats/yaml/src/test/java/org/apache/tamaya/yaml/YAMLPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/formats/yaml/src/test/java/org/apache/tamaya/yaml/YAMLPropertySourceTest.java b/modules/formats/yaml/src/test/java/org/apache/tamaya/yaml/YAMLPropertySourceTest.java
new file mode 100644
index 0000000..8aa90bc
--- /dev/null
+++ b/modules/formats/yaml/src/test/java/org/apache/tamaya/yaml/YAMLPropertySourceTest.java
@@ -0,0 +1,52 @@
+/*
+ * 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.yaml;
+
+import org.hamcrest.CoreMatchers;
+import org.junit.Test;
+
+import java.net.URL;
+
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertEquals;
+
+public class YAMLPropertySourceTest {
+
+ @Test
+ public void testYamlWithOrdinal() throws Exception {
+ URL configURL = YAMLPropertySourceTest.class.getResource("/configs/valid/test-with-prio.yaml");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ YAMLPropertySource source = new YAMLPropertySource(configURL, 4);
+ assertEquals(source.getOrdinal(), 16784);
+ }
+
+ @Test
+ public void testYamlDefaultOrdinal() throws Exception {
+ URL configURL = YAMLPropertySourceTest.class.getResource("/configs/valid/test.yaml");
+
+ assertThat(configURL, CoreMatchers.notNullValue());
+
+ YAMLPropertySource source = new YAMLPropertySource(configURL, 4);
+ assertEquals(source.getOrdinal(), 4);
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/functions/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/functions/bnd.bnd b/modules/functions/bnd.bnd
new file mode 100644
index 0000000..3951e26
--- /dev/null
+++ b/modules/functions/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+ org.apache.tamaya.functions
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/injection/injection-api/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/injection/injection-api/bnd.bnd b/modules/injection/injection-api/bnd.bnd
new file mode 100644
index 0000000..c68fb11
--- /dev/null
+++ b/modules/injection/injection-api/bnd.bnd
@@ -0,0 +1,3 @@
+Export-Package: \
+ org.apache.tamaya.inject.api,\
+ org.apache.tamaya.inject.spi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/injection/standalone/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/injection/standalone/bnd.bnd b/modules/injection/standalone/bnd.bnd
new file mode 100644
index 0000000..8bfdf02
--- /dev/null
+++ b/modules/injection/standalone/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+ org.apache.tamaya.inject
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/mutable-config/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/mutable-config/bnd.bnd b/modules/mutable-config/bnd.bnd
new file mode 100644
index 0000000..89222d7
--- /dev/null
+++ b/modules/mutable-config/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+ org.apache.tamaya.mutableconfig
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/optional/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/optional/bnd.bnd b/modules/optional/bnd.bnd
new file mode 100644
index 0000000..9463045
--- /dev/null
+++ b/modules/optional/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+ org.apache.tamaya.optional
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/resolver/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/resolver/bnd.bnd b/modules/resolver/bnd.bnd
new file mode 100644
index 0000000..21965e8
--- /dev/null
+++ b/modules/resolver/bnd.bnd
@@ -0,0 +1,3 @@
+Export-Package: \
+ org.apache.tamaya.resolver,\
+ org.apache.tamaya.resolver.spi
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/resources/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/resources/bnd.bnd b/modules/resources/bnd.bnd
new file mode 100644
index 0000000..44ece01
--- /dev/null
+++ b/modules/resources/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+ org.apache.tamaya.resource
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/spi-support/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/spi-support/bnd.bnd b/modules/spi-support/bnd.bnd
new file mode 100644
index 0000000..37c99b7
--- /dev/null
+++ b/modules/spi-support/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+ org.apache.tamaya.spisupport
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/modules/spring/bnd.bnd
----------------------------------------------------------------------
diff --git a/modules/spring/bnd.bnd b/modules/spring/bnd.bnd
new file mode 100644
index 0000000..eb0c2fb
--- /dev/null
+++ b/modules/spring/bnd.bnd
@@ -0,0 +1,2 @@
+Export-Package: \
+ org.apache.tamaya.integration.spring
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/85ae2a47/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index c3e9a69..36b672c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -505,32 +505,14 @@ under the License.
</configuration>
</plugin>
<plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>3.2.0</version>
- <inherited>true</inherited>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Bundle-DocURL>http://tamaya.incubator.apache.org</Bundle-DocURL>
- <Bundle-SymbolicName>
- ${project.groupId}.${project.artifactId}
- </Bundle-SymbolicName>
- <Bundle-Vendor>The Apache Software Foundation</Bundle-Vendor>
- </instructions>
- </configuration>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ <version>3.3.0</version>
<executions>
<execution>
- <id>cleanVersions</id>
- <phase>generate-sources</phase>
<goals>
- <goal>cleanVersions</goal>
+ <goal>bnd-process</goal>
</goals>
- <configuration>
- <versions>
- <karaf.osgi.version>${osgi.version}</karaf.osgi.version>
- </versions>
- </configuration>
</execution>
</executions>
</plugin>
@@ -767,6 +749,18 @@ under the License.
<target>1.7</target>
</configuration>
</plugin>
+ <plugin>
+ <groupId>biz.aQute.bnd</groupId>
+ <artifactId>bnd-maven-plugin</artifactId>
+ <version>3.3.0</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>bnd-process</goal>
+ </goals>
+ </execution>
+ </executions>
+ </plugin>
</plugins>
</build>