pdolif commented on code in PR #23449:
URL: https://github.com/apache/pulsar/pull/23449#discussion_r1807912463


##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/SubscriptionTestBase.java:
##########
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.broker.service;
+
+import static org.mockito.Mockito.doReturn;
+import static org.mockito.Mockito.mock;
+import org.apache.pulsar.broker.BrokerTestUtil;
+import org.apache.pulsar.common.api.proto.CommandSubscribe;
+import org.apache.pulsar.common.api.proto.KeySharedMeta;
+import org.apache.pulsar.common.api.proto.KeySharedMode;
+import org.testng.annotations.DataProvider;
+
+public abstract class SubscriptionTestBase {

Review Comment:
   I moved them to a separate test class. 
   I thought of combining the two test methods (for persistent/non-persistent 
subscription) into one because they are very similar except for the 
subscription used. But in my opinion, adding the subscription to the data 
provider could decrease the test readability. 
   Maybe it makes sense to extract a method from this (or parts of it):
   ```java
   try {
       // add second consumer with incompatible key_shared policy
       sub.addConsumer(keySharedConsumerMock2).get(5, TimeUnit.SECONDS);
       
fail(BrokerServiceException.SubscriptionBusyException.class.getSimpleName() + " 
not thrown");
   } catch (Exception e) {
       // subscription throws exception when consumer with incompatible 
key_shared policy is added
       Throwable cause = e.getCause();
       assertTrue(cause instanceof 
BrokerServiceException.SubscriptionBusyException);
       assertEquals(cause.getMessage(), expectedErrorMessage);
   }
   ```
   What do you think?



-- 
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]

Reply via email to