Search in sources :

Example 1 with SchemaTestUtils

use of org.apache.pulsar.client.impl.schema.SchemaTestUtils in project incubator-pulsar by apache.

the class MultiVersionSchemaInfoProviderTest method testGetSchema.

@Test
public void testGetSchema() throws Exception {
    CompletableFuture<Optional<SchemaInfo>> completableFuture = new CompletableFuture<>();
    SchemaInfo schemaInfo = AvroSchema.of(SchemaDefinition.<SchemaTestUtils>builder().withPojo(SchemaTestUtils.class).build()).getSchemaInfo();
    completableFuture.complete(Optional.of(schemaInfo));
    when(schemaProvider.getPulsarClient().getLookup().getSchema(any(TopicName.class), any(byte[].class))).thenReturn(completableFuture);
    SchemaInfo schemaInfoByVersion = schemaProvider.getSchemaByVersion(new byte[0]).get();
    assertEquals(schemaInfoByVersion, schemaInfo);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Optional(java.util.Optional) SchemaTestUtils(org.apache.pulsar.client.impl.schema.SchemaTestUtils) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo) TopicName(org.apache.pulsar.common.naming.TopicName) Test(org.testng.annotations.Test)

Example 2 with SchemaTestUtils

use of org.apache.pulsar.client.impl.schema.SchemaTestUtils in project pulsar by apache.

the class MultiVersionSchemaInfoProviderTest method testGetSchema.

@Test
public void testGetSchema() throws Exception {
    CompletableFuture<Optional<SchemaInfo>> completableFuture = new CompletableFuture<>();
    SchemaInfo schemaInfo = AvroSchema.of(SchemaDefinition.<SchemaTestUtils>builder().withPojo(SchemaTestUtils.class).build()).getSchemaInfo();
    completableFuture.complete(Optional.of(schemaInfo));
    when(schemaProvider.getPulsarClient().getLookup().getSchema(any(TopicName.class), any(byte[].class))).thenReturn(completableFuture);
    SchemaInfo schemaInfoByVersion = schemaProvider.getSchemaByVersion(new byte[0]).get();
    assertEquals(schemaInfoByVersion, schemaInfo);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Optional(java.util.Optional) SchemaTestUtils(org.apache.pulsar.client.impl.schema.SchemaTestUtils) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo) TopicName(org.apache.pulsar.common.naming.TopicName) Test(org.testng.annotations.Test)

Example 3 with SchemaTestUtils

use of org.apache.pulsar.client.impl.schema.SchemaTestUtils in project pulsar by yahoo.

the class MultiVersionSchemaInfoProviderTest method testGetSchema.

@Test
public void testGetSchema() throws Exception {
    CompletableFuture<Optional<SchemaInfo>> completableFuture = new CompletableFuture<>();
    SchemaInfo schemaInfo = AvroSchema.of(SchemaDefinition.<SchemaTestUtils>builder().withPojo(SchemaTestUtils.class).build()).getSchemaInfo();
    completableFuture.complete(Optional.of(schemaInfo));
    when(schemaProvider.getPulsarClient().getLookup().getSchema(any(TopicName.class), any(byte[].class))).thenReturn(completableFuture);
    SchemaInfo schemaInfoByVersion = schemaProvider.getSchemaByVersion(new byte[0]).get();
    assertEquals(schemaInfoByVersion, schemaInfo);
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Optional(java.util.Optional) SchemaTestUtils(org.apache.pulsar.client.impl.schema.SchemaTestUtils) SchemaInfo(org.apache.pulsar.common.schema.SchemaInfo) TopicName(org.apache.pulsar.common.naming.TopicName) Test(org.testng.annotations.Test)

Aggregations

Optional (java.util.Optional)3 CompletableFuture (java.util.concurrent.CompletableFuture)3 SchemaTestUtils (org.apache.pulsar.client.impl.schema.SchemaTestUtils)3 TopicName (org.apache.pulsar.common.naming.TopicName)3 SchemaInfo (org.apache.pulsar.common.schema.SchemaInfo)3 Test (org.testng.annotations.Test)3