This is an automated email from the ASF dual-hosted git repository. mivanac pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/geode.git
The following commit(s) were added to refs/heads/develop by this push: new 596a601d19 GEODE-10337: add use of SocketCreatorFactory.close() (#7842) 596a601d19 is described below commit 596a601d199ed810caf06cbc0bfc58ae3581f691 Author: Mario Ivanac <48509724+miva...@users.noreply.github.com> AuthorDate: Wed Sep 7 15:16:38 2022 +0200 GEODE-10337: add use of SocketCreatorFactory.close() (#7842) * GEODE-10337: add use of SocketCreatorFactory.close() * GEODE-10337: added UT --- .../internal/InternalDistributedSystem.java | 1 + .../geode/internal/net/SocketCreatorFactory.java | 14 +- .../net/SocketCreatorFactoryJUnitTest.java | 435 ++++++++++++--------- 3 files changed, 253 insertions(+), 197 deletions(-) diff --git a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java index c8e7ba8241..cf90439791 100644 --- a/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java +++ b/geode-core/src/main/java/org/apache/geode/distributed/internal/InternalDistributedSystem.java @@ -1642,6 +1642,7 @@ public class InternalDistributedSystem extends DistributedSystem removeSystem(this); if (!attemptingToReconnect) { loggingSession.shutdown(); + SocketCreatorFactory.close(); } alertingService.useAlertMessaging(new NullAlertMessaging()); clusterAlertMessaging.get().close(); diff --git a/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreatorFactory.java b/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreatorFactory.java index 415c5bacd2..477ecaec46 100644 --- a/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreatorFactory.java +++ b/geode-core/src/main/java/org/apache/geode/internal/net/SocketCreatorFactory.java @@ -54,10 +54,14 @@ public class SocketCreatorFactory { } private static synchronized SocketCreatorFactory getInstance(boolean closing) { - if (instance == null && !closing) { - instance = new SocketCreatorFactory(); + SocketCreatorFactory result = instance; + if (result == null && !closing) { + result = new SocketCreatorFactory(); + instance = result; + } else if (result != null && closing) { + instance = null; } - return instance; + return result; } private static synchronized SocketCreatorFactory getInstance() { @@ -74,6 +78,10 @@ public class SocketCreatorFactory { sslConfigForComponent); } + static boolean checkInstanceIsNull() { + return instance == null; + } + public static SocketCreator getSocketCreatorForComponent( SecurableCommunicationChannel sslEnabledComponent) { return getSocketCreatorForComponent(getInstance().getDistributionConfig(), sslEnabledComponent); diff --git a/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java b/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java index 2fc2c072bd..f76e540520 100644 --- a/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java +++ b/geode-core/src/test/java/org/apache/geode/internal/net/SocketCreatorFactoryJUnitTest.java @@ -72,8 +72,7 @@ import static org.apache.geode.distributed.ConfigurationProperties.SSL_REQUIRE_A import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE; import static org.apache.geode.distributed.ConfigurationProperties.SSL_TRUSTSTORE_PASSWORD; import static org.apache.geode.test.util.ResourceUtils.createTempFileFromResource; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.assertj.core.api.Assertions.assertThat; import java.io.File; import java.io.IOException; @@ -110,18 +109,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -131,18 +133,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isTrue(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -153,18 +158,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -175,18 +183,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -196,18 +207,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -217,18 +231,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -240,18 +257,21 @@ public class SocketCreatorFactoryJUnitTest { SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -263,18 +283,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -288,18 +311,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -319,18 +345,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isTrue(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -347,18 +376,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isTrue(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } private Properties configureSSLProperties(String sslComponents) throws IOException { @@ -409,18 +441,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -443,18 +478,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isTrue(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -477,18 +515,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -511,18 +552,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertTrue(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isTrue(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } @Test @@ -545,18 +589,21 @@ public class SocketCreatorFactoryJUnitTest { DistributionConfigImpl distributionConfig = new DistributionConfigImpl(properties); SocketCreatorFactory.setDistributionConfig(distributionConfig); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()); - assertFalse(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()); - assertTrue(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) - .useSSL()); - assertFalse(SocketCreatorFactory - .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.CLUSTER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.GATEWAY).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.JMX) + .useSSL()).isFalse(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.SERVER).useSSL()).isFalse(); + assertThat(SocketCreatorFactory.getSocketCreatorForComponent(SecurableCommunicationChannel.WEB) + .useSSL()).isTrue(); + assertThat(SocketCreatorFactory + .getSocketCreatorForComponent(SecurableCommunicationChannel.LOCATOR).useSSL()).isFalse(); + + SocketCreatorFactory.close(); + assertThat(SocketCreatorFactory.checkInstanceIsNull()).isTrue(); } private File findTestJKS() {