use of org.apache.flink.connector.pulsar.SampleMessage.TestMessage in project flink by apache.
the class PulsarDeserializationSchemaTest method createFromPulsarSchema.
@Test
void createFromPulsarSchema() throws Exception {
Schema<TestMessage> schema1 = PROTOBUF_NATIVE(TestMessage.class);
PulsarDeserializationSchema<TestMessage> schema2 = pulsarSchema(schema1, TestMessage.class);
schema2.open(new TestingDeserializationContext(), mock(SourceConfiguration.class));
assertDoesNotThrow(() -> InstantiationUtil.clone(schema2));
TestMessage message1 = TestMessage.newBuilder().setStringField(randomAlphabetic(10)).setDoubleField(ThreadLocalRandom.current().nextDouble()).setIntField(ThreadLocalRandom.current().nextInt()).build();
Message<byte[]> message2 = getMessage(message1, schema1::encode);
SingleMessageCollector<TestMessage> collector = new SingleMessageCollector<>();
schema2.deserialize(message2, collector);
assertNotNull(collector.result);
assertEquals(collector.result, message1);
}
Aggregations