tamaya-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From anat...@apache.org
Subject [02/10] incubator-tamaya git commit: TAMAYA-128: Added ConversionContext for supporting more complex conversion cases.
Date Thu, 29 Oct 2015 12:09:55 GMT
TAMAYA-128: Added ConversionContext for supporting more complex conversion cases.


Project: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/commit/b0cba86f
Tree: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/tree/b0cba86f
Diff: http://git-wip-us.apache.org/repos/asf/incubator-tamaya/diff/b0cba86f

Branch: refs/heads/master
Commit: b0cba86f19e24e3c6aef8df4dfa6627d4a5918b7
Parents: a037268
Author: Anatole Tresch <anatole@apache.org>
Authored: Thu Oct 29 11:40:27 2015 +0100
Committer: Anatole Tresch <anatole@apache.org>
Committed: Thu Oct 29 11:40:27 2015 +0100

----------------------------------------------------------------------
 modules/builder/pom.xml                         |   8 +-
 .../tamaya/builder/ConfigurationBuilder.java    |  48 ++---
 .../ProgrammaticConfigurationContext.java       | 205 +++++++++----------
 .../builder/ConfigurationBuilderTest.java       |  34 ++-
 .../builder/util/mockito/NotMockedAnswer.java   |   4 +-
 .../types/CustomTypeCPropertyConverter.java     |   3 +-
 6 files changed, 151 insertions(+), 151 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b0cba86f/modules/builder/pom.xml
----------------------------------------------------------------------
diff --git a/modules/builder/pom.xml b/modules/builder/pom.xml
index 710e5e7..746af5e 100644
--- a/modules/builder/pom.xml
+++ b/modules/builder/pom.xml
@@ -54,7 +54,13 @@ under the License.
             <groupId>org.apache.tamaya</groupId>
             <artifactId>tamaya-core</artifactId>
             <version>${project.version}</version>
-            <scope>provided</scope>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.tamaya.ext</groupId>
+            <artifactId>tamaya-spisupport</artifactId>
+            <version>${project.version}</version>
         </dependency>
 
         <dependency>

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b0cba86f/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
b/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
index 82eb3eb..ad92d51 100644
--- a/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
+++ b/modules/builder/src/main/java/org/apache/tamaya/builder/ConfigurationBuilder.java
@@ -22,7 +22,6 @@ import org.apache.tamaya.ConfigException;
 import org.apache.tamaya.Configuration;
 import org.apache.tamaya.spi.PropertyConverter;
 import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.core.internal.DefaultConfiguration;
 import org.apache.tamaya.format.ConfigurationData;
 import org.apache.tamaya.format.ConfigurationFormats;
 import org.apache.tamaya.format.FlattenedDefaultPropertySource;
@@ -31,16 +30,13 @@ import org.apache.tamaya.spi.PropertyFilter;
 import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertySourceProvider;
 import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
+import org.apache.tamaya.spisupport.DefaultConfiguration;
 
 import java.io.IOException;
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Arrays;
 import java.util.Collection;
 import java.util.Objects;
-import java.util.function.Function;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 import static java.lang.String.format;
 
