Search in sources :

Example 31 with SchemaIdVersion

use of com.hortonworks.registries.schemaregistry.SchemaIdVersion in project registry by hortonworks.

the class SchemaBranchLifeCycleTest method deleteBranchWithEnabledSchema.

@Test(expected = InvalidSchemaBranchDeletionException.class)
public void deleteBranchWithEnabledSchema() throws IOException, SchemaBranchNotFoundException, InvalidSchemaException, SchemaNotFoundException, IncompatibleSchemaException, SchemaBranchAlreadyExistsException, InvalidSchemaBranchDeletionException, SchemaLifecycleException {
    SchemaMetadata schemaMetadata = addSchemaMetadata(testNameRule.getMethodName(), SchemaCompatibility.NONE);
    SchemaIdVersion masterSchemaIdVersion1 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device.avsc");
    SchemaBranch schemaBranch1 = addSchemaBranch("BRANCH1", schemaMetadata, masterSchemaIdVersion1.getSchemaVersionId());
    SchemaIdVersion schemaBranch1Version1 = addSchemaVersion(schemaBranch1.getName(), schemaMetadata, "/device-incompat.avsc");
    schemaRegistryClient.enableSchemaVersion(schemaBranch1Version1.getSchemaVersionId());
    schemaRegistryClient.deleteSchemaBranch(schemaBranch1.getId());
}
Also used : SchemaBranch(com.hortonworks.registries.schemaregistry.SchemaBranch) SchemaMetadata(com.hortonworks.registries.schemaregistry.SchemaMetadata) SchemaIdVersion(com.hortonworks.registries.schemaregistry.SchemaIdVersion) Test(org.junit.Test)

Example 32 with SchemaIdVersion

use of com.hortonworks.registries.schemaregistry.SchemaIdVersion in project registry by hortonworks.

the class SchemaBranchLifeCycleTest method getAllBranches.

@Test
public void getAllBranches() throws IOException, SchemaBranchNotFoundException, InvalidSchemaException, SchemaNotFoundException, IncompatibleSchemaException, SchemaBranchAlreadyExistsException {
    SchemaMetadata schemaMetadata = addSchemaMetadata(testNameRule.getMethodName(), SchemaCompatibility.NONE);
    SchemaIdVersion masterSchemaIdVersion1 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device.avsc");
    SchemaBranch schemaBranch1 = addSchemaBranch("BRANCH1", schemaMetadata, masterSchemaIdVersion1.getSchemaVersionId());
    SchemaIdVersion masterSchemaIdVersion2 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device-incompat.avsc");
    SchemaBranch schemaBranch2 = addSchemaBranch("BRANCH2", schemaMetadata, masterSchemaIdVersion2.getSchemaVersionId());
    Set<String> actualSchemaBranches = schemaRegistryClient.getSchemaBranches(schemaMetadata.getName()).stream().map(branch -> branch.getName()).collect(Collectors.toSet());
    Set<String> expectedSchemaBranches = new HashSet<>(Lists.newArrayList("MASTER", schemaBranch1.getName(), schemaBranch2.getName()));
    Assert.assertTrue(SetUtils.isEqualSet(actualSchemaBranches, expectedSchemaBranches));
}
Also used : Arrays(java.util.Arrays) SchemaVersion(com.hortonworks.registries.schemaregistry.SchemaVersion) SchemaBranchNotFoundException(com.hortonworks.registries.schemaregistry.errors.SchemaBranchNotFoundException) SchemaRegistryTestProfileType(com.hortonworks.registries.schemaregistry.avro.conf.SchemaRegistryTestProfileType) SchemaVersionLifecycleStates(com.hortonworks.registries.schemaregistry.state.SchemaVersionLifecycleStates) SchemaRegistryTestServerClientWrapper(com.hortonworks.registries.schemaregistry.avro.helper.SchemaRegistryTestServerClientWrapper) RunWith(org.junit.runner.RunWith) SchemaMetadata(com.hortonworks.registries.schemaregistry.SchemaMetadata) AvroSchemaRegistryClientUtil(com.hortonworks.registries.schemaregistry.avro.util.AvroSchemaRegistryClientUtil) HashSet(java.util.HashSet) Lists(com.google.common.collect.Lists) TestName(org.junit.rules.TestName) After(org.junit.After) SchemaVersionInfo(com.hortonworks.registries.schemaregistry.SchemaVersionInfo) Before(org.junit.Before) IncompatibleSchemaException(com.hortonworks.registries.schemaregistry.errors.IncompatibleSchemaException) SchemaCompatibility(com.hortonworks.registries.schemaregistry.SchemaCompatibility) InvalidSchemaException(com.hortonworks.registries.schemaregistry.errors.InvalidSchemaException) SetUtils(org.apache.commons.collections.SetUtils) Collection(java.util.Collection) InvalidSchemaBranchDeletionException(com.hortonworks.registries.schemaregistry.errors.InvalidSchemaBranchDeletionException) SchemaLifecycleException(com.hortonworks.registries.schemaregistry.state.SchemaLifecycleException) Set(java.util.Set) SchemaRegistryClient(com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient) Test(org.junit.Test) IOException(java.io.IOException) Collectors(java.util.stream.Collectors) SchemaBranch(com.hortonworks.registries.schemaregistry.SchemaBranch) Rule(org.junit.Rule) SchemaNotFoundException(com.hortonworks.registries.schemaregistry.errors.SchemaNotFoundException) CustomParameterizedRunner(com.hortonworks.registries.schemaregistry.avro.util.CustomParameterizedRunner) SchemaBranchAlreadyExistsException(com.hortonworks.registries.schemaregistry.errors.SchemaBranchAlreadyExistsException) Assert(org.junit.Assert) SchemaIdVersion(com.hortonworks.registries.schemaregistry.SchemaIdVersion) SchemaBranch(com.hortonworks.registries.schemaregistry.SchemaBranch) SchemaMetadata(com.hortonworks.registries.schemaregistry.SchemaMetadata) SchemaIdVersion(com.hortonworks.registries.schemaregistry.SchemaIdVersion) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 33 with SchemaIdVersion

