HQebupt commented on code in PR #17084:
URL: https://github.com/apache/pulsar/pull/17084#discussion_r947719894
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java:
##########
@@ -2153,4 +2167,139 @@ public void
testHandleAuthResponseWithoutClientVersion() {
verify(authResponse, times(1)).hasClientVersion();
verify(authResponse, times(0)).getClientVersion();
}
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleLookup() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+ serverCnx.handleLookup(any(CommandLookupTopic.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandlePartitionMetadataRequest() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+
serverCnx.handlePartitionMetadataRequest(any(CommandPartitionedTopicMetadata.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleConsumerStats() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+ serverCnx.handleConsumerStats(any(CommandConsumerStats.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleGetTopicsOfNamespace() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+
serverCnx.handleGetTopicsOfNamespace(any(CommandGetTopicsOfNamespace.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleGetSchema() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+ serverCnx.handleGetSchema(any(CommandGetSchema.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleGetOrCreateSchema() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+ serverCnx.handleGetOrCreateSchema(any(CommandGetOrCreateSchema.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleTcClientConnectRequest() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+
serverCnx.handleTcClientConnectRequest(any(CommandTcClientConnectRequest.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleNewTxn() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
Review Comment:
No, we can not due to 'java.lang.IllegalArgumentException' in the
constructor of `ServerCnx`
##########
pulsar-broker/src/test/java/org/apache/pulsar/broker/service/ServerCnxTest.java:
##########
@@ -2153,4 +2167,139 @@ public void
testHandleAuthResponseWithoutClientVersion() {
verify(authResponse, times(1)).hasClientVersion();
verify(authResponse, times(0)).getClientVersion();
}
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleLookup() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+ serverCnx.handleLookup(any(CommandLookupTopic.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandlePartitionMetadataRequest() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+
serverCnx.handlePartitionMetadataRequest(any(CommandPartitionedTopicMetadata.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleConsumerStats() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+ serverCnx.handleConsumerStats(any(CommandConsumerStats.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleGetTopicsOfNamespace() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+
serverCnx.handleGetTopicsOfNamespace(any(CommandGetTopicsOfNamespace.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleGetSchema() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+ serverCnx.handleGetSchema(any(CommandGetSchema.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleGetOrCreateSchema() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+ serverCnx.handleGetOrCreateSchema(any(CommandGetOrCreateSchema.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleTcClientConnectRequest() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+
serverCnx.handleTcClientConnectRequest(any(CommandTcClientConnectRequest.class));
+ }
+
+ @Test(expectedExceptions = IllegalArgumentException.class)
+ public void shouldFailHandleNewTxn() throws Exception {
+ ServerCnx serverCnx = mock(ServerCnx.class, CALLS_REAL_METHODS);
+ Field stateUpdater = ServerCnx.class.getDeclaredField("state");
+ stateUpdater.setAccessible(true);
+ stateUpdater.set(serverCnx, ServerCnx.State.Failed);
+ serverCnx.handleNewTxn(any(CommandNewTxn.class));
Review Comment:
OK
--
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]