Demogorgon314 commented on code in PR #16023:
URL: https://github.com/apache/pulsar/pull/16023#discussion_r895622744


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceAutoTopicCreationTest.java:
##########
@@ -414,4 +419,105 @@ public void 
testAutoCreationOfSystemTopicNamespaceEvents() throws Exception {
         
assertTrue(admin.namespaces().getTopics("prop/ns-abc").contains(topicString));
         
assertFalse(admin.topics().getPartitionedTopicList("prop/ns-abc").contains(topicString));
     }
+
+    @Test
+    public void testDynamicConfigurationTopicAutoCreationDisable() throws 
PulsarAdminException {
+        // test disable AllowAutoTopicCreation
+        pulsar.getConfiguration().setAllowAutoTopicCreation(true);
+        admin.brokers().updateDynamicConfiguration("allowAutoTopicCreation", 
"false");
+        final String namespaceName = "prop/ns-abc";
+        final String topic = "persistent://" + namespaceName + 
"/test-dynamicConfiguration-topic-auto-creation-"
+                + UUID.randomUUID();
+        try {
+            org.apache.pulsar.client.api.Producer<byte[]> producer = 
pulsarClient.newProducer()

Review Comment:
   ```suggestion
               pulsarClient.newProducer()
   ```



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceAutoTopicCreationTest.java:
##########
@@ -414,4 +419,105 @@ public void 
testAutoCreationOfSystemTopicNamespaceEvents() throws Exception {
         
assertTrue(admin.namespaces().getTopics("prop/ns-abc").contains(topicString));
         
assertFalse(admin.topics().getPartitionedTopicList("prop/ns-abc").contains(topicString));
     }
+
+    @Test
+    public void testDynamicConfigurationTopicAutoCreationDisable() throws 
PulsarAdminException {
+        // test disable AllowAutoTopicCreation
+        pulsar.getConfiguration().setAllowAutoTopicCreation(true);
+        admin.brokers().updateDynamicConfiguration("allowAutoTopicCreation", 
"false");
+        final String namespaceName = "prop/ns-abc";
+        final String topic = "persistent://" + namespaceName + 
"/test-dynamicConfiguration-topic-auto-creation-"
+                + UUID.randomUUID();
+        try {
+            org.apache.pulsar.client.api.Producer<byte[]> producer = 
pulsarClient.newProducer()
+                    .topic(topic)
+                    .create();

Review Comment:
   ```suggestion
                       .create();
              fail();
   ```
   Should add `fail()`.



##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceAutoTopicCreationTest.java:
##########
@@ -414,4 +419,105 @@ public void 
testAutoCreationOfSystemTopicNamespaceEvents() throws Exception {
         
assertTrue(admin.namespaces().getTopics("prop/ns-abc").contains(topicString));
         
assertFalse(admin.topics().getPartitionedTopicList("prop/ns-abc").contains(topicString));
     }
+
+    @Test
+    public void testDynamicConfigurationTopicAutoCreationDisable() throws 
PulsarAdminException {
+        // test disable AllowAutoTopicCreation
+        pulsar.getConfiguration().setAllowAutoTopicCreation(true);
+        admin.brokers().updateDynamicConfiguration("allowAutoTopicCreation", 
"false");
+        final String namespaceName = "prop/ns-abc";
+        final String topic = "persistent://" + namespaceName + 
"/test-dynamicConfiguration-topic-auto-creation-"
+                + UUID.randomUUID();
+        try {
+            org.apache.pulsar.client.api.Producer<byte[]> producer = 
pulsarClient.newProducer()
+                    .topic(topic)
+                    .create();
+        } catch (Exception e) {
+            assertTrue(e instanceof PulsarClientException);

Review Comment:
   ```suggestion
               assertTrue(e instanceof PulsarClientException.NotFoundException);
   ```



-- 
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-unsubscr...@pulsar.apache.org

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

Reply via email to