Skip to content

Commit

Permalink
add tests for no retrying when subscription not found
Browse files Browse the repository at this point in the history
  • Loading branch information
zifengmo committed Feb 21, 2024
1 parent a8bcaac commit a37aca2
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -371,4 +371,36 @@ public void testMultipleIOThreads() throws PulsarAdminException, PulsarClientExc
assertTrue(consumer instanceof MultiTopicsConsumerImpl);
assertTrue(consumer.isConnected());
}

@Test(timeOut = 30000)
public void testSubscriptionNotFound() throws PulsarAdminException, PulsarClientException {
final var topic1 = newTopicName();
final var topic2 = newTopicName();

pulsar.getConfiguration().setAllowAutoSubscriptionCreation(false);

try {
final var singleTopicConsumer = pulsarClient.newConsumer()
.topic(topic1)
.subscriptionName("sub-1")
.isAckReceiptEnabled(true)
.subscribe();
assertTrue(singleTopicConsumer instanceof ConsumerImpl);
} catch (Throwable t) {
assertTrue(t.getCause().getCause() instanceof PulsarClientException.SubscriptionNotFoundException);
}

try {
final var multiTopicsConsumer = pulsarClient.newConsumer()
.topics(List.of(topic1, topic2))
.subscriptionName("sub-2")
.isAckReceiptEnabled(true)
.subscribe();
assertTrue(multiTopicsConsumer instanceof MultiTopicsConsumerImpl);
} catch (Throwable t) {
assertTrue(t.getCause().getCause() instanceof PulsarClientException.SubscriptionNotFoundException);
}

pulsar.getConfiguration().setAllowAutoSubscriptionCreation(true);
}
}

0 comments on commit a37aca2

Please sign in to comment.