use of com.hortonworks.registries.schemaregistry.SchemaIdVersion in project registry by hortonworks.

the class SchemaBranchLifeCycleTest method addSchemaVersion.

private SchemaIdVersion addSchemaVersion(String schemaBranchName, SchemaMetadata schemaMetadata, String pathToSchema) throws IOException, SchemaNotFoundException, InvalidSchemaException, IncompatibleSchemaException {
    String schema = AvroSchemaRegistryClientUtil.getSchema(pathToSchema);
    SchemaIdVersion schemaIdVersion = schemaRegistryClient.addSchemaVersion(schemaBranchName, schemaMetadata, new SchemaVersion(schema, "schema version description"));
    return schemaIdVersion;
}
Also used : SchemaVersion(com.hortonworks.registries.schemaregistry.SchemaVersion) SchemaIdVersion(com.hortonworks.registries.schemaregistry.SchemaIdVersion)

Example 34 with SchemaIdVersion

use of com.hortonworks.registries.schemaregistry.SchemaIdVersion in project registry by hortonworks.

the class SchemaBranchLifeCycleTest method deleteInvalidSchemaBranch.

@Test(expected = SchemaBranchNotFoundException.class)
public void deleteInvalidSchemaBranch() throws IOException, SchemaBranchNotFoundException, InvalidSchemaException, SchemaNotFoundException, IncompatibleSchemaException, SchemaBranchAlreadyExistsException, InvalidSchemaBranchDeletionException {
    SchemaMetadata schemaMetadata = addSchemaMetadata(testNameRule.getMethodName(), SchemaCompatibility.NONE);
    SchemaIdVersion masterSchemaIdVersion1 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device.avsc");
    SchemaBranch schemaBranch1 = addSchemaBranch("BRANCH1", schemaMetadata, masterSchemaIdVersion1.getSchemaVersionId());
    addSchemaVersion(schemaBranch1.getName(), schemaMetadata, "/device-incompat.avsc");
    schemaRegistryClient.deleteSchemaBranch(schemaBranch1.getId() + 1);
}
Also used : SchemaBranch(com.hortonworks.registries.schemaregistry.SchemaBranch) SchemaMetadata(com.hortonworks.registries.schemaregistry.SchemaMetadata) SchemaIdVersion(com.hortonworks.registries.schemaregistry.SchemaIdVersion) Test(org.junit.Test)

