diff --git a/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala b/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala index 50add6786..3604e6a27 100644 --- a/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala +++ b/config/src/test/scala/com/typesafe/config/impl/ConfigValueTest.scala @@ -280,13 +280,13 @@ class ConfigValueTest extends TestUtils { } /** - * Reproduces the issue #461. - *
- * We use a custom de-/serializer that encodes String objects in a JDK-incompatible way. Encoding used here - * is rather simplistic: a long indicating the length in bytes (JDK uses a variable length integer) followed - * by the string's bytes. Running this test with the original SerializedConfigValue.readExternal() - * implementation results in an EOFException thrown during deserialization. - */ + * Reproduces the issue #461. + *
+ * We use a custom de-/serializer that encodes String objects in a JDK-incompatible way. Encoding used here + * is rather simplistic: a long indicating the length in bytes (JDK uses a variable length integer) followed + * by the string's bytes. Running this test with the original SerializedConfigValue.readExternal() + * implementation results in an EOFException thrown during deserialization. + */ @Test def configConfigCustomSerializable() { val aMap = configMap("a" -> 1, "b" -> 2, "c" -> 3) @@ -295,7 +295,7 @@ class ConfigValueTest extends TestUtils { assertEquals(expected, actual) } - + @Test def configListEquality() { val aScalaSeq = Seq(1, 2, 3) map { intValue(_): AbstractConfigValue } diff --git a/config/src/test/scala/com/typesafe/config/impl/TestUtils.scala b/config/src/test/scala/com/typesafe/config/impl/TestUtils.scala index 13ccd1600..24e6a07e6 100644 --- a/config/src/test/scala/com/typesafe/config/impl/TestUtils.scala +++ b/config/src/test/scala/com/typesafe/config/impl/TestUtils.scala @@ -74,8 +74,8 @@ abstract trait TestUtils { private object notEqualToAnything extends NotEqualToAnythingElse private def checkNotEqualToRandomOtherThing(a: Any) { - assertFalse(a.equals(notEqualToAnything)) - assertFalse(notEqualToAnything.equals(a)) + assertFalse("not any", a.equals(notEqualToAnything)) + assertFalse("any not", notEqualToAnything.equals(a)) } protected def checkNotEqualObjects(a: Any, b: Any) { @@ -92,9 +92,9 @@ abstract trait TestUtils { } protected def checkEqualObjects(a: Any, b: Any) { - assertTrue(a.equals(b)) - assertTrue(b.equals(a)) - assertTrue(a.hashCode() == b.hashCode()) + assertTrue("a equals b", a.equals(b)) + assertTrue("b equals a", b.equals(a)) + assertTrue("a.hashCode equals b.hashCode", a.hashCode() == b.hashCode()) checkNotEqualToRandomOtherThing(a) checkNotEqualToRandomOtherThing(b) } diff --git a/config/src/test/scala/com/typesafe/config/impl/ValidationTest.scala b/config/src/test/scala/com/typesafe/config/impl/ValidationTest.scala index 6dce7bfee..5e45aad61 100644 --- a/config/src/test/scala/com/typesafe/config/impl/ValidationTest.scala +++ b/config/src/test/scala/com/typesafe/config/impl/ValidationTest.scala @@ -97,6 +97,21 @@ class ValidationTest extends TestUtils { checkValidationException(e, expecteds) } + @Test + def validationFailedSerializable(): Unit = { + // Reusing a previous test case to generate an error + val reference = parseConfig("""{ a : [{},{},{}] }""") + val conf = parseConfig("""{ a : 42 }""") + val e = intercept[ConfigException.ValidationFailed] { + conf.checkValid(reference) + } + + val expecteds = Seq(WrongType("a", 1, "list", "number")) + + val actual = checkSerializableNoMeaningfulEquals(e) + checkValidationException(actual, expecteds) + } + @Test def validationAllowsListOverriddenWithSameTypeList() { val reference = parseConfig("""{ a : [1,2,3] }""")