use of com.hortonworks.registries.schemaregistry.CompatibilityResult in project registry by hortonworks.
the class AvroCompatibilityCheckerTest method testBackwardCompatibility.
@Test
public void testBackwardCompatibility() throws Exception {
CompatibilityResult compatibilityResult = new AvroSchemaProvider().checkCompatibility(fetchResourceText("/avro/book-backward.avsc"), initialVersionSchema(), SchemaCompatibility.BACKWARD);
Assert.assertTrue(compatibilityResult.isCompatible());
}
use of com.hortonworks.registries.schemaregistry.CompatibilityResult in project registry by hortonworks.
the class AvroCompatibilityCheckerTest method testNoneCompatibility.
@Test
public void testNoneCompatibility() throws Exception {
CompatibilityResult compatibilityResult = new AvroSchemaProvider().checkCompatibility(fetchResourceText("/avro/user.avsc"), initialVersionSchema(), SchemaCompatibility.NONE);
Assert.assertTrue(compatibilityResult.isCompatible());
}
use of com.hortonworks.registries.schemaregistry.CompatibilityResult in project registry by hortonworks.
the class AvroCompatibilityCheckerTest method testFullCompatibility.
@Test
public void testFullCompatibility() throws Exception {
CompatibilityResult compatibilityResult = new AvroSchemaProvider().checkCompatibility(fetchResourceText("/avro/book-both.avsc"), initialVersionSchema(), SchemaCompatibility.BOTH);
Assert.assertTrue(compatibilityResult.isCompatible());
}
use of com.hortonworks.registries.schemaregistry.CompatibilityResult in project registry by hortonworks.
the class SchemaRegistryResource method checkCompatibilityWithSchema.
@POST
@Path("/schemas/{name}/compatibility")
@ApiOperation(value = "Checks if the given schema text is compatible with all the versions of the schema identified by the name", response = CompatibilityResult.class, tags = OPERATION_GROUP_SCHEMA)
@Timed
@UnitOfWork
public Response checkCompatibilityWithSchema(@QueryParam("branch") @DefaultValue(MASTER_BRANCH) String schemaBranchName, @ApiParam(value = "Schema name", required = true) @PathParam("name") String schemaName, @ApiParam(value = "schema text", required = true) String schemaText) {
Response response;
try {
CompatibilityResult compatibilityResult = schemaRegistry.checkCompatibility(schemaBranchName, schemaName, schemaText);
response = WSUtils.respondEntity(compatibilityResult, Response.Status.OK);
} catch (SchemaNotFoundException e) {
LOG.error("No schemas found with schemakey: [{}]", schemaName, e);
response = WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, schemaName);
} catch (SchemaBranchNotFoundException e) {
return WSUtils.respond(Response.Status.NOT_FOUND, CatalogResponse.ResponseMessage.ENTITY_NOT_FOUND, e.getMessage());
} catch (Exception ex) {
LOG.error("Encountered error while checking compatibility with versions of schema with [{}] for given schema text [{}]", schemaName, schemaText, ex);
response = WSUtils.respond(Response.Status.INTERNAL_SERVER_ERROR, CatalogResponse.ResponseMessage.EXCEPTION, ex.getMessage());
}
return response;
}
use of com.hortonworks.registries.schemaregistry.CompatibilityResult in project registry by hortonworks.
the class AvroCompatibilityCheckerTest method testForwardCompatibility.
@Test
public void testForwardCompatibility() throws Exception {
CompatibilityResult compatibilityResult = new AvroSchemaProvider().checkCompatibility(fetchResourceText("/avro/book-forward.avsc"), initialVersionSchema(), SchemaCompatibility.FORWARD);
Assert.assertTrue(compatibilityResult.isCompatible());
}
Aggregations