Example 35 with SchemaIdVersion

use of com.hortonworks.registries.schemaregistry.SchemaIdVersion in project registry by hortonworks.

the class SchemaBranchLifeCycleTest method deleteBranchWithArchivedSchema.

@Test
public void deleteBranchWithArchivedSchema() throws InvalidSchemaException, SchemaNotFoundException, IncompatibleSchemaException, IOException, SchemaBranchAlreadyExistsException, SchemaLifecycleException, InvalidSchemaBranchDeletionException {
    SchemaMetadata schemaMetadata = addSchemaMetadata(testNameRule.getMethodName(), SchemaCompatibility.NONE);
    SchemaIdVersion masterSchemaIdVersion1 = addSchemaVersion(SchemaBranch.MASTER_BRANCH, schemaMetadata, "/device.avsc");
    SchemaBranch schemaBranch1 = addSchemaBranch("BRANCH1", schemaMetadata, masterSchemaIdVersion1.getSchemaVersionId());
    SchemaIdVersion schemaBranch1Version1 = addSchemaVersion(schemaBranch1.getName(), schemaMetadata, "/device-incompat.avsc");
    schemaRegistryClient.enableSchemaVersion(schemaBranch1Version1.getSchemaVersionId());
    schemaRegistryClient.archiveSchemaVersion(schemaBranch1Version1.getSchemaVersionId());
    schemaRegistryClient.deleteSchemaBranch(schemaBranch1.getId());
}
Also used : SchemaBranch(com.hortonworks.registries.schemaregistry.SchemaBranch) SchemaMetadata(com.hortonworks.registries.schemaregistry.SchemaMetadata) SchemaIdVersion(com.hortonworks.registries.schemaregistry.SchemaIdVersion) Test(org.junit.Test)

Aggregations

SchemaIdVersion (com.hortonworks.registries.schemaregistry.SchemaIdVersion)45 SchemaMetadata (com.hortonworks.registries.schemaregistry.SchemaMetadata)32 SchemaVersion (com.hortonworks.registries.schemaregistry.SchemaVersion)22 Test (org.junit.Test)21 SchemaBranch (com.hortonworks.registries.schemaregistry.SchemaBranch)15 SchemaVersionInfo (com.hortonworks.registries.schemaregistry.SchemaVersionInfo)15 IOException (java.io.IOException)11 SchemaVersionKey (com.hortonworks.registries.schemaregistry.SchemaVersionKey)10 InvalidSchemaException (com.hortonworks.registries.schemaregistry.errors.InvalidSchemaException)10 IncompatibleSchemaException (com.hortonworks.registries.schemaregistry.errors.IncompatibleSchemaException)9 SchemaNotFoundException (com.hortonworks.registries.schemaregistry.errors.SchemaNotFoundException)9 Timed (com.codahale.metrics.annotation.Timed)5 CatalogResponse (com.hortonworks.registries.common.catalog.CatalogResponse)5 SchemaRegistryTestServerClientWrapper (com.hortonworks.registries.schemaregistry.avro.helper.SchemaRegistryTestServerClientWrapper)5 SchemaRegistryClient (com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient)5 InvalidSchemaBranchDeletionException (com.hortonworks.registries.schemaregistry.errors.InvalidSchemaBranchDeletionException)5 SchemaBranchAlreadyExistsException (com.hortonworks.registries.schemaregistry.errors.SchemaBranchAlreadyExistsException)5 SchemaBranchNotFoundException (com.hortonworks.registries.schemaregistry.errors.SchemaBranchNotFoundException)5 SchemaLifecycleException (com.hortonworks.registries.schemaregistry.state.SchemaLifecycleException)5 SchemaMetadataInfo (com.hortonworks.registries.schemaregistry.SchemaMetadataInfo)4