Skip to content

Commit

Permalink
Fix configuration messages
Browse files Browse the repository at this point in the history
  • Loading branch information
adrienlauer committed Aug 28, 2018
1 parent a6b2e46 commit c0c2ad4
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

<groupId>org.seedstack.coffig</groupId>
<artifactId>coffig</artifactId>
<version>3.1.1-SNAPSHOT</version>
<version>3.1.2-SNAPSHOT</version>

<properties>
<shed.version>1.1.2</shed.version>
<shed.version>1.1.3</shed.version>

<compatibility.version>3.0.0</compatibility.version>

Expand Down
22 changes: 22 additions & 0 deletions src/test/java/org/seedstack/coffig/CoffigTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -156,4 +174,8 @@ private static class App {
String[] items;
String[] elements;
}

private static class ClassConfig {
private Class<? extends List> someListClass;
}
}

0 comments on commit c0c2ad4

Please sign in to comment.