Search in sources :

Example 6 with SchemaRegistryTestServerClientWrapper

use of com.hortonworks.registries.schemaregistry.avro.helper.SchemaRegistryTestServerClientWrapper in project registry by hortonworks.

the class LocalRegistryServerHATest method startZooKeeper.

@Before
public void startZooKeeper() throws Exception {
    testingServer = new TestingServer(true);
    File serverYAMLFile = new File(SCHEMA_REGISTRY_TEST_CONFIGURATION.getServerYAMLPath());
    String fileContent = FileUtils.readFileToString(serverYAMLFile, "UTF-8");
    File registryConfigFile = File.createTempFile("ha-", ".yaml");
    registryConfigFile.deleteOnExit();
    try (FileWriter writer = new FileWriter(registryConfigFile)) {
        IOUtils.write(fileContent.replace("__zk_connect_url__", testingServer.getConnectString()), writer);
    }
    SchemaRegistryTestConfiguration testConfiguration = new SchemaRegistryTestConfiguration(registryConfigFile.getAbsolutePath(), SCHEMA_REGISTRY_TEST_CONFIGURATION.getClientYAMLPath());
    List<SchemaRegistryTestServerClientWrapper> schemaRegistryServers = new ArrayList<>();
    for (int i = 1; i < 4; i++) {
        SchemaRegistryTestServerClientWrapper server = new SchemaRegistryTestServerClientWrapper(testConfiguration);
        schemaRegistryServers.add(server);
        server.startTestServer();
    }
    registryServers = Collections.unmodifiableList(schemaRegistryServers);
}
Also used : TestingServer(org.apache.curator.test.TestingServer) SchemaRegistryTestServerClientWrapper(com.hortonworks.registries.schemaregistry.avro.helper.SchemaRegistryTestServerClientWrapper) SchemaRegistryTestConfiguration(com.hortonworks.registries.schemaregistry.avro.conf.SchemaRegistryTestConfiguration) FileWriter(java.io.FileWriter) ArrayList(java.util.ArrayList) File(java.io.File) Before(org.junit.Before)

Example 7 with SchemaRegistryTestServerClientWrapper

use of com.hortonworks.registries.schemaregistry.avro.helper.SchemaRegistryTestServerClientWrapper in project registry by hortonworks.

the class LocalRegistryServerTest method testSanity.

@Test
public void testSanity() throws Exception {
    SchemaRegistryTestServerClientWrapper schemaRegistryTestServerClientWrapper = new SchemaRegistryTestServerClientWrapper(SCHEMA_REGISTRY_TEST_CONFIGURATION);
    schemaRegistryTestServerClientWrapper.startTestServer();
    SchemaRegistryClient schemaRegistryClient = schemaRegistryTestServerClientWrapper.getClient();
    // registering schema metadata
    SchemaMetadata schemaMetadata = new SchemaMetadata.Builder("foo").type("avro").build();
    Long schemaId = schemaRegistryClient.registerSchemaMetadata(schemaMetadata);
    Assert.assertNotNull(schemaId);
    // registering a new schema
    String schemaName = schemaMetadata.getName();
    String schema1 = IOUtils.toString(LocalRegistryServerTest.class.getResourceAsStream("/schema-1.avsc"), "UTF-8");
    SchemaIdVersion v1 = schemaRegistryClient.addSchemaVersion(schemaName, new SchemaVersion(schema1, "Initial version of the schema"));
    schemaRegistryTestServerClientWrapper.stopTestServer();
}
Also used : SchemaRegistryTestServerClientWrapper(com.hortonworks.registries.schemaregistry.avro.helper.SchemaRegistryTestServerClientWrapper) SchemaMetadata(com.hortonworks.registries.schemaregistry.SchemaMetadata) SchemaVersion(com.hortonworks.registries.schemaregistry.SchemaVersion) SchemaIdVersion(com.hortonworks.registries.schemaregistry.SchemaIdVersion) SchemaRegistryClient(com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient) Test(org.junit.Test)

Aggregations

SchemaRegistryTestServerClientWrapper (com.hortonworks.registries.schemaregistry.avro.helper.SchemaRegistryTestServerClientWrapper)7 SchemaIdVersion (com.hortonworks.registries.schemaregistry.SchemaIdVersion)2 SchemaMetadata (com.hortonworks.registries.schemaregistry.SchemaMetadata)2 SchemaVersion (com.hortonworks.registries.schemaregistry.SchemaVersion)2 SchemaRegistryTestConfiguration (com.hortonworks.registries.schemaregistry.avro.conf.SchemaRegistryTestConfiguration)2 SchemaRegistryClient (com.hortonworks.registries.schemaregistry.client.SchemaRegistryClient)2 Before (org.junit.Before)2 Test (org.junit.Test)2 SchemaMetadataInfo (com.hortonworks.registries.schemaregistry.SchemaMetadataInfo)1 SchemaVersionKey (com.hortonworks.registries.schemaregistry.SchemaVersionKey)1 File (java.io.File)1 FileWriter (java.io.FileWriter)1 ArrayList (java.util.ArrayList)1 TestingServer (org.apache.curator.test.TestingServer)1 EmbeddedKafkaCluster (org.apache.kafka.streams.integration.utils.EmbeddedKafkaCluster)1