diff --git a/bootstrap/src/test/java/org/apache/shardingsphere/elasticjob/bootstrap/type/OneOffJobBootstrapTest.java b/bootstrap/src/test/java/org/apache/shardingsphere/elasticjob/bootstrap/type/OneOffJobBootstrapTest.java index 443a1a865c..e1f6e73e20 100644 --- a/bootstrap/src/test/java/org/apache/shardingsphere/elasticjob/bootstrap/type/OneOffJobBootstrapTest.java +++ b/bootstrap/src/test/java/org/apache/shardingsphere/elasticjob/bootstrap/type/OneOffJobBootstrapTest.java @@ -41,7 +41,7 @@ class OneOffJobBootstrapTest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(7181); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), OneOffJobBootstrapTest.class.getSimpleName()); diff --git a/lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lifecycle/internal/operate/JobOperateAPIImplTest.java b/lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lifecycle/internal/operate/JobOperateAPIImplTest.java index d42db686fa..a295f521d9 100644 --- a/lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lifecycle/internal/operate/JobOperateAPIImplTest.java +++ b/lifecycle/src/test/java/org/apache/shardingsphere/elasticjob/lifecycle/internal/operate/JobOperateAPIImplTest.java @@ -36,8 +36,6 @@ @ExtendWith(MockitoExtension.class) class JobOperateAPIImplTest { - static final int DUMP_PORT = 9000; - private JobOperateAPI jobOperateAPI; // TODO We should not use `Mock.Strictness.LENIENT` here, but the default. This is a flaw in the unit test design. diff --git a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperElectionServiceTest.java b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperElectionServiceTest.java index 440191c2e9..a3838911a0 100644 --- a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperElectionServiceTest.java +++ b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperElectionServiceTest.java @@ -43,7 +43,7 @@ @ExtendWith(MockitoExtension.class) class ZookeeperElectionServiceTest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(9181); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static final String HOST_AND_PORT = "localhost:8899"; diff --git a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterExecuteInLeaderTest.java b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterExecuteInLeaderTest.java index f44fb68d2d..88f5a3ae77 100644 --- a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterExecuteInLeaderTest.java +++ b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterExecuteInLeaderTest.java @@ -33,18 +33,16 @@ class ZookeeperRegistryCenterExecuteInLeaderTest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(9181); - - private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = - new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterExecuteInLeaderTest.class.getName()); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll static void setUp() { EMBED_TESTING_SERVER.start(); - zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); - ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); + ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterExecuteInLeaderTest.class.getName()); + zkRegCenter = new ZookeeperRegistryCenter(zookeeperConfiguration); + zookeeperConfiguration.setConnectionTimeoutMilliseconds(30000); zkRegCenter.init(); } diff --git a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterForAuthTest.java b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterForAuthTest.java index 95592c85c8..eeccf9113d 100644 --- a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterForAuthTest.java +++ b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterForAuthTest.java @@ -33,21 +33,20 @@ class ZookeeperRegistryCenterForAuthTest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(9181); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static final String NAME_SPACE = ZookeeperRegistryCenterForAuthTest.class.getName(); - private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), NAME_SPACE); - private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll static void setUp() { EMBED_TESTING_SERVER.start(); - ZOOKEEPER_CONFIGURATION.setDigest("digest:password"); - ZOOKEEPER_CONFIGURATION.setSessionTimeoutMilliseconds(5000); - ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(5000); - zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); + ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), NAME_SPACE); + zookeeperConfiguration.setDigest("digest:password"); + zookeeperConfiguration.setSessionTimeoutMilliseconds(5000); + zookeeperConfiguration.setConnectionTimeoutMilliseconds(5000); + zkRegCenter = new ZookeeperRegistryCenter(zookeeperConfiguration); zkRegCenter.init(); RegistryCenterEnvironmentPreparer.persist(zkRegCenter); } diff --git a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterMiscellaneousTest.java b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterMiscellaneousTest.java index c92d551989..9f9a74583d 100644 --- a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterMiscellaneousTest.java +++ b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterMiscellaneousTest.java @@ -30,18 +30,18 @@ class ZookeeperRegistryCenterMiscellaneousTest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(9181); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); - private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = - new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterMiscellaneousTest.class.getName()); + private static ZookeeperConfiguration zookeeperConfiguration; private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll static void setUp() { EMBED_TESTING_SERVER.start(); - ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); - zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); + zookeeperConfiguration = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterMiscellaneousTest.class.getName()); + zookeeperConfiguration.setConnectionTimeoutMilliseconds(30000); + zkRegCenter = new ZookeeperRegistryCenter(zookeeperConfiguration); zkRegCenter.init(); zkRegCenter.addCacheData("/test"); } @@ -64,7 +64,7 @@ void assertGetRawCache() { @Test void assertGetZkConfig() { - ZookeeperRegistryCenter zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); - assertThat(zkRegCenter.getZkConfig(), is(ZOOKEEPER_CONFIGURATION)); + ZookeeperRegistryCenter zkRegCenter = new ZookeeperRegistryCenter(zookeeperConfiguration); + assertThat(zkRegCenter.getZkConfig(), is(zookeeperConfiguration)); } } diff --git a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterModifyTest.java b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterModifyTest.java index d4a1c9c5fc..300ac2e154 100644 --- a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterModifyTest.java +++ b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterModifyTest.java @@ -37,17 +37,16 @@ class ZookeeperRegistryCenterModifyTest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(9181); - - private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterModifyTest.class.getName()); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll static void setUp() { EMBED_TESTING_SERVER.start(); - zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); - ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); + ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterModifyTest.class.getName()); + zkRegCenter = new ZookeeperRegistryCenter(zookeeperConfiguration); + zookeeperConfiguration.setConnectionTimeoutMilliseconds(30000); zkRegCenter.init(); RegistryCenterEnvironmentPreparer.persist(zkRegCenter); } diff --git a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithCacheTest.java b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithCacheTest.java index 59eb61cf83..f37f1276a7 100644 --- a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithCacheTest.java +++ b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithCacheTest.java @@ -29,18 +29,16 @@ class ZookeeperRegistryCenterQueryWithCacheTest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(9181); - - private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = - new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterQueryWithCacheTest.class.getName()); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll static void setUp() { EMBED_TESTING_SERVER.start(); - zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); - ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); + ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterQueryWithCacheTest.class.getName()); + zkRegCenter = new ZookeeperRegistryCenter(zookeeperConfiguration); + zookeeperConfiguration.setConnectionTimeoutMilliseconds(30000); zkRegCenter.init(); RegistryCenterEnvironmentPreparer.persist(zkRegCenter); zkRegCenter.addCacheData("/test"); diff --git a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithoutCacheTest.java b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithoutCacheTest.java index c370073a85..d253d09056 100644 --- a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithoutCacheTest.java +++ b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterQueryWithoutCacheTest.java @@ -34,18 +34,16 @@ class ZookeeperRegistryCenterQueryWithoutCacheTest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(9181); - - private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = - new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterQueryWithoutCacheTest.class.getName()); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll static void setUp() { EMBED_TESTING_SERVER.start(); - ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); - zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); + ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterQueryWithoutCacheTest.class.getName()); + zookeeperConfiguration.setConnectionTimeoutMilliseconds(30000); + zkRegCenter = new ZookeeperRegistryCenter(zookeeperConfiguration); zkRegCenter.init(); RegistryCenterEnvironmentPreparer.persist(zkRegCenter); zkRegCenter.addCacheData("/other"); diff --git a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterTransactionTest.java b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterTransactionTest.java index b08795a04b..d73c975a59 100644 --- a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterTransactionTest.java +++ b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterTransactionTest.java @@ -34,18 +34,16 @@ class ZookeeperRegistryCenterTransactionTest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(9181); - - private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = - new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterTransactionTest.class.getName()); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll static void setUp() { EMBED_TESTING_SERVER.start(); - zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); - ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); + ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterTransactionTest.class.getName()); + zkRegCenter = new ZookeeperRegistryCenter(zookeeperConfiguration); + zookeeperConfiguration.setConnectionTimeoutMilliseconds(30000); zkRegCenter.init(); } diff --git a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterWatchTest.java b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterWatchTest.java index 1ead5e3f15..735afc18be 100644 --- a/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterWatchTest.java +++ b/registry-center/provider/zookeeper-curator/src/test/java/org/apache/shardingsphere/elasticjob/reg/zookeeper/ZookeeperRegistryCenterWatchTest.java @@ -37,17 +37,16 @@ class ZookeeperRegistryCenterWatchTest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(9181); - - private static final ZookeeperConfiguration ZOOKEEPER_CONFIGURATION = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterWatchTest.class.getName()); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static ZookeeperRegistryCenter zkRegCenter; @BeforeAll static void setUp() { EMBED_TESTING_SERVER.start(); - zkRegCenter = new ZookeeperRegistryCenter(ZOOKEEPER_CONFIGURATION); - ZOOKEEPER_CONFIGURATION.setConnectionTimeoutMilliseconds(30000); + ZookeeperConfiguration zookeeperConfiguration = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), ZookeeperRegistryCenterWatchTest.class.getName()); + zkRegCenter = new ZookeeperRegistryCenter(zookeeperConfiguration); + zookeeperConfiguration.setConnectionTimeoutMilliseconds(30000); zkRegCenter.init(); RegistryCenterEnvironmentPreparer.persist(zkRegCenter); } diff --git a/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/annotation/BaseAnnotationE2ETest.java b/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/annotation/BaseAnnotationE2ETest.java index 8dfa287dd3..1c1c30f75e 100644 --- a/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/annotation/BaseAnnotationE2ETest.java +++ b/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/annotation/BaseAnnotationE2ETest.java @@ -39,7 +39,7 @@ @Getter(AccessLevel.PROTECTED) public abstract class BaseAnnotationE2ETest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(7181); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static final ZookeeperConfiguration ZOOKEEPER_CONFIG = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), "zkRegTestCenter"); diff --git a/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/raw/BaseE2ETest.java b/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/raw/BaseE2ETest.java index ba384d29a9..3c16b028d2 100644 --- a/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/raw/BaseE2ETest.java +++ b/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/raw/BaseE2ETest.java @@ -38,7 +38,7 @@ @Getter(AccessLevel.PROTECTED) public abstract class BaseE2ETest { - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(7181); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static final ZookeeperConfiguration ZOOKEEPER_CONFIG = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), "zkRegTestCenter"); diff --git a/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/snapshot/BaseSnapshotServiceE2ETest.java b/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/snapshot/BaseSnapshotServiceE2ETest.java index e6d75ba387..02327898ca 100644 --- a/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/snapshot/BaseSnapshotServiceE2ETest.java +++ b/test/e2e/src/test/java/org/apache/shardingsphere/elasticjob/test/e2e/snapshot/BaseSnapshotServiceE2ETest.java @@ -35,9 +35,9 @@ public abstract class BaseSnapshotServiceE2ETest { - static final int DUMP_PORT = 9000; + static final int DUMP_PORT = -1; - private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(7181); + private static final EmbedTestingServer EMBED_TESTING_SERVER = new EmbedTestingServer(); private static final ZookeeperConfiguration ZOOKEEPER_CONFIG = new ZookeeperConfiguration(EMBED_TESTING_SERVER.getConnectionString(), "zkRegTestCenter"); diff --git a/test/util/src/main/java/org/apache/shardingsphere/elasticjob/test/util/EmbedTestingServer.java b/test/util/src/main/java/org/apache/shardingsphere/elasticjob/test/util/EmbedTestingServer.java index ee460f25cb..b98bfd022b 100644 --- a/test/util/src/main/java/org/apache/shardingsphere/elasticjob/test/util/EmbedTestingServer.java +++ b/test/util/src/main/java/org/apache/shardingsphere/elasticjob/test/util/EmbedTestingServer.java @@ -41,8 +41,6 @@ public final class EmbedTestingServer { private static final Object INIT_LOCK = new Object(); - private final int port; - /** * Start embed zookeeper server. */ @@ -64,7 +62,7 @@ public void start() { private void start0() { try { - testingServer = new TestingServer(port, true); + testingServer = new TestingServer(); // CHECKSTYLE:OFF } catch (final Exception ex) { // CHECKSTYLE:ON @@ -132,6 +130,6 @@ private boolean isIgnoredException(final Throwable cause) { * @return connection string */ public String getConnectionString() { - return "localhost:" + port; + return testingServer.getConnectString(); } }