mattisonchao commented on code in PR #18555:
URL: https://github.com/apache/pulsar/pull/18555#discussion_r1027657460
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/persistent/PersistentTopicTest.java:
##########
@@ -271,4 +272,70 @@ public void testPersistentPartitionedTopicUnload() throws
Exception {
producer.close();
}
}
+
+ @Test
+ public void testCreateSchemaAfterDeletion() throws Exception {
+ //init namespace
+ final String myNamespace = "prop/ns";
+ admin.namespaces().createNamespace(myNamespace,
Sets.newHashSet("test"));
+ final String topicName =
"persistent://prop/ns/test-create-schema-after-deletion" + UUID.randomUUID();
+
+ // create namespace
+ // Create a topic with `Person`
+ try (Producer<Person> producer =
pulsarClient.newProducer(Schema.AVRO(Person.class))
+ .topic(topicName)
+ .create()
+ ) {
+ Person person = new Person();
+ person.setName("Tom Hanks");
+ person.setAge(60);
+
+ producer.send(person);
+
+ }
+
+ // delete the topic
+ admin.topics().delete(topicName);
+
+ try (Producer<Student> ignored =
pulsarClient.newProducer(Schema.AVRO(Student.class))
+ .topic(topicName)
+ .create()) {
+ Assert.fail("Should fail to create a the producer with a new
schema since the schema is not deleted.");
+ } catch (PulsarClientException pce) {
+ Assert.assertTrue(pce instanceof
PulsarClientException.IncompatibleSchemaException);
+ }
+
+ // delete the schema
+ admin.schemas().deleteSchema(topicName);
+
+ // after deleting the schema, try to create a topic with a different
schema
+ try (Producer<Student> producer =
pulsarClient.newProducer(Schema.AVRO(Student.class))
+ .topic(topicName)
+ .create()
+ ) {
+ Student student = new Student();
+ student.setName("Tom Jerry");
+ student.setAge(30);
+ student.setGpa(6);
+ student.setGpa(10);
Review Comment:
fixed
--
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]