Skip to content

Commit 55a2e3d

Browse files
committed
Improve error message in AvroAliasTest
it gives the reason of schema incompatibility when the schema is expected to be compatible. It can help investigation on FasterXML#167 Signed-off-by: Aurélien Pupier <[email protected]>
1 parent 23f40d9 commit 55a2e3d

File tree

1 file changed

+11
-5
lines changed
  • avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations

1 file changed

+11
-5
lines changed

avro/src/test/java/com/fasterxml/jackson/dataformat/avro/interop/annotations/AvroAliasTest.java

+11-5
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ public void testAliasedRecordForwardsCompatible() throws IOException {
6666
SchemaCompatibility.SchemaPairCompatibility compatibility =
6767
SchemaCompatibility.checkReaderWriterCompatibility(newSchema, oldSchema);
6868
//
69-
assertThat(compatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
69+
checkSchemaIsCompatible(compatibility);
7070
}
7171

7272
@Test
@@ -88,7 +88,7 @@ public void testAliasedRecordForwardsCompatibleSameNamespace() throws IOExceptio
8888
SchemaCompatibility.SchemaPairCompatibility compatibility =
8989
SchemaCompatibility.checkReaderWriterCompatibility(newSchema, oldSchema);
9090
//
91-
assertThat(compatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
91+
checkSchemaIsCompatible(compatibility);
9292
}
9393

9494
@Test
@@ -110,7 +110,13 @@ public void testAliasedEnumForwardsCompatible() throws IOException {
110110
SchemaCompatibility.SchemaPairCompatibility compatibility =
111111
SchemaCompatibility.checkReaderWriterCompatibility(newSchema, oldSchema);
112112
//
113-
assertThat(compatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
113+
checkSchemaIsCompatible(compatibility);
114+
}
115+
116+
private void checkSchemaIsCompatible(SchemaCompatibility.SchemaPairCompatibility compatibility) {
117+
assertThat(compatibility.getType())
118+
.withFailMessage("Expected schema to be compatible but was not. Reason:\n%s", compatibility.getDescription())
119+
.isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
114120
}
115121

116122
@Test
@@ -134,8 +140,8 @@ public void testAliasedEnumForwardsAndBackwardsCompatible() throws IOException {
134140
SchemaCompatibility.SchemaPairCompatibility forwardsCompatibility =
135141
SchemaCompatibility.checkReaderWriterCompatibility(newSchema, oldSchema);
136142
//
137-
assertThat(backwardsCompatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
138-
assertThat(forwardsCompatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
143+
checkSchemaIsCompatible(backwardsCompatibility);
144+
checkSchemaIsCompatible(forwardsCompatibility);
139145
}
140146

141147
}

0 commit comments

Comments
 (0)