diff --git a/CHANGELOG.md b/CHANGELOG.md index ba4ed72..b4385a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# Version 3.1.2 (2018-08-29) + +* [fix] Fixed missing detailed error messages for configuration exceptions. + # Version 3.1.1 (2018-07-31) * [fix] Always make ServiceLoader use the most complete classloader it can find. diff --git a/pom.xml b/pom.xml index d6e9879..64d688d 100644 --- a/pom.xml +++ b/pom.xml @@ -19,10 +19,10 @@ org.seedstack.coffig coffig - 3.1.1-SNAPSHOT + 3.1.2-SNAPSHOT - 1.1.2 + 1.1.3 3.0.0 diff --git a/src/main/resources/org/seedstack/coffig/ConfigurationErrorCode.properties b/src/main/resources/org/seedstack/coffig/internal/ConfigurationErrorCode.properties similarity index 100% rename from src/main/resources/org/seedstack/coffig/ConfigurationErrorCode.properties rename to src/main/resources/org/seedstack/coffig/internal/ConfigurationErrorCode.properties diff --git a/src/test/java/org/seedstack/coffig/CoffigTest.java b/src/test/java/org/seedstack/coffig/CoffigTest.java index ce02e6b..cdf686e 100644 --- a/src/test/java/org/seedstack/coffig/CoffigTest.java +++ b/src/test/java/org/seedstack/coffig/CoffigTest.java @@ -9,7 +9,9 @@ package org.seedstack.coffig; import static org.assertj.core.api.Assertions.assertThat; +import static org.assertj.core.api.Assertions.fail; +import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import org.junit.Test; import org.seedstack.coffig.fixture.EnumFixture; @@ -37,6 +39,9 @@ public class CoffigTest { new MapNode(new NamedNode("key1", mutableValue2), new NamedNode("key2", mutableValue3))), new NamedNode("items", "one")); + private final ConfigurationProvider classConfigProvider = () -> new MapNode( + new NamedNode("someListClass", "java.lang.Object")); + @Test public void testConfigurationNotNull() { Coffig coffig = Coffig.builder().withProviders(new VoidProvider()).build(); @@ -107,6 +112,19 @@ public void testGetMapAsArray() throws Exception { assertThat(coffig.get(App.class).elements).containsOnly("val1", "val2"); } + @Test + public void testErrorMessages() throws Exception { + Coffig coffig = Coffig.builder().withProviders(classConfigProvider).build(); + try { + coffig.get(ClassConfig.class); + fail("should have thrown a ConfigurationException"); + } catch (ConfigurationException e) { + assertThat(e.getMessage()).isEqualTo("[CONFIGURATION] Non assignable class"); + assertThat(e.getDescription()) + .isEqualTo("Class 'java.lang.Object' is not assignable to '? extends java.util.List'."); + } + } + @Test public void testListeners() { AtomicInteger listener0CallCount = new AtomicInteger(); @@ -156,4 +174,8 @@ private static class App { String[] items; String[] elements; } + + private static class ClassConfig { + private Class someListClass; + } }