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

The following examples show how to use io.confluent.kafka.schemaregistry.client.SchemaRegistryClient#deleteSubject() . 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 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 2
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 3
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;
    });
}