You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/03/11 04:57:41 UTC

[GitHub] [pulsar] Technoboy- commented on a change in pull request #14626: Fix inconsistent prompt message when schema version is empty using AVRO.

Technoboy- commented on a change in pull request #14626:
URL: https://github.com/apache/pulsar/pull/14626#discussion_r824386897



##########
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:
       Yes, right. updated. I have specified `isTcpLookup=false` in `testAvroSchemaWithHttpLookup`




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org