You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tamaya.apache.org by pl...@apache.org on 2016/09/25 21:23:54 UTC

[06/50] [abbrv] incubator-tamaya-sandbox git commit: TAMAYA-60 Removed the modules package for the package hierarchy.

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java b/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java
new file mode 100644
index 0000000..5f33c24
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java
@@ -0,0 +1,896 @@
+/*
+ * 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.builder;
+
+import org.apache.tamaya.ConfigException;
+import org.apache.tamaya.Configuration;
+import org.apache.tamaya.TypeLiteral;
+import org.apache.tamaya.builder.util.types.CustomTypeA;
+import org.apache.tamaya.builder.util.types.CustomTypeB;
+import org.apache.tamaya.builder.util.types.CustomTypeC;
+import org.apache.tamaya.spi.PropertyFilter;
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertySourceProvider;
+import org.hamcrest.CoreMatchers;
+import org.hamcrest.Matchers;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.mockito.Mockito;
+
+
+import java.io.IOException;
+import java.net.URL;
+
+import static java.util.Arrays.asList;
+import static org.apache.tamaya.builder.util.mockito.NotMockedAnswer.NOT_MOCKED_ANSWER;
+import static org.hamcrest.CoreMatchers.equalTo;
+import static org.hamcrest.CoreMatchers.nullValue;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.is;
+import static org.hamcrest.Matchers.notNullValue;
+import static org.mockito.Matchers.anyString;
+import static org.mockito.Mockito.CALLS_REAL_METHODS;
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+
+
+public class ConfigurationBuilderTest {
+
+    @Test
+    public void buildCanBuildEmptyConfiguration() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.build();
+
+        assertThat(config, notNullValue());
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void buildCanBeCalledOnlyOnce() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.build();
+        builder.build();
+    }
+
+    /*********************************************************************
+     * Tests for adding P r o p e r t y S o u r c e s
+     */
+
+    @Test(expected = NullPointerException.class)
+    public void addPropertySourcesDoesNotAcceptNullValue() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.addPropertySources((PropertySource[])null);
+    }
+
+    @Test(expected = IllegalStateException.class)
+    public void propertySourceCanNotBeAddedAfterBuildingTheConfiguration() {
+        PropertySource first = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("first").when(first).getName();
+        doReturn(100).when(first).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(first);
+
+        builder.build();
+
+        PropertySource second = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("second").when(first).getName();
+
+        builder.addPropertySources(second);
+    }
+
+    @Test
+    public void singleAddedPropertySourceIsUsed() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("one").when(source).getName();
+        doReturn("a").when(source).get("keyOfA");
+        doReturn(100).when(source).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(source);
+
+        Configuration config = builder.build();
+
+        String valueOfA = config.get("keyOfA");
+
+        assertThat(valueOfA, notNullValue());
+        assertThat(valueOfA, equalTo("a"));
+    }
+
+    @Test
+    public void twoAddedPropertySourcesAreUsed() {
+        PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("one").when(sourceOne).getName();
+        doReturn("b").when(sourceOne).get("keyOfA");
+        doReturn(10).when(sourceOne).getOrdinal();
+
+        PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+        doReturn("two").when(sourceTwo).getName();
+        doReturn("a").when(sourceTwo).get("keyOfA");
+        doReturn(10).when(sourceTwo).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne)
+                                                                 .addPropertySources(sourceTwo);
+
+        Configuration config = builder.build();
+
+        String valueOfA = config.get("keyOfA");
+
+        assertThat(valueOfA, notNullValue());
+        assertThat(valueOfA, equalTo("a"));
+    }
+
+    @Ignore
+    @Test(expected = ConfigException.class)
+    public void twoPropertySourcesSamePrioritySameKey() {
+        PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("one").when(sourceOne).getName();
+        doReturn("b").when(sourceOne).get("keyOfA");
+        doReturn(20).when(sourceOne).getOrdinal();
+
+        PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+        doReturn("two").when(sourceTwo).getName();
+        doReturn("a").when(sourceTwo).get("keyOfA");
+        doReturn(20).when(sourceTwo).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne)
+                                                                 .addPropertySources(sourceTwo);
+
+        Configuration config = builder.build();
+
+        config.get("keyOfA");
+    }
+
+    @Test
+    public void twoPropertySourcesDiffPrioritySameKeyLowerAddedFirst() {
+        PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("one").when(sourceOne).getName();
+        doReturn("b").when(sourceOne).get("keyOfA");
+        doReturn(10).when(sourceOne).getOrdinal();
+
+        PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+        doReturn("two").when(sourceTwo).getName();
+        doReturn("a").when(sourceTwo).get("keyOfA");
+        doReturn(20).when(sourceTwo).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne)
+                                                                 .addPropertySources(sourceTwo);
+
+        Configuration config = builder.build();
+
+        String valueOfA = config.get("keyOfA");
+
+        assertThat(valueOfA, notNullValue());
+        assertThat(valueOfA, equalTo("a"));
+    }
+
+    @Test
+    public void twoPropertySourcesDiffPrioritySameKeyHigherAddedFirst() {
+        PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("one").when(sourceOne).getName();
+        doReturn("b").when(sourceOne).get("keyOfA");
+        doReturn(30).when(sourceOne).getOrdinal();
+
+        PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+        doReturn("two").when(sourceTwo).getName();
+        doReturn("a").when(sourceTwo).get("keyOfA");
+        doReturn(20).when(sourceTwo).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne, sourceTwo);
+
+        Configuration config = builder.build();
+
+        String valueOfA = config.get("keyOfA");
+
+        assertThat(valueOfA, notNullValue());
+        assertThat(valueOfA, equalTo("b"));
+    }
+
+    @Test
+    public void consecutiveCallsToAddPropertySourceArePossible() {
+        PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("one").when(sourceOne).getName();
+        doReturn(null).when(sourceOne).get(anyString());
+        doReturn("b").when(sourceOne).get("b");
+        doReturn(30).when(sourceOne).getOrdinal();
+
+        PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+        doReturn("two").when(sourceTwo).getName();
+        doReturn(null).when(sourceTwo).get(anyString());
+        doReturn("a").when(sourceTwo).get("a");
+        doReturn(30).when(sourceTwo).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne)
+                                                                 .addPropertySources(sourceTwo);
+
+        Configuration config = builder.build();
+
+        assertThat(config.get("b"), equalTo("b"));
+        assertThat(config.get("a"), equalTo("a"));
+    }
+
+    @Test
+    public void addMultiplePropertySourcesWhereOneIsNull() {
+        PropertySource sourceOne = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("one").when(sourceOne).getName();
+        doReturn(null).when(sourceOne).get(anyString());
+        doReturn("b").when(sourceOne).get("b");
+        doReturn(30).when(sourceOne).getOrdinal();
+
+        PropertySource sourceTwo = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+        doReturn("two").when(sourceTwo).getName();
+        doReturn(null).when(sourceTwo).get(anyString());
+        doReturn("a").when(sourceTwo).get("a");
+        doReturn(30).when(sourceTwo).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(sourceOne, null, sourceTwo);
+
+        Configuration config = builder.build();
+
+        assertThat(config.get("b"), equalTo("b"));
+        assertThat(config.get("a"), equalTo("a"));
+    }
+
+    /**
+     * ******************************************************************
+     * Tests for adding P r o p e r t y C o n v e r t e r
+     */
+
+    @Test(expected = NullPointerException.class)
+    public void canNotAddNullPropertyConverter() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.addPropertyConverter(TypeLiteral.of(CustomTypeA.class), null);
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void canNotAddNullTypeLiteralButPropertyConverter() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.addPropertyConverter((TypeLiteral<CustomTypeA>)null,
+                                     prop -> new CustomTypeA(prop, prop));
+    }
+
+    @Test
+    public void addedPropertyConverterWithTypeLiteralIsUsedByConfiguration() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("source").when(source).getName();
+        doReturn("A").when(source).get("key");
+        doReturn(100).when(source).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.addPropertyConverter(TypeLiteral.of(CustomTypeA.class),
+                                     prop -> new CustomTypeA(prop, prop))
+               .addPropertySources(source);
+
+        Configuration config = builder.build();
+
+        Object resultRaw = config.get("key", CustomTypeA.class);
+
+        assertThat(resultRaw, CoreMatchers.notNullValue());
+
+        CustomTypeA result = (CustomTypeA)resultRaw;
+
+        assertThat(result.getName(), equalTo("AA"));
+    }
+
+    @Test
+    public void addedPropertyConverterWithClassIsUsedByConfiguration() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("source").when(source).getName();
+        doReturn("A").when(source).get("key");
+        doReturn(100).when(source).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.addPropertyConverter(CustomTypeA.class,
+                                     prop -> new CustomTypeA(prop, prop))
+               .addPropertySources(source);
+
+        Configuration config = builder.build();
+
+        Object resultRaw = config.get("key", CustomTypeA.class);
+
+        assertThat(resultRaw, CoreMatchers.notNullValue());
+
+        CustomTypeA result = (CustomTypeA)resultRaw;
+
+        assertThat(result.getName(), equalTo("AA"));
+    }
+
+    @Test
+    public void canGetAndConvertPropertyViaOfMethod() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("source").when(source).getName();
+        doReturn("A").when(source).get("key");
+        doReturn(100).when(source).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.addPropertySources(source);
+
+        Configuration config = builder.build();
+
+        Object resultRaw = config.get("key", CustomTypeB.class);
+
+        assertThat(resultRaw, CoreMatchers.notNullValue());
+
+        CustomTypeB result = (CustomTypeB)resultRaw;
+
+        assertThat(result.getName(), equalTo("A"));
+    }
+
+    /*********************************************************************
+     * Tests for adding P r o p e r t y F i l t e r
+     */
+
+    @Test(expected = NullPointerException.class)
+    public void canNotAddNullAsPropertyFilter() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.addPropertyFilters(null);
+    }
+
+    @Test
+    public void canAddNonSPIPropertyFilter() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("M").when(source).get("key");
+        doReturn("source").when(source).getName();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySources(source)
+                                      .addPropertyFilters(new TestNonSPIPropertyFilterA())
+                                      .build();
+
+        String property = config.get("key");
+
+        assertThat(property, CoreMatchers.notNullValue());
+        assertThat(property, CoreMatchers.containsString("ABC"));
+    }
+
+    @Test
+    public void canAddNonSPIPropertyFiltersViaConsecutiveCalls() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("M").when(source).get("key");
+        doReturn("source").when(source).getName();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySources(source)
+                                      .addPropertyFilters(new TestNonSPIPropertyFilterA())
+                                      .addPropertyFilters(new TestNonSPIPropertyFilterB())
+                                      .build();
+
+        String property = config.get("key");
+
+        assertThat(property, CoreMatchers.notNullValue());
+        assertThat(property, CoreMatchers.containsString("ABC"));
+        assertThat(property, CoreMatchers.containsString("XYZ"));
+    }
+
+    @Test
+    public void canAddMultipleNonSPIPropertyFiltersWhileOneIsNull() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("M").when(source).get("key");
+        doReturn("source").when(source).getName();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySources(source)
+                                      .addPropertyFilters(new TestNonSPIPropertyFilterA(),
+                                              null,
+                                              new TestNonSPIPropertyFilterB())
+                                      .build();
+
+        String property = config.get("key");
+
+        assertThat(property, CoreMatchers.notNullValue());
+        assertThat(property, CoreMatchers.containsString("ABC"));
+        assertThat(property, CoreMatchers.containsString("XYZ"));
+    }
+
+    @Test
+    public void overhandedNullPropertyFilterIsSafelyHandled() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("M").when(source).get("key");
+        doReturn("source").when(source).getName();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySources(source)
+                                      .addPropertyFilters((PropertyFilter)null) // The cast is needed!
+                                      .addPropertyFilters(new TestNonSPIPropertyFilterB())
+                                      .build();
+
+        String property = config.get("key");
+
+        assertThat(property, CoreMatchers.notNullValue());
+        assertThat(property, CoreMatchers.containsString("XYZ"));
+    }
+
+    @Test
+    public void canAddMultipleNonSPIPropertyFilter() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("M").when(source).get("key");
+        doReturn("source").when(source).getName();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySources(source)
+                                      .addPropertyFilters(new TestNonSPIPropertyFilterA(),
+                                                          new TestNonSPIPropertyFilterB())
+                                      .build();
+
+        String property = config.get("key");
+
+        assertThat(property, CoreMatchers.notNullValue());
+        assertThat(property, CoreMatchers.containsString("ABC"));
+        assertThat(property, CoreMatchers.containsString("XYZ"));
+    }
+
+    /*********************************************************************
+     * Tests for adding
+     * P r o p e r t y S o u r c e P r o v i d e r s
+     */
+
+    @Test
+    public void handlesSafelyPropertyProviderReturningNullInsteadOfPropertySource() {
+        PropertySourceProvider nullReturning = mock(PropertySourceProvider.class, NOT_MOCKED_ANSWER);
+
+        doReturn(asList((PropertySource)null)).when(nullReturning).getPropertySources();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySourceProviders(new TestPropertySourceProviderB(),
+                                                                  nullReturning,
+                                                                  new TestPropertySourceProvider())
+                                      .build();
+
+        assertThat(config.get("tpsp_a"), Matchers.equalTo("A"));
+        assertThat(config.get("tpsp_b"), Matchers.equalTo("B"));
+        assertThat(config.get("tpsp_x"), Matchers.equalTo("X"));
+        assertThat(config.get("tpsp_y"), Matchers.equalTo("Y"));
+
+        verify(nullReturning).getPropertySources();
+    }
+
+    @Test(expected = NullPointerException.class)
+    public void cannotAddNullAsPropertyProvider() {
+        new ConfigurationBuilder().addPropertySourceProviders(null);
+    }
+
+    @Test
+    public void canAddMultipleNonSPIPropertySourceProviders() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySourceProviders(new TestPropertySourceProviderB(),
+                                                                  new TestPropertySourceProvider())
+                                      .build();
+
+        assertThat(config.get("tpsp_a"), Matchers.equalTo("A"));
+        assertThat(config.get("tpsp_b"), Matchers.equalTo("B"));
+        assertThat(config.get("tpsp_x"), Matchers.equalTo("X"));
+        assertThat(config.get("tpsp_y"), Matchers.equalTo("Y"));
+    }
+
+    @Test
+    public void canAddMultipleNonSPIPropertySourceProvidersWhileOfOfThemIsNull() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySourceProviders(new TestPropertySourceProviderB(), null,
+                                                                  new TestPropertySourceProvider())
+                                      .build();
+
+        assertThat(config.get("tpsp_a"), Matchers.equalTo("A"));
+        assertThat(config.get("tpsp_b"), Matchers.equalTo("B"));
+        assertThat(config.get("tpsp_x"), Matchers.equalTo("X"));
+        assertThat(config.get("tpsp_y"), Matchers.equalTo("Y"));
+    }
+
+
+    /*********************************************************************
+     * Tests for adding
+     * P r o p e r t y V a l u e C o m b i n a t i o n P o l i c y
+     */
+
+    // @todo TAYAMA-60 Write more tests
+
+    /*********************************************************************
+     * Tests for enabling and disabling of automatic loading of
+     * P r o p e r t y S o u r c e s
+     */
+
+    @Test
+    public void enablingOfProvidedPropertySourceServiceProvidersIsOk() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.disableProvidedPropertyConverters()
+               .enableProvidedPropertyConverters();
+
+        assertThat(builder.isPropertyConverterLoadingEnabled(), is(true));
+    }
+
+    @Test
+    public void disablingOfProvidedPropertySourceServiceProvidersIsOk() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.enableProvidedPropertyConverters()
+               .disableProvidedPropertyConverters();
+
+        assertThat(builder.isPropertyConverterLoadingEnabled(), is(false));
+    }
+
+    @Test(expected = ConfigException.class)
+    public void loadingOrPropertyConvertersCanBeDisabled() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("source").when(source).getName();
+        doReturn("A").when(source).get("key");
+        doReturn(100).when(source).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(source)
+                                                                 .enableProvidedPropertyConverters()
+                                                                 .disableProvidedPropertyConverters();
+
+        Configuration config = builder.build();
+
+        config.get("key", CustomTypeC.class);
+    }
+
+    @Test
+    public void loadingOfPropertyConvertersCanBeEnabled() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("source").when(source).getName();
+        doReturn("A").when(source).get("key");
+        doReturn(100).when(source).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder().addPropertySources(source)
+                                                                 .disableProvidedPropertyConverters()
+                                                                 .enableProvidedPropertyConverters();
+
+        Configuration config = builder.build();
+
+        CustomTypeC result = config.get("key", CustomTypeC.class);
+
+        assertThat(result, notNullValue());
+        assertThat(result.getValue(), equalTo("A"));
+    }
+
+    /*********************************************************************
+     * Tests for enabling and disabling of automatic loading of
+     * P r o p e r t y S o u r c e s
+     */
+
+    @Test
+    public void enablingOfPropertySourceLoadingIsOk() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.disableProvidedPropertySources()
+               .enableProvidedPropertySources();
+
+        assertThat(builder.isPropertySourcesLoadingEnabled(), is(true));
+    }
+
+    @Test
+    public void disablingPropertySourceLoadingIsOk() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.enableProvidedPropertySources()
+               .disableProvidedPropertySources();
+
+        assertThat(builder.isPropertySourcesLoadingEnabled(), is(false));
+    }
+
+    @Test
+    public void loadingOfPropertySourcesCanBeEnabled() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.disableProvidedPropertySources()
+                                      .enableProvidedPropertySources()
+                                      .build();
+
+
+        assertThat(builder.isPropertySourcesLoadingEnabled(), is(true));
+        assertThat(config.get("tps_a"), Matchers.equalTo("A"));
+    }
+
+    @Test
+    public void loadingOfPropertySourcesCanBeDisabled() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.enableProvidedPropertySources()
+                                      .disableProvidedPropertySources()
+                                      .build();
+
+
+        assertThat(builder.isPropertySourcesLoadingEnabled(), is(false));
+        assertThat(config.get("tps_c"), Matchers.nullValue());
+    }
+
+    /*********************************************************************
+     * Tests for enabling and disabling of automatic loading of
+     * P r o p e r t y F i l t e r s
+     */
+
+    @Test
+    public void enablingOfPropertyFiltersLoadingIsOk() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("source").when(source).getName();
+        doReturn("A").when(source).get("key");
+        doReturn(100).when(source).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.disableProvidedPropertyFilters()
+                                      .enabledProvidedPropertyFilters()
+                                      .addPropertySources(source)
+                                      .build();
+
+        String property = config.get("key");
+
+        assertThat(property, CoreMatchers.notNullValue());
+        assertThat(property, Matchers.equalTo("AinBerlin"));
+    }
+
+    @Test
+    public void disablingOfPropertyFiltersLoadingIsOk() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.enabledProvidedPropertyFilters()
+               .disableProvidedPropertyFilters();
+
+        assertThat(builder.isPropertyFilterLoadingEnabled(), is(false));
+    }
+
+    @Test
+    public void loadingOfPropertyFiltersCanBeDisabled() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.disableProvidedPropertyFilters()
+               .enabledProvidedPropertyFilters();
+
+        assertThat(builder.isPropertyFilterLoadingEnabled(), is(true));
+    }
+
+    @Test
+    public void loadingOfPropertyFiltersCanBeEnabled() {
+        PropertySource source = mock(PropertySource.class, NOT_MOCKED_ANSWER);
+
+        doReturn("source").when(source).getName();
+        doReturn("A").when(source).get("key");
+        doReturn(100).when(source).getOrdinal();
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.enabledProvidedPropertyFilters()
+                                      .disableProvidedPropertyFilters()
+                                      .addPropertySources(source)
+                                      .build();
+
+        String property = config.get("key");
+
+        assertThat(property, CoreMatchers.notNullValue());
+        assertThat(property, Matchers.equalTo("A"));
+    }
+
+    /*********************************************************************
+     * Tests for enabling and disabling of automatic loading of
+     * P r o p e r t y S o u r c e P r o v i d e r s
+     */
+
+    @Test
+    public void disablingOfPropertySourceProvidersIsOk() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.enableProvidedPropertySourceProviders()
+               .disableProvidedPropertySourceProviders()
+               .build();
+
+        assertThat(builder.isPropertySourceProvidersLoadingEnabled(), is(false));
+    }
+
+    @Test
+    public void enablingOfPropertySourceProvidersIsOk() {
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.disableProvidedPropertySourceProviders()
+               .enableProvidedPropertySourceProviders()
+               .build();
+
+        assertThat(builder.isPropertySourceProvidersLoadingEnabled(), is(true));
+    }
+
+    @Test
+    public void loadingOfPropertySourceProvidersCanBeEnabled() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.disableProvidedPropertySourceProviders()
+                                      .enableProvidedPropertySourceProviders()
+                                      .build();
+
+        assertThat(builder.isPropertySourceProvidersLoadingEnabled(), is(true));
+        assertThat(config.get("tpsp_x"), Matchers.equalTo("X"));
+        assertThat(config.get("tpsp_y"), Matchers.equalTo("Y"));
+    }
+
+    @Test
+    public void loadingOfPropertySourceProvidersCanBeDisabled() {
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.enableProvidedPropertySourceProviders()
+                                      .disableProvidedPropertySourceProviders()
+                                      .build();
+
+        assertThat(builder.isPropertySourceProvidersLoadingEnabled(), is(false));
+        assertThat(config.get("tpsp_x"), nullValue());
+        assertThat(config.get("tpsp_x"), nullValue());
+    }
+
+    @Test(expected = ConfigException.class)
+    public void ioExceptionIsTurnedInConfigExceptionWhenLoadingResourceViaURL() throws Exception {
+        URL resource = this.getClass().getResource("/configfiles/json/simple.json");
+
+        assertThat(resource, CoreMatchers.notNullValue());
+
+        ConfigurationBuilder builder = mock(ConfigurationBuilder.class, CALLS_REAL_METHODS);
+
+        doThrow(IOException.class).when(builder).getConfigurationDataFromURL(Mockito.eq(resource));
+
+        builder.addPropertySource(resource).build();
+    }
+
+    /*********************************************************************
+     * Tests for loading resources via URL (as String)
+     */
+
+    @Test(expected = ConfigException.class)
+    public void tryToLoadOneUnsupportedPropertySourceViaStringURL() {
+        URL resource = this.getClass().getResource("/configfiles/other/simple.oml");
+
+        assertThat(resource, CoreMatchers.notNullValue());
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        builder.addPropertySource(resource.toString()).build();
+    }
+
+    @Test
+    public void loadOneJSONPropertySourceViaStringURL() {
+        URL resource = this.getClass().getResource("/configfiles/json/simple.json");
+
+        assertThat(resource, CoreMatchers.notNullValue());
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySource(resource.toString())
+                                      .build();
+
+        assertThat(config, CoreMatchers.notNullValue());
+        assertThat(config.get("a"), equalTo("A"));
+        assertThat(config.get("b"), equalTo("B"));
+    }
+
+    @Test
+    public void loadMultipleJSONPropertySourceViaStringURL() {
+        URL first = this.getClass().getResource("/configfiles/json/first.json");
+        URL second = this.getClass().getResource("/configfiles/json/second.json");
+        URL third = this.getClass().getResource("/configfiles/json/third.json");
+
+        assertThat(first, CoreMatchers.notNullValue());
+        assertThat(second, CoreMatchers.notNullValue());
+        assertThat(third, CoreMatchers.notNullValue());
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySource(first.toString(), second.toString(),
+                                                         null, third.toString())
+                                      .build();
+
+        assertThat(config, CoreMatchers.notNullValue());
+
+        // from first.json
+        assertThat(config.get("d"), equalTo("D"));
+        assertThat(config.get("e"), equalTo("E"));
+
+        // from second.json
+        assertThat(config.get("m"), equalTo("M"));
+        assertThat(config.get("n"), equalTo("N"));
+
+        // from thrid.json
+        assertThat(config.get("p"), equalTo("P"));
+        assertThat(config.get("q"), equalTo("Q"));
+    }
+
+    /**
+     * ******************************************************************
+     * Tests for loading resources via URL (as URL object)
+     */
+
+    @Test
+    public void loadOneJSONPropertySourceViaURL() {
+        URL resource = this.getClass().getResource("/configfiles/json/simple.json");
+
+        assertThat(resource, CoreMatchers.notNullValue());
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySource(resource)
+                                      .build();
+
+        assertThat(config, CoreMatchers.notNullValue());
+        assertThat(config.get("a"), equalTo("A"));
+        assertThat(config.get("b"), equalTo("B"));
+    }
+
+    @Test
+    public void loadMultipleJSONPropertySourceViaURL() {
+        URL first = this.getClass().getResource("/configfiles/json/first.json");
+        URL second = this.getClass().getResource("/configfiles/json/second.json");
+        URL third = this.getClass().getResource("/configfiles/json/third.json");
+
+        assertThat(first, CoreMatchers.notNullValue());
+        assertThat(second, CoreMatchers.notNullValue());
+        assertThat(third, CoreMatchers.notNullValue());
+
+        ConfigurationBuilder builder = new ConfigurationBuilder();
+
+        Configuration config = builder.addPropertySource(first, second,
+                                                         null, third)
+                                      .build();
+
+        assertThat(config, CoreMatchers.notNullValue());
+
+        // from first.json
+        assertThat(config.get("d"), equalTo("D"));
+        assertThat(config.get("e"), equalTo("E"));
+
+        // from second.json
+        assertThat(config.get("m"), equalTo("M"));
+        assertThat(config.get("n"), equalTo("N"));
+
+        // from thrid.json
+        assertThat(config.get("p"), equalTo("P"));
+        assertThat(config.get("q"), equalTo("Q"));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/TestNonSPIPropertyFilterA.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/TestNonSPIPropertyFilterA.java b/src/test/java/org/apache/tamaya/builder/TestNonSPIPropertyFilterA.java
new file mode 100644
index 0000000..4b9ae72
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/TestNonSPIPropertyFilterA.java
@@ -0,0 +1,34 @@
+/*
+ * 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.builder;
+
+import org.apache.tamaya.spi.PropertyFilter;
+
+public class TestNonSPIPropertyFilterA implements PropertyFilter {
+    @Override
+    public String filterProperty(String key, String value) {
+        String result = value;
+
+        if (!result.contains(("ABC"))) {
+            result = value + "ABC";
+        }
+
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/TestNonSPIPropertyFilterB.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/TestNonSPIPropertyFilterB.java b/src/test/java/org/apache/tamaya/builder/TestNonSPIPropertyFilterB.java
new file mode 100644
index 0000000..95112b0
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/TestNonSPIPropertyFilterB.java
@@ -0,0 +1,34 @@
+/*
+ * 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.builder;
+
+import org.apache.tamaya.spi.PropertyFilter;
+
+public class TestNonSPIPropertyFilterB implements PropertyFilter {
+    @Override
+    public String filterProperty(String key, String value) {
+        String result = value;
+
+        if (!result.contains(("XYZ"))) {
+            result = value + "XYZ";
+        }
+
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/TestPropertyFilter.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/TestPropertyFilter.java b/src/test/java/org/apache/tamaya/builder/TestPropertyFilter.java
new file mode 100644
index 0000000..80c4cb3
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/TestPropertyFilter.java
@@ -0,0 +1,34 @@
+/*
+ * 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.builder;
+
+import org.apache.tamaya.spi.PropertyFilter;
+
+public class TestPropertyFilter implements PropertyFilter {
+    @Override
+    public String filterProperty(String key, String value) {
+        String result = value;
+
+        if (!result.contains(("inBerlin"))) {
+            result = value + "inBerlin";
+        }
+
+        return result;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/TestPropertySource.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/TestPropertySource.java b/src/test/java/org/apache/tamaya/builder/TestPropertySource.java
new file mode 100644
index 0000000..54deca3
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/TestPropertySource.java
@@ -0,0 +1,58 @@
+/*
+ * 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.builder;
+
+import org.apache.tamaya.spi.PropertySource;
+
+import java.util.Collections;
+import java.util.Hashtable;
+import java.util.Map;
+
+public class TestPropertySource
+    implements PropertySource
+{
+    private Map<String, String> properties;
+
+    {
+        properties = new Hashtable<>(3);
+        properties.put("tps_a", "A");
+        properties.put("tps_b", "B");
+        properties.put("tps_c", "C");
+    }
+
+    @Override
+    public int getOrdinal() {
+        return 456;
+    }
+
+    @Override
+    public String getName() {
+        return "TestPropertySource";
+    }
+
+    @Override
+    public String get(String key) {
+        return getProperties().get(key);
+    }
+
+    @Override
+    public Map<String, String> getProperties() {
+        return Collections.unmodifiableMap(properties);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/TestPropertySourceProvider.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/TestPropertySourceProvider.java b/src/test/java/org/apache/tamaya/builder/TestPropertySourceProvider.java
new file mode 100644
index 0000000..4e7db79
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/TestPropertySourceProvider.java
@@ -0,0 +1,89 @@
+/*
+ * 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.builder;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertySourceProvider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+public class TestPropertySourceProvider
+    implements PropertySourceProvider
+{
+    @Override
+    public Collection<PropertySource> getPropertySources() {
+        ArrayList<PropertySource> sources = new ArrayList<>(2);
+
+        sources.add(new XProvidingPropertySource());
+        sources.add(new YProvidingPropertySource());
+
+        return sources;
+    }
+
+    private class YProvidingPropertySource implements PropertySource {
+        private Map<String, String> props = Collections.singletonMap("tpsp_x", "X");
+
+        @Override
+        public int getOrdinal() {
+            return 100;
+        }
+
+        @Override
+        public String getName() {
+            return "YProvidingPropertySource";
+        }
+
+        @Override
+        public String get(String key) {
+            return getProperties().get(key);
+        }
+
+        @Override
+        public Map<String, String> getProperties() {
+            return props;
+        }
+    }
+
+    private class XProvidingPropertySource implements PropertySource {
+        private Map<String, String> props = Collections.singletonMap("tpsp_y", "Y");
+
+        @Override
+        public Map<String, String> getProperties() {
+            return props;
+        }
+
+        @Override
+        public String get(String key) {
+            return getProperties().get(key);
+        }
+
+        @Override
+        public int getOrdinal() {
+            return 100;
+        }
+
+        @Override
+        public String getName() {
+            return "XProvidingPropertySource";
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/TestPropertySourceProviderB.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/TestPropertySourceProviderB.java b/src/test/java/org/apache/tamaya/builder/TestPropertySourceProviderB.java
new file mode 100644
index 0000000..ddfb132
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/TestPropertySourceProviderB.java
@@ -0,0 +1,89 @@
+/*
+ * 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.builder;
+
+import org.apache.tamaya.spi.PropertySource;
+import org.apache.tamaya.spi.PropertySourceProvider;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Map;
+
+public class TestPropertySourceProviderB
+    implements PropertySourceProvider
+{
+    @Override
+    public Collection<PropertySource> getPropertySources() {
+        ArrayList<PropertySource> sources = new ArrayList<>(2);
+
+        sources.add(new AProvidingPropertySource());
+        sources.add(new BProvidingPropertySource());
+
+        return sources;
+    }
+
+    private class BProvidingPropertySource implements PropertySource {
+        private Map<String, String> props = Collections.singletonMap("tpsp_b", "B");
+
+        @Override
+        public int getOrdinal() {
+            return 100;
+        }
+
+        @Override
+        public String getName() {
+            return "BProvidingPropertySource";
+        }
+
+        @Override
+        public String get(String key) {
+            return getProperties().get(key);
+        }
+
+        @Override
+        public Map<String, String> getProperties() {
+            return props;
+        }
+    }
+
+    private class AProvidingPropertySource implements PropertySource {
+        private Map<String, String> props = Collections.singletonMap("tpsp_a", "A");
+
+        @Override
+        public Map<String, String> getProperties() {
+            return props;
+        }
+
+        @Override
+        public String get(String key) {
+            return getProperties().get(key);
+        }
+
+        @Override
+        public int getOrdinal() {
+            return 100;
+        }
+
+        @Override
+        public String getName() {
+            return "AProvidingPropertySource";
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java b/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java
new file mode 100644
index 0000000..10b3734
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java
@@ -0,0 +1,55 @@
+/*
+ * 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.builder.util.mockito;
+
+import org.mockito.exceptions.base.MockitoException;
+import org.mockito.invocation.InvocationOnMock;
+import org.mockito.stubbing.Answer;
+
+import java.io.Serializable;
+
+// @todo This is a duplicated class
+public class NotMockedAnswer implements Answer<Object>, Serializable {
+    public final static NotMockedAnswer NOT_MOCKED_ANSWER = new NotMockedAnswer();
+
+    private NotMockedAnswer() {
+    }
+
+    @Override
+    public Object answer(InvocationOnMock invocation) throws Throwable {
+        StringBuilder msgBuilder = new StringBuilder();
+
+        msgBuilder.append("Invocation of method not mocked: ")
+                  .append(invocation.getMethod().toGenericString());
+
+        if (invocation.getArguments().length > 0) {
+            msgBuilder.append(" Supplied arguments: ");
+
+            for (int i = 0; i < invocation.getArguments().length; i++) {
+                msgBuilder.append(invocation.getArguments()[i]);
+
+                if (i - 1 < invocation.getArguments().length) {
+                    msgBuilder.append(", ");
+                }
+            }
+        }
+
+        throw new MockitoException(msgBuilder.toString());
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeA.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeA.java b/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeA.java
new file mode 100644
index 0000000..89b2f5b
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeA.java
@@ -0,0 +1,34 @@
+/*
+ * 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.builder.util.types;
+
+/**
+ * Custom type with two argument constructor.
+ */
+public class CustomTypeA {
+    private String name;
+
+    public CustomTypeA(String name, String other) {
+        this.name = name + other;
+    }
+
+    public String getName() {
+        return name;
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeB.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeB.java b/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeB.java
new file mode 100644
index 0000000..f7f4d99
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeB.java
@@ -0,0 +1,39 @@
+/*
+ * 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.builder.util.types;
+
+/**
+ * Custom type with factory method
+ * {@link org.apache.tamaya.builder.util.types.CustomTypeB#of(String)}
+ */
+public class CustomTypeB {
+    private String name;
+
+    private CustomTypeB(String value) {
+        this.name = value;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public static CustomTypeB of(String source) {
+        return new CustomTypeB(source);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeC.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeC.java b/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeC.java
new file mode 100644
index 0000000..da9ce56
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeC.java
@@ -0,0 +1,36 @@
+/*
+ * 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.builder.util.types;
+
+public class CustomTypeC {
+    private String value;
+
+
+    public CustomTypeC(String in, @SuppressWarnings("unused") int iHideThisConstructorForTamaya) {
+        value = in;
+    }
+
+    public String getValue() {
+        return value;
+    }
+
+    public static CustomTypeC produceFrom(String in) {
+        return new CustomTypeC(in, -1);
+    }
+}

http://git-wip-us.apache.org/repos/asf/incubator-tamaya-sandbox/blob/f78f6a11/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java
----------------------------------------------------------------------
diff --git a/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java b/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java
new file mode 100644
index 0000000..1754b30
--- /dev/null
+++ b/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java
@@ -0,0 +1,28 @@
+/*
+ * 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.builder.util.types;
+
+import org.apache.tamaya.PropertyConverter;
+
+public class CustomTypeCPropertyConverter implements PropertyConverter<org.apache.tamaya.builder.util.types.CustomTypeC> {
+    @Override
+    public org.apache.tamaya.builder.util.types.CustomTypeC convert(String value) {
+        return org.apache.tamaya.builder.util.types.CustomTypeC.produceFrom(value);
+    }
+}