diff --git a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/cli/ReplicateSubscriptionStateTest.java b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/cli/ReplicateSubscriptionStateTest.java index bb6f36986e92a..d70f71d68c3e0 100644 --- a/tests/integration/src/test/java/org/apache/pulsar/tests/integration/cli/ReplicateSubscriptionStateTest.java +++ b/tests/integration/src/test/java/org/apache/pulsar/tests/integration/cli/ReplicateSubscriptionStateTest.java @@ -20,8 +20,11 @@ import static org.awaitility.Awaitility.await; import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertThrows; import static org.testng.Assert.assertTrue; +import static org.testng.Assert.expectThrows; import org.apache.pulsar.common.naming.TopicName; +import org.apache.pulsar.tests.integration.docker.ContainerExecException; import org.apache.pulsar.tests.integration.docker.ContainerExecResult; import org.apache.pulsar.tests.integration.suites.PulsarCliTestSuite; import org.testng.annotations.AfterClass; @@ -142,18 +145,14 @@ public void testReplicateSubscriptionStateCmd() throws Exception { @Test public void testReplicateSubscriptionStateCmdWithInvalidParameters() throws Exception { - ContainerExecResult result = pulsarCluster.runAdminCommandOnAnyBroker("namespaces", - "set-replicate-subscription-state", "public/default"); - assertTrue(result.getExitCode() != 0); - result = pulsarCluster.runAdminCommandOnAnyBroker("namespaces", - "set-replicate-subscription-state", "--enabled", "public/default"); - assertTrue(result.getExitCode() != 0); + assertThrows(ContainerExecException.class, () -> pulsarCluster.runAdminCommandOnAnyBroker("namespaces", + "set-replicate-subscription-state", "public/default")); + assertThrows(ContainerExecException.class, () -> pulsarCluster.runAdminCommandOnAnyBroker("namespaces", + "set-replicate-subscription-state", "--enabled", "public/default")); - result = pulsarCluster.runAdminCommandOnAnyBroker("topicPolicies", - "set-replicate-subscription-state", "public/default/test"); - assertTrue(result.getExitCode() != 0); - result = pulsarCluster.runAdminCommandOnAnyBroker("topicPolicies", - "set-replicate-subscription-state", "--enabled", "public/default/test"); - assertTrue(result.getExitCode() != 0); + assertThrows(ContainerExecException.class, () -> pulsarCluster.runAdminCommandOnAnyBroker("topicPolicies", + "set-replicate-subscription-state", "public/default/test")); + assertThrows(ContainerExecException.class, () -> pulsarCluster.runAdminCommandOnAnyBroker("topicPolicies", + "set-replicate-subscription-state", "--enabled", "public/default/test")); } } \ No newline at end of file