gaoran10 commented on a change in pull request #14626:
URL: https://github.com/apache/pulsar/pull/14626#discussion_r824383212
##########
File path: pulsar-broker/src/test/java/org/apache/pulsar/schema/SchemaTest.java
##########
@@ -1112,4 +1114,102 @@ private void
checkSchemaForAutoSchema(Message<GenericRecord> message) {
}
}
+ @Test
+ public void testAvroSchemaWithHttpLookup() throws Exception {
+ final String namespace = "test-namespace-" + randomName(16);
+ String ns = PUBLIC_TENANT + "/" + namespace;
+ admin.namespaces().createNamespace(ns, Sets.newHashSet(CLUSTER_NAME));
+ final String autoProducerTopic = getTopicName(ns,
"testAvroSchemaWithHttpLookup");
+
+ @Cleanup
+ Consumer<User> consumer = pulsarClient
+ .newConsumer(Schema.AVRO(User.class))
+ .topic(autoProducerTopic)
+ .subscriptionType(SubscriptionType.Shared)
+ .subscriptionName("sub-1")
+ .subscribe();
+
+ @Cleanup
+ Producer<User> userProducer = pulsarClient
+ .newProducer(Schema.AVRO(User.class))
+ .topic(autoProducerTopic)
+ .enableBatching(false)
+ .create();
+
+ @Cleanup
+ Producer<byte[]> producer = pulsarClient
+ .newProducer()
+ .topic(autoProducerTopic)
+ .enableBatching(false)
+ .create();
+ User test = new User("test");
+ userProducer.send(test);
+ producer.send("test".getBytes(StandardCharsets.UTF_8));
+ Message<User> message1 = consumer.receive();
+ Assert.assertEquals(test, message1.getValue());
+ try {
+ Message<User> message2 = consumer.receive();
+ message2.getValue();
+ } catch (Throwable ex) {
+ Assert.assertTrue(Throwables.getRootCause(ex) instanceof
SchemaSerializationException);
+
Assert.assertEquals(Throwables.getRootCause(ex).getMessage(),"Empty schema
version");
+ }
+ }
+
+ @Test
+ public void testAvroSchemaWithTcpLookup() throws Exception {
Review comment:
I'm not sure which test will be executed first. Maybe we could set
lookup way for both `testAvroSchemaWithHttpLookup` and
`testAvroSchemaWithTcpLookup` and merge their logic, or we need to specify the
test execution order, if not we couldn't make sure the test
`testAvroSchemaWithHttpLookup` use HTTP lookup way, for example, if the test
`testAvroSchemaWithTcpLookup` execute first, the broker lookup way will be
change to TCP lookup.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]