@@ -187,12 +183,11 @@ public class ConfigurationBuilder {
      * @see org.apache.tamaya.format.ConfigurationFormats#getFormats()
      */
     public ConfigurationBuilder addPropertySources(URL... urls) {
-        Stream.of(Arrays.asList(urls))
-              .flatMap(Collection::stream)
-              .filter(entry -> entry != null)
-              .collect(Collectors.toList())
-              .forEach(this::addPropertySource);
-
+        for(URL url:urls){
+            if(url!=null){
+                addPropertySource(url);
+            }
+        }
         return this;
     }
 
@@ -218,9 +213,11 @@ public class ConfigurationBuilder {
      * @see org.apache.tamaya.format.ConfigurationFormats#getFormats()
      */
     public ConfigurationBuilder addPropertySources(Collection<URL> urls) {
-        urls.stream()
-                .filter(entry -> entry != null)
-                .forEach(this::addPropertySource);
+        for(URL url:urls) {
+            if (url != null) {
+                addPropertySource(url);
+            }
+        }
         return this;
     }
 
@@ -245,13 +242,15 @@ public class ConfigurationBuilder {
      * @see org.apache.tamaya.format.ConfigurationFormats#getFormats()
      */
     public ConfigurationBuilder addPropertySources(String... urls) {
-        Stream.of(Arrays.asList(urls))
-              .flatMap(Collection::stream)
-              .filter(entry -> entry != null)
-              .map(new StringToURLMapper())
-              .collect(Collectors.toList())
-              .forEach(this::addPropertySource);
-
+        for(String url:urls) {
+            if (url != null) {
+                try{
+                    addPropertySource(new URL(url));
+                } catch(Exception e){
+                    throw new ConfigException("Invalid URL: " + url);
+                }
+            }
+        }
         return this;
     }
 
@@ -360,8 +359,7 @@ public class ConfigurationBuilder {
     public <T> ConfigurationBuilder addPropertyConverter(Class<T> type, PropertyConverter<T>
converter) {
         Objects.requireNonNull(type);
         Objects.requireNonNull(converter);
-
-        return addPropertyConverter(TypeLiteral.of(type), converter);
+        return addPropertyConverter(TypeLiteral.of(type), (PropertyConverter<Object>)converter);
     }
 
     /**
@@ -370,7 +368,6 @@ public class ConfigurationBuilder {
     public <T> ConfigurationBuilder addPropertyConverter(TypeLiteral<T> type,
PropertyConverter<T> propertyConverter){
         Objects.requireNonNull(type);
         Objects.requireNonNull(propertyConverter);
-
         contextBuilder.addPropertyConverter(type, propertyConverter);
         return this;
     }
@@ -591,8 +588,7 @@ public class ConfigurationBuilder {
     /**
      * Mapper to map a URL given as string to an URL instance.
      */
-    private static class StringToURLMapper implements Function<String, URL> {
-        @Override
+    private static class StringToURLMapper {
         public URL apply(String u) {
             try {
                 return new URL(u);

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b0cba86f/modules/builder/src/main/java/org/apache/tamaya/builder/ProgrammaticConfigurationContext.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/main/java/org/apache/tamaya/builder/ProgrammaticConfigurationContext.java
b/modules/builder/src/main/java/org/apache/tamaya/builder/ProgrammaticConfigurationContext.java
index 9f675dc..b67d18a 100644
--- a/modules/builder/src/main/java/org/apache/tamaya/builder/ProgrammaticConfigurationContext.java
+++ b/modules/builder/src/main/java/org/apache/tamaya/builder/ProgrammaticConfigurationContext.java
@@ -21,7 +21,6 @@ package org.apache.tamaya.builder;
 
 import org.apache.tamaya.spi.PropertyConverter;
 import org.apache.tamaya.TypeLiteral;
-import org.apache.tamaya.core.internal.PropertyConverterManager;
 import org.apache.tamaya.spi.ConfigurationContext;
 import org.apache.tamaya.spi.ConfigurationContextBuilder;
 import org.apache.tamaya.spi.PropertyFilter;
@@ -29,25 +28,15 @@ import org.apache.tamaya.spi.PropertySource;
 import org.apache.tamaya.spi.PropertySourceProvider;
 import org.apache.tamaya.spi.PropertyValueCombinationPolicy;
 import org.apache.tamaya.spi.ServiceContextManager;
+import org.apache.tamaya.spisupport.PriorityServiceComparator;
+import org.apache.tamaya.spisupport.PropertyConverterManager;
+import org.apache.tamaya.spisupport.PropertySourceComparator;
 
 import javax.annotation.Priority;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.concurrent.locks.Lock;
 import java.util.concurrent.locks.StampedLock;
-import java.util.function.Function;
-import java.util.function.Predicate;
 import java.util.logging.Logger;
-import java.util.stream.Collectors;
-import java.util.stream.Stream;
-
-import static java.util.stream.Collectors.toList;
 
 /**
  * Implementation of the {@link org.apache.tamaya.spi.ConfigurationContext}
@@ -56,6 +45,8 @@ import static java.util.stream.Collectors.toList;
  */
 class ProgrammaticConfigurationContext implements ConfigurationContext {
 
+    private static final Comparator<PropertySource> PS_COMPARATOR = new PropertySourceComparator();
+    private static final Comparator<Object> COMP_COMPARATOR = new PriorityServiceComparator();
     /**
      * The logger used.
      */
@@ -96,75 +87,78 @@ class ProgrammaticConfigurationContext implements ConfigurationContext
{
     public ProgrammaticConfigurationContext(Builder builder) {
         propertyConverterManager = new PropertyConverterManager(builder.loadProvidedPropertyConverters);
 
-        immutablePropertySources = getAllPropertySources(builder).stream()
-                                                                 .sorted(this::comparePropertySources)
-                                                                 .collect(Collectors.toList());
+        List<PropertySource> sources = getAllPropertySources(builder);
+        Collections.sort(sources, PS_COMPARATOR);
+        immutablePropertySources = Collections.unmodifiableList(sources);
 
 
-        immutablePropertyFilters = getPropertyFilters(builder).stream()
-                                                              .sorted(this::comparePropertyFilters)
-                                                              .collect(toList());
+        List<PropertyFilter> filters = getPropertyFilters(builder);
+        Collections.sort(filters, COMP_COMPARATOR);
+        immutablePropertyFilters = Collections.unmodifiableList(filters);
 
 
         propertyValueCombinationPolicy = builder.propertyValueCombinationPolicy;
+        for(Map.Entry<TypeLiteral<?>, List<PropertyConverter<?>>>
en: builder.propertyConverters.entrySet()){
+            if(en!=null){
+                for(PropertyConverter pv:en.getValue()) {
+                    propertyConverterManager.register(en.getKey(), pv);
+                }
+            }
+        }
 
-        builder.propertyConverters.forEach((literal, converters) -> {
-            converters.stream().filter(c -> c != null)
-                      .forEach(c -> propertyConverterManager.register((TypeLiteral<Object>)
literal,
-                                                                      (PropertyConverter<Object>)
c));
-        });
-
-        LOG.info(() -> "Using " + immutablePropertySources.size() + " property sources:
" +
-                createStringList(immutablePropertySources, ps -> ps.getName() + '[' +
ps.getClass().getName() + ']'));
-
-
-        LOG.info(() -> "Using " + immutablePropertyFilters.size() + " property filters:
" +
-                createStringList(immutablePropertyFilters, f -> f.getClass().getName()));
-
-
-        LOG.info(() -> "Using PropertyValueCombinationPolicy: " + propertyValueCombinationPolicy);
+        LOG.info("Using " + immutablePropertySources.size() + " property sources: " + immutablePropertySources);
+        LOG.info("Using " + immutablePropertyFilters.size() + " property filters: " + immutablePropertyFilters);
+        LOG.info("Using PropertyValueCombinationPolicy: " + propertyValueCombinationPolicy);
     }
 
     private List<PropertyFilter> getPropertyFilters(Builder builder) {
-        List<PropertyFilter> provided = builder.loadProvidedPropertyFilters
-                ? ServiceContextManager.getServiceContext().getServices(PropertyFilter.class)
-                : new ArrayList<>(0);
-
-        List<PropertyFilter> configured = builder.propertyFilters;
-
-        return Stream.of(provided, configured).flatMap(Collection::stream)
-                     .collect(toList());
+        List<PropertyFilter> provided = new ArrayList<>();
+        if(builder.loadProvidedPropertyFilters) {
+            provided.addAll(ServiceContextManager.getServiceContext().getServices(PropertyFilter.class));
+        }
+        for(PropertyFilter pf:builder.propertyFilters) {
+            if (pf != null) {
+                provided.add(pf);
+            }
+        }
+        return provided;
     }
 
     private List<PropertySource> getAllPropertySources(Builder builder) {
-        List<PropertySource> provided = builder.loadProvidedPropertySources
-                ? ServiceContextManager.getServiceContext().getServices(PropertySource.class)
-                : new ArrayList<>(0);
-
+        List<PropertySource> provided = new ArrayList<>();
+        if(builder.loadProvidedPropertySources) {
+            provided.addAll(ServiceContextManager.getServiceContext().getServices(PropertySource.class));
+        }
+        for(PropertySource ps:builder.propertySources){
+            if(ps!=null){
+                provided.add(ps);
+            }
+        }
         if (builder.loadProvidedPropertySourceProviders) {
             List<PropertySourceProvider> providers = ServiceContextManager.getServiceContext()
                                                                   .getServices(PropertySourceProvider.class);
             for (PropertySourceProvider provider : providers) {
-                Collection<PropertySource> sources = provider.getPropertySources();
-                provided.addAll(sources);
+                for(PropertySource ps:provider.getPropertySources()) {
+                    if(ps!=null) {
+                        provided.addAll(provider.getPropertySources());
+                    }
+                }
             }
         }
-
-        List<PropertySource> configured = builder.propertySources;
-
-        return Stream.of(provided, configured).flatMap(Collection::stream)
-                     .collect(toList());
+        return provided;
     }
 
     public void addPropertySources(PropertySource... propertySourcesToAdd) {
         Lock writeLock = propertySourceLock.asWriteLock();
         try {
             writeLock.lock();
-            List<PropertySource> newPropertySources = new ArrayList<>(this.immutablePropertySources);
-            newPropertySources.addAll(Arrays.asList(propertySourcesToAdd));
-            Collections.sort(newPropertySources, this::comparePropertySources);
-
-            this.immutablePropertySources = Collections.unmodifiableList(newPropertySources);
+            List<PropertySource> provided = new ArrayList<>();
+            for(PropertySource ps:propertySourcesToAdd){
+                if(ps!=null){
+                    provided.add(ps);
+                }
+            }
+            this.immutablePropertySources = Collections.unmodifiableList(provided);
         } finally {
             writeLock.unlock();
         }
@@ -224,7 +218,7 @@ class ProgrammaticConfigurationContext implements ConfigurationContext
{
 
     public <T> void addPropertyConverter(TypeLiteral<T> typeToConvert, PropertyConverter<T>
propertyConverter) {
         propertyConverterManager.register(typeToConvert, propertyConverter);
-        LOG.info(() -> "Added PropertyConverter: " + propertyConverter.getClass().getName());
+        LOG.info("Added PropertyConverter: " + propertyConverter.getClass().getName());
     }
 
     @Override
@@ -247,11 +241,6 @@ class ProgrammaticConfigurationContext implements ConfigurationContext
{
         return propertyValueCombinationPolicy;
     }
 
-    private <T> String createStringList(Collection<T> propertySources, Function<T,
String> mapper) {
-        StringBuilder joiner = new StringBuilder(", ");
-        propertySources.forEach(t -> joiner.append(mapper.apply(t)));
-        return joiner.toString();
-    }
 
     @Override
     public ConfigurationContextBuilder toBuilder() {
@@ -259,11 +248,6 @@ class ProgrammaticConfigurationContext implements ConfigurationContext
{
         throw new RuntimeException("This method is currently not supported.");
     }
 
-    public Collection<PropertySource> getPropertySources(Predicate<PropertySource>
selector) {
-        // @todo Check if it could be useful to support this method, Oliver B. Fischer
-        throw new RuntimeException("This method is currently not supported.");
-    }
-
     /**
      * The Builder for {@link ProgrammaticConfigurationContext}
      */
@@ -298,56 +282,56 @@ class ProgrammaticConfigurationContext implements ConfigurationContext
{
         }
 
         public Builder addPropertySources(PropertySource... propertySources) {
-            List<PropertySource> filtered = Stream.of(propertySources).filter(this::isNotNull)
-                                                  .collect(toList());
-
-            this.propertySources.addAll(filtered);
-
+            for (PropertySource ps : propertySources) {
+                if (ps != null) {
+                    this.propertySources.add(ps);
+                }
+            }
             return this;
         }
 
         public Builder addPropertySources(Collection<PropertySource> propertySources)
{
-            List<PropertySource> filtered = propertySources.stream().filter(this::isNotNull)
-                                                           .collect(toList());
-
-            this.propertySources.addAll(filtered);
-
+            for (PropertySource ps : propertySources) {
+                if (ps != null) {
+                    this.propertySources.add(ps);
+                }
+            }
             return this;
         }
 
         public Builder addPropertySourceProviders(PropertySourceProvider... propertySourceProviders)
{
-            List<PropertySourceProvider> providers = Stream.of(propertySourceProviders).filter(this::isNotNull)
-                                                           .collect(toList());
-
-            return addPropertySourceProviders(providers);
+            for (PropertySourceProvider ps : propertySourceProviders) {
+                if (ps != null) {
+                    this.propertySources.addAll(ps.getPropertySources());
+                }
+            }
+            return this;
         }
 
-        public Builder addPropertySourceProviders(Collection<PropertySourceProvider>
providers) {
-            List<PropertySource> filtered = providers.stream().filter(this::isNotNull)
-                                                     .flatMap(p -> p.getPropertySources().stream())
-                                                     .filter(this::isNotNull)
-                                                     .collect(toList());
-
-            this.propertySources.addAll(filtered);
-
+        public Builder addPropertySourceProviders(Collection<PropertySourceProvider>
propertySourceProviders) {
+            for (PropertySourceProvider ps : propertySourceProviders) {
+                if (ps != null) {
+                    this.propertySources.addAll(ps.getPropertySources());
+                }
+            }
             return this;
         }
 
-        public Builder addPropertyFilters(PropertyFilter... propertySources) {
-            List<PropertyFilter> sources = Stream.of(propertySources).filter(this::isNotNull)
-                                                 .collect(toList());
-
-            this.propertyFilters.addAll(sources);
-
+        public Builder addPropertyFilters(PropertyFilter... propertyFIlter) {
+            for (PropertyFilter pf : propertyFIlter) {
+                if (pf != null) {
+                    this.propertyFilters.add(pf);
+                }
+            }
             return this;
         }
 
-        public Builder addPropertyFilters(Collection<PropertyFilter> propertySources)
{
-            List<PropertyFilter> sources = propertySources.stream().filter(this::isNotNull)
-                                                          .collect(toList());
-
-            this.propertyFilters.addAll(sources);
-
+        public Builder addPropertyFilters(Collection<PropertyFilter> propertyFIlter)
{
+            for (PropertyFilter pf : propertyFIlter) {
+                if (pf != null) {
+                    this.propertyFilters.add(pf);
+                }
+            }
             return this;
         }
 
@@ -367,9 +351,11 @@ class ProgrammaticConfigurationContext implements ConfigurationContext
{
         //X TODO as overrides used first.
 
         public <T> Builder addPropertyConverter(TypeLiteral<T> type, PropertyConverter<T>
propertyConverter) {
-            propertyConverters.computeIfAbsent(type, (t) -> new ArrayList<>())
-                              .add(propertyConverter);
-
+            if(!propertyConverters.containsKey(type)){
+                List<PropertyConverter<?>> convList = new ArrayList<>();
+                convList.add(propertyConverter);
+                propertyConverters.put(type, convList);
+            }
             return this;
         }
 
@@ -394,9 +380,6 @@ class ProgrammaticConfigurationContext implements ConfigurationContext
{
             loadProvidedPropertyFilters = state;
         }
 
-        private <T> boolean isNotNull(T item) {
-            return null != item;
-        }
     }
 
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b0cba86f/modules/builder/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java
b/modules/builder/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java
index e5ec668..023fb27 100644
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java
+++ b/modules/builder/src/test/java/org/apache/tamaya/builder/ConfigurationBuilderTest.java
@@ -24,9 +24,7 @@ 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.apache.tamaya.spi.*;
 import org.hamcrest.CoreMatchers;
 import org.hamcrest.Matchers;
 import org.junit.Ignore;
@@ -273,9 +271,13 @@ public class ConfigurationBuilderTest {
     @Test(expected = NullPointerException.class)
     public void canNotAddNullTypeLiteralButPropertyConverter() {
         ConfigurationBuilder builder = new ConfigurationBuilder();
-
-        builder.addPropertyConverter((TypeLiteral<CustomTypeA>)null,
-                                     prop -> new CustomTypeA(prop, prop));
+        builder.addPropertyConverter((TypeLiteral)null,
+                new PropertyConverter() {
+                    @Override
+                    public CustomTypeA convert(final String prop, ConversionContext context)
{
+                        return new CustomTypeA(prop, prop);
+                    }
+                });
     }
 
     @Test
@@ -289,8 +291,13 @@ public class ConfigurationBuilderTest {
         ConfigurationBuilder builder = new ConfigurationBuilder();
 
         builder.addPropertyConverter(TypeLiteral.of(CustomTypeA.class),
-                                     prop -> new CustomTypeA(prop, prop))
-               .addPropertySources(source);
+                new PropertyConverter() {
+                    @Override
+                    public CustomTypeA convert(final String prop, ConversionContext context)
{
+                        return new CustomTypeA(prop, prop);
+                    }
+                });
+        builder.addPropertySources(source);
 
         Configuration config = builder.build();
 
@@ -313,9 +320,14 @@ public class ConfigurationBuilderTest {
 
         ConfigurationBuilder builder = new ConfigurationBuilder();
 
-        builder.addPropertyConverter(CustomTypeA.class,
-                                     prop -> new CustomTypeA(prop, prop))
-               .addPropertySources(source);
+        builder.addPropertyConverter(TypeLiteral.of(CustomTypeA.class),
+                new PropertyConverter() {
+                    @Override
+                    public CustomTypeA convert(final String prop, ConversionContext context)
{
+                        return new CustomTypeA(prop, prop);
+                    }
+                });
+        builder.addPropertySources(source);
 
         Configuration config = builder.build();
 

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b0cba86f/modules/builder/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java
b/modules/builder/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java
index 10b3734..3188d85 100644
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java
+++ b/modules/builder/src/test/java/org/apache/tamaya/builder/util/mockito/NotMockedAnswer.java
@@ -33,6 +33,9 @@ public class NotMockedAnswer implements Answer<Object>, Serializable
{
 
     @Override
     public Object answer(InvocationOnMock invocation) throws Throwable {
+        if("toString".equals(invocation.getMethod().getName())){
+            return "Some "+invocation.getMethod().getDeclaringClass().getName();
+        }
         StringBuilder msgBuilder = new StringBuilder();
 
         msgBuilder.append("Invocation of method not mocked: ")
@@ -49,7 +52,6 @@ public class NotMockedAnswer implements Answer<Object>, Serializable
{
                 }
             }
         }
-
         throw new MockitoException(msgBuilder.toString());
     }
 }

http://git-wip-us.apache.org/repos/asf/incubator-tamaya/blob/b0cba86f/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java
----------------------------------------------------------------------
diff --git a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java
b/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java
index c7d1490..9e56613 100644
--- a/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java
+++ b/modules/builder/src/test/java/org/apache/tamaya/builder/util/types/CustomTypeCPropertyConverter.java
@@ -18,11 +18,12 @@
  */
 package org.apache.tamaya.builder.util.types;
 
+import org.apache.tamaya.spi.ConversionContext;
 import org.apache.tamaya.spi.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) {
+    public org.apache.tamaya.builder.util.types.CustomTypeC convert(String value, ConversionContext
context) {
         return org.apache.tamaya.builder.util.types.CustomTypeC.produceFrom(value);
     }
 }


Mime
View raw message