@@ -683,6 +683,40 @@ public void testAutoSubscribePatterConsumerFromBrokerWatcher(boolean delayWatchi
683
683
}
684
684
}
685
685
686
+ @ Test (timeOut = testTimeout )
687
+ public void testSubscribePatterWithOutTopicDomain () throws Exception {
688
+ final String key = "testSubscribePatterWithOutTopicDomain" ;
689
+ final String subscriptionName = "my-ex-subscription-" + key ;
690
+ final Pattern pattern = Pattern .compile ("my-property/my-ns/test-pattern.*" );
691
+
692
+ Consumer <byte []> consumer = pulsarClient .newConsumer ()
693
+ .topicsPattern (pattern )
694
+ .subscriptionName (subscriptionName )
695
+ .subscriptionType (SubscriptionType .Shared )
696
+ .receiverQueueSize (4 )
697
+ .subscribe ();
698
+
699
+ // 0. Need make sure topic watcher started
700
+ waitForTopicListWatcherStarted (consumer );
701
+
702
+ // 1. create partition topic
703
+ String topicName = "persistent://my-property/my-ns/test-pattern" + key ;
704
+ admin .topics ().createPartitionedTopic (topicName , 4 );
705
+
706
+ // 2. verify broker will push the changes to update(CommandWatchTopicUpdate).
707
+ assertSame (pattern .pattern (), ((PatternMultiTopicsConsumerImpl <?>) consumer ).getPattern ().pattern ());
708
+ Awaitility .await ().atMost (Duration .ofSeconds (5 )).untilAsserted (() -> {
709
+ assertEquals (((PatternMultiTopicsConsumerImpl <?>) consumer ).getPartitions ().size (), 4 );
710
+ assertEquals (((PatternMultiTopicsConsumerImpl <?>) consumer ).getConsumers ().size (), 4 );
711
+ assertEquals (((PatternMultiTopicsConsumerImpl <?>) consumer ).getPartitionedTopics ().size (), 1 );
712
+ });
713
+
714
+ // cleanup.
715
+ consumer .close ();
716
+ admin .topics ().deletePartitionedTopic (topicName );
717
+ pulsarClient .close ();
718
+ }
719
+
686
720
@ DataProvider (name = "regexpConsumerArgs" )
687
721
public Object [][] regexpConsumerArgs (){
688
722
return new Object [][]{
0 commit comments