Java Code Examples for io.confluent.kafka.schemaregistry.client.SchemaRegistryClient#getAllSubjects()

The following examples show how to use io.confluent.kafka.schemaregistry.client.SchemaRegistryClient#getAllSubjects() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SchemaRegistryMockTest.java    From fluent-kafka-streams-tests with MIT License 5 votes vote down vote up
@Test
void shouldDeleteKeySchema() throws IOException, RestClientException {
    this.schemaRegistry.registerKeySchema("test-topic", createSchema("key_schema"));
    final SchemaRegistryClient client = this.schemaRegistry.getSchemaRegistryClient();
    final Collection<String> allSubjects = client.getAllSubjects();
    assertThat(allSubjects).hasSize(1).containsExactly("test-topic-key");
    this.schemaRegistry.deleteKeySchema("test-topic");
    final Collection<String> subjectsAfterDeletion = client.getAllSubjects();
    assertThat(subjectsAfterDeletion).isEmpty();
}
 
Example 2
Source File: SchemaRegistryMockTest.java    From fluent-kafka-streams-tests with MIT License 5 votes vote down vote up
@Test
void shouldDeleteValueSchema() throws IOException, RestClientException {
    final SchemaRegistryClient client = this.schemaRegistry.getSchemaRegistryClient();
    this.schemaRegistry.registerValueSchema("test-topic", createSchema("value_schema"));
    final Collection<String> allSubjects = client.getAllSubjects();
    assertThat(allSubjects).hasSize(1).containsExactly("test-topic-value");
    this.schemaRegistry.deleteValueSchema("test-topic");
    final Collection<String> subjectsAfterDeletion = client.getAllSubjects();
    assertThat(subjectsAfterDeletion).isEmpty();
}
 
Example 3
Source File: SchemaRegistryMockTest.java    From fluent-kafka-streams-tests with MIT License 5 votes vote down vote up
@Test
void shouldDeleteKeySchemaWithClient() throws IOException, RestClientException {
    final SchemaRegistryClient client = this.schemaRegistry.getSchemaRegistryClient();
    this.schemaRegistry.registerKeySchema("test-topic", createSchema("key_schema"));
    final Collection<String> allSubjects = client.getAllSubjects();
    assertThat(allSubjects).hasSize(1).containsExactly("test-topic-key");
    client.deleteSubject("test-topic-key");
    final Collection<String> subjectsAfterDeletion = client.getAllSubjects();
    assertThat(subjectsAfterDeletion).isEmpty();
}
 
Example 4
Source File: SchemaRegistryMockTest.java    From fluent-kafka-streams-tests with MIT License 5 votes vote down vote up
@Test
void shouldDeleteValueSchemaWithClient() throws IOException, RestClientException {
    final SchemaRegistryClient client = this.schemaRegistry.getSchemaRegistryClient();
    this.schemaRegistry.registerValueSchema("test-topic", createSchema("value_schema"));
    final Collection<String> allSubjects = client.getAllSubjects();
    assertThat(allSubjects).hasSize(1).containsExactly("test-topic-value");
    client.deleteSubject("test-topic-value");
    final Collection<String> subjectsAfterDeletion = client.getAllSubjects();
    assertThat(subjectsAfterDeletion).isEmpty();
}
 
Example 5
Source File: ConfluentClientTest.java    From apicurio-registry with Apache License 2.0 4 votes vote down vote up
@Test
public void testSmoke() throws Exception {
    SchemaRegistryClient client = buildClient();
    Collection<String> subjects = client.getAllSubjects();
    Assertions.assertNotNull(subjects);
}
 
Example 6
Source File: ConfluentClientTest.java    From apicurio-registry with Apache License 2.0 4 votes vote down vote up
@Test
    public void testSimpleOps() throws Exception {
        SchemaRegistryClient client = buildClient();
        final String subject = generateArtifactId();

        Schema schema1 = new Schema.Parser().parse("{\"type\":\"record\",\"name\":\"myrecord1\",\"fields\":[{\"name\":\"f1\",\"type\":\"string\"}]}");
        int id1 = client.register(subject, schema1);
        
        // Reset the client cache so that the next line actually does what we want.
        client.reset();

        ParsedSchema ps1 = TestUtils.retry(() -> client.getSchemaById(id1));

        Schema schema2 = new Schema.Parser().parse("{\"type\":\"record\",\"name\":\"myrecord2\",\"fields\":[{\"name\":\"f2\",\"type\":\"string\"}]}");
        int id2 = client.register(subject, schema2);

        ParsedSchema ps2 = TestUtils.retry(() -> client.getSchemaById(id2));

        Schema schema = client.getById(id1);
        Assertions.assertNotNull(schema);

        client.reset();

        Assertions.assertTrue(client.testCompatibility(subject, schema2));

        // global id can be mapped async
        retry(() -> {
            Schema schema3 = client.getById(id2);
            Assertions.assertNotNull(schema3);
            return schema3;
        });

        Collection<String> subjects = client.getAllSubjects();
        Assertions.assertTrue(subjects.contains(subject));

        List<Integer> versions = client.getAllVersions(subject);
        Assertions.assertTrue(versions.contains(1));
        Assertions.assertTrue(versions.contains(2));

        // TODO -- match per schema!
        //int v1 = client.getVersion(subject, schema1);
        //Assertions.assertEquals(1, v1);

        int v2 = client.getVersion(subject, schema2);
        Assertions.assertEquals(2, v2);

        int d1 = client.deleteSchemaVersion(subject, "1");
        Assertions.assertEquals(1, d1);
        int d2 = client.deleteSchemaVersion(subject, "2");
        Assertions.assertEquals(2, d2);
        //int dl = client.deleteSchemaVersion(subject, "latest");
        //Assertions.assertEquals(2, dl);

        // TODO: discuss with Ales: both versions of the schema were deleted above.  should the subject be deleted when all versions are deleted?
//        versions = client.deleteSubject(subject);
        // TODO: why would this work?  deleting the subject would return the already-deleted versions?
//        Assertions.assertTrue(versions.contains(1));
//        Assertions.assertTrue(versions.contains(2));
    }
 
Example 7
Source File: ConfluentClientTest.java    From apicurio-registry with Apache License 2.0 4 votes vote down vote up
@Test
public void testDelete() throws Exception {
    SchemaRegistryClient client = buildClient();

    String nonExisting = generateArtifactId();
    try {
        client.deleteSubject(nonExisting);
        Assertions.fail();
    } catch (RestClientException e) {
        Assertions.assertEquals(404, e.getStatus());
    }

    retry(() -> {
        HealthUtils.assertIsReady();
        HealthUtils.assertIsLive();
    });

    String subject = generateArtifactId();

    Schema schema = new Schema.Parser().parse("{\"type\":\"record\",\"name\":\"myrecord3\",\"fields\":[{\"name\":\"bar\",\"type\":\"string\"}]}");
    int id = client.register(subject, schema);
    client.reset();

    // global id can be mapped async
    retry(() -> {
        Schema schema2 = client.getById(id);
        Assertions.assertNotNull(schema2);
        return schema2;
    });

    Collection<String> subjects = client.getAllSubjects();
    Assertions.assertTrue(subjects.contains(subject));

    client.deleteSubject(subject);

    retry(() -> {
        // delete can be async
        Collection<String> all = client.getAllSubjects();
        Assertions.assertFalse(all.contains(subject));
        return null;
    });
}