You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@geode.apache.org by GitBox <gi...@apache.org> on 2020/09/09 16:50:40 UTC

[GitHub] [geode] jchen21 commented on a change in pull request #5499: GEODE-8485: When connection is closed, its server could be null

jchen21 commented on a change in pull request #5499:
URL: https://github.com/apache/geode/pull/5499#discussion_r485769839



##########
File path: geode-wan/src/test/java/org/apache/geode/internal/cache/wan/GatewaySenderEventRemoteDispatcherJUnitTest.java
##########
@@ -54,4 +58,22 @@ public void shuttingDownAckThreadReaderConnectionShouldshutdownTheAckThreadReade
     dispatcher.shutDownAckReaderConnection();
     assertTrue(ackReaderThread.isShutdown());
   }
+
+  @Test
+  public void getConnectionShouldCreateNewConnectionWhenServerIsNull() {
+    AbstractGatewaySender sender = mock(AbstractGatewaySender.class);
+    when(sender.isParallel()).thenReturn(false);
+    AbstractGatewaySenderEventProcessor eventProcessor =
+        mock(AbstractGatewaySenderEventProcessor.class);
+    when(eventProcessor.getSender()).thenReturn(sender);
+    Connection connection = mock(Connection.class);
+    when(connection.isDestroyed()).thenReturn(false);
+    when(connection.getServer()).thenReturn(null);
+    GatewaySenderEventRemoteDispatcher dispatcher =
+        new GatewaySenderEventRemoteDispatcher(eventProcessor, connection);
+    dispatcher = spy(dispatcher);
+    doNothing().when(dispatcher).initializeConnection();
+    Connection newConnection = dispatcher.getConnection(true);

Review comment:
       You can also assert `getConnection` does not throw NPE.




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

For queries about this service, please contact Infrastructure at:
users@infra.apache.org