@@ -154,12 +154,11 @@ protected void doInitConf() throws Exception {
154154 @ Override
155155 @ AfterClass (alwaysRun = true )
156156 protected void cleanup () throws Exception {
157- internalCleanup ();
158-
159157 proxyService .close ();
160158 if (proxyClientAuthentication != null ) {
161159 proxyClientAuthentication .close ();
162160 }
161+ internalCleanup ();
163162 }
164163
165164 @ Test
@@ -245,6 +244,8 @@ public void testPartitions() throws Exception {
245244 **/
246245 @ Test
247246 public void testAutoCreateTopic () throws Exception {
247+ TopicType originalAllowAutoTopicCreationType = pulsar .getConfiguration ().getAllowAutoTopicCreationType ();
248+ int originalDefaultNumPartitions = pulsar .getConfiguration ().getDefaultNumPartitions ();
248249 int defaultPartition = 2 ;
249250 int defaultNumPartitions = pulsar .getConfiguration ().getDefaultNumPartitions ();
250251 pulsar .getConfiguration ().setAllowAutoTopicCreationType (TopicType .PARTITIONED );
@@ -256,10 +257,10 @@ public void testAutoCreateTopic() throws Exception{
256257 String topic = "persistent://sample/test/local/partitioned-proxy-topic" ;
257258 CompletableFuture <List <String >> partitionNamesFuture = client .getPartitionsForTopic (topic );
258259 List <String > partitionNames = partitionNamesFuture .get (30000 , TimeUnit .MILLISECONDS );
259- Assert . assertEquals (partitionNames .size (), defaultPartition );
260+ assertEquals (partitionNames .size (), defaultPartition );
260261 } finally {
261- pulsar .getConfiguration ().setAllowAutoTopicCreationType (TopicType . NON_PARTITIONED );
262- pulsar .getConfiguration ().setDefaultNumPartitions (defaultNumPartitions );
262+ pulsar .getConfiguration ().setAllowAutoTopicCreationType (originalAllowAutoTopicCreationType );
263+ pulsar .getConfiguration ().setDefaultNumPartitions (originalDefaultNumPartitions );
263264 }
264265 }
265266
@@ -318,8 +319,9 @@ public Object[][] topicTypes() {
318319 };
319320 }
320321
321- @ Test (timeOut = 60_000 , dataProvider = "topicTypes" , invocationCount = 100 )
322+ @ Test (timeOut = 60_000 , dataProvider = "topicTypes" )
322323 public void testRegexSubscriptionWithTopicDiscovery (TopicType topicType ) throws Exception {
324+ @ Cleanup
323325 final PulsarClient client = PulsarClient .builder ().serviceUrl (proxyService .getServiceUrl ()).build ();
324326 final int topics = 10 ;
325327 final String subName = "s1" ;
@@ -394,7 +396,7 @@ public void testGetSchema() throws Exception {
394396 SchemaInfo schemaInfo = ((PulsarClientImpl ) client ).getLookup ()
395397 .getSchema (TopicName .get ("persistent://sample/test/local/get-schema" ), schemaVersion )
396398 .get ().orElse (null );
397- Assert . assertEquals (new String (schemaInfo .getSchema ()), new String (schema .getSchemaInfo ().getSchema ()));
399+ assertEquals (new String (schemaInfo .getSchema ()), new String (schema .getSchemaInfo ().getSchema ()));
398400 }
399401
400402 @ Test
@@ -462,7 +464,7 @@ public void testGetClientVersion() throws Exception {
462464 PulsarClient client = PulsarClient .builder ().serviceUrl (proxyService .getServiceUrl ())
463465 .build ();
464466
465- String topic = "persistent://sample/test/local/testGetClientVersion" ;
467+ String topic = BrokerTestUtil . newUniqueName ( "persistent://sample/test/local/testGetClientVersion" ) ;
466468 String subName = "test-sub" ;
467469
468470 @ Cleanup
@@ -473,8 +475,8 @@ public void testGetClientVersion() throws Exception {
473475
474476 consumer .receiveAsync ();
475477
476-
477- Assert . assertEquals (admin .topics ().getStats (topic ).getSubscriptions ().get (subName ).getConsumers ()
478+ String partition = TopicName . get ( topic ). getPartition ( 0 ). toString ();
479+ assertEquals (admin .topics ().getStats (partition ).getSubscriptions ().get (subName ).getConsumers ()
478480 .get (0 ).getClientVersion (), String .format ("Pulsar-Java-v%s" , PulsarVersion .getVersion ()));
479481 }
480482
0 commit comments