|
55 | 55 | import java.util.Map;
|
56 | 56 | import java.util.Optional;
|
57 | 57 | import java.util.Set;
|
| 58 | +import java.util.UUID; |
58 | 59 | import java.util.concurrent.CompletableFuture;
|
59 | 60 | import java.util.concurrent.ExecutionException;
|
60 | 61 | import java.util.concurrent.TimeUnit;
|
@@ -926,6 +927,43 @@ public void testDisableBroker() throws Exception {
|
926 | 927 | }
|
927 | 928 | }
|
928 | 929 |
|
| 930 | + @Test(timeOut = 30 * 1000) |
| 931 | + public void testListTopic() throws Exception { |
| 932 | + final String namespace = "public/testListTopic"; |
| 933 | + admin.namespaces().createNamespace(namespace, 3); |
| 934 | + |
| 935 | + final String persistentTopicName = TopicName.get( |
| 936 | + "persistent", NamespaceName.get(namespace), |
| 937 | + "get_topics_mode_" + UUID.randomUUID()).toString(); |
| 938 | + |
| 939 | + final String nonPersistentTopicName = TopicName.get( |
| 940 | + "non-persistent", NamespaceName.get(namespace), |
| 941 | + "get_topics_mode_" + UUID.randomUUID()).toString(); |
| 942 | + admin.topics().createPartitionedTopic(persistentTopicName, 3); |
| 943 | + admin.topics().createPartitionedTopic(nonPersistentTopicName, 3); |
| 944 | + pulsarClient.newProducer().topic(persistentTopicName).create().close(); |
| 945 | + pulsarClient.newProducer().topic(nonPersistentTopicName).create().close(); |
| 946 | + |
| 947 | + BundlesData bundlesData = admin.namespaces().getBundles(namespace); |
| 948 | + List<String> boundaries = bundlesData.getBoundaries(); |
| 949 | + int topicNum = 0; |
| 950 | + for (int i = 0; i < boundaries.size() - 1; i++) { |
| 951 | + String bundle = String.format("%s_%s", boundaries.get(i), boundaries.get(i + 1)); |
| 952 | + List<String> topic = admin.topics().getListInBundle(namespace, bundle); |
| 953 | + if (topic == null) { |
| 954 | + continue; |
| 955 | + } |
| 956 | + topicNum += topic.size(); |
| 957 | + for (String s : topic) { |
| 958 | + assertFalse(TopicName.get(s).isPersistent()); |
| 959 | + } |
| 960 | + } |
| 961 | + assertEquals(topicNum, 3); |
| 962 | + |
| 963 | + List<String> list = admin.topics().getList(namespace); |
| 964 | + assertEquals(list.size(), 6); |
| 965 | + } |
| 966 | + |
929 | 967 | private static abstract class MockBrokerFilter implements BrokerFilter {
|
930 | 968 |
|
931 | 969 | @Override
|
|
0 commit comments