BewareMyPower commented on code in PR #16023:
URL: https://github.com/apache/pulsar/pull/16023#discussion_r911590864
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/BrokerServiceAutoSubscriptionCreationTest.java:
##########
@@ -152,4 +154,24 @@ public void
testNonPersistentTopicSubscriptionCreationWithAutoCreationDisable()
assertTrue(admin.topics().getSubscriptions(topicName).contains(subscriptionName));
}
+ @Test
+ public void testDynamicConfigurationTopicAutoSubscriptionCreation()
+ throws PulsarAdminException, PulsarClientException {
+ pulsar.getConfiguration().setAllowAutoTopicCreation(false);
+ pulsar.getConfiguration().setAllowAutoSubscriptionCreation(true);
+
admin.brokers().updateDynamicConfiguration("allowAutoSubscriptionCreation",
"false");
+ String topicString = "persistent://prop/ns-abc/non-partitioned-topic"
+ UUID.randomUUID();
+ String subscriptionName = "non-partitioned-topic-sub";
+ admin.topics().createNonPartitionedTopic(topicString);
+ try {
+
pulsarClient.newConsumer().topic(topicString).subscriptionName(subscriptionName).subscribe();
+ fail("Subscribe operation should have failed");
+ } catch (Exception e) {
+ assertTrue(e instanceof PulsarClientException);
+ }
Review Comment:
We can simplify this type of verification to
```java
Assert.assertThrows(PulsarClientException.class, () ->
pulsarClient.newConsumer().topic(topicString).subscriptionName(subscriptionName).subscribe());
```
I think we can also apply similar changes to
`testDynamicConfigurationTopicAutoCreationDisable`.
--
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]