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/10/30 22:06:35 UTC
[13/15] incubator-tamaya-extensions git commit: TAMAYA-182:
Streamlined/unified builder API and fixed some bugs popping up during
testing.
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/BasePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/BasePropertySourceTest.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/BasePropertySourceTest.java
new file mode 100644
index 0000000..96f1c7f
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/BasePropertySourceTest.java
@@ -0,0 +1,106 @@
+/*
+ * 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.spisupport;
+
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.apache.tamaya.spi.PropertyValueBuilder;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+public class BasePropertySourceTest {
+
+ @Test
+ public void testGetOrdinal() {
+
+ PropertySource defaultPropertySource = new BasePropertySource(56) {
+
+ @Override
+ public String getName() {
+ return "testWithDefault";
+ }
+
+ @Override
+ public PropertyValue get(String key) {
+ return null;
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return Collections.emptyMap();
+ }
+ };
+
+ Assert.assertEquals(56, defaultPropertySource.getOrdinal());
+ Assert.assertEquals(1000, new OverriddenOrdinalPropertySource().getOrdinal());
+
+ // propertySource with invalid ordinal
+ Assert.assertEquals(1, new OverriddenInvalidOrdinalPropertySource().getOrdinal());
+ }
+
+ @Test
+ public void testGet() {
+ Assert.assertEquals("1000", new OverriddenOrdinalPropertySource().get(PropertySource.TAMAYA_ORDINAL).get(PropertySource.TAMAYA_ORDINAL));
+ }
+
+ private static class OverriddenOrdinalPropertySource extends BasePropertySource {
+
+ private OverriddenOrdinalPropertySource() {
+ super(250);
+ }
+
+ @Override
+ public String getName() {
+ return "overriddenOrdinal";
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ Map<String, String> map = new HashMap<>(1);
+ map.put(PropertySource.TAMAYA_ORDINAL, "1000");
+ return map;
+ }
+ }
+
+ private static class OverriddenInvalidOrdinalPropertySource extends BasePropertySource {
+
+ private OverriddenInvalidOrdinalPropertySource() {
+ super(1);
+ }
+
+ @Override
+ public String getName() {
+ return "overriddenInvalidOrdinal";
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ Map<String, String> map = new HashMap<>(1);
+ map.put(PropertySource.TAMAYA_ORDINAL, "invalid");
+ return map;
+ }
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/C.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/C.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/C.java
new file mode 100644
index 0000000..da581e6
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/C.java
@@ -0,0 +1,56 @@
+/*
+ * 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.spisupport;
+
+import java.io.IOException;
+import java.nio.CharBuffer;
+
+/**
+ * Test class for testing transitively evaluated property converters.
+ */
+public class C extends B implements Readable{
+
+ private final String inValue;
+
+ public C(String inValue){
+ this.inValue = inValue;
+ }
+
+ @Override
+ public int read(CharBuffer cb) throws IOException {
+ return 0;
+ }
+
+ /**
+ * Returns the input value, set on creation. Used for test assertion.
+ * @return the in value.
+ */
+ public String getInValue() {
+ return inValue;
+ }
+
+ @Override
+ public String toString() {
+ return "C{" +
+ "inValue='" + inValue + '\'' +
+ '}';
+ }
+
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/CLIPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/CLIPropertySourceTest.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/CLIPropertySourceTest.java
new file mode 100644
index 0000000..2c2baa4
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/CLIPropertySourceTest.java
@@ -0,0 +1,59 @@
+/*
+ * 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.spisupport;
+
+import org.apache.tamaya.core.propertysource.CLIPropertySource;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Tests for PropertySource for reading main arguments as configuration.
+ */
+public class CLIPropertySourceTest {
+
+ @Test
+ public void setCLIProps() throws Exception {
+ System.clearProperty("main.args");
+ CLIPropertySource ps = new CLIPropertySource();
+ assertTrue(ps.getProperties().isEmpty());
+ CLIPropertySource.initMainArgs("-a", "b");
+ assertFalse(ps.getProperties().isEmpty());
+ assertEquals(ps.getProperties().get("a"), "b");
+ CLIPropertySource.initMainArgs("--c");
+ assertFalse(ps.getProperties().isEmpty());
+ assertEquals(ps.getProperties().get("c"), "c");
+ CLIPropertySource.initMainArgs("sss");
+ assertFalse(ps.getProperties().isEmpty());
+ assertEquals(ps.getProperties().get("sss"), "sss");
+ CLIPropertySource.initMainArgs("-a", "b", "--c", "sss", "--val=vvv");
+ assertFalse(ps.getProperties().isEmpty());
+ assertEquals(ps.getProperties().get("a"), "b");
+ assertEquals(ps.getProperties().get("c"), "c");
+ assertEquals(ps.getProperties().get("sss"), "sss");
+ // getProperties() throws Exception {
+ System.setProperty("main.args", "-a b\t--c sss ");
+ ps = new CLIPropertySource();
+ assertFalse(ps.getProperties().isEmpty());
+ System.clearProperty("main.args");
+ assertEquals(ps.getProperties().get("a"), "b");
+ assertEquals(ps.getProperties().get("c"), "c");
+ assertEquals(ps.getProperties().get("sss"), "sss");
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java
new file mode 100644
index 0000000..dce8121
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/CTestConverter.java
@@ -0,0 +1,32 @@
+/*
+ * 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.spisupport;
+
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+
+/**
+ * Created by Anatole on 13.06.2015.
+ */
+public class CTestConverter implements PropertyConverter<C>{
+ @Override
+ public C convert(String value, ConversionContext context) {
+ return new C(value);
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextTest.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextTest.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextTest.java
new file mode 100644
index 0000000..0e08be4
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/DefaultConfigurationContextTest.java
@@ -0,0 +1,183 @@
+/*
+ * 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.spisupport;
+
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConfigurationContext;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.FilterContext;
+import org.apache.tamaya.spi.PropertyConverter;
+import org.apache.tamaya.spi.PropertyFilter;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Simple tests for {@link DefaultConfigurationContext} by atsticks on 16.08.16.
+ */
+public class DefaultConfigurationContextTest {
+
+ @Test
+ public void addPropertySources() throws Exception {
+ ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
+ PropertySource def = new TestPropertyDefaultSource();
+ assertFalse(ctx.getPropertySources().contains(def));
+ ctx.addPropertySources(def);
+ assertTrue(ctx.getPropertySources().contains(def));
+ }
+
+ @Test
+ public void testToString() throws Exception {
+ String toString = ConfigurationProvider.getConfiguration().getContext().toString();
+ System.out.println(toString);
+ }
+
+ @Test
+ public void getPropertySources() throws Exception {
+ ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
+ assertNotNull(ctx.getPropertySources());
+ assertEquals(ctx.getPropertySources().size(), 0);
+ ctx = new DefaultConfigurationContextBuilder().loadDefaultPropertySources().build();
+ assertNotNull(ctx.getPropertySources());
+ assertEquals(3, ctx.getPropertySources().size());
+ }
+
+ @Test
+ public void getPropertySource() throws Exception {
+ PropertySource ps = new TestPropertyDefaultSource();
+ ConfigurationContext ctx = new DefaultConfigurationContextBuilder()
+ .addPropertySources(ps).build();
+ assertNotNull(ctx.getPropertySources());
+ assertEquals(ctx.getPropertySources().size(), 1);
+ assertNotNull(((DefaultConfigurationContext)ctx).getPropertySource(ps.getName()));
+ assertEquals(ps.getName(), ((DefaultConfigurationContext)ctx).getPropertySource(ps.getName()).getName());
+ assertNull(((DefaultConfigurationContext)ctx).getPropertySource("huhu"));
+
+ }
+
+ @Test
+ public void testHashCode() throws Exception {
+ PropertySource ps = new TestPropertyDefaultSource();
+ ConfigurationContext ctx1 = new DefaultConfigurationContextBuilder()
+ .addPropertySources(ps).build();
+ ConfigurationContext ctx2 = new DefaultConfigurationContextBuilder()
+ .addPropertySources(ps).build();
+ assertEquals(ctx1.hashCode(), ctx2.hashCode());
+ ctx2 = new DefaultConfigurationContextBuilder()
+ .build();
+ assertNotEquals(ctx1.hashCode(), ctx2.hashCode());
+
+ }
+
+ @Test
+ public void addPropertyConverter() throws Exception {
+ ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
+ PropertyConverter testConverter = new PropertyConverter() {
+ @Override
+ public Object convert(String value, ConversionContext context) {
+ return "";
+ }
+ };
+ assertFalse(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(testConverter));
+ ctx.addPropertyConverter(TypeLiteral.of(String.class), testConverter);
+ assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(testConverter));
+ }
+
+ @Test
+ public void getPropertyConverters() throws Exception {
+ ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
+ PropertyConverter testConverter = new PropertyConverter() {
+ @Override
+ public Object convert(String value, ConversionContext context) {
+ return "";
+ }
+ };
+ ctx.addPropertyConverter(TypeLiteral.of(String.class), testConverter);
+ assertNotNull(ctx.getPropertyConverters());
+ assertTrue(ctx.getPropertyConverters().containsKey(TypeLiteral.of(String.class)));
+ assertTrue(ctx.getPropertyConverters().get(TypeLiteral.of(String.class)).contains(testConverter));
+ testConverter = new PropertyConverter() {
+ @Override
+ public Object convert(String value, ConversionContext context) {
+ return Integer.valueOf(5);
+ }
+ };
+ ctx.addPropertyConverter(TypeLiteral.of(Integer.class), testConverter);
+ assertTrue(ctx.getPropertyConverters().containsKey(TypeLiteral.of(Integer.class)));
+ assertTrue(ctx.getPropertyConverters().get(TypeLiteral.of(Integer.class)).contains(testConverter));
+ }
+
+ @Test
+ public void getPropertyConverters1() throws Exception {
+ ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
+ PropertyConverter testConverter = new PropertyConverter() {
+ @Override
+ public Object convert(String value, ConversionContext context) {
+ return "";
+ }
+ };
+ assertNotNull(ctx.getPropertyConverters(TypeLiteral.of(String.class)));
+ assertEquals(ctx.getPropertyConverters(TypeLiteral.of(String.class)).size(),0);
+ ctx.addPropertyConverter(TypeLiteral.of(String.class), testConverter);
+ assertNotNull(ctx.getPropertyConverters(TypeLiteral.of(String.class)));
+ assertEquals(ctx.getPropertyConverters(TypeLiteral.of(String.class)).size(),1);
+ assertTrue(ctx.getPropertyConverters(TypeLiteral.of(String.class)).contains(testConverter));
+
+ }
+
+ @Test
+ public void getPropertyFilters() throws Exception {
+ ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
+ PropertyFilter testFilter = new PropertyFilter() {
+
+ @Override
+ public String filterProperty(String value, FilterContext context) {
+ return value;
+ }
+ };
+ assertNotNull(ctx.getPropertyFilters());
+ assertFalse(ctx.getPropertyFilters().contains(testFilter));
+ ctx = ctx.toBuilder().addPropertyFilters(testFilter).build();
+ assertTrue(ctx.getPropertyFilters().contains(testFilter));
+ }
+
+ @Test
+ public void getPropertyValueCombinationPolicy() throws Exception {
+ ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
+ assertNotNull(ctx.getPropertyValueCombinationPolicy());
+ assertEquals(ctx.getPropertyValueCombinationPolicy(),
+ PropertyValueCombinationPolicy.DEFAULT_OVERRIDING_COLLECTOR);
+ }
+
+ @Test
+ public void toBuilder() throws Exception {
+ assertNotNull(new DefaultConfigurationContextBuilder().build().toBuilder());
+ }
+
+ @Test
+ public void testRoundTrip() throws Exception {
+ ConfigurationContext ctx = new DefaultConfigurationContextBuilder().build();
+ assertEquals(ctx.toBuilder().build(), ctx);
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java
new file mode 100644
index 0000000..c846e81
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/EnumConverterTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.spisupport;
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.spi.ConversionContext;
+import org.junit.Test;
+
+import java.math.RoundingMode;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+
+/**
+ * Test class testing the {@link EnumConverter} class.
+ */
+public class EnumConverterTest {
+
+ private final EnumConverter testConverter = new EnumConverter(RoundingMode.class);
+
+ private final ConversionContext DUMMY_CONTEXT = new ConversionContext.Builder("someKey", TypeLiteral.of(Enum.class)).build();
+
+ @Test
+ public void testConvert() {
+ assertEquals(testConverter.convert(RoundingMode.CEILING.toString(),
+ DUMMY_CONTEXT), RoundingMode.CEILING);
+ }
+
+ @Test
+ public void testConvert_LowerCase() {
+ assertEquals(testConverter.convert("ceiling", DUMMY_CONTEXT), RoundingMode.CEILING);
+ }
+
+ @Test
+ public void testConvert_MixedCase() {
+ assertEquals(testConverter.convert("CeiLinG", DUMMY_CONTEXT), RoundingMode.CEILING);
+ }
+
+ @Test
+ public void testConvert_OtherValue() {
+ assertNull(testConverter.convert("fooBars", DUMMY_CONTEXT));
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/EnvironmentPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/EnvironmentPropertySourceTest.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/EnvironmentPropertySourceTest.java
new file mode 100644
index 0000000..a7f0497
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/EnvironmentPropertySourceTest.java
@@ -0,0 +1,67 @@
+/*
+ * 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.spisupport;
+
+import org.apache.tamaya.core.propertysource.EnvironmentPropertySource;
+import org.junit.Test;
+
+import java.util.Map;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+/**
+ * Tests for {@link EnvironmentPropertySource}.
+ */
+public class EnvironmentPropertySourceTest {
+
+ private final EnvironmentPropertySource envPropertySource = new EnvironmentPropertySource();
+
+ @Test
+ public void testGetOrdinal() throws Exception {
+ assertEquals(EnvironmentPropertySource.DEFAULT_ORDINAL, envPropertySource.getOrdinal());
+ }
+
+ @Test
+ public void testGetName() throws Exception {
+ assertEquals("environment-properties", envPropertySource.getName());
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ for (Map.Entry<String, String> envEntry : System.getenv().entrySet()) {
+ assertEquals(envPropertySource.get(envEntry.getKey()).get(envEntry.getKey()), envEntry.getValue());
+ }
+ }
+
+ @Test
+ public void testGetProperties() throws Exception {
+ Map<String, String> props = envPropertySource.getProperties();
+ for(Map.Entry<String,String> en: props.entrySet()){
+ if(!en.getKey().startsWith("_")){
+ assertEquals(System.getenv(en.getKey()), en.getValue());
+ }
+ }
+ }
+
+ @Test
+ public void testIsScannable() throws Exception {
+ assertTrue(envPropertySource.isScannable());
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PriorityServiceComparatorTest.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PriorityServiceComparatorTest.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PriorityServiceComparatorTest.java
new file mode 100644
index 0000000..846e283
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PriorityServiceComparatorTest.java
@@ -0,0 +1,45 @@
+/*
+ * 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.spisupport;
+
+import org.junit.Test;
+
+import javax.annotation.Priority;
+
+import static org.junit.Assert.*;
+
+/**
+ * Created by atsticks on 12.09.16.
+ */
+public class PriorityServiceComparatorTest {
+
+ private PriorityServiceComparator comp = new PriorityServiceComparator();
+
+ @Test
+ public void compare() throws Exception {
+ assertTrue(comp.compare("a", "b")==0);
+ assertTrue(comp.compare(getClass(), getClass())==0);
+ assertTrue(comp.compare(new A(), new SystemPropertySource())==-1);
+ assertTrue(comp.compare(new SystemPropertySource(), new A())==1);
+ }
+
+ @Priority(100)
+ private static final class A{}
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertiesFilePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertiesFilePropertySourceTest.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertiesFilePropertySourceTest.java
new file mode 100644
index 0000000..889e905
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertiesFilePropertySourceTest.java
@@ -0,0 +1,60 @@
+/*
+ * 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.spisupport;
+
+import org.apache.tamaya.core.propertysource.SimplePropertySource;
+import org.apache.tamaya.spi.PropertySource;
+import org.junit.Assert;
+import org.junit.Test;
+
+public class PropertiesFilePropertySourceTest {
+
+ private final SimplePropertySource testfilePropertySource = new SimplePropertySource(Thread.currentThread()
+ .getContextClassLoader().getResource("testfile.properties"));
+ private final SimplePropertySource overrideOrdinalPropertySource = new SimplePropertySource(
+ Thread.currentThread().getContextClassLoader().getResource("overrideOrdinal.properties"));
+
+
+ @Test
+ public void testGetOrdinal() {
+ Assert.assertEquals(0, testfilePropertySource.getOrdinal());
+ Assert.assertEquals(Integer.parseInt(overrideOrdinalPropertySource.get(PropertySource.TAMAYA_ORDINAL)
+ .get(PropertySource.TAMAYA_ORDINAL)),
+ overrideOrdinalPropertySource.getOrdinal());
+ }
+
+
+ @Test
+ public void testGet() {
+ Assert.assertEquals("val3", testfilePropertySource.get("key3").get("key3"));
+ Assert.assertEquals("myval5", overrideOrdinalPropertySource.get("mykey5").get("mykey5"));
+ Assert.assertNull(testfilePropertySource.get("nonpresentkey"));
+ }
+
+
+ @Test
+ public void testGetProperties() throws Exception {
+ Assert.assertEquals(5, testfilePropertySource.getProperties().size());
+ Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key1"));
+ Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key2"));
+ Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key3"));
+ Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key4"));
+ Assert.assertTrue(testfilePropertySource.getProperties().containsKey("key5"));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java
new file mode 100644
index 0000000..45ecc9d
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/PropertyConverterManagerTest.java
@@ -0,0 +1,180 @@
+/*
+ * 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.spisupport;
+
+
+
+import org.apache.tamaya.ConfigurationProvider;
+import org.apache.tamaya.spi.ConversionContext;
+import org.apache.tamaya.spi.PropertyConverter;
+import org.apache.tamaya.TypeLiteral;
+import org.junit.Test;
+
+import java.util.List;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.equalTo;
+import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
+
+public class PropertyConverterManagerTest {
+
+ private final ConversionContext DUMMY_CONTEXT = new ConversionContext.Builder(
+ "someKey", TypeLiteral.of(Object.class)).build();
+
+ @Test
+ public void customTypeWithFactoryMethodOfIsRecognizedAsSupported() {
+ PropertyConverterManager manager = new PropertyConverterManager();
+
+ assertThat(manager.isTargetTypeSupported(TypeLiteral.of(MyType.class)),
+ is(true));
+ }
+
+ @Test
+ public void factoryMethodOfIsUsedAsConverter() {
+ PropertyConverterManager manager = new PropertyConverterManager();
+
+ List<PropertyConverter<MyType>> converters = manager.getPropertyConverters(
+ (TypeLiteral)TypeLiteral.of(MyType.class));
+
+ assertThat(converters, hasSize(1));
+
+ PropertyConverter<MyType> converter = converters.get(0);
+
+ Object result = converter.convert("IN", DUMMY_CONTEXT);
+
+ assertThat(result, notNullValue());
+ assertThat(result, instanceOf(MyType.class));
+ assertThat(((MyType)result).getValue(), equalTo("IN"));
+ }
+
+ @Test
+ public void testDirectConverterMapping(){
+ PropertyConverterManager manager = new PropertyConverterManager();
+ List<PropertyConverter<C>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(C.class)));
+ assertThat(converters, hasSize(1));
+
+ PropertyConverter<C> converter = converters.get(0);
+ C result = converter.convert("testDirectConverterMapping", DUMMY_CONTEXT);
+
+ assertThat(result, notNullValue());
+ assertThat(result, instanceOf(C.class));
+ assertThat((result).getInValue(), equalTo("testDirectConverterMapping"));
+ }
+
+ @Test
+ public void testDirectSuperclassConverterMapping(){
+ PropertyConverterManager manager = new PropertyConverterManager();
+ List<PropertyConverter<B>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
+ assertThat(converters, hasSize(1));
+ converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
+ assertThat(converters, hasSize(1));
+
+ PropertyConverter<B> converter = converters.get(0);
+ B result = converter.convert("testDirectSuperclassConverterMapping", DUMMY_CONTEXT);
+
+ assertThat(result, notNullValue());
+ assertThat(result, instanceOf(C.class));
+ assertThat(((C)result).getInValue(), equalTo("testDirectSuperclassConverterMapping"));
+ }
+
+ @Test
+ public void testMultipleConverterLoad(){
+ PropertyConverterManager manager = new PropertyConverterManager();
+ List<PropertyConverter<B>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
+ assertThat(converters, hasSize(1));
+ manager = new PropertyConverterManager();
+ converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(B.class)));
+ assertThat(converters, hasSize(1));
+ }
+
+ @Test
+ public void testTransitiveSuperclassConverterMapping(){
+ PropertyConverterManager manager = new PropertyConverterManager();
+ List<PropertyConverter<A>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(A.class)));
+ assertThat(converters, hasSize(1));
+
+ PropertyConverter<A> converter = converters.get(0);
+ A result = converter.convert("testTransitiveSuperclassConverterMapping", DUMMY_CONTEXT);
+
+ assertThat(result, notNullValue());
+ assertThat(result, instanceOf(C.class));
+ assertThat(((C)result).getInValue(), equalTo("testTransitiveSuperclassConverterMapping"));
+ }
+
+ @Test
+ public void testDirectInterfaceMapping(){
+ PropertyConverterManager manager = new PropertyConverterManager();
+ List<PropertyConverter<Readable>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(Readable.class)));
+ assertThat(converters, hasSize(1));
+
+ PropertyConverter<Readable> converter = converters.get(0);
+ Readable result = converter.convert("testDirectInterfaceMapping", DUMMY_CONTEXT);
+
+ assertThat(result, notNullValue());
+ assertThat(result, instanceOf(C.class));
+ assertThat(((C)result).getInValue(), equalTo("testDirectInterfaceMapping"));
+ }
+
+ @Test
+ public void testTransitiveInterfaceMapping1(){
+ PropertyConverterManager manager = new PropertyConverterManager();
+ List<PropertyConverter<Runnable>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(Runnable.class)));
+ assertThat(converters, hasSize(1));
+
+ PropertyConverter<Runnable> converter = converters.get(0);
+ Runnable result = converter.convert("testTransitiveInterfaceMapping1", DUMMY_CONTEXT);
+
+ assertThat(result, notNullValue());
+ assertThat(result, instanceOf(C.class));
+ assertThat(((C)result).getInValue(), equalTo("testTransitiveInterfaceMapping1"));
+ }
+
+ @Test
+ public void testTransitiveInterfaceMapping2(){
+ PropertyConverterManager manager = new PropertyConverterManager();
+ List<PropertyConverter<AutoCloseable>> converters = List.class.cast(manager.getPropertyConverters(TypeLiteral.of(AutoCloseable.class)));
+ assertThat(converters, hasSize(1));
+
+ PropertyConverter<AutoCloseable> converter = converters.get(0);
+ AutoCloseable result = converter.convert("testTransitiveInterfaceMapping2", DUMMY_CONTEXT);
+
+ assertThat(result, notNullValue());
+ assertThat(result, instanceOf(C.class));
+ assertThat(((C)result).getInValue(), equalTo("testTransitiveInterfaceMapping2"));
+ }
+
+ public static class MyType {
+ private final String typeValue;
+
+ private MyType(String value) {
+ typeValue = value;
+ }
+
+ public static MyType of(String source) {
+ return new MyType(source);
+ }
+
+ public String getValue() {
+ return typeValue;
+ }
+
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/SimplePropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/SimplePropertySourceTest.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/SimplePropertySourceTest.java
new file mode 100644
index 0000000..e199609
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/SimplePropertySourceTest.java
@@ -0,0 +1,85 @@
+/*
+ * 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.spisupport;
+
+import org.apache.tamaya.ConfigException;
+import org.junit.Test;
+
+import java.net.URL;
+
+import static org.hamcrest.CoreMatchers.*;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.aMapWithSize;
+import static org.hamcrest.Matchers.hasEntry;
+
+public class SimplePropertySourceTest {
+ @Test
+ public void successfulCreationWithPropertiesFromXMLPropertiesFile() {
+ URL resource = getClass().getResource("/valid-properties.xml");
+
+ SimplePropertySource source = new SimplePropertySource(resource);
+
+ assertThat(source, notNullValue());
+ assertThat(source.getProperties(), aMapWithSize(2));
+ assertThat(source.getProperties(), hasEntry("a", "b"));
+ assertThat(source.getProperties(), hasEntry("b", "1"));
+
+ }
+
+ @Test
+ public void failsToCreateFromNonXMLPropertiesXMLFile() {
+ URL resource = getClass().getResource("/non-xml-properties.xml");
+ ConfigException catchedException = null;
+
+ try {
+ new SimplePropertySource(resource);
+ } catch (ConfigException ce) {
+ catchedException = ce;
+ }
+
+ assertThat(catchedException.getMessage(), allOf(startsWith("Error loading properties from"),
+ endsWith("non-xml-properties.xml")));
+ }
+
+ @Test
+ public void failsToCreateFromInvalidPropertiesXMLFile() {
+ URL resource = getClass().getResource("/invalid-properties.xml");
+ ConfigException catchedException = null;
+
+ try {
+ new SimplePropertySource(resource);
+ } catch (ConfigException ce) {
+ catchedException = ce;
+ }
+
+ assertThat(catchedException.getMessage(), allOf(startsWith("Error loading properties from"),
+ endsWith("invalid-properties.xml")));
+ }
+
+
+ @Test
+ public void successfulCreationWithPropertiesFromSimplePropertiesFile() {
+ URL resource = getClass().getResource("/testfile.properties");
+
+ SimplePropertySource source = new SimplePropertySource(resource);
+
+ assertThat(source, notNullValue());
+ assertThat(source.getProperties(), aMapWithSize(5));
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/SystemPropertySourceTest.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/SystemPropertySourceTest.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/SystemPropertySourceTest.java
new file mode 100644
index 0000000..54e970c
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/SystemPropertySourceTest.java
@@ -0,0 +1,102 @@
+/*
+ * 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.spisupport;
+
+import org.apache.tamaya.core.propertysource.SystemPropertySource;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertyValue;
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Map;
+import java.util.Properties;
+
+public class SystemPropertySourceTest {
+
+ private final SystemPropertySource testPropertySource = new SystemPropertySource();
+
+
+ @Test
+ public void testGetOrdinal() throws Exception {
+
+ // test the default ordinal
+ Assert.assertEquals(SystemPropertySource.DEFAULT_ORDINAL, testPropertySource.getOrdinal());
+
+ // set the ordinal to 1000
+ System.setProperty(PropertySource.TAMAYA_ORDINAL, "1000");
+ Assert.assertEquals(1000, new SystemPropertySource().getOrdinal());
+ // currently its not possible to change ordinal at runtime
+
+ // reset it to not destroy other tests!!
+ System.clearProperty(PropertySource.TAMAYA_ORDINAL);
+ }
+
+ @Test
+ public void testGetName() throws Exception {
+ Assert.assertEquals("system-properties", testPropertySource.getName());
+ }
+
+ @Test
+ public void testGet() throws Exception {
+ String propertyKeyToCheck = System.getProperties().stringPropertyNames().iterator().next();
+
+ PropertyValue property = testPropertySource.get(propertyKeyToCheck);
+ Assert.assertNotNull("Property '" + propertyKeyToCheck + "' is not present in " +
+ SystemPropertySource.class.getSimpleName(), property);
+ Assert.assertEquals(System.getProperty(propertyKeyToCheck), property.getValue());
+ }
+
+ @Test
+ public void testGetProperties() throws Exception {
+ checkWithSystemProperties(testPropertySource.getProperties());
+
+ // modify system properties
+ System.setProperty("test", "myTestVal");
+
+ checkWithSystemProperties(testPropertySource.getProperties());
+
+ // cleanup
+ System.clearProperty("test");
+
+ // no modifaction
+ try {
+ testPropertySource.getProperties().put("add.new.keys", "must throw exception");
+ Assert.fail(UnsupportedOperationException.class.getName() + " expected");
+ }
+ catch (UnsupportedOperationException e) {
+ // expected -> all is fine
+ }
+ }
+
+ private void checkWithSystemProperties(Map<String, String> toCheck) {
+ Properties systemEntries = System.getProperties();
+
+ Assert.assertEquals("size of System.getProperties().entrySet() must be the same as SystemPropertySrouce.getProperties().entrySet()",
+ systemEntries.size(), toCheck.size()/2);
+
+ for (Map.Entry<String, String> propertySourceEntry : toCheck.entrySet()) {
+ if(propertySourceEntry.getKey().startsWith("_")){
+ continue; // meta entry
+ }
+ Assert.assertEquals("Entry values for key '" + propertySourceEntry.getKey() + "' do not match",
+ systemEntries.getProperty(propertySourceEntry.getKey()), propertySourceEntry.getValue());
+ }
+
+ }
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/TestPropertyDefaultSource.java
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/TestPropertyDefaultSource.java b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/TestPropertyDefaultSource.java
new file mode 100644
index 0000000..f55d8e4
--- /dev/null
+++ b/modules/spi-support/src/test/java/org/apache/tamaya/spisupport/TestPropertyDefaultSource.java
@@ -0,0 +1,56 @@
+/*
+ * 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.spisupport;
+
+import org.apache.tamaya.core.propertysource.BasePropertySource;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Test provider reading properties from classpath:cfg/defaults/**.properties.
+ */
+public class TestPropertyDefaultSource extends BasePropertySource{
+
+ private Map<String,String> properties = new HashMap<>();
+
+ public TestPropertyDefaultSource() {
+ super(100);
+ properties.put("name","Anatole");
+ properties.put("name2","Sabine");
+ properties = Collections.unmodifiableMap(properties);
+ }
+
+ @Override
+ public String getName() {
+ return "default-testdata-properties";
+ }
+
+ @Override
+ public Map<String, String> getProperties() {
+ return properties;
+ }
+
+ @Override
+ public boolean isScannable() {
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter b/modules/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
new file mode 100644
index 0000000..ff5d32c
--- /dev/null
+++ b/modules/spi-support/src/test/resources/META-INF/services/org.apache.tamaya.spi.PropertyConverter
@@ -0,0 +1,38 @@
+#
+# 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.
+#
+
+#
+# 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.
+#
+org.apache.tamaya.spisupport.CTestConverter
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/resources/invalid-properties.xml
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/resources/invalid-properties.xml b/modules/spi-support/src/test/resources/invalid-properties.xml
new file mode 100644
index 0000000..d8b10b7
--- /dev/null
+++ b/modules/spi-support/src/test/resources/invalid-properties.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <entry key="a">
+ <entry key="b">1</entry>
+</properties>
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/resources/non-xml-properties.xml
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/resources/non-xml-properties.xml b/modules/spi-support/src/test/resources/non-xml-properties.xml
new file mode 100644
index 0000000..8de819a
--- /dev/null
+++ b/modules/spi-support/src/test/resources/non-xml-properties.xml
@@ -0,0 +1,18 @@
+<!--
+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.
+-->
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/resources/overrideOrdinal.properties
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/resources/overrideOrdinal.properties b/modules/spi-support/src/test/resources/overrideOrdinal.properties
new file mode 100644
index 0000000..96935a8
--- /dev/null
+++ b/modules/spi-support/src/test/resources/overrideOrdinal.properties
@@ -0,0 +1,25 @@
+# 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.
+
+#override ordinal
+tamaya.ordinal=16784
+
+mykey1=myval1
+mykey2=myval2
+mykey3=myval3
+mykey4=myval4
+mykey5=myval5
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/resources/testfile.properties
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/resources/testfile.properties b/modules/spi-support/src/test/resources/testfile.properties
new file mode 100644
index 0000000..abd7ee8
--- /dev/null
+++ b/modules/spi-support/src/test/resources/testfile.properties
@@ -0,0 +1,22 @@
+# 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.
+
+key1=val1
+key2=val2
+key3=val3
+key4=val4
+key5=val5
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-tamaya-extensions/blob/3aca9112/modules/spi-support/src/test/resources/valid-properties.xml
----------------------------------------------------------------------
diff --git a/modules/spi-support/src/test/resources/valid-properties.xml b/modules/spi-support/src/test/resources/valid-properties.xml
new file mode 100644
index 0000000..7eb51d9
--- /dev/null
+++ b/modules/spi-support/src/test/resources/valid-properties.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+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.
+-->
+
+<!DOCTYPE properties SYSTEM "http://java.sun.com/dtd/properties.dtd">
+<properties>
+ <entry key="a">b</entry>
+ <entry key="b">1</entry>
+</properties>