Skip to content

Commit f8be18b

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 f8be18b

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,7 @@ 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);
114114
}
115115

116116
@Test
@@ -134,8 +134,14 @@ public void testAliasedEnumForwardsAndBackwardsCompatible() throws IOException {
134134
SchemaCompatibility.SchemaPairCompatibility forwardsCompatibility =
135135
SchemaCompatibility.checkReaderWriterCompatibility(newSchema, oldSchema);
136136
//
137-
assertThat(backwardsCompatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
138-
assertThat(forwardsCompatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
137+
checkSchemaIsCompatible(backwardsCompatibility);
138+
checkSchemaIsCompatible(forwardsCompatibility);
139+
}
140+
141+
private void checkSchemaIsCompatible(SchemaCompatibility.SchemaPairCompatibility compatibility) {
142+
assertThat(compatibility.getType())
143+
.withFailMessage("Expected schema to be compatible but was not. Reason:\n%s", compatibility.getDescription())
144+
.isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
139145
}
140146

141147
}

0 commit comments

Comments
 (0)