Skip to content

Commit

Permalink
Improve error message in AvroAliasTest
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
apupier committed Jan 5, 2024
1 parent 23f40d9 commit f8be18b
Showing 1 changed file with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public void testAliasedRecordForwardsCompatible() throws IOException {
SchemaCompatibility.SchemaPairCompatibility compatibility =
SchemaCompatibility.checkReaderWriterCompatibility(newSchema, oldSchema);
//
assertThat(compatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
checkSchemaIsCompatible(compatibility);
}

@Test
Expand All @@ -88,7 +88,7 @@ public void testAliasedRecordForwardsCompatibleSameNamespace() throws IOExceptio
SchemaCompatibility.SchemaPairCompatibility compatibility =
SchemaCompatibility.checkReaderWriterCompatibility(newSchema, oldSchema);
//
assertThat(compatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
checkSchemaIsCompatible(compatibility);
}

@Test
Expand All @@ -110,7 +110,7 @@ public void testAliasedEnumForwardsCompatible() throws IOException {
SchemaCompatibility.SchemaPairCompatibility compatibility =
SchemaCompatibility.checkReaderWriterCompatibility(newSchema, oldSchema);
//
assertThat(compatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
checkSchemaIsCompatible(compatibility);
}

@Test
Expand All @@ -134,8 +134,14 @@ public void testAliasedEnumForwardsAndBackwardsCompatible() throws IOException {
SchemaCompatibility.SchemaPairCompatibility forwardsCompatibility =
SchemaCompatibility.checkReaderWriterCompatibility(newSchema, oldSchema);
//
assertThat(backwardsCompatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
assertThat(forwardsCompatibility.getType()).isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
checkSchemaIsCompatible(backwardsCompatibility);
checkSchemaIsCompatible(forwardsCompatibility);
}

private void checkSchemaIsCompatible(SchemaCompatibility.SchemaPairCompatibility compatibility) {
assertThat(compatibility.getType())
.withFailMessage("Expected schema to be compatible but was not. Reason:\n%s", compatibility.getDescription())
.isEqualTo(SchemaCompatibility.SchemaCompatibilityType.COMPATIBLE);
}

}

0 comments on commit f8be18b

Please sign in to comment.