You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ky...@apache.org on 2021/11/06 10:19:19 UTC
[dubbo] branch 3.0 updated: [Feature] Support the global registry
center in unit tests (#9138)
This is an automated email from the ASF dual-hosted git repository.
kylixs pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new b06e5c2 [Feature] Support the global registry center in unit tests (#9138)
b06e5c2 is described below
commit b06e5c2fdb7dc8fdf5ee3d18b3ef62cfe333e2c5
Author: Pin Xiong <pi...@foxmail.com>
AuthorDate: Sat Nov 6 18:19:06 2021 +0800
[Feature] Support the global registry center in unit tests (#9138)
---
.../dubbo/config/ConfigCenterConfigTest.java | 13 +-
.../apache/dubbo/config/ReferenceConfigTest.java | 19 +-
.../apache/dubbo/config/RegistryConfigTest.java | 7 +-
.../dubbo/config/bootstrap/DubboBootstrapTest.java | 11 +-
.../bootstrap/DubboServiceConsumerBootstrap.java | 5 +-
.../bootstrap/DubboServiceProviderBootstrap.java | 7 +-
.../DubboServiceProviderMinimumBootstrap.java | 3 +-
.../dubbo/config/bootstrap/MultiInstanceTest.java | 27 +--
.../ZookeeperDubboServiceConsumerBootstrap.java | 3 +-
.../DubboInterfaceConsumerBootstrap.java | 3 +-
.../AbstractRegistryCenterExporterListener.java | 2 +-
.../AbstractRegistryCenterServiceListener.java | 2 +-
.../dubbo/{ => config}/integration/Constants.java | 2 +-
.../{ => config}/integration/IntegrationTest.java | 2 +-
.../integration/multiple/AbstractStorage.java | 2 +-
.../{ => config}/integration/multiple/Storage.java | 2 +-
...gistryCenterExportMetadataExporterListener.java | 4 +-
...egistryCenterExportMetadataIntegrationTest.java | 25 +--
...ultipleRegistryCenterExportMetadataService.java | 2 +-
...pleRegistryCenterExportMetadataServiceImpl.java | 2 +-
...egistryCenterExportMetadataServiceListener.java | 4 +-
...gistryCenterExportProviderExporterListener.java | 4 +-
...MultipleRegistryCenterExportProviderFilter.java | 2 +-
...egistryCenterExportProviderIntegrationTest.java | 27 +--
...nterExportProviderRegistryProtocolListener.java | 2 +-
...ultipleRegistryCenterExportProviderService.java | 2 +-
...pleRegistryCenterExportProviderServiceImpl.java | 2 +-
...egistryCenterExportProviderServiceListener.java | 4 +-
...ultipleRegistryCenterInjvmExporterListener.java | 4 +-
.../injvm/MultipleRegistryCenterInjvmFilter.java | 2 +-
...MultipleRegistryCenterInjvmIntegrationTest.java | 29 +--
.../injvm/MultipleRegistryCenterInjvmService.java | 2 +-
.../MultipleRegistryCenterInjvmServiceImpl.java | 2 +-
...MultipleRegistryCenterInjvmServiceListener.java | 4 +-
.../integration/multiple/package-info.java | 2 +-
...terServiceDiscoveryRegistryIntegrationTest.java | 48 ++--
...ceDiscoveryRegistryRegistryServiceListener.java | 4 +-
...istryCenterServiceDiscoveryRegistryService.java | 2 +-
...yCenterServiceDiscoveryRegistryServiceImpl.java | 2 +-
.../ServiceDiscoveryRegistryInfoWrapper.java | 2 +-
.../ServiceDiscoveryRegistryStorage.java | 4 +-
...RegistryCenterDubboProtocolIntegrationTest.java | 24 +-
...ingleRegistryCenterExportedServiceListener.java | 4 +-
.../SingleRegistryCenterIntegrationService.java | 2 +-
...SingleRegistryCenterIntegrationServiceImpl.java | 2 +-
...gistryCenterExportMetadataExporterListener.java | 4 +-
...egistryCenterExportMetadataIntegrationTest.java | 23 +-
.../SingleRegistryCenterExportMetadataService.java | 2 +-
...gleRegistryCenterExportMetadataServiceImpl.java | 2 +-
...egistryCenterExportMetadataServiceListener.java | 4 +-
...gistryCenterExportProviderExporterListener.java | 4 +-
.../SingleRegistryCenterExportProviderFilter.java | 2 +-
...egistryCenterExportProviderIntegrationTest.java | 24 +-
...nterExportProviderRegistryProtocolListener.java | 4 +-
.../SingleRegistryCenterExportProviderService.java | 2 +-
...gleRegistryCenterExportProviderServiceImpl.java | 2 +-
...egistryCenterExportProviderServiceListener.java | 4 +-
.../SingleRegistryCenterInjvmExporterListener.java | 4 +-
.../injvm/SingleRegistryCenterInjvmFilter.java | 2 +-
.../SingleRegistryCenterInjvmIntegrationTest.java | 23 +-
.../injvm/SingleRegistryCenterInjvmService.java | 2 +-
.../SingleRegistryCenterInjvmServiceImpl.java | 2 +-
.../SingleRegistryCenterInjvmServiceListener.java | 4 +-
.../integration/single/package-info.java | 2 +-
.../metadata/MetadataServiceExporterTest.java | 20 +-
.../registrycenter/AbstractRegistryCenter.java | 107 ---------
.../dubbo/registrycenter/RegistryCenter.java | 70 ------
.../ZookeeperMultipleRegistryCenter.java | 45 ----
.../registrycenter/ZookeeperRegistryCenter.java | 142 ------------
.../org.apache.dubbo.config.ServiceListener | 14 +-
...g.apache.dubbo.registry.RegistryServiceListener | 2 +-
...o.registry.integration.RegistryProtocolListener | 4 +-
.../services/org.apache.dubbo.rpc.ExporterListener | 12 +-
.../META-INF/services/org.apache.dubbo.rpc.Filter | 8 +-
.../org/apache/dubbo/config/spring/ConfigTest.java | 15 --
.../dubbo/config/spring/JavaConfigBeanTest.java | 19 +-
.../annotation/MethodConfigCallbackTest.java | 9 +-
.../XmlReferenceBeanConditionalTest.java | 7 -
...nfigAnnotationReferenceBeanConditionalTest.java | 7 -
.../JavaConfigRawReferenceBeanConditionalTest.java | 7 -
.../JavaConfigReferenceBeanConditionalTest4.java | 7 -
.../configprops/SpringBootConfigPropsTest.java | 64 +++---
.../SpringBootMultipleConfigPropsTest.java | 17 +-
.../importxml/SpringBootImportDubboXmlTest.java | 7 -
.../annotation/DubboConfigConfigurationTest.java | 24 +-
.../context/annotation/EnableDubboConfigTest.java | 7 -
.../customize/DubboSpringInitCustomizerTest.java | 11 +-
.../spring/issues/issue6000/Issue6000Test.java | 7 -
.../spring/issues/issue6252/Issue6252Test.java | 7 -
.../spring/issues/issue7003/Issue7003Test.java | 7 -
.../issue9172/MultipleConsumerAndProviderTest.java | 18 --
.../consumer/PropertyConfigurerTest.java | 7 -
.../propertyconfigurer/consumer/app.properties | 2 +-
.../propertyconfigurer/consumer/dubbo-consumer.xml | 2 +-
.../consumer2/PropertySourcesConfigurerTest.java | 7 -
.../propertyconfigurer/consumer2/app.properties | 2 +-
.../consumer2/dubbo-consumer.xml | 2 +-
.../consumer3/PropertySourcesInJavaConfigTest.java | 16 --
.../propertyconfigurer/consumer3/app.properties | 2 +-
.../consumer3/dubbo-consumer.xml | 2 +-
.../propertyconfigurer/provider/app.properties | 6 +-
.../reference/DubboConfigBeanInitializerTest.java | 8 +-
.../config/spring/reference/ReferenceKeyTest.java | 18 --
.../javaconfig/JavaConfigReferenceBeanTest.java | 19 --
.../reference/javaconfig/consumer.properties | 2 +-
.../spring/reference/localcall/LocalCallTest.java | 8 -
.../spring/reference/localcall/LocalCallTest2.java | 7 -
.../reference/localcall/local-call-provider.xml | 2 +-
.../LocalCallMultipleReferenceAnnotationsTest.java | 12 -
.../localcallam/local-call-config.properties | 2 +-
.../registrycenter/AbstractRegistryCenter.java | 107 ---------
.../spring/registrycenter/RegistryCenter.java | 75 -------
.../ZookeeperMultipleRegistryCenter.java | 43 ----
.../registrycenter/ZookeeperRegistryCenter.java | 147 ------------
.../ZookeeperSingleRegistryCenter.java | 44 ----
.../config/spring/schema/GenericServiceTest.java | 7 -
.../schema/GenericServiceWithoutInterfaceTest.java | 7 -
.../META-INF/issues/issue6000/config.properties | 2 +-
.../META-INF/issues/issue6252/config.properties | 4 +-
.../META-INF/issues/issue7003/config.properties | 2 +-
.../zookeeper-dubbb-consumer.properties | 2 +-
.../zookeeper-dubbb-provider.properties | 2 +-
.../zookeeper-dubbo-consumer.xml | 4 +-
.../dubbo-generic-consumer-without-interface.xml | 2 +-
.../META-INF/spring/dubbo-generic-consumer.xml | 2 +-
.../resources/spring/dubbo-consumer.properties | 2 +-
.../src/main/resources/spring/dubbo-consumer.xml | 4 +-
dubbo-test/dubbo-test-check/pom.xml | 46 +++-
...bstractRegistryCenterTestExecutionListener.java | 93 ++++++++
.../dubbo/test/check/RegistryCenterFinished.java | 26 ++-
.../dubbo/test/check/RegistryCenterStarted.java | 50 +++++
.../test/check/exception/DubboTestException.java | 43 ++++
.../dubbo/test/check/registrycenter/Config.java | 67 ++++++
.../dubbo/test/check/registrycenter/Context.java | 11 +-
.../registrycenter/GlobalRegistryCenter.java} | 35 ++-
.../test/check/registrycenter/Initializer.java | 14 +-
.../dubbo/test/check/registrycenter/Processor.java | 18 +-
.../test/check/registrycenter/RegistryCenter.java | 31 +--
.../registrycenter/ZookeeperRegistryCenter.java | 186 ++++++++++++++++
.../registrycenter/config/ZookeeperConfig.java | 175 +++++++++++++++
.../config/ZookeeperRegistryCenterConfig.java | 84 +++++++
.../registrycenter/context/ZookeeperContext.java | 73 ++++++
.../context/ZookeeperWindowsContext.java | 110 +++++++++
.../initializer/ConfigZookeeperInitializer.java | 119 ++++++++++
.../initializer/DownloadZookeeperInitializer.java | 92 ++++++++
.../initializer/UnpackZookeeperInitializer.java | 97 ++++++++
.../initializer/ZookeeperInitializer.java | 51 +++++
.../processor/FindPidWindowsProcessor.java | 119 ++++++++++
.../processor/KillProcessWindowsProcessor.java | 61 +++++
.../processor/ResetZookeeperProcessor.java | 55 +++++
.../processor/StartZookeeperUnixProcessor.java | 64 ++++++
.../processor/StartZookeeperWindowsProcessor.java | 81 +++++++
.../processor/StopZookeeperUnixProcessor.java | 61 +++++
.../processor/StopZookeeperWindowsProcessor.java | 52 +++++
.../processor/ZookeeperUnixProcessor.java | 100 +++++++++
.../processor/ZookeeperWindowsProcessor.java | 41 ++++
...g.junit.platform.launcher.TestExecutionListener | 4 +
.../dubbo/test/common/EmbeddedZooKeeper.java | 248 ---------------------
.../apache/dubbo/test/common/ZooKeeperServer.java | 57 -----
.../registrycenter/AbstractRegistryCenter.java | 107 ---------
.../test/common/registrycenter/RegistryCenter.java | 70 ------
.../ZookeeperMultipleRegistryCenter.java | 43 ----
.../registrycenter/ZookeeperRegistryCenter.java | 142 ------------
.../test/spring/SpringAnnotationBeanTest.java | 7 -
.../test/spring/SpringJavaConfigBeanTest.java | 10 +-
.../dubbo/test/spring/SpringXmlConfigTest.java | 7 -
.../src/main/resources/demo-app.properties | 6 +-
.../src/main/resources/spring/dubbo-demo.xml | 6 +-
168 files changed, 2256 insertions(+), 2197 deletions(-)
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java
index d006c0f..6de79d8 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ConfigCenterConfigTest.java
@@ -21,6 +21,7 @@ package org.apache.dubbo.config;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -60,11 +61,11 @@ public class ConfigCenterConfigTest {
ConfigCenterConfig config = new ConfigCenterConfig();
config.setNamespace("namespace");
config.setGroup("group");
- config.setAddress("zookeeper://127.0.0.1:2181");
+ config.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress());
config.setHighestPriority(null);
config.refresh();
- Assertions.assertEquals("zookeeper://127.0.0.1:2181/ConfigCenterConfig?check=true&" +
+ Assertions.assertEquals(ZookeeperRegistryCenterConfig.getConnectionAddress()+"/ConfigCenterConfig?check=true&" +
"config-file=dubbo.properties&group=group&" +
"namespace=namespace&timeout=3000",
config.toUrl().toFullString()
@@ -74,7 +75,7 @@ public class ConfigCenterConfigTest {
@Test
public void testOverrideConfig() {
- String zkAddr = "zookeeper://127.0.0.1:2181";
+ String zkAddr = ZookeeperRegistryCenterConfig.getConnectionAddress();
// sysprops has no id
SysProps.setProperty("dubbo.config-center.check", "false");
SysProps.setProperty("dubbo.config-center.address", zkAddr);
@@ -116,7 +117,7 @@ public class ConfigCenterConfigTest {
try {
//No id but has address
ConfigCenterConfig configCenter = new ConfigCenterConfig();
- configCenter.setAddress("zookeeper://127.0.0.1:2181");
+ configCenter.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress());
DubboBootstrap.getInstance()
.application("demo-app")
@@ -277,7 +278,7 @@ public class ConfigCenterConfigTest {
@Test
public void testAttributes() {
ConfigCenterConfig cc = new ConfigCenterConfig();
- cc.setAddress("zookeeper://127.0.0.1:2181");
+ cc.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress());
Map<String, String> attributes = new LinkedHashMap<>();
ConfigCenterConfig.appendAttributes(attributes, cc);
@@ -291,7 +292,7 @@ public class ConfigCenterConfigTest {
@Test
public void testSetAddress() {
- String address = "zookeeper://127.0.0.1:2181";
+ String address = ZookeeperRegistryCenterConfig.getConnectionAddress();
ConfigCenterConfig cc = new ConfigCenterConfig();
cc.setUsername("user123"); // set username first
cc.setPassword("pass123");
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
index e3fd806..3a0b747 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ReferenceConfigTest.java
@@ -32,8 +32,6 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.context.ModuleConfigManager;
import org.apache.dubbo.config.provider.impl.DemoServiceImpl;
import org.apache.dubbo.registry.client.migration.MigrationInvoker;
-import org.apache.dubbo.registrycenter.RegistryCenter;
-import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.rpc.Exporter;
import org.apache.dubbo.rpc.Invoker;
import org.apache.dubbo.rpc.ProxyFactory;
@@ -54,7 +52,6 @@ import demo.MultiClassLoaderServiceResult;
import javassist.CannotCompileException;
import javassist.CtClass;
import javassist.NotFoundException;
-import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -127,17 +124,11 @@ public class ReferenceConfigTest {
private static String zkUrl1;
private static String zkUrl2;
private static String registryUrl1;
- private static RegistryCenter registryCenter1;
- private static RegistryCenter registryCenter2;
@BeforeAll
public static void beforeAll() {
- int zkServerPort1 = NetUtils.getAvailablePort(NetUtils.getRandomPort());
- registryCenter1 = new ZookeeperSingleRegistryCenter(zkServerPort1);
- registryCenter1.startup();
- int zkServerPort2 = NetUtils.getAvailablePort(NetUtils.getRandomPort());
- registryCenter2 = new ZookeeperSingleRegistryCenter(zkServerPort2);
- registryCenter2.startup();
+ int zkServerPort1 = 2181;
+ int zkServerPort2 = 2182;
zkUrl1 = "zookeeper://localhost:" + zkServerPort1;
zkUrl2 = "zookeeper://localhost:" + zkServerPort2;
registryUrl1 = "registry://localhost:" + zkServerPort1 + "?registry=zookeeper";
@@ -156,12 +147,6 @@ public class ReferenceConfigTest {
Mockito.framework().clearInlineMocks();
}
- @AfterAll
- public static void afterAll() {
- registryCenter1.shutdown();
- registryCenter2.shutdown();
- }
-
/**
* Test whether the configuration required for the aggregation service reference meets expectations
*/
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/RegistryConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/RegistryConfigTest.java
index b895d6d..10186e1 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/RegistryConfigTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/RegistryConfigTest.java
@@ -22,6 +22,7 @@ import org.apache.dubbo.common.utils.UrlUtils;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -202,7 +203,7 @@ public class RegistryConfigTest {
public void testEquals() throws Exception {
RegistryConfig registry1 = new RegistryConfig();
RegistryConfig registry2 = new RegistryConfig();
- registry1.setAddress("zookeeper://127.0.0.1:2182");
+ registry1.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress2());
registry2.setAddress("zookeeper://127.0.0.1:2183");
Assertions.assertNotEquals(registry1, registry2);
}
@@ -241,7 +242,7 @@ public class RegistryConfigTest {
// process Parameter annotation
AbstractConfig.appendParameters(map, registry);
// Simulate the check that ZoneAwareClusterInvoker#doInvoke do
- URL url = UrlUtils.parseURL("zookeeper://127.0.0.1:2181", map);
+ URL url = UrlUtils.parseURL(ZookeeperRegistryCenterConfig.getConnectionAddress1(), map);
Assertions.assertTrue(url.getParameter(PREFERRED_KEY, false));
}
@@ -253,7 +254,7 @@ public class RegistryConfigTest {
// Process Parameter annotation
AbstractConfig.appendParameters(map, registry);
// Simulate the check that ZoneAwareClusterInvoker#doInvoke do
- URL url = UrlUtils.parseURL("zookeeper://127.0.0.1:2181", map);
+ URL url = UrlUtils.parseURL(ZookeeperRegistryCenterConfig.getConnectionAddress1(), map);
Assertions.assertFalse(url.getParameter(PREFERRED_KEY, false));
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
index 2df9558..c238c0d 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboBootstrapTest.java
@@ -44,6 +44,7 @@ import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.protocol.dubbo.DubboProtocol;
import org.apache.curator.test.TestingServer;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
@@ -192,7 +193,7 @@ public class DubboBootstrapTest {
MonitorConfig monitorConfig = new MonitorConfig();
monitorConfig.setProtocol("registry");
- URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf("zookeeper://127.0.0.1:2181"));
+ URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf(ZookeeperRegistryCenterConfig.getConnectionAddress()));
Assertions.assertEquals("dubbo", url.getProtocol());
Assertions.assertEquals("registry", url.getParameter("protocol"));
}
@@ -203,14 +204,14 @@ public class DubboBootstrapTest {
MonitorConfig monitorConfig = new MonitorConfig();
monitorConfig.setProtocol("service-discovery-registry");
- URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf("zookeeper://127.0.0.1:2181"));
+ URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf(ZookeeperRegistryCenterConfig.getConnectionAddress()));
Assertions.assertEquals("dubbo", url.getProtocol());
Assertions.assertEquals("service-discovery-registry", url.getParameter("protocol"));
}
@Test
public void testLoadUserMonitor_no_monitor() {
- URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(null), URL.valueOf("zookeeper://127.0.0.1:2181"));
+ URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(null), URL.valueOf(ZookeeperRegistryCenterConfig.getConnectionAddress()));
Assertions.assertNull(url);
}
@@ -220,7 +221,7 @@ public class DubboBootstrapTest {
MonitorConfig monitorConfig = new MonitorConfig();
monitorConfig.setProtocol("user");
- URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf("zookeeper://127.0.0.1:2181"));
+ URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf(ZookeeperRegistryCenterConfig.getConnectionAddress()));
Assertions.assertEquals("user", url.getProtocol());
}
@@ -229,7 +230,7 @@ public class DubboBootstrapTest {
// dubbo.monitor.address=user://1.2.3.4:5678?k=v
MonitorConfig monitorConfig = new MonitorConfig();
monitorConfig.setAddress("user://1.2.3.4:5678?param1=value1");
- URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf("zookeeper://127.0.0.1:2181"));
+ URL url = ConfigValidationUtils.loadMonitor(getTestInterfaceConfig(monitorConfig), URL.valueOf(ZookeeperRegistryCenterConfig.getConnectionAddress()));
Assertions.assertEquals("user", url.getProtocol());
Assertions.assertEquals("1.2.3.4:5678", url.getAddress());
Assertions.assertEquals("value1", url.getParameter("param1"));
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceConsumerBootstrap.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceConsumerBootstrap.java
index f493c16..ca84218 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceConsumerBootstrap.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceConsumerBootstrap.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.config.bootstrap;
import org.apache.dubbo.config.MetadataReportConfig;
import org.apache.dubbo.config.bootstrap.rest.UserService;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
/**
* Dubbo Provider Bootstrap
@@ -35,8 +36,8 @@ public class DubboServiceConsumerBootstrap {
// .registry(builder -> builder.address("eureka://127.0.0.1:8761?registry-type=service&subscribed-services=dubbo-provider-demo"))
// Zookeeper
- .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181?registry-type=service&subscribed-services=dubbo-provider-demo"))
- .metadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181"))
+ .registry("zookeeper", builder -> builder.address(ZookeeperRegistryCenterConfig.getConnectionAddress()+"?registry-type=service&subscribed-services=dubbo-provider-demo"))
+ .metadataReport(new MetadataReportConfig(ZookeeperRegistryCenterConfig.getConnectionAddress()))
// Nacos
// .registry("nacos", builder -> builder.address("nacos://127.0.0.1:8848?registry.type=service&subscribed.services=dubbo-provider-demo"))
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceProviderBootstrap.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceProviderBootstrap.java
index 35285dd..6ed4511 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceProviderBootstrap.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceProviderBootstrap.java
@@ -23,6 +23,7 @@ import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.bootstrap.rest.UserService;
import org.apache.dubbo.config.bootstrap.rest.UserServiceImpl;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import java.util.Arrays;
@@ -45,11 +46,11 @@ public class DubboServiceProviderBootstrap {
RegistryConfig interfaceRegistry = new RegistryConfig();
interfaceRegistry.setId("interfaceRegistry");
- interfaceRegistry.setAddress("zookeeper://127.0.0.1:2181");
+ interfaceRegistry.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress());
RegistryConfig serviceRegistry = new RegistryConfig();
serviceRegistry.setId("serviceRegistry");
- serviceRegistry.setAddress("zookeeper://127.0.0.1:2181?registry-type=service");
+ serviceRegistry.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress()+"?registry-type=service");
ServiceConfig<EchoService> echoService = new ServiceConfig<>();
echoService.setInterface(EchoService.class.getName());
@@ -73,7 +74,7 @@ public class DubboServiceProviderBootstrap {
.registries(Arrays.asList(interfaceRegistry, serviceRegistry))
// .registry(RegistryBuilder.newBuilder().address("consul://127.0.0.1:8500?registry.type=service").build())
.protocol(builder -> builder.port(-1).name("dubbo"))
- .metadataReport(new MetadataReportConfig("zookeeper://127.0.0.1:2181"))
+ .metadataReport(new MetadataReportConfig(ZookeeperRegistryCenterConfig.getConnectionAddress()))
.service(echoService)
.service(userService)
.start()
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceProviderMinimumBootstrap.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceProviderMinimumBootstrap.java
index b4e3cfa..2d705ac 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceProviderMinimumBootstrap.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/DubboServiceProviderMinimumBootstrap.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.config.bootstrap;
import org.apache.dubbo.config.bootstrap.rest.UserService;
import org.apache.dubbo.config.bootstrap.rest.UserServiceImpl;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
/**
* TODO
@@ -27,7 +28,7 @@ public class DubboServiceProviderMinimumBootstrap {
public static void main(String[] args) {
DubboBootstrap.getInstance()
.application("dubbo-provider-demo")
- .registry(builder -> builder.address("zookeeper://127.0.0.1:2181?registry-type=service"))
+ .registry(builder -> builder.address(ZookeeperRegistryCenterConfig.getConnectionAddress()+"?registry-type=service"))
// .registry(builder -> builder.address("eureka://127.0.0.1:8761?registry-type=service"))
.protocol(builder -> builder.port(-1).name("dubbo"))
.service("echo", builder -> builder.interfaceClass(EchoService.class).ref(new EchoServiceImpl()))
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/MultiInstanceTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/MultiInstanceTest.java
index b3a98ec..4aacacd 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/MultiInstanceTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/MultiInstanceTest.java
@@ -34,14 +34,13 @@ import org.apache.dubbo.config.api.DemoService;
import org.apache.dubbo.config.api.Greeting;
import org.apache.dubbo.config.mock.GreetingLocal2;
import org.apache.dubbo.config.provider.impl.DemoServiceImpl;
-import org.apache.dubbo.registrycenter.RegistryCenter;
-import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.dubbo.rpc.model.FrameworkServiceRepository;
import org.apache.dubbo.rpc.model.ModuleModel;
import org.apache.dubbo.rpc.model.ServiceDescriptor;
import org.apache.dubbo.test.check.DubboTestChecker;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
@@ -63,8 +62,6 @@ public class MultiInstanceTest {
private static final Logger logger = LoggerFactory.getLogger(MultiInstanceTest.class);
- private static ZookeeperSingleRegistryCenter registryCenter;
-
private static RegistryConfig registryConfig;
private static DubboTestChecker testChecker;
@@ -73,13 +70,7 @@ public class MultiInstanceTest {
@BeforeAll
public static void beforeAll() {
FrameworkModel.destroyAll();
- registryCenter = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
- registryCenter.startup();
- RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
- registryConfig = new RegistryConfig(String.format("%s://%s:%s",
- instance.getType(),
- instance.getHostname(),
- instance.getPort()));
+ registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress1());
// pre-check threads
//precheckUnclosedThreads();
@@ -87,7 +78,6 @@ public class MultiInstanceTest {
@AfterAll
public static void afterAll() throws Exception {
- registryCenter.shutdown();
FrameworkModel.destroyAll();
// check threads
@@ -321,7 +311,6 @@ public class MultiInstanceTest {
DubboBootstrap providerBootstrap1 = null;
DubboBootstrap providerBootstrap2 = null;
- ZookeeperSingleRegistryCenter registryCenter2 = null;
try {
@@ -349,13 +338,7 @@ public class MultiInstanceTest {
Assertions.assertTrue(stackTraces1.size() > 0, "Get threads of provider app 1 failed");
// start zk server 2
- registryCenter2 = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
- registryCenter2.startup();
- RegistryCenter.Instance instance = registryCenter2.getRegistryCenterInstance().get(0);
- RegistryConfig registryConfig2 = new RegistryConfig(String.format("%s://%s:%s",
- instance.getType(),
- instance.getHostname(),
- instance.getPort()));
+ RegistryConfig registryConfig2 = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress2());
// start provider app 2 use a difference zk server 2
ServiceConfig serviceConfig2 = new ServiceConfig();
@@ -388,7 +371,6 @@ public class MultiInstanceTest {
// stop provider app 2 and check threads
providerBootstrap2.stop();
// shutdown register center after dubbo application to avoid unregister services blocking
- registryCenter2.shutdown();
checkUnclosedThreadsOfApp(stackTraces2, "Found unclosed threads of app 2: ", null);
} finally {
@@ -398,9 +380,6 @@ public class MultiInstanceTest {
if (providerBootstrap2 != null) {
providerBootstrap2.stop();
}
- if (registryCenter2 != null) {
- registryCenter2.shutdown();
- }
}
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/ZookeeperDubboServiceConsumerBootstrap.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/ZookeeperDubboServiceConsumerBootstrap.java
index 27f3eb9..2509320 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/ZookeeperDubboServiceConsumerBootstrap.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/ZookeeperDubboServiceConsumerBootstrap.java
@@ -17,6 +17,7 @@
package org.apache.dubbo.config.bootstrap;
import org.apache.dubbo.config.bootstrap.rest.UserService;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import static org.apache.dubbo.common.constants.CommonConstants.COMPOSITE_METADATA_STORAGE_TYPE;
import static org.apache.dubbo.common.constants.RegistryConstants.REGISTRY_TYPE_KEY;
@@ -33,7 +34,7 @@ public class ZookeeperDubboServiceConsumerBootstrap {
DubboBootstrap bootstrap = DubboBootstrap.getInstance()
.application("zookeeper-dubbo-consumer", app -> app.metadata(COMPOSITE_METADATA_STORAGE_TYPE))
- .registry("zookeeper", builder -> builder.address("zookeeper://127.0.0.1:2181")
+ .registry("zookeeper", builder -> builder.address(ZookeeperRegistryCenterConfig.getConnectionAddress())
.parameter(REGISTRY_TYPE_KEY, SERVICE_REGISTRY_TYPE)
.useAsConfigCenter(true)
.useAsMetadataCenter(true))
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/compatible/DubboInterfaceConsumerBootstrap.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/compatible/DubboInterfaceConsumerBootstrap.java
index 738a881..d9c9c57 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/compatible/DubboInterfaceConsumerBootstrap.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/bootstrap/compatible/DubboInterfaceConsumerBootstrap.java
@@ -20,6 +20,7 @@ import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.bootstrap.EchoService;
import org.apache.dubbo.config.bootstrap.rest.UserService;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
/**
* Dubbo Provider Bootstrap
@@ -31,7 +32,7 @@ public class DubboInterfaceConsumerBootstrap {
public static void main(String[] args) throws Exception {
RegistryConfig interfaceRegistry = new RegistryConfig();
interfaceRegistry.setId("interfaceRegistry");
- interfaceRegistry.setAddress("zookeeper://127.0.0.1:2181");
+ interfaceRegistry.setAddress(ZookeeperRegistryCenterConfig.getConnectionAddress());
DubboBootstrap bootstrap = DubboBootstrap.getInstance()
.application("dubbo-consumer-demo")
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/AbstractRegistryCenterExporterListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/AbstractRegistryCenterExporterListener.java
similarity index 98%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/AbstractRegistryCenterExporterListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/AbstractRegistryCenterExporterListener.java
index c23e400..69a3d5e 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/AbstractRegistryCenterExporterListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/AbstractRegistryCenterExporterListener.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration;
+package org.apache.dubbo.config.integration;
import org.apache.dubbo.rpc.Exporter;
import org.apache.dubbo.rpc.ExporterListener;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/AbstractRegistryCenterServiceListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/AbstractRegistryCenterServiceListener.java
similarity index 97%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/AbstractRegistryCenterServiceListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/AbstractRegistryCenterServiceListener.java
index 438e228..c898c91 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/AbstractRegistryCenterServiceListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/AbstractRegistryCenterServiceListener.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration;
+package org.apache.dubbo.config.integration;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.ServiceListener;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/Constants.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/Constants.java
similarity index 95%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/Constants.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/Constants.java
index 6680d31..1acd830 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/Constants.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/Constants.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration;
+package org.apache.dubbo.config.integration;
public interface Constants {
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/IntegrationTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/IntegrationTest.java
similarity index 95%
copy from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/IntegrationTest.java
copy to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/IntegrationTest.java
index 37ba809..a185231 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/IntegrationTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/IntegrationTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration;
+package org.apache.dubbo.config.integration;
/**
* The interface for integration testcases.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/AbstractStorage.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/AbstractStorage.java
similarity index 97%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/AbstractStorage.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/AbstractStorage.java
index 7a0b938..f113cde 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/AbstractStorage.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/AbstractStorage.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple;
+package org.apache.dubbo.config.integration.multiple;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/Storage.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/Storage.java
similarity index 97%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/Storage.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/Storage.java
index 064289c..cf2d870 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/Storage.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/Storage.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple;
+package org.apache.dubbo.config.integration.multiple;
/**
* This interface to store the given type instance in multiple registry center.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataExporterListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataExporterListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataExporterListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataExporterListener.java
index 796a5e4..1dc3e79 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataExporterListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataExporterListener.java
@@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportmetadata;
+package org.apache.dubbo.config.integration.multiple.exportmetadata;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
-import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
import org.apache.dubbo.metadata.MetadataService;
@Activate(group = CommonConstants.PROVIDER, order = 1000)
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataIntegrationTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataIntegrationTest.java
similarity index 90%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataIntegrationTest.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataIntegrationTest.java
index 958d558..4468434 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataIntegrationTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataIntegrationTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportmetadata;
+package org.apache.dubbo.config.integration.multiple.exportmetadata;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.config.RegistryConfig;
@@ -23,13 +23,12 @@ import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ServiceListener;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.config.integration.IntegrationTest;
import org.apache.dubbo.metadata.MetadataService;
-import org.apache.dubbo.registrycenter.RegistryCenter;
-import org.apache.dubbo.registrycenter.ZookeeperMultipleRegistryCenter;
import org.apache.dubbo.rpc.Exporter;
import org.apache.dubbo.rpc.ExporterListener;
import org.apache.dubbo.rpc.Filter;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -77,17 +76,11 @@ public class MultipleRegistryCenterExportMetadataIntegrationTest implements Inte
*/
private MultipleRegistryCenterExportMetadataExporterListener exporterListener;
- /**
- * Define a registry center.
- */
- private RegistryCenter registryCenter;
@BeforeEach
public void setUp() throws Exception {
logger.info(getClass().getSimpleName() + " testcase is beginning...");
DubboBootstrap.reset();
- registryCenter = new ZookeeperMultipleRegistryCenter();
- registryCenter.startup();
// initialize service config
serviceConfig = new ServiceConfig<>();
serviceConfig.setInterface(MultipleRegistryCenterExportMetadataService.class);
@@ -99,13 +92,9 @@ public class MultipleRegistryCenterExportMetadataIntegrationTest implements Inte
DubboBootstrap.getInstance()
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
.protocol(new ProtocolConfig(PROTOCOL_NAME))
- .service(serviceConfig);
- for (RegistryCenter.Instance instance : registryCenter.getRegistryCenterInstance()) {
- DubboBootstrap.getInstance().registry(new RegistryConfig(String.format("%s://%s:%s",
- instance.getType(),
- instance.getHostname(),
- instance.getPort())));
- }
+ .service(serviceConfig)
+ .registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress1()))
+ .registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress2()));
}
/**
@@ -201,7 +190,5 @@ public class MultipleRegistryCenterExportMetadataIntegrationTest implements Inte
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
serviceListener = null;
logger.info(getClass().getSimpleName() + " testcase is ending...");
- registryCenter.shutdown();
- registryCenter = null;
}
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataService.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataService.java
similarity index 93%
copy from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataService.java
copy to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataService.java
index 5cd33e3..e6a58fe 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataService.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataService.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportmetadata;
+package org.apache.dubbo.config.integration.multiple.exportmetadata;
/**
* This interface is used to check if the exported metadata service works well or not in multiple registry center.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceImpl.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceImpl.java
similarity index 94%
copy from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceImpl.java
copy to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceImpl.java
index 9836d74..a6ea415 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceImpl.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceImpl.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportmetadata;
+package org.apache.dubbo.config.integration.multiple.exportmetadata;
/**
* The simple implementation for {@link MultipleRegistryCenterExportMetadataService}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceListener.java
index 13605be..7a057cd 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceListener.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportmetadata;
+package org.apache.dubbo.config.integration.multiple.exportmetadata;
import org.apache.dubbo.config.ServiceListener;
-import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
import org.apache.dubbo.metadata.MetadataService;
/**
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderExporterListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderExporterListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderExporterListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderExporterListener.java
index bf867b1..4aba6c9 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderExporterListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderExporterListener.java
@@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportprovider;
+package org.apache.dubbo.config.integration.multiple.exportprovider;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
-import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
@Activate(group = CommonConstants.PROVIDER, order = 1000)
public class MultipleRegistryCenterExportProviderExporterListener extends AbstractRegistryCenterExporterListener {
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderFilter.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderFilter.java
similarity index 97%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderFilter.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderFilter.java
index 0457238..daf839b 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderFilter.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderFilter.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportprovider;
+package org.apache.dubbo.config.integration.multiple.exportprovider;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderIntegrationTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderIntegrationTest.java
similarity index 92%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderIntegrationTest.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderIntegrationTest.java
index 7b80c23..3f9a4c4 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderIntegrationTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderIntegrationTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportprovider;
+package org.apache.dubbo.config.integration.multiple.exportprovider;
import org.apache.dubbo.common.config.configcenter.ConfigItem;
import org.apache.dubbo.common.constants.CommonConstants;
@@ -26,15 +26,14 @@ import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.ServiceListener;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.config.integration.IntegrationTest;
import org.apache.dubbo.metadata.ServiceNameMapping;
import org.apache.dubbo.metadata.report.MetadataReportInstance;
import org.apache.dubbo.registry.integration.RegistryProtocolListener;
-import org.apache.dubbo.registrycenter.RegistryCenter;
-import org.apache.dubbo.registrycenter.ZookeeperMultipleRegistryCenter;
import org.apache.dubbo.rpc.ExporterListener;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -76,11 +75,6 @@ public class MultipleRegistryCenterExportProviderIntegrationTest implements Inte
private ServiceConfig<MultipleRegistryCenterExportProviderService> serviceConfig;
/**
- * Define a registry center.
- */
- private RegistryCenter registryCenter;
-
- /**
* Define a {@link RegistryProtocolListener} instance.
*/
private MultipleRegistryCenterExportProviderRegistryProtocolListener registryProtocolListener;
@@ -104,8 +98,6 @@ public class MultipleRegistryCenterExportProviderIntegrationTest implements Inte
public void setUp() throws Exception {
logger.info(getClass().getSimpleName() + " testcase is beginning...");
DubboBootstrap.reset();
- registryCenter = new ZookeeperMultipleRegistryCenter();
- registryCenter.startup();
// initialize service config
serviceConfig = new ServiceConfig<>();
serviceConfig.setInterface(MultipleRegistryCenterExportProviderService.class);
@@ -116,14 +108,9 @@ public class MultipleRegistryCenterExportProviderIntegrationTest implements Inte
DubboBootstrap.getInstance()
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
.protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
- .service(serviceConfig);
- for (RegistryCenter.Instance instance : registryCenter.getRegistryCenterInstance()) {
- RegistryConfig registryConfig = new RegistryConfig(String.format("%s://%s:%s",
- instance.getType(),
- instance.getHostname(),
- instance.getPort()));
- DubboBootstrap.getInstance().registry(registryConfig);
- }
+ .service(serviceConfig)
+ .registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress1()))
+ .registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress2()));
}
/**
@@ -254,8 +241,6 @@ public class MultipleRegistryCenterExportProviderIntegrationTest implements Inte
// The exported service has been unexported
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
logger.info(getClass().getSimpleName() + " testcase is ending...");
- registryCenter.shutdown();
registryProtocolListener = null;
- registryCenter = null;
}
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderRegistryProtocolListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderRegistryProtocolListener.java
similarity index 97%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderRegistryProtocolListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderRegistryProtocolListener.java
index b4ca7b3..8b6c87f 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderRegistryProtocolListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderRegistryProtocolListener.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportprovider;
+package org.apache.dubbo.config.integration.multiple.exportprovider;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Activate;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderService.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderService.java
similarity index 93%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderService.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderService.java
index a933113..070fa6c 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderService.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderService.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportprovider;
+package org.apache.dubbo.config.integration.multiple.exportprovider;
/**
* This interface is used to check if the exported provider works well or not in multiple registry center.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceImpl.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceImpl.java
similarity index 94%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceImpl.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceImpl.java
index 760c164..520b14b 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceImpl.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceImpl.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportprovider;
+package org.apache.dubbo.config.integration.multiple.exportprovider;
/**
* The implementation of {@link MultipleRegistryCenterExportProviderService}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceListener.java
index c8a6576..517c608 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/exportprovider/MultipleRegistryCenterExportProviderServiceListener.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportprovider;
+package org.apache.dubbo.config.integration.multiple.exportprovider;
import org.apache.dubbo.config.ServiceListener;
-import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
/**
* This implementation of {@link ServiceListener} is to record exported services with injvm protocol in single registry center.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmExporterListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmExporterListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmExporterListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmExporterListener.java
index 1820a12..ead3bb6 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmExporterListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmExporterListener.java
@@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.injvm;
+package org.apache.dubbo.config.integration.multiple.injvm;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
-import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
@Activate(group = CommonConstants.PROVIDER, order = 1000)
public class MultipleRegistryCenterInjvmExporterListener extends AbstractRegistryCenterExporterListener {
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmFilter.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmFilter.java
similarity index 97%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmFilter.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmFilter.java
index 679ff83..cd2e87d 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmFilter.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmFilter.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.injvm;
+package org.apache.dubbo.config.integration.multiple.injvm;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmIntegrationTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmIntegrationTest.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmIntegrationTest.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmIntegrationTest.java
index 0c7cf66..291f559 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmIntegrationTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmIntegrationTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.injvm;
+package org.apache.dubbo.config.integration.multiple.injvm;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.config.ApplicationConfig;
@@ -24,11 +24,10 @@ import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.ServiceListener;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.integration.IntegrationTest;
-import org.apache.dubbo.registrycenter.RegistryCenter;
-import org.apache.dubbo.registrycenter.ZookeeperMultipleRegistryCenter;
+import org.apache.dubbo.config.integration.IntegrationTest;
import org.apache.dubbo.rpc.ExporterListener;
import org.apache.dubbo.rpc.Filter;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -77,18 +76,10 @@ public class MultipleRegistryCenterInjvmIntegrationTest implements IntegrationTe
*/
private MultipleRegistryCenterInjvmFilter filter;
- /**
- * Default a registry center.
- */
- private RegistryCenter registryCenter;
-
@BeforeEach
public void setUp() throws Exception {
logger.info(getClass().getSimpleName() + " testcase is beginning...");
DubboBootstrap.reset();
- //start all zookeeper services only once
- registryCenter = new ZookeeperMultipleRegistryCenter();
- registryCenter.startup();
// initialize service config
serviceConfig = new ServiceConfig<>();
serviceConfig.setInterface(MultipleRegistryCenterInjvmService.class);
@@ -96,17 +87,12 @@ public class MultipleRegistryCenterInjvmIntegrationTest implements IntegrationTe
serviceConfig.setAsync(false);
serviceConfig.setScope(SCOPE_LOCAL);
- // initailize bootstrap
- for (RegistryCenter.Instance instance : registryCenter.getRegistryCenterInstance()) {
- DubboBootstrap.getInstance().registry(new RegistryConfig(String.format("%s://%s:%s",
- instance.getType(),
- instance.getHostname(),
- instance.getPort())));
- }
DubboBootstrap.getInstance()
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
.protocol(new ProtocolConfig("injvm"))
- .service(serviceConfig);
+ .service(serviceConfig)
+ .registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress1()))
+ .registry(new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress2()));
}
/**
@@ -201,8 +187,5 @@ public class MultipleRegistryCenterInjvmIntegrationTest implements IntegrationTe
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
serviceListener = null;
logger.info(getClass().getSimpleName() + " testcase is ending...");
- // destroy registry center
- registryCenter.shutdown();
- registryCenter = null;
}
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmService.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmService.java
similarity index 94%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmService.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmService.java
index fba0451..44cd816 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmService.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmService.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.injvm;
+package org.apache.dubbo.config.integration.multiple.injvm;
/**
* This interface is used to check if the exported injvm protocol works well or not.
*/
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceImpl.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceImpl.java
similarity index 94%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceImpl.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceImpl.java
index 533da89..7c5a167 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceImpl.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceImpl.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.injvm;
+package org.apache.dubbo.config.integration.multiple.injvm;
/**
* The simple implementation for {@link MultipleRegistryCenterInjvmService}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceListener.java
index 766fa18..c5bfd71 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/injvm/MultipleRegistryCenterInjvmServiceListener.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.injvm;
+package org.apache.dubbo.config.integration.multiple.injvm;
import org.apache.dubbo.config.ServiceListener;
-import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
/**
* This implementation of {@link ServiceListener} is to record exported services with injvm protocol in multiple registry center.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/package-info.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/package-info.java
similarity index 95%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/package-info.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/package-info.java
index c186c7d..314d9de 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/package-info.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/package-info.java
@@ -19,4 +19,4 @@
* The one is single registry center, the other is multiple registry centers.<p>
* The purpose of all of testcases in this package is to test for multiple registry center.
*/
-package org.apache.dubbo.integration.multiple;
+package org.apache.dubbo.config.integration.multiple;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
similarity index 85%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
index 2be4305..aa61d4a 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
+package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
@@ -24,12 +24,11 @@ import org.apache.dubbo.config.ReferenceConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.config.integration.IntegrationTest;
import org.apache.dubbo.registry.RegistryServiceListener;
import org.apache.dubbo.registry.client.metadata.store.InMemoryWritableMetadataService;
-import org.apache.dubbo.registrycenter.RegistryCenter;
-import org.apache.dubbo.registrycenter.ZookeeperMultipleRegistryCenter;
-
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -43,7 +42,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import static org.apache.dubbo.integration.Constants.MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY;
+import static org.apache.dubbo.config.integration.Constants.MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY;
/**
* The testcases are only for checking the process of exporting provider using service-discovery-registry protocol.
@@ -72,11 +71,6 @@ public class MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest imple
private ServiceConfig<MultipleRegistryCenterServiceDiscoveryRegistryService> serviceConfig;
/**
- * Default a registry center.
- */
- private RegistryCenter registryCenter;
-
- /**
* Define a {@link RegistryServiceListener} instance.
*/
private MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener registryServiceListener;
@@ -95,27 +89,26 @@ public class MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest imple
public void setUp() throws Exception {
logger.info(getClass().getSimpleName() + " testcase is beginning...");
DubboBootstrap.reset();
- //start all zookeeper services only once
- registryCenter = new ZookeeperMultipleRegistryCenter();
- registryCenter.startup();
// initialize service config
serviceConfig = new ServiceConfig<>();
serviceConfig.setInterface(MultipleRegistryCenterServiceDiscoveryRegistryService.class);
serviceConfig.setRef(new MultipleRegistryCenterServiceDiscoveryRegistryServiceImpl());
serviceConfig.setAsync(false);
- // initialize bootstrap
- for (RegistryCenter.Instance instance : registryCenter.getRegistryCenterInstance()) {
- RegistryConfig registryConfig = new RegistryConfig(String.format("%s://%s:%s",
- instance.getType(),
- instance.getHostname(),
- instance.getPort()));
- Map<String, String> parameters = new HashMap<>();
- parameters.put("registry.listeners", MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY);
- registryConfig.updateParameters(parameters);
- DubboBootstrap.getInstance().registry(registryConfig);
- ports.add(instance.getPort());
- }
+ RegistryConfig registryConfig1 = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress1());
+ Map<String, String> parameters1 = new HashMap<>();
+ parameters1.put("registry.listeners", MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY);
+ registryConfig1.updateParameters(parameters1);
+ DubboBootstrap.getInstance().registry(registryConfig1);
+ ports.add(ZookeeperConfig.DEFAULT_CLIENT_PORT_1);
+
+ RegistryConfig registryConfig2 = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress2());
+ Map<String, String> parameters2 = new HashMap<>();
+ parameters2.put("registry.listeners", MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY);
+ registryConfig2.updateParameters(parameters2);
+ DubboBootstrap.getInstance().registry(registryConfig2);
+ ports.add(ZookeeperConfig.DEFAULT_CLIENT_PORT_2);
+
DubboBootstrap.getInstance()
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
.protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
@@ -218,8 +211,5 @@ public class MultipleRegistryCenterServiceDiscoveryRegistryIntegrationTest imple
registryServiceListener.getStorage().clear();
registryServiceListener = null;
logger.info(getClass().getSimpleName() + " testcase is ending...");
- // destroy registry center
- registryCenter.shutdown();
- registryCenter = null;
}
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener.java
similarity index 96%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener.java
index 00d45f4..519f75a 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
+package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Activate;
@@ -24,7 +24,7 @@ import org.apache.dubbo.registry.RegistryServiceListener;
import org.apache.dubbo.registry.client.ServiceDiscoveryRegistry;
import org.apache.dubbo.registry.client.metadata.store.InMemoryWritableMetadataService;
-import static org.apache.dubbo.integration.Constants.MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY;
+import static org.apache.dubbo.config.integration.Constants.MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY;
@Activate(value = MULTIPLE_CONFIG_CENTER_SERVICE_DISCOVERY_REGISTRY)
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryService.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryService.java
similarity index 93%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryService.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryService.java
index 476ccb9..f5c66ab 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryService.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryService.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
+package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
/**
* This interface is used to check if the exported service-discovery-registry protocol works well or not.
*/
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryServiceImpl.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryServiceImpl.java
similarity index 93%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryServiceImpl.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryServiceImpl.java
index 104a513..09469df 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryServiceImpl.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/MultipleRegistryCenterServiceDiscoveryRegistryServiceImpl.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
+package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
/**
* The simple implementation for {@link MultipleRegistryCenterServiceDiscoveryRegistryService}
*/
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryInfoWrapper.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryInfoWrapper.java
similarity index 97%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryInfoWrapper.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryInfoWrapper.java
index 583eec9..a5f35f8 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryInfoWrapper.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryInfoWrapper.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
+package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
import org.apache.dubbo.registry.client.ServiceDiscoveryRegistry;
import org.apache.dubbo.registry.client.metadata.store.InMemoryWritableMetadataService;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryStorage.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryStorage.java
similarity index 87%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryStorage.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryStorage.java
index ea84bea..3a615f6 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryStorage.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/multiple/servicediscoveryregistry/ServiceDiscoveryRegistryStorage.java
@@ -14,9 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.servicediscoveryregistry;
+package org.apache.dubbo.config.integration.multiple.servicediscoveryregistry;
-import org.apache.dubbo.integration.multiple.AbstractStorage;
+import org.apache.dubbo.config.integration.multiple.AbstractStorage;
/**
* The storage to store {@link ServiceDiscoveryRegistryInfoWrapper} instances in multiple registry center.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterDubboProtocolIntegrationTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterDubboProtocolIntegrationTest.java
similarity index 95%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterDubboProtocolIntegrationTest.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterDubboProtocolIntegrationTest.java
index 862a553..5b4b8dd 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterDubboProtocolIntegrationTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterDubboProtocolIntegrationTest.java
@@ -14,12 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single;
+package org.apache.dubbo.config.integration.single;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.ExtensionLoader;
-import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ReferenceConfig;
@@ -27,7 +26,7 @@ import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.ServiceListener;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.config.integration.IntegrationTest;
import org.apache.dubbo.metadata.MetadataInfo;
import org.apache.dubbo.metadata.WritableMetadataService;
import org.apache.dubbo.registry.ListenerRegistryWrapper;
@@ -38,10 +37,9 @@ import org.apache.dubbo.registry.client.metadata.store.InMemoryWritableMetadataS
import org.apache.dubbo.registry.client.migration.MigrationInvoker;
import org.apache.dubbo.registry.support.RegistryManager;
import org.apache.dubbo.registry.zookeeper.ZookeeperServiceDiscovery;
-import org.apache.dubbo.registrycenter.RegistryCenter;
-import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.rpc.cluster.Directory;
import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -101,17 +99,10 @@ public class SingleRegistryCenterDubboProtocolIntegrationTest implements Integra
*/
private SingleRegistryCenterExportedServiceListener singleRegistryCenterExportedServiceListener;
- /**
- * Define a registry center.
- */
- private RegistryCenter registryCenter;
-
@BeforeEach
public void setUp() throws Exception {
logger.info(getClass().getSimpleName() + " testcase is beginning...");
DubboBootstrap.reset();
- registryCenter = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
- registryCenter.startup();
// initialize ServiceConfig
serviceConfig = new ServiceConfig<>();
serviceConfig.setInterface(SingleRegistryCenterIntegrationService.class);
@@ -122,11 +113,7 @@ public class SingleRegistryCenterDubboProtocolIntegrationTest implements Integra
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
.protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
.service(serviceConfig);
- RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
- registryConfig = new RegistryConfig(String.format("%s://%s:%s",
- instance.getType(),
- instance.getHostname(),
- instance.getPort()));
+ registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress());
DubboBootstrap.getInstance().registry(registryConfig);
}
@@ -386,8 +373,5 @@ public class SingleRegistryCenterDubboProtocolIntegrationTest implements Integra
Assertions.assertTrue(singleRegistryCenterExportedServiceListener.getExportedServices().isEmpty());
singleRegistryCenterExportedServiceListener = null;
logger.info(getClass().getSimpleName() + " testcase is ending...");
- // destroy registry center
- registryCenter.shutdown();
- registryCenter = null;
}
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterExportedServiceListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterExportedServiceListener.java
similarity index 90%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterExportedServiceListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterExportedServiceListener.java
index 37a733a..6312171 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterExportedServiceListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterExportedServiceListener.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single;
+package org.apache.dubbo.config.integration.single;
import org.apache.dubbo.config.ServiceListener;
-import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
/**
* This implementation of {@link ServiceListener} is to record exported services in single registry center.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterIntegrationService.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterIntegrationService.java
similarity index 94%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterIntegrationService.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterIntegrationService.java
index 2db63d3..3b83860 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterIntegrationService.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterIntegrationService.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single;
+package org.apache.dubbo.config.integration.single;
/**
* This interface for integration testcases in single registry center.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterIntegrationServiceImpl.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterIntegrationServiceImpl.java
similarity index 96%
copy from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterIntegrationServiceImpl.java
copy to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterIntegrationServiceImpl.java
index 99e5d8a..eba3304 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterIntegrationServiceImpl.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/SingleRegistryCenterIntegrationServiceImpl.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single;
+package org.apache.dubbo.config.integration.single;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataExporterListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataExporterListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataExporterListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataExporterListener.java
index 151f572..ad75d9c 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataExporterListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataExporterListener.java
@@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportmetadata;
+package org.apache.dubbo.config.integration.single.exportmetadata;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
-import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
import org.apache.dubbo.metadata.MetadataService;
@Activate(group = CommonConstants.PROVIDER, order = 1000)
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataIntegrationTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataIntegrationTest.java
similarity index 90%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataIntegrationTest.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataIntegrationTest.java
index 0306a5d..bfab1a6 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataIntegrationTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataIntegrationTest.java
@@ -14,23 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportmetadata;
+package org.apache.dubbo.config.integration.single.exportmetadata;
import org.apache.dubbo.common.extension.ExtensionLoader;
-import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ServiceListener;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.config.integration.IntegrationTest;
import org.apache.dubbo.metadata.MetadataService;
-import org.apache.dubbo.registrycenter.RegistryCenter;
-import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.rpc.Exporter;
import org.apache.dubbo.rpc.ExporterListener;
import org.apache.dubbo.rpc.Filter;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -78,17 +76,10 @@ public class SingleRegistryCenterExportMetadataIntegrationTest implements Integr
*/
private SingleRegistryCenterExportMetadataExporterListener exporterListener;
- /**
- * Define a registry center.
- */
- private RegistryCenter registryCenter;
-
@BeforeEach
public void setUp() throws Exception {
logger.info(getClass().getSimpleName() + " testcase is beginning...");
DubboBootstrap.reset();
- registryCenter = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
- registryCenter.startup();
// initialize service config
serviceConfig = new ServiceConfig<>();
serviceConfig.setInterface(SingleRegistryCenterExportMetadataService.class);
@@ -101,11 +92,7 @@ public class SingleRegistryCenterExportMetadataIntegrationTest implements Integr
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
.protocol(new ProtocolConfig(PROTOCOL_NAME))
.service(serviceConfig);
- RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
- RegistryConfig registryConfig = new RegistryConfig(String.format("%s://%s:%s",
- instance.getType(),
- instance.getHostname(),
- instance.getPort()));
+ RegistryConfig registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress());
DubboBootstrap.getInstance().registry(registryConfig);
}
@@ -199,7 +186,5 @@ public class SingleRegistryCenterExportMetadataIntegrationTest implements Integr
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
serviceListener = null;
logger.info(getClass().getSimpleName() + " testcase is ending...");
- registryCenter.shutdown();
- registryCenter = null;
}
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataService.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataService.java
similarity index 93%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataService.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataService.java
index 22f2ab0..727a58b 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataService.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataService.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportmetadata;
+package org.apache.dubbo.config.integration.single.exportmetadata;
/**
* This interface is used to check if the exported metadata service works well or not.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceImpl.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceImpl.java
similarity index 94%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceImpl.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceImpl.java
index 338a09c..9bc4d0c 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceImpl.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceImpl.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportmetadata;
+package org.apache.dubbo.config.integration.single.exportmetadata;
/**
* The simple implementation for {@link SingleRegistryCenterExportMetadataService}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceListener.java
index 6008b4d..42b5d97 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportmetadata/SingleRegistryCenterExportMetadataServiceListener.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportmetadata;
+package org.apache.dubbo.config.integration.single.exportmetadata;
import org.apache.dubbo.config.ServiceListener;
-import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
import org.apache.dubbo.metadata.MetadataService;
/**
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderExporterListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderExporterListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderExporterListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderExporterListener.java
index 1eca462..3da4567 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderExporterListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderExporterListener.java
@@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportprovider;
+package org.apache.dubbo.config.integration.single.exportprovider;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
-import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
@Activate(group = CommonConstants.PROVIDER, order = 1000)
public class SingleRegistryCenterExportProviderExporterListener extends AbstractRegistryCenterExporterListener {
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderFilter.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderFilter.java
similarity index 97%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderFilter.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderFilter.java
index 26bbcda..caf9963 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderFilter.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderFilter.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportprovider;
+package org.apache.dubbo.config.integration.single.exportprovider;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderIntegrationTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderIntegrationTest.java
similarity index 92%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderIntegrationTest.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderIntegrationTest.java
index 5a92db8..3c9b9cb 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderIntegrationTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderIntegrationTest.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportprovider;
+package org.apache.dubbo.config.integration.single.exportprovider;
import org.apache.dubbo.common.config.configcenter.ConfigItem;
import org.apache.dubbo.common.constants.CommonConstants;
@@ -26,15 +26,14 @@ import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.ServiceListener;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.config.integration.IntegrationTest;
import org.apache.dubbo.metadata.ServiceNameMapping;
import org.apache.dubbo.metadata.report.MetadataReportInstance;
import org.apache.dubbo.registry.integration.RegistryProtocolListener;
-import org.apache.dubbo.registrycenter.RegistryCenter;
-import org.apache.dubbo.registrycenter.ZookeeperMultipleRegistryCenter;
import org.apache.dubbo.rpc.ExporterListener;
import org.apache.dubbo.rpc.Filter;
import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -47,7 +46,7 @@ import java.util.HashMap;
import java.util.Map;
import static org.apache.dubbo.common.constants.CommonConstants.REGISTRY_PROTOCOL_LISTENER_KEY;
-import static org.apache.dubbo.integration.Constants.SINGLE_CONFIG_CENTER_EXPORT_PROVIDER;
+import static org.apache.dubbo.config.integration.Constants.SINGLE_CONFIG_CENTER_EXPORT_PROVIDER;
import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
/**
@@ -77,11 +76,6 @@ public class SingleRegistryCenterExportProviderIntegrationTest implements Integr
private ServiceConfig<SingleRegistryCenterExportProviderService> serviceConfig;
/**
- * Define a registry center.
- */
- private RegistryCenter registryCenter;
-
- /**
* Define a {@link RegistryProtocolListener} instance.
*/
private SingleRegistryCenterExportProviderRegistryProtocolListener registryProtocolListener;
@@ -105,8 +99,6 @@ public class SingleRegistryCenterExportProviderIntegrationTest implements Integr
public void setUp() throws Exception {
logger.info(getClass().getSimpleName() + " testcase is beginning...");
DubboBootstrap.reset();
- registryCenter = new ZookeeperMultipleRegistryCenter();
- registryCenter.startup();
// initialize service config
serviceConfig = new ServiceConfig<>();
serviceConfig.setInterface(SingleRegistryCenterExportProviderService.class);
@@ -118,12 +110,8 @@ public class SingleRegistryCenterExportProviderIntegrationTest implements Integr
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
.protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
.service(serviceConfig);
- RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
- RegistryConfig registryConfig = new RegistryConfig(String.format("%s://%s:%s",
- instance.getType(),
- instance.getHostname(),
- instance.getPort()));
+ RegistryConfig registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress());
Map<String, String> parameters = new HashMap<>();
parameters.put(REGISTRY_PROTOCOL_LISTENER_KEY, "singleConfigCenterExportProvider");
registryConfig.updateParameters(parameters);
@@ -253,8 +241,6 @@ public class SingleRegistryCenterExportProviderIntegrationTest implements Integr
// The exported service has been unexported
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
logger.info(getClass().getSimpleName() + " testcase is ending...");
- registryCenter.shutdown();
registryProtocolListener = null;
- registryCenter = null;
}
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderRegistryProtocolListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderRegistryProtocolListener.java
similarity index 93%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderRegistryProtocolListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderRegistryProtocolListener.java
index 09b973d..c7de521 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderRegistryProtocolListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderRegistryProtocolListener.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportprovider;
+package org.apache.dubbo.config.integration.single.exportprovider;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.Activate;
@@ -24,7 +24,7 @@ import org.apache.dubbo.registry.integration.RegistryProtocolListener;
import org.apache.dubbo.rpc.Exporter;
import org.apache.dubbo.rpc.cluster.ClusterInvoker;
-import static org.apache.dubbo.integration.Constants.SINGLE_CONFIG_CENTER_EXPORT_PROVIDER;
+import static org.apache.dubbo.config.integration.Constants.SINGLE_CONFIG_CENTER_EXPORT_PROVIDER;
/**
* The {@link RegistryProtocolListener} for {@link SingleRegistryCenterExportProviderService}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderService.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderService.java
similarity index 93%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderService.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderService.java
index 4ea9980..c23214c 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderService.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderService.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportprovider;
+package org.apache.dubbo.config.integration.single.exportprovider;
/**
* This interface is used to check if the exported provider works well or not.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceImpl.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceImpl.java
similarity index 94%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceImpl.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceImpl.java
index 01aad07..f0fa56d 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceImpl.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceImpl.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportprovider;
+package org.apache.dubbo.config.integration.single.exportprovider;
/**
* The implementation of {@link SingleRegistryCenterExportProviderService}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceListener.java
index 1eefe4d..55ad2eb 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/exportprovider/SingleRegistryCenterExportProviderServiceListener.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.exportprovider;
+package org.apache.dubbo.config.integration.single.exportprovider;
import org.apache.dubbo.config.ServiceListener;
-import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
/**
* This implementation of {@link ServiceListener} is to record exported services with injvm protocol in single registry center.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmExporterListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmExporterListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmExporterListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmExporterListener.java
index 4edec5f..3d9085c 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmExporterListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmExporterListener.java
@@ -14,11 +14,11 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.injvm;
+package org.apache.dubbo.config.integration.single.injvm;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
-import org.apache.dubbo.integration.AbstractRegistryCenterExporterListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterExporterListener;
@Activate(group = CommonConstants.PROVIDER, order = 1000)
public class SingleRegistryCenterInjvmExporterListener extends AbstractRegistryCenterExporterListener {
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmFilter.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmFilter.java
similarity index 97%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmFilter.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmFilter.java
index 6580b7e..48b56df 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmFilter.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmFilter.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.injvm;
+package org.apache.dubbo.config.integration.single.injvm;
import org.apache.dubbo.common.constants.CommonConstants;
import org.apache.dubbo.common.extension.Activate;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmIntegrationTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmIntegrationTest.java
similarity index 90%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmIntegrationTest.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmIntegrationTest.java
index c13fcab..4e1bab9 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmIntegrationTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmIntegrationTest.java
@@ -14,10 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.injvm;
+package org.apache.dubbo.config.integration.single.injvm;
import org.apache.dubbo.common.extension.ExtensionLoader;
-import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ReferenceConfig;
@@ -25,11 +24,10 @@ import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.ServiceListener;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.integration.IntegrationTest;
-import org.apache.dubbo.registrycenter.RegistryCenter;
-import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
+import org.apache.dubbo.config.integration.IntegrationTest;
import org.apache.dubbo.rpc.ExporterListener;
import org.apache.dubbo.rpc.Filter;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -77,17 +75,10 @@ public class SingleRegistryCenterInjvmIntegrationTest implements IntegrationTest
*/
private SingleRegistryCenterInjvmFilter filter;
- /**
- * Define a registry center.
- */
- private RegistryCenter registryCenter;
-
@BeforeEach
public void setUp() throws Exception {
logger.info(getClass().getSimpleName() + " testcase is beginning...");
DubboBootstrap.reset();
- registryCenter = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
- registryCenter.startup();
// initialize service config
serviceConfig = new ServiceConfig<>();
serviceConfig.setInterface(SingleRegistryCenterInjvmService.class);
@@ -100,11 +91,7 @@ public class SingleRegistryCenterInjvmIntegrationTest implements IntegrationTest
.application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
.protocol(new ProtocolConfig("injvm"))
.service(serviceConfig);
- RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
- RegistryConfig registryConfig = new RegistryConfig(String.format("%s://%s:%s",
- instance.getType(),
- instance.getHostname(),
- instance.getPort()));
+ RegistryConfig registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress());
DubboBootstrap.getInstance().registry(registryConfig);
}
@@ -199,7 +186,5 @@ public class SingleRegistryCenterInjvmIntegrationTest implements IntegrationTest
Assertions.assertTrue(serviceListener.getExportedServices().isEmpty());
serviceListener = null;
logger.info(getClass().getSimpleName() + " testcase is ending...");
- registryCenter.shutdown();
- registryCenter = null;
}
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmService.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmService.java
similarity index 94%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmService.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmService.java
index 916ca69..078338f 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmService.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmService.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.injvm;
+package org.apache.dubbo.config.integration.single.injvm;
/**
* This interface is used to check if the exported injvm protocol works well or not.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmServiceImpl.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmServiceImpl.java
similarity index 95%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmServiceImpl.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmServiceImpl.java
index c1f6bda..88f8210 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmServiceImpl.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmServiceImpl.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.injvm;
+package org.apache.dubbo.config.integration.single.injvm;
/**
* The simple implementation for {@link SingleRegistryCenterInjvmService}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmServiceListener.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmServiceListener.java
similarity index 89%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmServiceListener.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmServiceListener.java
index b1ff898..b56e1cc 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/injvm/SingleRegistryCenterInjvmServiceListener.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/injvm/SingleRegistryCenterInjvmServiceListener.java
@@ -14,10 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single.injvm;
+package org.apache.dubbo.config.integration.single.injvm;
import org.apache.dubbo.config.ServiceListener;
-import org.apache.dubbo.integration.AbstractRegistryCenterServiceListener;
+import org.apache.dubbo.config.integration.AbstractRegistryCenterServiceListener;
/**
* This implementation of {@link ServiceListener} is to record exported services with injvm protocol in single registry center.
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/package-info.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/package-info.java
similarity index 95%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/package-info.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/package-info.java
index ab1dda2..3dccb4f 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/package-info.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/integration/single/package-info.java
@@ -19,4 +19,4 @@
* The one is single registry center, the other is multiple registry centers.<p>
* The purpose of all of testcases in this package is to test for single registry center.
*/
-package org.apache.dubbo.integration.single;
+package org.apache.dubbo.config.integration.single;
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/metadata/MetadataServiceExporterTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/metadata/MetadataServiceExporterTest.java
similarity index 93%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/metadata/MetadataServiceExporterTest.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/metadata/MetadataServiceExporterTest.java
index abf99c1..da704e4 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/metadata/MetadataServiceExporterTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/metadata/MetadataServiceExporterTest.java
@@ -14,23 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.metadata;
+package org.apache.dubbo.config.metadata;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.utils.NetUtils;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.ServiceConfig;
import org.apache.dubbo.config.api.DemoService;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.config.metadata.ConfigurableMetadataServiceExporter;
import org.apache.dubbo.config.provider.impl.DemoServiceImpl;
-import org.apache.dubbo.registrycenter.RegistryCenter;
-import org.apache.dubbo.registrycenter.ZookeeperSingleRegistryCenter;
+import org.apache.dubbo.metadata.MetadataService;
+import org.apache.dubbo.metadata.MetadataServiceExporter;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
-
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
@@ -241,20 +239,12 @@ public class MetadataServiceExporterTest {
// assertFalse(exporter.isExported());
// }
- private static ZookeeperSingleRegistryCenter registryCenter;
private static RegistryConfig registryConfig;
@BeforeAll
public static void beforeAll() {
FrameworkModel.destroyAll();
- registryCenter = new ZookeeperSingleRegistryCenter(NetUtils.getAvailablePort());
- registryCenter.startup();
- RegistryCenter.Instance instance = registryCenter.getRegistryCenterInstance().get(0);
- registryConfig = new RegistryConfig(String.format("%s://%s:%s",
- instance.getType(),
- instance.getHostname(),
- instance.getPort()));
-
+ registryConfig = new RegistryConfig(ZookeeperRegistryCenterConfig.getConnectionAddress());
// pre-check threads
//precheckUnclosedThreads();
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/AbstractRegistryCenter.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/AbstractRegistryCenter.java
deleted file mode 100644
index 3ef9e58..0000000
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/AbstractRegistryCenter.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registrycenter;
-
-import org.apache.curator.test.InstanceSpec;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The abstraction of {@link RegistryCenter} implements the basic methods.
- */
-abstract class AbstractRegistryCenter implements RegistryCenter {
-
- /**
- * The default data directory is null
- */
- private static final File DEFAULT_DATA_DIRECTORY = null;
-
- /**
- * The default election port is -1.
- */
- private static final int DEFAULT_ELECTION_PORT = -1;
-
- /**
- * The default quorum port is -1.
- */
- private static final int DEFAULT_QUORUM_PORT = -1;
-
- /**
- * The default value is true.
- */
- private static final boolean DEFAULT_DELETE_DATA_DIRECTORY_ON_CLOSE = true;
-
- /**
- * The default service id is -1.
- */
- private static final int DEFAULT_SERVER_ID = -1;
-
- /**
- * The default tick time is 5000
- */
- private static final int DEFAULT_TICK_TIME = 5 * 1000;
-
- /**
- * The default value is -1.
- */
- private static final int DEFAULT_MAX_CLIENT_CNXNS = 200;
-
- /**
- * The minimum session timeout.
- */
- private static final int DEFAULT_MINIMUM_SESSION_TIMEOUT = DEFAULT_TICK_TIME * 2;
-
- /**
- * The maximum session timeout.
- */
- private static final int DEFAULT_MAXIMUM_SESSION_TIMEOUT = 60 * 1000;
-
- /**
- * The default customer properties.
- */
- private static final Map<String, Object> DEFAULT_CUSTOM_PROPERTIES = new HashMap<>(2);
-
- /**
- * The default hostname.
- */
- private static final String DEFAULT_HOSTNAME = "127.0.0.1";
-
- static {
- DEFAULT_CUSTOM_PROPERTIES.put("minSessionTimeout", DEFAULT_MINIMUM_SESSION_TIMEOUT);
- DEFAULT_CUSTOM_PROPERTIES.put("maxSessionTimeout", DEFAULT_MAXIMUM_SESSION_TIMEOUT);
- }
-
- /**
- * Create an {@link InstanceSpec} instance to initialize {@link org.apache.curator.test.TestingServer}
- *
- * @param port the zookeeper server's port.
- */
- protected InstanceSpec createInstanceSpec(int port) {
- return new InstanceSpec(DEFAULT_DATA_DIRECTORY,
- port,
- DEFAULT_ELECTION_PORT,
- DEFAULT_QUORUM_PORT,
- DEFAULT_DELETE_DATA_DIRECTORY_ON_CLOSE,
- DEFAULT_SERVER_ID,
- DEFAULT_TICK_TIME,
- DEFAULT_MAX_CLIENT_CNXNS,
- DEFAULT_CUSTOM_PROPERTIES,
- DEFAULT_HOSTNAME);
- }
-}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/RegistryCenter.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/RegistryCenter.java
deleted file mode 100644
index fd95509..0000000
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/RegistryCenter.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registrycenter;
-
-import org.apache.dubbo.rpc.RpcException;
-
-import java.util.List;
-
-/**
- * The mock registry center.
- */
-public interface RegistryCenter {
-
- /**
- * Start the registry center.
- *
- * @throws RpcException when an exception occurred
- */
- void startup() throws RpcException;
-
- /**
- * Returns the registry center instance.
- * <p>This method can be called only after {@link #startup()} is called</p>
- *
- * @throws RpcException when an exception occurred
- */
- List<Instance> getRegistryCenterInstance() throws RpcException;
-
- /**
- * Stop the registry center.
- *
- * @throws RpcException when an exception occurred
- */
- void shutdown() throws RpcException;
-
- /**
- * The registry center instance.
- */
- interface Instance {
-
- /**
- * Returns the registry center type.
- */
- String getType();
-
- /**
- * Returns the hostname of registry center.
- */
- String getHostname();
-
- /**
- * Returns the port of registry center.
- */
- int getPort();
- }
-}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/ZookeeperMultipleRegistryCenter.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/ZookeeperMultipleRegistryCenter.java
deleted file mode 100644
index 254d794..0000000
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/ZookeeperMultipleRegistryCenter.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registrycenter;
-
-import org.apache.dubbo.common.utils.NetUtils;
-
-/**
- * The default zookeeper multiple registry center.
- */
-public class ZookeeperMultipleRegistryCenter extends ZookeeperRegistryCenter {
-
- /**
- * Initialize {@link ZookeeperMultipleRegistryCenter} instance.
- *
- * @param port1 the zookeeper server's port.
- * @param port2 the zookeeper server's port.
- */
- public ZookeeperMultipleRegistryCenter(int port1, int port2) {
- super(port1, port2);
- }
-
- /**
- * Initialize {@link ZookeeperMultipleRegistryCenter} instance.
- */
- public ZookeeperMultipleRegistryCenter() {
- this(NetUtils.getAvailablePort(), NetUtils.getAvailablePort());
- }
-
- private static final int DEFAULT_PORT1 = 2181;
- private static final int DEFAULT_PORT2 = 2182;
-}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/ZookeeperRegistryCenter.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/ZookeeperRegistryCenter.java
deleted file mode 100644
index 2f00cc3..0000000
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/ZookeeperRegistryCenter.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registrycenter;
-
-import org.apache.curator.test.InstanceSpec;
-import org.apache.curator.test.TestingServer;
-import org.apache.dubbo.common.logger.Logger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.rpc.RpcException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * The default implementation of registry center can support single and multiple registry center.
- * <p>Each port represents an instance. You can provide multiple ports to build multiple registry center,
- * if you want to create multiple registry center
- */
-class ZookeeperRegistryCenter extends AbstractRegistryCenter {
-
- /**
- * Initialize the default registry center.
- *
- * @param ports the registry center's ports.
- */
- public ZookeeperRegistryCenter(int... ports) {
- this.ports = ports;
- this.instanceSpecs = new ArrayList<>(this.ports.length);
- this.zookeeperServers = new ArrayList<>(this.ports.length);
- }
-
- private static final Logger logger = LoggerFactory.getLogger(ZookeeperRegistryCenter.class);
-
- /**
- * The type of the registry center.
- */
- private static final String DEFAULT_REGISTRY_CENTER_TYPE = "zookeeper";
-
- private int[] ports;
-
- private List<InstanceSpec> instanceSpecs;
-
- private List<TestingServer> zookeeperServers;
-
- private AtomicBoolean started = new AtomicBoolean(false);
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startup() throws RpcException {
- try {
- if (started.compareAndSet(false, true)) {
- logger.info("The ZookeeperRegistryCenter is starting...");
- for (int port : this.ports) {
- InstanceSpec instanceSpec = this.createInstanceSpec(port);
- this.instanceSpecs.add(instanceSpec);
- this.zookeeperServers.add(new TestingServer(instanceSpec, true));
- }
- logger.info("The ZookeeperRegistryCenter is started successfully");
- }
- } catch (Exception exception) {
- started.set(false);
- throw new RpcException("Failed to initialize ZookeeperRegistryCenter instance", exception);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<Instance> getRegistryCenterInstance() throws RpcException {
- this.startup();
- List<Instance> instances = new ArrayList<>(this.instanceSpecs.size());
- for (InstanceSpec instanceSpec : this.instanceSpecs) {
- instances.add(new Instance() {
- @Override
- public String getType() {
- return DEFAULT_REGISTRY_CENTER_TYPE;
- }
-
- @Override
- public String getHostname() {
- return instanceSpec.getHostname();
- }
-
- @Override
- public int getPort() {
- return instanceSpec.getPort();
- }
- });
- }
- return instances;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void shutdown() throws RpcException {
- logger.info("The ZookeeperRegistryCenter is stopping...");
- List<RpcException> exceptions = new ArrayList<>(this.zookeeperServers.size());
- for (TestingServer testingServer : this.zookeeperServers) {
- try {
- testingServer.close();
- logger.info(String.format("The zookeeper instance of %s is shutdown successfully",
- testingServer.getConnectString()));
- } catch (IOException exception) {
- RpcException rpcException = new RpcException(String.format("Failed to close zookeeper instance of %s",
- testingServer.getConnectString()),
- exception);
- exceptions.add(rpcException);
- logger.error(rpcException);
- }
- }
- this.instanceSpecs.clear();
- this.zookeeperServers.clear();
- if (!exceptions.isEmpty()) {
- logger.info("The ZookeeperRegistryCenter failed to close.");
- // throw any one of exceptions
- throw exceptions.get(0);
- } else {
- logger.info("The ZookeeperRegistryCenter close successfully.");
- }
- }
-}
diff --git a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.config.ServiceListener b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.config.ServiceListener
index 6aa34fa..2653337 100644
--- a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.config.ServiceListener
+++ b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.config.ServiceListener
@@ -1,8 +1,8 @@
mock=org.apache.dubbo.config.mock.MockServiceListener
-exported=org.apache.dubbo.integration.single.SingleRegistryCenterExportedServiceListener
-singleConfigCenterInjvm=org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmServiceListener
-multipleConfigCenterInjvm=org.apache.dubbo.integration.multiple.injvm.MultipleRegistryCenterInjvmServiceListener
-singleConfigCenterExportProvider=org.apache.dubbo.integration.single.exportprovider.SingleRegistryCenterExportProviderServiceListener
-singleConfigCenterExportMetadata=org.apache.dubbo.integration.single.exportmetadata.SingleRegistryCenterExportMetadataServiceListener
-multipleConfigCenterExportMetadata=org.apache.dubbo.integration.multiple.exportmetadata.MultipleRegistryCenterExportMetadataServiceListener
-multipleConfigCenterExportProvider=org.apache.dubbo.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderServiceListener
+exported=org.apache.dubbo.config.integration.single.SingleRegistryCenterExportedServiceListener
+singleConfigCenterInjvm=org.apache.dubbo.config.integration.single.injvm.SingleRegistryCenterInjvmServiceListener
+multipleConfigCenterInjvm=org.apache.dubbo.config.integration.multiple.injvm.MultipleRegistryCenterInjvmServiceListener
+singleConfigCenterExportProvider=org.apache.dubbo.config.integration.single.exportprovider.SingleRegistryCenterExportProviderServiceListener
+singleConfigCenterExportMetadata=org.apache.dubbo.config.integration.single.exportmetadata.SingleRegistryCenterExportMetadataServiceListener
+multipleConfigCenterExportMetadata=org.apache.dubbo.config.integration.multiple.exportmetadata.MultipleRegistryCenterExportMetadataServiceListener
+multipleConfigCenterExportProvider=org.apache.dubbo.config.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderServiceListener
diff --git a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.registry.RegistryServiceListener b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.registry.RegistryServiceListener
index 530f279..460ffb3 100644
--- a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.registry.RegistryServiceListener
+++ b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.registry.RegistryServiceListener
@@ -1 +1 @@
-multipleConfigCenterServiceDiscoveryRegistry=org.apache.dubbo.integration.multiple.servicediscoveryregistry.MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener
+multipleConfigCenterServiceDiscoveryRegistry=org.apache.dubbo.config.integration.multiple.servicediscoveryregistry.MultipleRegistryCenterServiceDiscoveryRegistryRegistryServiceListener
diff --git a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.registry.integration.RegistryProtocolListener b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.registry.integration.RegistryProtocolListener
index 6ad6a1a..11d11d0 100644
--- a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.registry.integration.RegistryProtocolListener
+++ b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.registry.integration.RegistryProtocolListener
@@ -1,2 +1,2 @@
-singleConfigCenterExportProvider=org.apache.dubbo.integration.single.exportprovider.SingleRegistryCenterExportProviderRegistryProtocolListener
-multipleConfigCenterExportProvider=org.apache.dubbo.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderRegistryProtocolListener
+singleConfigCenterExportProvider=org.apache.dubbo.config.integration.single.exportprovider.SingleRegistryCenterExportProviderRegistryProtocolListener
+multipleConfigCenterExportProvider=org.apache.dubbo.config.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderRegistryProtocolListener
diff --git a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.rpc.ExporterListener b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.rpc.ExporterListener
index b76b514..ad30773 100644
--- a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.rpc.ExporterListener
+++ b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.rpc.ExporterListener
@@ -1,7 +1,7 @@
mockexporterlistener=org.apache.dubbo.config.mock.MockExporterListener
-singleConfigCenterInjvm=org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmExporterListener
-multipleConfigCenterInjvm=org.apache.dubbo.integration.multiple.injvm.MultipleRegistryCenterInjvmExporterListener
-singleConfigCenterExportProvider=org.apache.dubbo.integration.single.exportprovider.SingleRegistryCenterExportProviderExporterListener
-singleConfigCenterExportMetadata=org.apache.dubbo.integration.single.exportmetadata.SingleRegistryCenterExportMetadataExporterListener
-multipleConfigCenterExportMetadata=org.apache.dubbo.integration.multiple.exportmetadata.MultipleRegistryCenterExportMetadataExporterListener
-multipleConfigCenterExportProvider=org.apache.dubbo.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderExporterListener
+singleConfigCenterInjvm=org.apache.dubbo.config.integration.single.injvm.SingleRegistryCenterInjvmExporterListener
+multipleConfigCenterInjvm=org.apache.dubbo.config.integration.multiple.injvm.MultipleRegistryCenterInjvmExporterListener
+singleConfigCenterExportProvider=org.apache.dubbo.config.integration.single.exportprovider.SingleRegistryCenterExportProviderExporterListener
+singleConfigCenterExportMetadata=org.apache.dubbo.config.integration.single.exportmetadata.SingleRegistryCenterExportMetadataExporterListener
+multipleConfigCenterExportMetadata=org.apache.dubbo.config.integration.multiple.exportmetadata.MultipleRegistryCenterExportMetadataExporterListener
+multipleConfigCenterExportProvider=org.apache.dubbo.config.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderExporterListener
diff --git a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.rpc.Filter b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.rpc.Filter
index 94e6e01..ca8bdf8 100644
--- a/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.rpc.Filter
+++ b/dubbo-config/dubbo-config-api/src/test/resources/META-INF/services/org.apache.dubbo.rpc.Filter
@@ -1,5 +1,5 @@
mockfilter=org.apache.dubbo.config.mock.MockFilter
-singleConfigCenterInjvm=org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmFilter
-multipleConfigCenterInjvm=org.apache.dubbo.integration.multiple.injvm.MultipleRegistryCenterInjvmFilter
-singleConfigCenterExportProvider=org.apache.dubbo.integration.single.exportprovider.SingleRegistryCenterExportProviderFilter
-multipleConfigCenterExportProvider=org.apache.dubbo.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderFilter
+singleConfigCenterInjvm=org.apache.dubbo.config.integration.single.injvm.SingleRegistryCenterInjvmFilter
+multipleConfigCenterInjvm=org.apache.dubbo.config.integration.multiple.injvm.MultipleRegistryCenterInjvmFilter
+singleConfigCenterExportProvider=org.apache.dubbo.config.integration.single.exportprovider.SingleRegistryCenterExportProviderFilter
+multipleConfigCenterExportProvider=org.apache.dubbo.config.integration.multiple.exportprovider.MultipleRegistryCenterExportProviderFilter
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java
index ff03bd8..027e365 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/ConfigTest.java
@@ -43,8 +43,6 @@ import org.apache.dubbo.config.spring.impl.HelloServiceImpl;
import org.apache.dubbo.config.spring.impl.NotifyService;
import org.apache.dubbo.config.spring.registry.MockRegistry;
import org.apache.dubbo.config.spring.registry.MockRegistryFactory;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.registry.Registry;
import org.apache.dubbo.registry.RegistryService;
import org.apache.dubbo.rpc.Exporter;
@@ -86,19 +84,6 @@ public class ConfigTest {
private static String resourcePath = ConfigTest.class.getPackage().getName().replace('.', '/');
- private static RegistryCenter singleRegistryCenter;
-
- @BeforeAll
- public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
- }
-
- @AfterAll
- public static void afterAll() {
- singleRegistryCenter.shutdown();
- }
-
@BeforeEach
public void setUp() {
SysProps.clear();
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/JavaConfigBeanTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/JavaConfigBeanTest.java
index abc20c3..abd2f25 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/JavaConfigBeanTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/JavaConfigBeanTest.java
@@ -29,14 +29,11 @@ import org.apache.dubbo.config.context.ModuleConfigManager;
import org.apache.dubbo.config.spring.api.DemoService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.config.spring.impl.DemoServiceImpl;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.rpc.Constants;
import org.apache.dubbo.rpc.model.ApplicationModel;
-import org.junit.jupiter.api.AfterAll;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -50,18 +47,6 @@ public class JavaConfigBeanTest {
private static final String MY_PROTOCOL_ID = "myProtocol";
private static final String MY_REGISTRY_ID = "my-registry";
- private static RegistryCenter singleRegistryCenter;
-
- @BeforeAll
- public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
- }
-
- @AfterAll
- public static void afterAll() {
- singleRegistryCenter.shutdown();
- }
@BeforeEach
public void beforeEach() {
@@ -80,7 +65,7 @@ public class JavaConfigBeanTest {
SysProps.setProperty("dubbo.application.qos-enable", "false");
SysProps.setProperty("dubbo.protocol.name", "dubbo");
SysProps.setProperty("dubbo.protocol.port", "2346");
- String registryAddress = "zookeeper://127.0.0.1:2181";
+ String registryAddress = ZookeeperRegistryCenterConfig.getConnectionAddress();
SysProps.setProperty("dubbo.registry.address", registryAddress);
SysProps.setProperty("dubbo.provider.group", "test");
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/MethodConfigCallbackTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/MethodConfigCallbackTest.java
index ce0b78c..ccb70c9 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/MethodConfigCallbackTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/beans/factory/annotation/MethodConfigCallbackTest.java
@@ -23,8 +23,6 @@ import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.api.MethodCallback;
import org.apache.dubbo.config.spring.context.annotation.provider.ProviderConfiguration;
import org.apache.dubbo.config.spring.impl.MethodCallbackImpl;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -49,25 +47,20 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
})
@TestPropertySource(properties = {
"dubbo.protocol.port=-1",
- "dubbo.registry.address=zookeeper://127.0.0.1:2181"
+ "dubbo.registry.address=${zookeeper.connection.address}"
})
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class MethodConfigCallbackTest {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Autowired
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional1/XmlReferenceBeanConditionalTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional1/XmlReferenceBeanConditionalTest.java
index 17cc50b..54ed291 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional1/XmlReferenceBeanConditionalTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional1/XmlReferenceBeanConditionalTest.java
@@ -18,8 +18,6 @@ package org.apache.dubbo.config.spring.boot.conditional1;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.api.HelloService;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -50,19 +48,14 @@ import java.util.Map;
//@ComponentScan
public class XmlReferenceBeanConditionalTest {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll(){
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll(){
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Autowired
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional2/JavaConfigAnnotationReferenceBeanConditionalTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional2/JavaConfigAnnotationReferenceBeanConditionalTest.java
index ba33808..5b4f7bb 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional2/JavaConfigAnnotationReferenceBeanConditionalTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional2/JavaConfigAnnotationReferenceBeanConditionalTest.java
@@ -22,8 +22,6 @@ import org.apache.dubbo.config.spring.ReferenceBean;
import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.config.spring.context.annotation.provider.HelloServiceImpl;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -56,19 +54,14 @@ import java.util.Map;
@EnableDubbo
public class JavaConfigAnnotationReferenceBeanConditionalTest {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll(){
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll(){
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Autowired
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional3/JavaConfigRawReferenceBeanConditionalTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional3/JavaConfigRawReferenceBeanConditionalTest.java
index 3e87455..014682b 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional3/JavaConfigRawReferenceBeanConditionalTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional3/JavaConfigRawReferenceBeanConditionalTest.java
@@ -22,8 +22,6 @@ import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.config.spring.context.annotation.provider.HelloServiceImpl;
import org.apache.dubbo.config.spring.reference.ReferenceBeanBuilder;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -56,19 +54,14 @@ import java.util.Map;
@EnableDubbo
public class JavaConfigRawReferenceBeanConditionalTest {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll(){
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll(){
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Autowired
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional4/JavaConfigReferenceBeanConditionalTest4.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional4/JavaConfigReferenceBeanConditionalTest4.java
index 9199a3f..ce6968a 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional4/JavaConfigReferenceBeanConditionalTest4.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/conditional4/JavaConfigReferenceBeanConditionalTest4.java
@@ -22,8 +22,6 @@ import org.apache.dubbo.config.spring.ReferenceBean;
import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.config.spring.context.annotation.provider.HelloServiceImpl;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -56,19 +54,14 @@ import java.util.Map;
@EnableDubbo
public class JavaConfigReferenceBeanConditionalTest4 {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll(){
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll(){
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Autowired
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/configprops/SpringBootConfigPropsTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/configprops/SpringBootConfigPropsTest.java
index 1d202be..1542a2a 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/configprops/SpringBootConfigPropsTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/configprops/SpringBootConfigPropsTest.java
@@ -30,9 +30,8 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.context.ConfigManager;
import org.apache.dubbo.config.context.ModuleConfigManager;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperMultipleRegistryCenter;
import org.apache.dubbo.rpc.model.ModuleModel;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -48,51 +47,46 @@ import java.util.List;
import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMETHEUS;
@SpringBootTest(
- properties = {
- "dubbo.application.NAME = dubbo-demo-application",
- "dubbo.module.name = dubbo-demo-module",
- "dubbo.registry.address = zookeeper://192.168.99.100:32770",
- "dubbo.protocol.name=dubbo",
- "dubbo.protocol.port=20880",
- "dubbo.metrics.protocol=prometheus",
- "dubbo.metrics.prometheus.exporter.enabled=true",
- "dubbo.metrics.prometheus.exporter.enable-http-service-discovery=true",
- "dubbo.metrics.prometheus.exporter.http-service-discovery-url=localhost:8080",
- "dubbo.metrics.prometheus.exporter.metrics-port=20888",
- "dubbo.metrics.prometheus.exporter.metrics-path=/metrics",
- "dubbo.metrics.aggregation.enabled=true",
- "dubbo.metrics.aggregation.bucket-num=5",
- "dubbo.metrics.aggregation.time-window-seconds=120",
- "dubbo.monitor.address=zookeeper://127.0.0.1:32770",
- "dubbo.Config-center.address=zookeeper://127.0.0.1:2181",
- "dubbo.config-Center.group=group1",
- "dubbo.metadata-report.address=zookeeper://127.0.0.1:2182",
- "dubbo.METADATA-REPORT.username=User",
- "dubbo.provider.host=127.0.0.1",
- "dubbo.consumer.client=netty"
- },
- classes = {
- SpringBootConfigPropsTest.class
- }
+ properties = {
+ "dubbo.application.NAME = dubbo-demo-application",
+ "dubbo.module.name = dubbo-demo-module",
+ "dubbo.registry.address = zookeeper://192.168.99.100:32770",
+ "dubbo.protocol.name=dubbo",
+ "dubbo.protocol.port=20880",
+ "dubbo.metrics.protocol=prometheus",
+ "dubbo.metrics.prometheus.exporter.enabled=true",
+ "dubbo.metrics.prometheus.exporter.enable-http-service-discovery=true",
+ "dubbo.metrics.prometheus.exporter.http-service-discovery-url=localhost:8080",
+ "dubbo.metrics.prometheus.exporter.metrics-port=20888",
+ "dubbo.metrics.prometheus.exporter.metrics-path=/metrics",
+ "dubbo.metrics.aggregation.enabled=true",
+ "dubbo.metrics.aggregation.bucket-num=5",
+ "dubbo.metrics.aggregation.time-window-seconds=120",
+ "dubbo.monitor.address=zookeeper://127.0.0.1:32770",
+ "dubbo.Config-center.address=${zookeeper.connection.address.1}",
+ "dubbo.config-Center.group=group1",
+ "dubbo.metadata-report.address=${zookeeper.connection.address.2}",
+ "dubbo.METADATA-REPORT.username=User",
+ "dubbo.provider.host=127.0.0.1",
+ "dubbo.consumer.client=netty"
+ },
+ classes = {
+ SpringBootConfigPropsTest.class
+ }
)
@Configuration
@ComponentScan
@EnableDubbo
public class SpringBootConfigPropsTest {
- private static RegistryCenter multipleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
- multipleRegistryCenter = new ZookeeperMultipleRegistryCenter();
- multipleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- multipleRegistryCenter.shutdown();
}
@Autowired
@@ -135,13 +129,13 @@ public class SpringBootConfigPropsTest {
Collection<ConfigCenterConfig> configCenters = configManager.getConfigCenters();
Assertions.assertEquals(1, configCenters.size());
ConfigCenterConfig centerConfig = configCenters.iterator().next();
- Assertions.assertEquals("zookeeper://127.0.0.1:2181", centerConfig.getAddress());
+ Assertions.assertEquals(ZookeeperRegistryCenterConfig.getConnectionAddress1(), centerConfig.getAddress());
Assertions.assertEquals("group1", centerConfig.getGroup());
Collection<MetadataReportConfig> metadataConfigs = configManager.getMetadataConfigs();
Assertions.assertEquals(1, metadataConfigs.size());
MetadataReportConfig reportConfig = metadataConfigs.iterator().next();
- Assertions.assertEquals("zookeeper://127.0.0.1:2182", reportConfig.getAddress());
+ Assertions.assertEquals(ZookeeperRegistryCenterConfig.getConnectionAddress2(), reportConfig.getAddress());
Assertions.assertEquals("User", reportConfig.getUsername());
// module configs
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/configprops/SpringBootMultipleConfigPropsTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/configprops/SpringBootMultipleConfigPropsTest.java
index d5eb21b..27151e6 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/configprops/SpringBootMultipleConfigPropsTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/configprops/SpringBootMultipleConfigPropsTest.java
@@ -30,10 +30,8 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.context.ConfigManager;
import org.apache.dubbo.config.context.ModuleConfigManager;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperMultipleRegistryCenter;
import org.apache.dubbo.rpc.model.ModuleModel;
-
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -65,9 +63,9 @@ import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMET
"dubbo.metricses.my-metrics.aggregation.bucket-num=5",
"dubbo.metricses.my-metrics.aggregation.time-window-seconds=120",
"dubbo.monitors.my-monitor.address=zookeeper://127.0.0.1:32770",
- "dubbo.config-centers.my-configcenter.address=zookeeper://127.0.0.1:2181",
+ "dubbo.config-centers.my-configcenter.address=${zookeeper.connection.address.1}",
"dubbo.config-centers.my-configcenter.group=group1",
- "dubbo.metadata-reports.my-metadata.address=zookeeper://127.0.0.1:2182",
+ "dubbo.metadata-reports.my-metadata.address=${zookeeper.connection.address.2}",
"dubbo.metadata-reports.my-metadata.username=User",
"dubbo.providers.my-provider.host=127.0.0.1",
"dubbo.consumers.my-consumer.client=netty"
@@ -81,19 +79,14 @@ import static org.apache.dubbo.common.constants.MetricsConstants.PROTOCOL_PROMET
@EnableDubbo
public class SpringBootMultipleConfigPropsTest {
- private static RegistryCenter multipleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
- multipleRegistryCenter = new ZookeeperMultipleRegistryCenter();
- multipleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- multipleRegistryCenter.shutdown();
}
@Autowired
@@ -137,13 +130,13 @@ public class SpringBootMultipleConfigPropsTest {
Collection<ConfigCenterConfig> configCenters = configManager.getConfigCenters();
Assertions.assertEquals(1, configCenters.size());
ConfigCenterConfig centerConfig = configCenters.iterator().next();
- Assertions.assertEquals("zookeeper://127.0.0.1:2181", centerConfig.getAddress());
+ Assertions.assertEquals(ZookeeperRegistryCenterConfig.getConnectionAddress1(), centerConfig.getAddress());
Assertions.assertEquals("group1", centerConfig.getGroup());
Collection<MetadataReportConfig> metadataConfigs = configManager.getMetadataConfigs();
Assertions.assertEquals(1, metadataConfigs.size());
MetadataReportConfig reportConfig = metadataConfigs.iterator().next();
- Assertions.assertEquals("zookeeper://127.0.0.1:2182", reportConfig.getAddress());
+ Assertions.assertEquals(ZookeeperRegistryCenterConfig.getConnectionAddress2(), reportConfig.getAddress());
Assertions.assertEquals("User", reportConfig.getUsername());
// module configs
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/importxml/SpringBootImportDubboXmlTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/importxml/SpringBootImportDubboXmlTest.java
index 0efc4e9..bd7ffea 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/importxml/SpringBootImportDubboXmlTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/boot/importxml/SpringBootImportDubboXmlTest.java
@@ -18,8 +18,6 @@ package org.apache.dubbo.config.spring.boot.importxml;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.api.HelloService;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -44,19 +42,14 @@ import org.springframework.context.annotation.ImportResource;
@ImportResource("classpath:/org/apache/dubbo/config/spring/boot/importxml/consumer/dubbo-consumer.xml")
public class SpringBootImportDubboXmlTest {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll(){
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll(){
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Autowired
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigConfigurationTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigConfigurationTest.java
index 3898b3e..e745f51 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigConfigurationTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/DubboConfigConfigurationTest.java
@@ -22,8 +22,6 @@ import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
@@ -83,20 +81,14 @@ public class DubboConfigConfigurationTest {
@Test
public void testMultiple() {
- RegistryCenter singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
- try{
- context.register(DubboConfigConfiguration.Multiple.class);
- context.refresh();
-
- RegistryConfig registry1 = context.getBean("registry1", RegistryConfig.class);
- Assertions.assertEquals(2181, registry1.getPort());
-
- RegistryConfig registry2 = context.getBean("registry2", RegistryConfig.class);
- Assertions.assertEquals(2182, registry2.getPort());
- }finally {
- singleRegistryCenter.shutdown();
- }
+ context.register(DubboConfigConfiguration.Multiple.class);
+ context.refresh();
+
+ RegistryConfig registry1 = context.getBean("registry1", RegistryConfig.class);
+ Assertions.assertEquals(2181, registry1.getPort());
+
+ RegistryConfig registry2 = context.getBean("registry2", RegistryConfig.class);
+ Assertions.assertEquals(2182, registry2.getPort());
}
}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigTest.java
index 4c309df..122a713 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/annotation/EnableDubboConfigTest.java
@@ -25,8 +25,6 @@ import org.apache.dubbo.config.ProviderConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.context.ConfigManager;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperMultipleRegistryCenter;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.junit.jupiter.api.AfterEach;
@@ -48,19 +46,14 @@ import static org.junit.jupiter.api.Assertions.assertFalse;
*/
public class EnableDubboConfigTest {
- private RegistryCenter multipleRegistryCenter;
-
@BeforeEach
public void setUp() {
- multipleRegistryCenter = new ZookeeperMultipleRegistryCenter();
- multipleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterEach
public void tearDown() {
DubboBootstrap.reset();
- multipleRegistryCenter.shutdown();
}
//@Test
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/customize/DubboSpringInitCustomizerTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/customize/DubboSpringInitCustomizerTest.java
index 1b5a0f9..c5e6cfb 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/customize/DubboSpringInitCustomizerTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/context/customize/DubboSpringInitCustomizerTest.java
@@ -20,12 +20,11 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.SysProps;
import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.DubboSpringInitCustomizerHolder;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.apache.dubbo.rpc.model.FrameworkModel;
import org.apache.dubbo.rpc.model.ModuleModel;
import org.apache.dubbo.rpc.model.ServiceDescriptor;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -34,22 +33,16 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
public class DubboSpringInitCustomizerTest {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
DubboBootstrap.reset();
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
- RegistryCenter.Instance registryCenterInstance = singleRegistryCenter.getRegistryCenterInstance().get(0);
- SysProps.setProperty("dubbo.registry.address", registryCenterInstance.toURL());
+ SysProps.setProperty("dubbo.registry.address", ZookeeperRegistryCenterConfig.getConnectionAddress());
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
SysProps.clear();
}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue6000/Issue6000Test.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue6000/Issue6000Test.java
index d055170..c652a4c 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue6000/Issue6000Test.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue6000/Issue6000Test.java
@@ -19,8 +19,6 @@ package org.apache.dubbo.config.spring.issues.issue6000;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.config.spring.issues.issue6000.adubbo.HelloDubbo;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.AfterAll;
@@ -40,19 +38,14 @@ import org.springframework.context.annotation.PropertySource;
@PropertySource("classpath:/META-INF/issues/issue6000/config.properties")
public class Issue6000Test {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Test
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue6252/Issue6252Test.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue6252/Issue6252Test.java
index b7609e4..8d9e815 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue6252/Issue6252Test.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue6252/Issue6252Test.java
@@ -18,10 +18,8 @@ package org.apache.dubbo.config.spring.issues.issue6252;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
import org.apache.dubbo.config.spring.api.DemoService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubboConfig;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperMultipleRegistryCenter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -39,19 +37,14 @@ import org.springframework.context.annotation.PropertySource;
@PropertySource("classpath:/META-INF/issues/issue6252/config.properties")
public class Issue6252Test {
- private static RegistryCenter multipleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
- multipleRegistryCenter = new ZookeeperMultipleRegistryCenter();
- multipleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- multipleRegistryCenter.shutdown();
}
@DubboReference
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue7003/Issue7003Test.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue7003/Issue7003Test.java
index 0da499e..a31fbee 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue7003/Issue7003Test.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue7003/Issue7003Test.java
@@ -22,8 +22,6 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.ReferenceBean;
import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.rpc.model.ApplicationModel;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
@@ -49,19 +47,14 @@ import java.util.Map;
@PropertySource("classpath:/META-INF/issues/issue7003/config.properties")
public class Issue7003Test {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Test
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue9172/MultipleConsumerAndProviderTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue9172/MultipleConsumerAndProviderTest.java
index 91b86da..654ba9c 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue9172/MultipleConsumerAndProviderTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/issues/issue9172/MultipleConsumerAndProviderTest.java
@@ -25,12 +25,9 @@ import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.config.spring.impl.DemoServiceImpl;
import org.apache.dubbo.config.spring.impl.HelloServiceImpl;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperMultipleRegistryCenter;
import org.apache.dubbo.config.spring.util.DubboBeanUtils;
import org.apache.dubbo.rpc.model.ModuleModel;
-import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
@@ -41,21 +38,6 @@ import org.springframework.context.annotation.PropertySource;
*/
public class MultipleConsumerAndProviderTest {
- private static ZookeeperMultipleRegistryCenter registryCenter;
-
- @BeforeAll
- public static void setUp() {
- registryCenter = new ZookeeperMultipleRegistryCenter();
- registryCenter.startup();
- }
-
- @AfterAll
- public static void tearDown() {
- if (registryCenter != null) {
- registryCenter.shutdown();
- }
- }
-
@Test
public void test() {
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/PropertyConfigurerTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/PropertyConfigurerTest.java
index 571c8cd..4191be8 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/PropertyConfigurerTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/PropertyConfigurerTest.java
@@ -19,8 +19,6 @@ package org.apache.dubbo.config.spring.propertyconfigurer.consumer;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -34,19 +32,14 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
public class PropertyConfigurerTest {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Test
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/app.properties b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/app.properties
index fcda447..5d67384 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/app.properties
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/app.properties
@@ -1,4 +1,4 @@
-dubbo.registry.address=zookeeper://127.0.0.1:2181?registry-type=service
+dubbo.registry.address=${zookeeper.connection.address}?registry-type=service
biz.group=greeting
biz.group2=group2
dubbo.call-timeout=2000
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/dubbo-consumer.xml b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/dubbo-consumer.xml
index 8b25aa1..d00f3b2 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/dubbo-consumer.xml
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer/dubbo-consumer.xml
@@ -30,7 +30,7 @@
<dubbo:application name="demo-consumer">
</dubbo:application>
- <!-- <dubbo:metadata-report address="zookeeper://127.0.0.1:2181"/>-->
+ <!-- <dubbo:metadata-report address="${zookeeper.connection.address}"/>-->
<dubbo:registry address="${dubbo.registry.address}"/>
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/PropertySourcesConfigurerTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/PropertySourcesConfigurerTest.java
index 06a2df4..a75d319 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/PropertySourcesConfigurerTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/PropertySourcesConfigurerTest.java
@@ -20,8 +20,6 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.config.spring.propertyconfigurer.consumer.DemoBeanFactoryPostProcessor;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -35,19 +33,14 @@ import org.springframework.context.support.ClassPathXmlApplicationContext;
public class PropertySourcesConfigurerTest {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Test
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/app.properties b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/app.properties
index fcda447..5d67384 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/app.properties
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/app.properties
@@ -1,4 +1,4 @@
-dubbo.registry.address=zookeeper://127.0.0.1:2181?registry-type=service
+dubbo.registry.address=${zookeeper.connection.address}?registry-type=service
biz.group=greeting
biz.group2=group2
dubbo.call-timeout=2000
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/dubbo-consumer.xml b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/dubbo-consumer.xml
index fe30acb..6048716 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/dubbo-consumer.xml
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer2/dubbo-consumer.xml
@@ -30,7 +30,7 @@
<dubbo:application name="demo-consumer">
</dubbo:application>
- <!-- <dubbo:metadata-report address="zookeeper://127.0.0.1:2181"/>-->
+ <!-- <dubbo:metadata-report address="${zookeeper.connection.address}"/>-->
<dubbo:registry address="${dubbo.registry.address}"/>
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/PropertySourcesInJavaConfigTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/PropertySourcesInJavaConfigTest.java
index 163b466..f209fdd 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/PropertySourcesInJavaConfigTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/PropertySourcesInJavaConfigTest.java
@@ -20,12 +20,8 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.config.spring.propertyconfigurer.consumer.DemoBeanFactoryPostProcessor;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
-import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -45,18 +41,6 @@ public class PropertySourcesInJavaConfigTest {
private static final String SCAN_PACKAGE_NAME = "org.apache.dubbo.config.spring.propertyconfigurer.consumer3.notexist";
private static final String PACKAGE_PATH = "/org/apache/dubbo/config/spring/propertyconfigurer/consumer3";
private static final String PROVIDER_CONFIG_PATH = "org/apache/dubbo/config/spring/propertyconfigurer/provider/dubbo-provider.xml";
- private static RegistryCenter singleRegistryCenter;
-
- @BeforeAll
- public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
- }
-
- @AfterAll
- public static void afterAll() {
- singleRegistryCenter.shutdown();
- }
@BeforeEach
public void setUp() throws Exception {
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/app.properties b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/app.properties
index fcda447..5d67384 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/app.properties
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/app.properties
@@ -1,4 +1,4 @@
-dubbo.registry.address=zookeeper://127.0.0.1:2181?registry-type=service
+dubbo.registry.address=${zookeeper.connection.address}?registry-type=service
biz.group=greeting
biz.group2=group2
dubbo.call-timeout=2000
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/dubbo-consumer.xml b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/dubbo-consumer.xml
index c5233e7..4a5d492 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/dubbo-consumer.xml
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/consumer3/dubbo-consumer.xml
@@ -24,7 +24,7 @@
<dubbo:application name="demo-consumer">
</dubbo:application>
- <!-- <dubbo:metadata-report address="zookeeper://127.0.0.1:2181"/>-->
+ <!-- <dubbo:metadata-report address="${zookeeper.connection.address}"/>-->
<dubbo:registry address="${dubbo.registry.address}"/>
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/provider/app.properties b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/provider/app.properties
index 56d423a..a7e4b1e 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/provider/app.properties
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/propertyconfigurer/provider/app.properties
@@ -1,6 +1,6 @@
dubbo.application.name=demo-provider
-dubbo.registry.address=zookeeper://127.0.0.1:2181?registry-type=service
-dubbo.config-center.address=zookeeper://127.0.0.1:2181
-dubbo.metadata-report.address=zookeeper://127.0.0.1:2181
+dubbo.registry.address=${zookeeper.connection.address}?registry-type=service
+dubbo.config-center.address=${zookeeper.connection.address}
+dubbo.metadata-report.address=${zookeeper.connection.address}
biz.group=greeting
biz.group2=group2
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/DubboConfigBeanInitializerTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/DubboConfigBeanInitializerTest.java
index 63bdde2..a056711 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/DubboConfigBeanInitializerTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/DubboConfigBeanInitializerTest.java
@@ -22,8 +22,6 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.DubboConfigBeanInitializer;
import org.apache.dubbo.config.spring.context.annotation.provider.ProviderConfiguration;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.config.spring.util.DubboBeanUtils;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
@@ -55,23 +53,19 @@ import java.util.List;
})
@TestPropertySource(properties = {
"dubbo.protocol.port=-1",
- "dubbo.registry.address=zookeeper://127.0.0.1:2181"
+ "dubbo.registry.address=${zookeeper.connection.address}"
})
@EnableAspectJAutoProxy(proxyTargetClass = true, exposeProxy = true)
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_EACH_TEST_METHOD)
public class DubboConfigBeanInitializerTest {
- private static RegistryCenter singleRegistryCenter;
@BeforeAll
public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
- singleRegistryCenter.shutdown();
DubboBootstrap.reset();
}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/ReferenceKeyTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/ReferenceKeyTest.java
index 79e1e5a..398ac4e 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/ReferenceKeyTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/ReferenceKeyTest.java
@@ -25,13 +25,9 @@ import org.apache.dubbo.config.spring.api.DemoService;
import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.impl.DemoServiceImpl;
import org.apache.dubbo.config.spring.impl.HelloServiceImpl;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import com.alibaba.spring.util.AnnotationUtils;
-import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
@@ -50,20 +46,6 @@ import java.util.Map;
public class ReferenceKeyTest {
- private static RegistryCenter singleRegistryCenter;
-
- @BeforeAll
- public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
- }
-
- @AfterAll
- public static void afterAll() {
- singleRegistryCenter.shutdown();
- }
-
-
@BeforeEach
protected void setUp() {
DubboBootstrap.reset();
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/javaconfig/JavaConfigReferenceBeanTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/javaconfig/JavaConfigReferenceBeanTest.java
index a4ec239..494fdc3 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/javaconfig/JavaConfigReferenceBeanTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/javaconfig/JavaConfigReferenceBeanTest.java
@@ -27,8 +27,6 @@ import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.config.spring.impl.HelloServiceImpl;
import org.apache.dubbo.config.spring.reference.ReferenceBeanBuilder;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperMultipleRegistryCenter;
import org.apache.dubbo.rpc.service.GenericException;
import org.apache.dubbo.rpc.service.GenericService;
import org.junit.jupiter.api.AfterAll;
@@ -53,23 +51,6 @@ import java.util.Map;
public class JavaConfigReferenceBeanTest {
- private static RegistryCenter multipleRegistryCenter;
-
- @BeforeAll
- public static void beforeAll() {
- multipleRegistryCenter = new ZookeeperMultipleRegistryCenter();
- multipleRegistryCenter.startup();
- }
-
- @AfterAll
- public static void afterAll() throws Exception {
- multipleRegistryCenter.shutdown();
- multipleRegistryCenter = null;
-
- //Thread.sleep(10000);
- //dumpHeap("/Users/gongdewei/work/dump/dubbo/", true);
- }
-
public static void dumpHeap(String dirpath, boolean live) throws Exception {
java.lang.management.RuntimeMXBean runtime =
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/javaconfig/consumer.properties b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/javaconfig/consumer.properties
index f2f6ea5..0782ed8 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/javaconfig/consumer.properties
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/javaconfig/consumer.properties
@@ -1,7 +1,7 @@
dubbo.application.name=consumer-app
dubbo.protocol.name=dubbo
dubbo.protocol.port=-1
-dubbo.registry.address=zookeeper://127.0.0.1:2181
+dubbo.registry.address=${zookeeper.connection.address}
dubbo.reference.org.apache.dubbo.config.spring.api.DemoService.init=false
#dubbo.reference.org.apache.dubbo.config.spring.api.HelloService.init=false
#dubbo.consumer.init=false
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest.java
index 25fee33..8283a97 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest.java
@@ -18,15 +18,12 @@ package org.apache.dubbo.config.spring.reference.localcall;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.api.HelloService;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.context.ApplicationContext;
import org.springframework.test.annotation.DirtiesContext;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit.jupiter.SpringExtension;
@@ -39,19 +36,14 @@ import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
public class LocalCallTest {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Autowired
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest2.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest2.java
index 5eb1a98..a443519 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest2.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/LocalCallTest2.java
@@ -19,8 +19,6 @@ package org.apache.dubbo.config.spring.reference.localcall;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.api.HelloService;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
@@ -39,19 +37,14 @@ import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
public class LocalCallTest2 {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void setUp() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void tearDown() {
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@DubboReference
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/local-call-provider.xml b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/local-call-provider.xml
index 0f7c0b5..dc811f6 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/local-call-provider.xml
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcall/local-call-provider.xml
@@ -25,7 +25,7 @@
<dubbo:application name="demo-provider"/>
- <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+ <dubbo:registry address="${zookeeper.connection.address}"/>
<dubbo:protocol name="dubbo" port="20880"/>
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/LocalCallMultipleReferenceAnnotationsTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/LocalCallMultipleReferenceAnnotationsTest.java
index 2da3732..763251a 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/LocalCallMultipleReferenceAnnotationsTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/LocalCallMultipleReferenceAnnotationsTest.java
@@ -22,10 +22,7 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.ReferenceBean;
import org.apache.dubbo.config.spring.api.HelloService;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.rpc.RpcContext;
-import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
@@ -49,18 +46,9 @@ import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER
@DirtiesContext(classMode = AFTER_EACH_TEST_METHOD)
public class LocalCallMultipleReferenceAnnotationsTest {
- private static RegistryCenter registryCenter;
-
@BeforeAll
public static void setUp() {
DubboBootstrap.reset();
- registryCenter = new ZookeeperSingleRegistryCenter();
- registryCenter.startup();
- }
-
- @AfterAll
- public static void tearDown() {
- registryCenter.shutdown();
}
@Autowired
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/local-call-config.properties b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/local-call-config.properties
index 7f19a27..be75cda 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/local-call-config.properties
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/reference/localcallam/local-call-config.properties
@@ -1,6 +1,6 @@
dubbo.application.name=local-call-demo
dubbo.protocol.name=dubbo
dubbo.protocol.port=-1
-dubbo.registry.address=zookeeper://127.0.0.1:2181
+dubbo.registry.address=${zookeeper.connection.address}
biz.group=demo
biz.version=2.0.0
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/AbstractRegistryCenter.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/AbstractRegistryCenter.java
deleted file mode 100644
index d373234..0000000
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/AbstractRegistryCenter.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.registrycenter;
-
-import org.apache.curator.test.InstanceSpec;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The abstraction of {@link RegistryCenter} implements the basic methods.
- */
-abstract class AbstractRegistryCenter implements RegistryCenter {
-
- /**
- * The default data directory is null
- */
- private static final File DEFAULT_DATA_DIRECTORY = null;
-
- /**
- * The default election port is -1.
- */
- private static final int DEFAULT_ELECTION_PORT = -1;
-
- /**
- * The default quorum port is -1.
- */
- private static final int DEFAULT_QUORUM_PORT = -1;
-
- /**
- * The default value is true.
- */
- private static final boolean DEFAULT_DELETE_DATA_DIRECTORY_ON_CLOSE = true;
-
- /**
- * The default service id is -1.
- */
- private static final int DEFAULT_SERVER_ID = -1;
-
- /**
- * The default tick time is 5000
- */
- private static final int DEFAULT_TICK_TIME = 5 * 1000;
-
- /**
- * The default value is 200.
- */
- private static final int DEFAULT_MAX_CLIENT_CNXNS = 200;
-
- /**
- * The minimum session timeout.
- */
- private static final int DEFAULT_MINIMUM_SESSION_TIMEOUT = DEFAULT_TICK_TIME * 2;
-
- /**
- * The maximum session timeout.
- */
- private static final int DEFAULT_MAXIMUM_SESSION_TIMEOUT = 600 * 1000;
-
- /**
- * The default customer properties.
- */
- private static final Map<String, Object> DEFAULT_CUSTOM_PROPERTIES = new HashMap<>(2);
-
- /**
- * The default hostname.
- */
- private static final String DEFAULT_HOSTNAME = "127.0.0.1";
-
- static {
- DEFAULT_CUSTOM_PROPERTIES.put("minSessionTimeout", DEFAULT_MINIMUM_SESSION_TIMEOUT);
- DEFAULT_CUSTOM_PROPERTIES.put("maxSessionTimeout", DEFAULT_MAXIMUM_SESSION_TIMEOUT);
- }
-
- /**
- * Create an {@link InstanceSpec} instance to initialize {@link org.apache.curator.test.TestingServer}
- *
- * @param port the zookeeper server's port.
- */
- protected InstanceSpec createInstanceSpec(int port) {
- return new InstanceSpec(DEFAULT_DATA_DIRECTORY,
- port,
- DEFAULT_ELECTION_PORT,
- DEFAULT_QUORUM_PORT,
- DEFAULT_DELETE_DATA_DIRECTORY_ON_CLOSE,
- DEFAULT_SERVER_ID,
- DEFAULT_TICK_TIME,
- DEFAULT_MAX_CLIENT_CNXNS,
- DEFAULT_CUSTOM_PROPERTIES,
- DEFAULT_HOSTNAME);
- }
-}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/RegistryCenter.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/RegistryCenter.java
deleted file mode 100644
index 0b8dd5b..0000000
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/RegistryCenter.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.registrycenter;
-
-import org.apache.dubbo.rpc.RpcException;
-
-import java.util.List;
-
-/**
- * The mock registry center.
- */
-public interface RegistryCenter {
-
- /**
- * Start the registry center.
- *
- * @throws RpcException when an exception occurred
- */
- void startup() throws RpcException;
-
- /**
- * Returns the registry center instance.
- * <p>This method can be called only after {@link #startup()} is called</p>
- *
- * @throws RpcException when an exception occurred
- */
- List<Instance> getRegistryCenterInstance() throws RpcException;
-
- /**
- * Stop the registry center.
- *
- * @throws RpcException when an exception occurred
- */
- void shutdown() throws RpcException;
-
- /**
- * The registry center instance.
- */
- interface Instance {
-
- /**
- * Returns the registry center type.
- */
- String getType();
-
- /**
- * Returns the hostname of registry center.
- */
- String getHostname();
-
- /**
- * Returns the port of registry center.
- */
- int getPort();
-
- /**
- * Return registry center url, such as: zookeeper://127.0.0.1:2181
- */
- String toURL();
- }
-}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/ZookeeperMultipleRegistryCenter.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/ZookeeperMultipleRegistryCenter.java
deleted file mode 100644
index ff6f3c7..0000000
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/ZookeeperMultipleRegistryCenter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.registrycenter;
-
-/**
- * The default zookeeper multiple registry center.
- */
-public class ZookeeperMultipleRegistryCenter extends ZookeeperRegistryCenter {
-
- /**
- * Initialize {@link ZookeeperMultipleRegistryCenter} instance.
- *
- * @param port1 the zookeeper server's port.
- * @param port2 the zookeeper server's port.
- */
- public ZookeeperMultipleRegistryCenter(int port1, int port2) {
- super(port1, port2);
- }
-
- /**
- * Initialize {@link ZookeeperMultipleRegistryCenter} instance.
- */
- public ZookeeperMultipleRegistryCenter() {
- this(DEFAULT_PORT1, DEFAULT_PORT2);
- }
-
- private static final int DEFAULT_PORT1 = 2181;
- private static final int DEFAULT_PORT2 = 2182;
-}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/ZookeeperRegistryCenter.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/ZookeeperRegistryCenter.java
deleted file mode 100644
index 0dd47a8..0000000
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/ZookeeperRegistryCenter.java
+++ /dev/null
@@ -1,147 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.registrycenter;
-
-import org.apache.curator.test.InstanceSpec;
-import org.apache.curator.test.TestingServer;
-import org.apache.dubbo.common.logger.Logger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.rpc.RpcException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * The default implementation of registry center can support single and multiple registry center.
- * <p>Each port represents an instance. You can provide multiple ports to build multiple registry center,
- * if you want to create multiple registry center
- */
-class ZookeeperRegistryCenter extends AbstractRegistryCenter {
-
- /**
- * Initialize the default registry center.
- *
- * @param ports the registry center's ports.
- */
- public ZookeeperRegistryCenter(int... ports) {
- this.ports = ports;
- this.instanceSpecs = new ArrayList<>(this.ports.length);
- this.zookeeperServers = new ArrayList<>(this.ports.length);
- }
-
- private static final Logger logger = LoggerFactory.getLogger(ZookeeperRegistryCenter.class);
-
- /**
- * The type of the registry center.
- */
- private static final String DEFAULT_REGISTRY_CENTER_TYPE = "zookeeper";
-
- private int[] ports;
-
- private List<InstanceSpec> instanceSpecs;
-
- private List<TestingServer> zookeeperServers;
-
- private AtomicBoolean started = new AtomicBoolean(false);
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startup() throws RpcException {
- try {
- if (started.compareAndSet(false, true)) {
- logger.info("The ZookeeperRegistryCenter is starting...");
- for (int port : this.ports) {
- InstanceSpec instanceSpec = this.createInstanceSpec(port);
- this.instanceSpecs.add(instanceSpec);
- this.zookeeperServers.add(new TestingServer(instanceSpec, true));
- }
- logger.info("The ZookeeperRegistryCenter is started successfully");
- }
- } catch (Exception exception) {
- started.set(false);
- throw new RpcException("Failed to initialize ZookeeperRegistryCenter instance", exception);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<Instance> getRegistryCenterInstance() throws RpcException {
- this.startup();
- List<Instance> instances = new ArrayList<>(this.instanceSpecs.size());
- for (InstanceSpec instanceSpec : this.instanceSpecs) {
- instances.add(new Instance() {
- @Override
- public String getType() {
- return DEFAULT_REGISTRY_CENTER_TYPE;
- }
-
- @Override
- public String getHostname() {
- return instanceSpec.getHostname();
- }
-
- @Override
- public int getPort() {
- return instanceSpec.getPort();
- }
-
- @Override
- public String toURL() {
- return String.format("%s://%s:%d", getType(), getHostname(), getPort());
- }
- });
- }
- return instances;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void shutdown() throws RpcException {
- logger.info("The ZookeeperRegistryCenter is stopping...");
- List<RpcException> exceptions = new ArrayList<>(this.zookeeperServers.size());
- for (TestingServer testingServer : this.zookeeperServers) {
- try {
- testingServer.close();
- logger.info(String.format("The zookeeper instance of %s is shutdown successfully",
- testingServer.getConnectString()));
- } catch (IOException exception) {
- RpcException rpcException = new RpcException(String.format("Failed to close zookeeper instance of %s",
- testingServer.getConnectString()),
- exception);
- exceptions.add(rpcException);
- logger.error(rpcException);
- }
- }
- this.instanceSpecs.clear();
- this.zookeeperServers.clear();
- if (!exceptions.isEmpty()) {
- logger.info("The ZookeeperRegistryCenter failed to close.");
- // throw any one of exceptions
- throw exceptions.get(0);
- } else {
- logger.info("The ZookeeperRegistryCenter close successfully.");
- }
- }
-}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/ZookeeperSingleRegistryCenter.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/ZookeeperSingleRegistryCenter.java
deleted file mode 100644
index ffc0ec3..0000000
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/registrycenter/ZookeeperSingleRegistryCenter.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.config.spring.registrycenter;
-
-/**
- * The default zookeeper single registry center.
- */
-public class ZookeeperSingleRegistryCenter extends ZookeeperRegistryCenter {
-
- /**
- * Initialize {@link ZookeeperSingleRegistryCenter} instance.
- */
- public ZookeeperSingleRegistryCenter() {
- this(DEFAULT_PORT);
- }
-
- /**
- * Initialize {@link RegistryCenter} instance.
- *
- * @param port the zookeeper server's port.
- */
- public ZookeeperSingleRegistryCenter(int port) {
- super(port);
- }
-
- /**
- * The zookeeper server's default port.
- */
- private static final int DEFAULT_PORT = 2181;
-}
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/schema/GenericServiceTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/schema/GenericServiceTest.java
index ae213a7..79d0afe 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/schema/GenericServiceTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/schema/GenericServiceTest.java
@@ -21,8 +21,6 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.context.ModuleConfigManager;
import org.apache.dubbo.config.spring.ServiceBean;
import org.apache.dubbo.config.spring.api.DemoService;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.rpc.service.GenericService;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
@@ -45,19 +43,14 @@ import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER
@ImportResource(locations = "classpath:/META-INF/spring/dubbo-generic-consumer.xml")
public class GenericServiceTest {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Autowired
diff --git a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/schema/GenericServiceWithoutInterfaceTest.java b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/schema/GenericServiceWithoutInterfaceTest.java
index 672c4b9..ff0861d 100644
--- a/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/schema/GenericServiceWithoutInterfaceTest.java
+++ b/dubbo-config/dubbo-config-spring/src/test/java/org/apache/dubbo/config/spring/schema/GenericServiceWithoutInterfaceTest.java
@@ -19,8 +19,6 @@ package org.apache.dubbo.config.spring.schema;
import org.apache.dubbo.common.utils.ClassUtils;
import org.apache.dubbo.config.ReferenceConfigBase;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
-import org.apache.dubbo.config.spring.registrycenter.RegistryCenter;
-import org.apache.dubbo.config.spring.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.rpc.service.GenericService;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
@@ -42,19 +40,14 @@ import static org.springframework.test.annotation.DirtiesContext.ClassMode.AFTER
@ImportResource(locations = "classpath:/META-INF/spring/dubbo-generic-consumer-without-interface.xml")
public class GenericServiceWithoutInterfaceTest {
- private static RegistryCenter singleRegistryCenter;
-
@BeforeAll
public static void beforeAll() {
- singleRegistryCenter = new ZookeeperSingleRegistryCenter();
- singleRegistryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll() {
DubboBootstrap.reset();
- singleRegistryCenter.shutdown();
}
@Autowired
diff --git a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue6000/config.properties b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue6000/config.properties
index 519de97..b415cc4 100644
--- a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue6000/config.properties
+++ b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue6000/config.properties
@@ -1,4 +1,4 @@
dubbo.application.name=demo-6000
dubbo.protocol.name=dubbo
dubbo.protocol.port=-1
-dubbo.registry.address=zookeeper://127.0.0.1:2181
+dubbo.registry.address=${zookeeper.connection.address}
diff --git a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue6252/config.properties b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue6252/config.properties
index 5d0ff91..b98da3c 100644
--- a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue6252/config.properties
+++ b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue6252/config.properties
@@ -4,12 +4,12 @@ dubbo.protocol.name=dubbo
dubbo.protocol.port=-1
dubbo.scan.basePackages=com.example.demo
dubbo.consumer.check=false
-dubbo.registries.z214.address=zookeeper://127.0.0.1:2181
+dubbo.registries.z214.address=${zookeeper.connection.address.1}
dubbo.registries.z214.timeout=20000
dubbo.registries.z214.subscribe=false
dubbo.registries.z214.useAsConfigCenter=false
dubbo.registries.z214.useAsMetadataCenter=false
-dubbo.registries.z205.address=zookeeper://127.0.0.1:2182
+dubbo.registries.z205.address=${zookeeper.connection.address.2}
dubbo.registries.z205.timeout=20000
dubbo.registries.z205.useAsConfigCenter=false
dubbo.registries.z205.useAsMetadataCenter=false
diff --git a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue7003/config.properties b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue7003/config.properties
index 35885f6..6620808 100644
--- a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue7003/config.properties
+++ b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/issues/issue7003/config.properties
@@ -1,4 +1,4 @@
dubbo.application.name=demo-app
dubbo.protocol.name=dubbo
dubbo.protocol.port=-1
-dubbo.registry.address=zookeeper://127.0.0.1:2181
+dubbo.registry.address=${zookeeper.connection.address}
diff --git a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbb-consumer.properties b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbb-consumer.properties
index 89e59a4..ecdc96a 100644
--- a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbb-consumer.properties
+++ b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbb-consumer.properties
@@ -2,7 +2,7 @@
dubbo.application.name = zookeeper-dubbo-spring-consumer
-dubbo.registry.address = zookeeper://127.0.0.1:2181?registry-type=service
+dubbo.registry.address = ${zookeeper.connection.address}?registry-type=service
dubbo.registry.useAsConfigCenter = true
dubbo.registry.useAsMetadataCenter = true
diff --git a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbb-provider.properties b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbb-provider.properties
index d81a529..2eb414a 100644
--- a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbb-provider.properties
+++ b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbb-provider.properties
@@ -2,7 +2,7 @@
dubbo.application.name = zookeeper-dubbo-spring-provider-1
-dubbo.registry.address = zookeeper://127.0.0.1:2181?registry-type=service
+dubbo.registry.address = ${zookeeper.connection.address}?registry-type=service
dubbo.registry.useAsConfigCenter = true
dubbo.registry.useAsMetadataCenter = true
diff --git a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbo-consumer.xml b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbo-consumer.xml
index 92305f5..89ef0a5 100644
--- a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbo-consumer.xml
+++ b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/service-introspection/zookeeper-dubbo-consumer.xml
@@ -25,10 +25,10 @@
<dubbo:application name="zookeeper-dubbo-spring-consumer"/>
<!-- 连接注册中心配置 -->
- <dubbo:registry address="zookeeper://127.0.0.1:2181?registry-type=service" use-as-config-center="true"
+ <dubbo:registry address="${zookeeper.connection.address}?registry-type=service" use-as-config-center="true"
use-as-metadata-center="true"/>
<dubbo:reference id="demoService" interface="org.apache.dubbo.config.spring.api.DemoService"
services="zookeeper-dubbo-spring-provider,zookeeper-dubbo-spring-provider"/>
-</beans>
\ No newline at end of file
+</beans>
diff --git a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/spring/dubbo-generic-consumer-without-interface.xml b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/spring/dubbo-generic-consumer-without-interface.xml
index 002f8f6..3078126 100644
--- a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/spring/dubbo-generic-consumer-without-interface.xml
+++ b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/spring/dubbo-generic-consumer-without-interface.xml
@@ -25,7 +25,7 @@
<dubbo:application name="dubbo-generic-consumer-without-interface"/>
<!-- 连接注册中心配置 -->
- <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
+ <dubbo:registry address="${zookeeper.connection.address}"/>
<bean id="genericService" class="org.apache.dubbo.config.spring.schema.MyGenericService"/>
diff --git a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/spring/dubbo-generic-consumer.xml b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/spring/dubbo-generic-consumer.xml
index e426e22..1bf81f0 100644
--- a/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/spring/dubbo-generic-consumer.xml
+++ b/dubbo-config/dubbo-config-spring/src/test/resources/META-INF/spring/dubbo-generic-consumer.xml
@@ -25,7 +25,7 @@
<dubbo:application name="dubbo-generic-consumer"/>
<!-- 连接注册中心配置 -->
- <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
+ <dubbo:registry address="${zookeeper.connection.address}"/>
<dubbo:reference id="demoServiceRef" interface="org.apache.dubbo.config.spring.api.DemoService" generic="true" init="false"/>
diff --git a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/resources/spring/dubbo-consumer.properties b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/resources/spring/dubbo-consumer.properties
index 151fc03..46ff34d 100644
--- a/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/resources/spring/dubbo-consumer.properties
+++ b/dubbo-demo/dubbo-demo-annotation/dubbo-demo-annotation-consumer/src/main/resources/spring/dubbo-consumer.properties
@@ -18,5 +18,5 @@
#
dubbo.application.name=dubbo-demo-annotation-consumer
-dubbo.registry.address=zookeeper://127.0.0.1:2181
+dubbo.registry.address=${zookeeper.connection.address}
dubbo.protocol.port=-1
diff --git a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/spring/dubbo-consumer.xml b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/spring/dubbo-consumer.xml
index a89803c..374060b 100644
--- a/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/spring/dubbo-consumer.xml
+++ b/dubbo-demo/dubbo-demo-xml/dubbo-demo-xml-consumer/src/main/resources/spring/dubbo-consumer.xml
@@ -24,9 +24,9 @@
<dubbo:application name="demo-consumer">
</dubbo:application>
- <dubbo:metadata-report address="zookeeper://127.0.0.1:2181"/>
+ <dubbo:metadata-report address="${zookeeper.connection.address}"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
+ <dubbo:registry address="${zookeeper.connection.address}"/>
<dubbo:protocol name="dubbo" port="-1"/>
<dubbo:protocol name="rest" port="-1"/>
diff --git a/dubbo-test/dubbo-test-check/pom.xml b/dubbo-test/dubbo-test-check/pom.xml
index 4cb1b10..d7bbd6a 100644
--- a/dubbo-test/dubbo-test-check/pom.xml
+++ b/dubbo-test/dubbo-test-check/pom.xml
@@ -32,6 +32,12 @@
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<skip_maven_deploy>true</skip_maven_deploy>
+ <curator.test.version>5.1.0</curator.test.version>
+ <zookeeper.version>3.6.0</zookeeper.version>
+ <curator5.version>5.1.0</curator5.version>
+ <commons.compress.version>1.20</commons.compress.version>
+ <junit.platform.launcher.version>1.6.2</junit.platform.launcher.version>
+ <commons.exec.version>1.3</commons.exec.version>
</properties>
<dependencies>
@@ -42,11 +48,49 @@
<dependency>
<groupId>org.junit.platform</groupId>
<artifactId>junit-platform-launcher</artifactId>
- <version>1.6.2</version>
+ <version>${junit.platform.launcher.version}</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-test</artifactId>
+ <version>${curator.test.version}</version>
+ <scope>compile</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>com.google.guava</groupId>
+ <artifactId>guava</artifactId>
+ </exclusion>
+ <exclusion>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.zookeeper</groupId>
+ <artifactId>zookeeper</artifactId>
+ <version>${zookeeper.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.curator</groupId>
+ <artifactId>curator-framework</artifactId>
+ <version>${curator5.version}</version>
+ </dependency>
+ <!-- tar.gz -->
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-compress</artifactId>
+ <version>${commons.compress.version}</version>
+ <scope>compile</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-exec</artifactId>
+ <version>${commons.exec.version}</version>
+ </dependency>
</dependencies>
</project>
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/AbstractRegistryCenterTestExecutionListener.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/AbstractRegistryCenterTestExecutionListener.java
new file mode 100644
index 0000000..45bab8f
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/AbstractRegistryCenterTestExecutionListener.java
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check;
+
+import org.junit.platform.engine.TestSource;
+import org.junit.platform.engine.support.descriptor.ClassSource;
+import org.junit.platform.launcher.TestExecutionListener;
+import org.junit.platform.launcher.TestIdentifier;
+import org.junit.platform.launcher.TestPlan;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * The abstract implementation provides the basic methods. <p></p>
+ * {@link #needRegistryCenter(TestPlan)}: checks if current {@link TestPlan} need registry center.
+ */
+public abstract class AbstractRegistryCenterTestExecutionListener implements TestExecutionListener {
+
+ /**
+ * The JVM arguments to set if it can use embedded zookeeper, the default value is {@code true}.
+ */
+ private static final String CONFIG_ENABLE_EMBEDDED_ZOOKEEPER = "enableEmbeddedZookeeper";
+
+ /**
+ * The registry center should start
+ * if we want to run the test cases in the given package.
+ */
+ private static final Set<String> PACKAGE_NAME = new HashSet<>();
+
+ /**
+ * Use embedded zookeeper or not.
+ */
+ private static boolean enableEmbeddedZookeeper;
+
+ static {
+ // dubbo-config module
+ PACKAGE_NAME.add("org.apache.dubbo.config");
+ // dubbo-test module
+ PACKAGE_NAME.add("org.apache.dubbo.test");
+ enableEmbeddedZookeeper = Boolean.valueOf(System.getProperty(CONFIG_ENABLE_EMBEDDED_ZOOKEEPER, "true"));
+ }
+
+ /**
+ * Checks if current {@link TestPlan} need registry center.
+ */
+ public boolean needRegistryCenter(TestPlan testPlan) {
+ return testPlan.getRoots().stream()
+ .flatMap(testIdentifier -> testPlan.getChildren(testIdentifier).stream())
+ .filter(testIdentifier -> testIdentifier.getSource().isPresent())
+ .filter(testIdentifier -> supportEmbeddedZookeeper(testIdentifier))
+ .count() > 0;
+ }
+
+ /**
+ * Checks if current {@link TestIdentifier} need registry center.
+ */
+ public boolean needRegistryCenter(TestIdentifier testIdentifier) {
+ return supportEmbeddedZookeeper(testIdentifier);
+ }
+
+ /**
+ * Checks if the current {@link TestIdentifier} need embedded zookeeper.
+ */
+ private boolean supportEmbeddedZookeeper(TestIdentifier testIdentifier) {
+ if (!enableEmbeddedZookeeper) {
+ return false;
+ }
+ TestSource testSource = testIdentifier.getSource().orElse(null);
+ if (testSource instanceof ClassSource) {
+ String packageName = ((ClassSource) testSource).getJavaClass().getPackage().getName();
+ for (String pkgName : PACKAGE_NAME) {
+ if (packageName.contains(pkgName)) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterIntegrationServiceImpl.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/RegistryCenterFinished.java
similarity index 54%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterIntegrationServiceImpl.java
rename to dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/RegistryCenterFinished.java
index 99e5d8a..28253fa 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/SingleRegistryCenterIntegrationServiceImpl.java
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/RegistryCenterFinished.java
@@ -14,22 +14,26 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.single;
+package org.apache.dubbo.test.check;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.dubbo.test.check.registrycenter.GlobalRegistryCenter;
+import org.junit.platform.launcher.TestPlan;
/**
- * The implementation for {@link SingleRegistryCenterIntegrationService}
+ * The entrance to terminate the mocked registry center.
*/
-public class SingleRegistryCenterIntegrationServiceImpl implements SingleRegistryCenterIntegrationService {
-
- private static final Logger logger = LoggerFactory.getLogger(SingleRegistryCenterIntegrationServiceImpl.class);
+public class RegistryCenterFinished extends AbstractRegistryCenterTestExecutionListener {
@Override
- public String hello(String name) {
- String value = "Hello " + name;
- logger.info(value);
- return value;
+ public void testPlanExecutionFinished(TestPlan testPlan) {
+ super.testPlanExecutionFinished(testPlan);
+ try {
+ if(needRegistryCenter(testPlan)){
+ GlobalRegistryCenter.shutdown();
+ }
+ } catch (Throwable cause) {
+ throw new IllegalStateException("Failed to terminate zookeeper instance in unit test",cause);
+ }
}
+
}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/RegistryCenterStarted.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/RegistryCenterStarted.java
new file mode 100644
index 0000000..e45b161
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/RegistryCenterStarted.java
@@ -0,0 +1,50 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check;
+
+import org.apache.dubbo.test.check.registrycenter.GlobalRegistryCenter;
+import org.junit.platform.engine.TestExecutionResult;
+import org.junit.platform.launcher.TestIdentifier;
+import org.junit.platform.launcher.TestPlan;
+
+/**
+ * The entrance to start the mocked registry center.
+ */
+public class RegistryCenterStarted extends AbstractRegistryCenterTestExecutionListener {
+
+ @Override
+ public void testPlanExecutionStarted(TestPlan testPlan) {
+ try {
+ if (needRegistryCenter(testPlan)) {
+ GlobalRegistryCenter.startup();
+ }
+ } catch (Throwable cause) {
+ throw new IllegalStateException("Failed to start zookeeper instance in unit test", cause);
+ }
+ }
+
+ @Override
+ public void executionFinished(TestIdentifier testIdentifier, TestExecutionResult testExecutionResult) {
+ try {
+ if (needRegistryCenter(testIdentifier)) {
+ GlobalRegistryCenter.reset();
+ }
+ } catch (Throwable cause) {
+ // ignore the exception
+ }
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/exception/DubboTestException.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/exception/DubboTestException.java
new file mode 100644
index 0000000..6c3f106
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/exception/DubboTestException.java
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.dubbo.test.check.exception;
+/**
+ * Define a specified exception when test.
+ */
+public class DubboTestException extends RuntimeException {
+
+ /**
+ * Constructs a new {@link DubboTestException} with the specified detail message.
+ *
+ * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
+ */
+ public DubboTestException(String message) {
+ super(message);
+ }
+
+ /**
+ * Constructs a new {@link DubboTestException} with the specified detail message and cause.
+ *
+ * @param message the detail message. The detail message is saved for later retrieval by the {@link #getMessage()} method.
+ * @param cause the cause (which is saved for later retrieval by the {@link #getCause()} method).
+ * (A null value is permitted, and indicates that the cause is nonexistent or unknown.)
+ */
+ public DubboTestException(String message, Throwable cause) {
+ super(message, cause);
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Config.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Config.java
new file mode 100644
index 0000000..0cda9b5
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Config.java
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter;
+
+/**
+ * Define the config to obtain the
+ */
+public interface Config {
+
+ /**
+ * Returns the default connection address in single registry center.
+ */
+ default String getConnectionAddress(){
+ return getConnectionAddress1();
+ }
+
+ /**
+ * Returns the first connection address in multiple registry center.
+ */
+ String getConnectionAddress1();
+
+ /**
+ * Returns the second connection address in multiple registry center.
+ */
+ String getConnectionAddress2();
+
+ /**
+ * Returns the default connection address key in single registry center.
+ * <h3>How to use</h3>
+ * <pre>
+ * System.getProperty({@link #getConnectionAddressKey()})
+ * </pre>
+ */
+ String getConnectionAddressKey();
+
+ /**
+ * Returns the first connection address key in multiple registry center.
+ * <h3>How to use</h3>
+ * <pre>
+ * System.getProperty({@link #getConnectionAddressKey1()})
+ * </pre>
+ */
+ String getConnectionAddressKey1();
+
+ /**
+ * Returns the second connection address key in multiple registry center.
+ * <h3>How to use</h3>
+ * <pre>
+ * System.getProperty({@link #getConnectionAddressKey2()})
+ * </pre>
+ */
+ String getConnectionAddressKey2();
+}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/IntegrationTest.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Context.java
similarity index 80%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/IntegrationTest.java
rename to dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Context.java
index 37ba809..76b15fc 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/IntegrationTest.java
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Context.java
@@ -14,15 +14,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration;
+package org.apache.dubbo.test.check.registrycenter;
/**
- * The interface for integration testcases.
+ * The global context to store all initialized variables.
*/
-public interface IntegrationTest {
-
- /**
- * Run the integration testcases.
- */
- void integrate();
+public interface Context {
}
diff --git a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/ZookeeperSingleRegistryCenter.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/GlobalRegistryCenter.java
similarity index 52%
rename from dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/ZookeeperSingleRegistryCenter.java
rename to dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/GlobalRegistryCenter.java
index 9f0e010..9fadc1e 100644
--- a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/ZookeeperSingleRegistryCenter.java
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/GlobalRegistryCenter.java
@@ -14,31 +14,42 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.test.common.registrycenter;
+package org.apache.dubbo.test.check.registrycenter;
/**
- * The default zookeeper single registry center.
+ * The global registry center.
*/
-public class ZookeeperSingleRegistryCenter extends ZookeeperRegistryCenter {
+public class GlobalRegistryCenter {
/**
- * Initialize {@link ZookeeperSingleRegistryCenter} instance.
+ * The default static registry center instance.
*/
- public ZookeeperSingleRegistryCenter() {
- this(DEFAULT_PORT);
+ private static final RegistryCenter INSTANCE = new ZookeeperRegistryCenter();
+
+ /**
+ * Start the registry center.
+ *
+ * @throws Exception when an exception occurred
+ */
+ public static void startup() throws Exception {
+ INSTANCE.startup();
}
/**
- * Initialize {@link RegistryCenter} instance.
+ * Reset the registry center.
*
- * @param port the zookeeper server's port.
+ * @throws Exception when an exception occurred
*/
- public ZookeeperSingleRegistryCenter(int port) {
- super(port);
+ public static void reset() throws Exception {
+ INSTANCE.reset();
}
/**
- * The zookeeper server's default port.
+ * Stop the registry center.
+ *
+ * @throws Exception when an exception occurred
*/
- private static final int DEFAULT_PORT = 2181;
+ public static void shutdown() throws Exception {
+ INSTANCE.shutdown();
+ }
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataService.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Initializer.java
similarity index 64%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataService.java
rename to dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Initializer.java
index 5cd33e3..7315565 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataService.java
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Initializer.java
@@ -14,15 +14,19 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportmetadata;
+package org.apache.dubbo.test.check.registrycenter;
+
+import org.apache.dubbo.test.check.exception.DubboTestException;
/**
- * This interface is used to check if the exported metadata service works well or not in multiple registry center.
+ * The purpose of this class is to do initialization when we build {@link RegistryCenter}.
*/
-public interface MultipleRegistryCenterExportMetadataService {
+public interface Initializer {
/**
- * The simple method for testing.
+ * Initialize the global context.
+ * @param context the global context to be initialized.
+ * @throws DubboTestException when any exception occurred.
*/
- String hello(String name);
+ void initialize(Context context) throws DubboTestException;
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceImpl.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Processor.java
similarity index 62%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceImpl.java
rename to dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Processor.java
index 9836d74..3df6c6a 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/multiple/exportmetadata/MultipleRegistryCenterExportMetadataServiceImpl.java
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/Processor.java
@@ -14,18 +14,20 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.integration.multiple.exportmetadata;
+package org.apache.dubbo.test.check.registrycenter;
+
+import org.apache.dubbo.test.check.exception.DubboTestException;
/**
- * The simple implementation for {@link MultipleRegistryCenterExportMetadataService}
+ * Define the processor to execute {@link Process} with the {@link org.apache.dubbo.test.check.registrycenter.Initializer.Context}
*/
-public class MultipleRegistryCenterExportMetadataServiceImpl implements MultipleRegistryCenterExportMetadataService {
+public interface Processor {
/**
- * {@inheritDoc}
+ * Process the command with the global context.
+ *
+ * @param context the global context.
+ * @throws DubboTestException when any exception occurred.
*/
- @Override
- public String hello(String name) {
- return "Hello " + name;
- }
+ void process(Context context) throws DubboTestException;
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/ZookeeperSingleRegistryCenter.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/RegistryCenter.java
similarity index 58%
rename from dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/ZookeeperSingleRegistryCenter.java
rename to dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/RegistryCenter.java
index 04e8f85..e28f65e 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/registrycenter/ZookeeperSingleRegistryCenter.java
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/RegistryCenter.java
@@ -14,31 +14,32 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registrycenter;
+package org.apache.dubbo.test.check.registrycenter;
+
+import org.apache.dubbo.test.check.exception.DubboTestException;
/**
- * The default zookeeper single registry center.
+ * The registry center.
*/
-public class ZookeeperSingleRegistryCenter extends ZookeeperRegistryCenter {
+public interface RegistryCenter {
/**
- * Initialize {@link ZookeeperSingleRegistryCenter} instance.
+ * Start the registry center.
+ *
+ * @throws DubboTestException when an exception occurred
*/
- public ZookeeperSingleRegistryCenter() {
- this(DEFAULT_PORT);
- }
+ void startup() throws DubboTestException;
/**
- * Initialize {@link RegistryCenter} instance.
- *
- * @param port the zookeeper server's port.
+ * Reset the registry center after ut exited.
+ * @throws DubboTestException when an exception occurred
*/
- public ZookeeperSingleRegistryCenter(int port) {
- super(port);
- }
+ void reset() throws DubboTestException;
/**
- * The zookeeper server's default port.
+ * Stop the registry center.
+ *
+ * @throws DubboTestException when an exception occurred
*/
- private static final int DEFAULT_PORT = 2181;
+ void shutdown() throws DubboTestException;
}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/ZookeeperRegistryCenter.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/ZookeeperRegistryCenter.java
new file mode 100644
index 0000000..144b7d3
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/ZookeeperRegistryCenter.java
@@ -0,0 +1,186 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter;
+
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperContext;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperWindowsContext;
+import org.apache.dubbo.test.check.registrycenter.initializer.ConfigZookeeperInitializer;
+import org.apache.dubbo.test.check.registrycenter.initializer.DownloadZookeeperInitializer;
+import org.apache.dubbo.test.check.registrycenter.initializer.UnpackZookeeperInitializer;
+import org.apache.dubbo.test.check.registrycenter.initializer.ZookeeperInitializer;
+import org.apache.dubbo.test.check.registrycenter.processor.StartZookeeperUnixProcessor;
+import org.apache.dubbo.test.check.registrycenter.processor.StartZookeeperWindowsProcessor;
+import org.apache.dubbo.test.check.registrycenter.processor.ResetZookeeperProcessor;
+import org.apache.dubbo.test.check.registrycenter.processor.StopZookeeperUnixProcessor;
+import org.apache.dubbo.test.check.registrycenter.processor.StopZookeeperWindowsProcessor;
+
+import java.util.List;
+import java.util.ArrayList;
+import java.util.Objects;
+import java.util.Map;
+import java.util.HashMap;
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * Build the registry center with embedded zookeeper, which is run by a new process.
+ */
+class ZookeeperRegistryCenter implements RegistryCenter {
+
+ public ZookeeperRegistryCenter() {
+ this.initializers = new ArrayList<>();
+ this.initializers.add(new DownloadZookeeperInitializer());
+ this.initializers.add(new UnpackZookeeperInitializer());
+ this.initializers.add(new ConfigZookeeperInitializer());
+ // start processor
+ this.put(OS.Unix, Command.Start, new StartZookeeperUnixProcessor());
+ this.put(OS.Windows, Command.Start, new StartZookeeperWindowsProcessor());
+
+ // reset processor
+ Processor resetProcessor = new ResetZookeeperProcessor();
+ this.put(OS.Unix, Command.Reset, resetProcessor);
+ this.put(OS.Windows, Command.Reset, resetProcessor);
+
+ // stop processor
+ this.put(OS.Unix, Command.Stop, new StopZookeeperUnixProcessor());
+ this.put(OS.Windows, Command.Stop, new StopZookeeperWindowsProcessor());
+
+ // initialize the global context
+ if (OS.Unix.equals(os)) {
+ this.context = new ZookeeperContext();
+ } else {
+ this.context = new ZookeeperWindowsContext();
+ }
+ }
+
+ /**
+ * The OS type.
+ */
+ private static OS os = getOS();
+
+ /**
+ * All of {@link ZookeeperInitializer} instances.
+ */
+ private List<Initializer> initializers;
+
+ /**
+ * The global context of zookeeper.
+ */
+ private ZookeeperContext context;
+
+ /**
+ * To store all processor instances.
+ */
+ private Map<OS, Map<Command, Processor>> processors = new HashMap<>();
+
+ /**
+ * The {@link #INITIALIZED} for flagging the {@link #startup()} method is called or not.
+ */
+ private final AtomicBoolean INITIALIZED = new AtomicBoolean(false);
+
+ /**
+ * Returns the Operating System.
+ */
+ private static OS getOS() {
+ String osName = System.getProperty("os.name").toLowerCase();
+ OS os = OS.Unix;
+ if (osName.contains("windows")) {
+ os = OS.Windows;
+ }
+ return os;
+ }
+
+ /**
+ * Store all initialized processor instances.
+ *
+ * @param os the {@link OS} type.
+ * @param command the {@link Command} to execute.
+ * @param processor the {@link Processor} to run.
+ */
+ private void put(OS os, Command command, Processor processor) {
+ Map<Command, Processor> commandProcessorMap = this.processors.get(os);
+ if (commandProcessorMap == null) {
+ commandProcessorMap = new HashMap<>();
+ this.processors.put(os, commandProcessorMap);
+ }
+ commandProcessorMap.put(command, processor);
+ }
+
+ /**
+ * Gets the {@link Processor} with the given {@link OS} type and {@link Command}.
+ *
+ * @param os the {@link OS} type.
+ * @param command the {@link Command} to execute.
+ * @return the {@link Processor} to run.
+ */
+ private Processor get(OS os, Command command) {
+ Map<Command, Processor> commandProcessorMap = this.processors.get(os);
+ Objects.requireNonNull(commandProcessorMap, "The command with the OS cannot be null");
+ Processor processor = commandProcessorMap.get(command);
+ Objects.requireNonNull(processor, "The processor cannot be null");
+ return processor;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void startup() throws DubboTestException {
+ if (!this.INITIALIZED.get()) {
+ if (!this.INITIALIZED.compareAndSet(false, true)) {
+ return;
+ }
+ for (Initializer initializer : this.initializers) {
+ initializer.initialize(this.context);
+ }
+ }
+ this.get(os, Command.Start).process(this.context);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void reset() throws DubboTestException {
+ this.get(os, Command.Reset).process(this.context);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void shutdown() throws DubboTestException {
+ this.get(os, Command.Stop).process(this.context);
+ }
+
+ /**
+ * The type of OS.
+ */
+ enum OS {
+ Windows,
+ Unix
+ }
+
+ /**
+ * The commands to support the zookeeper.
+ */
+ enum Command {
+ Start,
+ Reset,
+ Stop
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/config/ZookeeperConfig.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/config/ZookeeperConfig.java
new file mode 100644
index 0000000..9b601ae
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/config/ZookeeperConfig.java
@@ -0,0 +1,175 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.config;
+
+import org.apache.dubbo.test.check.registrycenter.Config;
+
+/**
+ * The zookeeper config in registry center.
+ */
+public class ZookeeperConfig implements Config {
+
+ /**
+ * The system properties config key with zookeeper port.
+ */
+ private static final String ZOOKEEPER_PORT_KEY = "zookeeper.port";
+
+ /**
+ * The system properties config key with first zookeeper port.
+ */
+ private static final String ZOOKEEPER_PORT_1_KEY = "zookeeper.port.1";
+
+ /**
+ * The system properties config key with second zookeeper port.
+ */
+ private static final String ZOOKEEPER_PORT_2_KEY = "zookeeper.port.2";
+
+ /**
+ * The system properties config key with zookeeper connection address.
+ */
+ private static final String ZOOKEEPER_CONNECTION_ADDRESS_KEY = "zookeeper.connection.address";
+
+ /**
+ * The system properties config key with first zookeeper connection address.
+ */
+ private static final String ZOOKEEPER_CONNECTION_ADDRESS_1_KEY = "zookeeper.connection.address.1";
+
+ /**
+ * The system properties config key with second zookeeper connection address.
+ */
+ private static final String ZOOKEEPER_CONNECTION_ADDRESS_2_KEY = "zookeeper.connection.address.2";
+
+ /**
+ * The default first client port of zookeeper.
+ */
+ public static final int DEFAULT_CLIENT_PORT_1 = 2181;
+
+ /**
+ * The default second client port of zookeeper.
+ */
+ public static final int DEFAULT_CLIENT_PORT_2 = 2182;
+
+ /**
+ * The default client ports of zookeeper.
+ */
+ private static final int[] CLIENT_PORTS = new int[2];
+
+ /**
+ * The default admin server ports of zookeeper.
+ */
+ private static final int[] DEFAULT_ADMIN_SERVER_PORTS = new int[]{8081, 8082};
+
+ /**
+ * The default version of zookeeper.
+ */
+ private static final String DEFAULT_ZOOKEEPER_VERSION = "3.6.0";
+
+ /**
+ * The format for zookeeper connection address.
+ */
+ private static final String CONNECTION_ADDRESS_FORMAT = "zookeeper://127.0.0.1:%d";
+
+ // initialize the client ports of zookeeper.
+ static {
+ // There are two client ports
+
+ // The priority of the one is that get it from system properties config
+ // with the key of {@link #ZOOKEEPER_PORT_1_KEY} first, and then {@link #ZOOKEEPER_PORT_KEY},
+ // finally use {@link #DEFAULT_CLIENT_PORT_1} as default port
+
+ // The priority of the other is that get it from system properties config with the key of {@link #ZOOKEEPER_PORT_2_KEY} first,
+ // and then use {@link #DEFAULT_CLIENT_PORT_2} as default port
+
+ int port1 = DEFAULT_CLIENT_PORT_1;
+ int port2 = DEFAULT_CLIENT_PORT_2;
+ String portConfig1 = System.getProperty(ZOOKEEPER_PORT_1_KEY, System.getProperty(ZOOKEEPER_PORT_KEY));
+ if (portConfig1 != null) {
+ try {
+ port1 = Integer.parseInt(portConfig1);
+ } catch (NumberFormatException e) {
+ port1 = DEFAULT_CLIENT_PORT_1;
+ }
+ }
+
+ String portConfig2 = System.getProperty(ZOOKEEPER_PORT_2_KEY);
+ if (portConfig2 != null) {
+ try {
+ port2 = Integer.parseInt(portConfig2);
+ } catch (NumberFormatException e) {
+ port2 = DEFAULT_CLIENT_PORT_2;
+ }
+ }
+
+ if (port1 == port2) {
+ throw new IllegalArgumentException(String.format("The client ports %d and %d of zookeeper cannot be same!", port1, port2));
+ }
+
+ CLIENT_PORTS[0] = port1;
+ CLIENT_PORTS[1] = port2;
+
+ // set system properties config
+ System.setProperty(ZOOKEEPER_CONNECTION_ADDRESS_KEY, String.format(CONNECTION_ADDRESS_FORMAT, CLIENT_PORTS[0]));
+ System.setProperty(ZOOKEEPER_CONNECTION_ADDRESS_1_KEY, String.format(CONNECTION_ADDRESS_FORMAT, CLIENT_PORTS[0]));
+ System.setProperty(ZOOKEEPER_CONNECTION_ADDRESS_2_KEY, String.format(CONNECTION_ADDRESS_FORMAT, CLIENT_PORTS[1]));
+ }
+
+ @Override
+ public String getConnectionAddress1() {
+ return String.format(CONNECTION_ADDRESS_FORMAT, CLIENT_PORTS[0]);
+ }
+
+ @Override
+ public String getConnectionAddress2() {
+ return String.format(CONNECTION_ADDRESS_FORMAT, CLIENT_PORTS[1]);
+ }
+
+ @Override
+ public String getConnectionAddressKey() {
+ return ZOOKEEPER_CONNECTION_ADDRESS_KEY;
+ }
+
+ @Override
+ public String getConnectionAddressKey1() {
+ return ZOOKEEPER_CONNECTION_ADDRESS_1_KEY;
+ }
+
+ @Override
+ public String getConnectionAddressKey2() {
+ return ZOOKEEPER_CONNECTION_ADDRESS_2_KEY;
+ }
+
+ /**
+ * Returns the zookeeper's version.
+ */
+ public String getVersion() {
+ return DEFAULT_ZOOKEEPER_VERSION;
+ }
+
+ /**
+ * Returns the client ports of zookeeper.
+ */
+ public int[] getClientPorts() {
+ return CLIENT_PORTS;
+ }
+
+ /**
+ * Returns the admin server ports of zookeeper.
+ */
+ public int[] getAdminServerPorts() {
+ return DEFAULT_ADMIN_SERVER_PORTS;
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/config/ZookeeperRegistryCenterConfig.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/config/ZookeeperRegistryCenterConfig.java
new file mode 100644
index 0000000..8608083
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/config/ZookeeperRegistryCenterConfig.java
@@ -0,0 +1,84 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.config;
+
+import org.apache.dubbo.test.check.registrycenter.Config;
+
+/**
+ * Define the zookeeper global config for registry center.
+ */
+public class ZookeeperRegistryCenterConfig {
+
+ /**
+ * Define the {@link Config} instance.
+ */
+ private static final Config CONFIG = new ZookeeperConfig();
+
+ /**
+ * Returns the connection address in single registry center.
+ */
+ public static String getConnectionAddress() {
+ return CONFIG.getConnectionAddress();
+ }
+
+ /**
+ * Returns the first connection address in multiple registry centers.
+ */
+ public static String getConnectionAddress1() {
+ return CONFIG.getConnectionAddress1();
+ }
+
+ /**
+ * Returns the second connection address in multiple registry centers.
+ */
+ public static String getConnectionAddress2() {
+ return CONFIG.getConnectionAddress2();
+ }
+
+ /**
+ * Returns the default connection address key in single registry center.
+ * <h3>How to use</h3>
+ * <pre>
+ * System.getProperty({@link ZookeeperRegistryCenterConfig#getConnectionAddressKey()})
+ * </pre>
+ */
+ public static String getConnectionAddressKey() {
+ return CONFIG.getConnectionAddressKey();
+ }
+
+ /**
+ * Returns the first connection address key in multiple registry center.
+ * <h3>How to use</h3>
+ * <pre>
+ * System.getProperty({@link ZookeeperRegistryCenterConfig#getConnectionAddressKey1()})
+ * </pre>
+ */
+ public static String getConnectionAddressKey1() {
+ return CONFIG.getConnectionAddressKey1();
+ }
+
+ /**
+ * Returns the second connection address key in multiple registry center.
+ * <h3>How to use</h3>
+ * <pre>
+ * System.getProperty({@link ZookeeperRegistryCenterConfig#getConnectionAddressKey2()})
+ * </pre>
+ */
+ public static String getConnectionAddressKey2() {
+ return CONFIG.getConnectionAddressKey2();
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/context/ZookeeperContext.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/context/ZookeeperContext.java
new file mode 100644
index 0000000..9fd6ab5
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/context/ZookeeperContext.java
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.context;
+
+import org.apache.dubbo.test.check.registrycenter.Context;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperConfig;
+
+import java.nio.file.Path;
+
+/**
+ * The global context for zookeeper.
+ */
+public class ZookeeperContext implements Context {
+
+ /**
+ * The config of zookeeper.
+ */
+ private ZookeeperConfig config = new ZookeeperConfig();
+
+ /**
+ * The the source file path of downloaded zookeeper binary archive.
+ */
+ private Path sourceFile;
+
+ /**
+ * Sets the source file path of downloaded zookeeper binary archive.
+ */
+ public void setSourceFile(Path sourceFile) {
+ this.sourceFile = sourceFile;
+ }
+
+ /**
+ * Returns the source file path of downloaded zookeeper binary archive.
+ */
+ public Path getSourceFile() {
+ return this.sourceFile;
+ }
+
+ /**
+ * Returns the zookeeper's version.
+ */
+ public String getVersion() {
+ return config.getVersion();
+ }
+
+ /**
+ * Returns the client ports of zookeeper.
+ */
+ public int[] getClientPorts() {
+ return config.getClientPorts();
+ }
+
+ /**
+ * Returns the admin server ports of zookeeper.
+ */
+ public int[] getAdminServerPorts() {
+ return config.getAdminServerPorts();
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/context/ZookeeperWindowsContext.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/context/ZookeeperWindowsContext.java
new file mode 100644
index 0000000..ffbe0a8
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/context/ZookeeperWindowsContext.java
@@ -0,0 +1,110 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.context;
+
+import org.apache.commons.exec.ExecuteWatchdog;
+import org.apache.dubbo.common.threadlocal.NamedInternalThreadFactory;
+
+import java.util.HashMap;
+import java.util.Map;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.SynchronousQueue;
+import java.util.concurrent.ThreadPoolExecutor;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * The global context for zookeeper on Windows OS.
+ */
+public class ZookeeperWindowsContext extends ZookeeperContext {
+
+ /**
+ * The default executor service to manage the lifecycle of zookeeper.
+ */
+ private final ExecutorService DEFAULT_EXECUTOR_SERVICE = new ThreadPoolExecutor(2, 2, 0, TimeUnit.MILLISECONDS,
+ new SynchronousQueue<>(),
+ new NamedInternalThreadFactory("mocked-zookeeper", true), new ThreadPoolExecutor.AbortPolicy());
+
+ /**
+ * Define the default {@link ExecuteWatchdog} for terminating all registered zookeeper processes.
+ */
+ private final ExecuteWatchdog WATCHDOG = new ExecuteWatchdog(ExecuteWatchdog.INFINITE_TIMEOUT);
+
+ /**
+ * The map to store the pair of clientPort and PID.
+ */
+ private Map<Integer, Integer> processIds = new HashMap<>();
+
+ /**
+ * Register the process id of zookeeper.
+ *
+ * @param clientPort the client port of zookeeper.
+ * @param pid the process id of zookeeper instance.
+ */
+ public void register(int clientPort, int pid) {
+ this.processIds.put(clientPort, pid);
+ }
+
+ /**
+ * Returns the pid of zookeeper instance with the given client port.
+ *
+ * @param clientPort the client port of zookeeper instance.
+ * @return the pid of zookeeper instance.
+ */
+ public Integer getPid(int clientPort) {
+ return this.processIds.get(clientPort);
+ }
+
+ /**
+ * Remove the registered pid with the given client port.
+ * @param clientPort the client port of zookeeper instance.
+ */
+ public void removePid(int clientPort){
+ this.processIds.remove(clientPort);
+ }
+
+ /**
+ * Returns the default executor service to manage the lifecycle of zookeeper.
+ */
+ public ExecutorService getExecutorService() {
+ return DEFAULT_EXECUTOR_SERVICE;
+ }
+
+ /**
+ * Returns the {@link ExecuteWatchdog}.
+ */
+ public ExecuteWatchdog getWatchdog() {
+ return WATCHDOG;
+ }
+
+ /**
+ * Destroy all registered resources.
+ */
+ public void destroy() {
+ this.processIds.clear();
+ this.WATCHDOG.destroyProcess();
+ try {
+ DEFAULT_EXECUTOR_SERVICE.shutdownNow();
+ } catch (SecurityException | NullPointerException ex) {
+ return;
+ }
+ try {
+ DEFAULT_EXECUTOR_SERVICE.awaitTermination(5, TimeUnit.SECONDS);
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ }
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/ConfigZookeeperInitializer.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/ConfigZookeeperInitializer.java
new file mode 100644
index 0000000..6ca7806
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/ConfigZookeeperInitializer.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.initializer;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperContext;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Properties;
+
+/**
+ * Update the config file of zookeeper.
+ */
+public class ConfigZookeeperInitializer extends ZookeeperInitializer {
+
+ private static final Logger logger = LoggerFactory.getLogger(ConfigZookeeperInitializer.class);
+
+ /**
+ * Update the config file with the given client port and admin server port.
+ *
+ * @param clientPort the client port
+ * @param adminServerPort the admin server port
+ * @throws DubboTestException when an exception occurred
+ */
+ private void updateConfig(ZookeeperContext context, int clientPort, int adminServerPort) throws DubboTestException {
+ Path zookeeperConf = Paths.get(context.getSourceFile().getParent().toString(),
+ String.valueOf(clientPort),
+ String.format("apache-zookeeper-%s-bin", context.getVersion()),
+ "conf");
+ File zooSample = Paths.get(zookeeperConf.toString(), "zoo_sample.cfg").toFile();
+
+ Properties properties = new Properties();
+ try {
+ properties.load(new FileInputStream(zooSample));
+ properties.setProperty("clientPort", String.valueOf(clientPort));
+ properties.setProperty("admin.serverPort", String.valueOf(adminServerPort));
+ Path dataDir = Paths.get(zookeeperConf.getParent().toString(), "data");
+ if (!Files.exists(dataDir)) {
+ try {
+ logger.info("It is creating the data directory...");
+ Files.createDirectories(dataDir);
+ } catch (IOException e) {
+ throw new RuntimeException(String.format("Failed to create the data directory to save zookeeper binary file, file path:%s", context.getSourceFile()), e);
+ }
+ }
+ properties.setProperty("dataDir", dataDir.toString());
+ FileOutputStream oFile = null;
+ try {
+ oFile = new FileOutputStream(Paths.get(zookeeperConf.toString(), "zoo.cfg").toFile());
+ properties.store(oFile, "");
+ } finally {
+ try {
+ oFile.close();
+ } catch (IOException e) {
+ throw new DubboTestException("Failed to close file", e);
+ }
+ }
+ } catch (IOException e) {
+ throw new DubboTestException(String.format("Failed to update %s file", zooSample.toString()), e);
+ }
+
+ File log4j = Paths.get(zookeeperConf.toString(), "log4j.properties").toFile();
+ try {
+ properties.load(new FileInputStream(log4j));
+ Path logDir = Paths.get(zookeeperConf.getParent().toString(), "logs");
+ if (!Files.exists(logDir)) {
+ try {
+ logger.info("It is creating the log directory...");
+ Files.createDirectories(logDir);
+ } catch (IOException e) {
+ throw new RuntimeException(String.format("Failed to create the log directory to save zookeeper binary file, file path:%s", context.getSourceFile()), e);
+ }
+ }
+ properties.setProperty("zookeeper.log.dir", logDir.toString());
+ FileOutputStream oFile = null;
+ try {
+ oFile = new FileOutputStream(Paths.get(zookeeperConf.toString(), "log4j.properties").toFile());
+ properties.store(oFile, "");
+ } finally {
+ try {
+ oFile.close();
+ } catch (IOException e) {
+ throw new DubboTestException("Failed to close file", e);
+ }
+ }
+ } catch (IOException e) {
+ throw new DubboTestException(String.format("Failed to update %s file", zooSample.toString()), e);
+ }
+ }
+
+ @Override
+ protected void doInitialize(ZookeeperContext context) throws DubboTestException {
+ for (int i = 0; i < context.getClientPorts().length; i++) {
+ this.updateConfig(context, context.getClientPorts()[i], context.getAdminServerPorts()[i]);
+ }
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/DownloadZookeeperInitializer.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/DownloadZookeeperInitializer.java
new file mode 100644
index 0000000..653c23a
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/DownloadZookeeperInitializer.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.initializer;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperContext;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
+
+/**
+ * Download zookeeper binary archive.
+ */
+public class DownloadZookeeperInitializer extends ZookeeperInitializer {
+
+ private static final Logger logger = LoggerFactory.getLogger(DownloadZookeeperInitializer.class);
+
+ /**
+ * The zookeeper binary file name format.
+ */
+ private static final String ZOOKEEPER_FILE_NAME_FORMAT = "apache-zookeeper-%s-bin.tar.gz";
+
+ /**
+ * The url format for zookeeper binary file.
+ */
+ private static final String ZOOKEEPER_BINARY_URL_FORMAT = "https://archive.apache.org/dist/zookeeper/zookeeper-%s/" + ZOOKEEPER_FILE_NAME_FORMAT;
+
+ /**
+ * The temporary directory name
+ */
+ private static final String TEMPORARY_DIRECTORY_NAME = "dubbo-mocked-zookeeper";
+
+ @Override
+ protected void doInitialize(ZookeeperContext context) throws DubboTestException {
+ String zookeeperFileName = String.format(ZOOKEEPER_FILE_NAME_FORMAT, context.getVersion());
+ try {
+ context.setSourceFile(Paths.get(Files.createTempDirectory("").getParent().toString(),
+ TEMPORARY_DIRECTORY_NAME,
+ zookeeperFileName));
+ } catch (IOException e) {
+ throw new RuntimeException(String.format("Cannot create the temporary directory, related directory:%s/%s",
+ TEMPORARY_DIRECTORY_NAME, zookeeperFileName), e);
+ }
+ // check if the zookeeper binary file exists
+ if (context.getSourceFile() != null && context.getSourceFile().toFile().isFile()) {
+ return;
+ }
+ // create the temporary directory path.
+ if (!Files.exists(context.getSourceFile())) {
+ try {
+ Files.createDirectories(context.getSourceFile());
+ } catch (IOException e) {
+ throw new RuntimeException(String.format("Failed to create the temporary directory to save zookeeper binary file, file path:%s", context.getSourceFile()), e);
+ }
+ }
+ // download zookeeper binary file
+ String zookeeperBinaryUrl = String.format(ZOOKEEPER_BINARY_URL_FORMAT, context.getVersion(), context.getVersion());
+ try {
+ logger.info("It is beginning to download the zookeeper binary archive, it will take several minutes...");
+ URL zookeeperBinaryURL = new URL(zookeeperBinaryUrl);
+ InputStream inputStream = zookeeperBinaryURL.openStream();
+ Files.copy(inputStream, context.getSourceFile(), StandardCopyOption.REPLACE_EXISTING);
+ } catch (Exception e) {
+ throw new RuntimeException(String.format("Download zookeeper binary archive failed, download url:%s, file path:%s",
+ zookeeperBinaryUrl, context.getSourceFile()), e);
+ }
+ // check if the zookeeper binary file exists again.
+ if (context.getSourceFile() == null || !context.getSourceFile().toFile().isFile()) {
+ throw new IllegalArgumentException(String.format("The zookeeper binary archive file doesn't exist, file path:%s", context.getSourceFile()));
+ }
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/UnpackZookeeperInitializer.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/UnpackZookeeperInitializer.java
new file mode 100644
index 0000000..622cf9a
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/UnpackZookeeperInitializer.java
@@ -0,0 +1,97 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.initializer;
+
+import org.apache.commons.compress.archivers.tar.TarArchiveEntry;
+import org.apache.commons.compress.archivers.tar.TarArchiveInputStream;
+import org.apache.commons.compress.compressors.gzip.GzipCompressorInputStream;
+import org.apache.commons.compress.utils.IOUtils;
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperContext;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+
+/**
+ * Unpack the downloaded zookeeper binary archive.
+ */
+public class UnpackZookeeperInitializer extends ZookeeperInitializer {
+
+ private static final Logger logger = LoggerFactory.getLogger(UnpackZookeeperInitializer.class);
+
+ /**
+ * Unpack the zookeeper binary file.
+ *
+ * @param context the global context of zookeeper.
+ * @param clientPort the client port
+ * @throws DubboTestException when an exception occurred
+ */
+ private void unpack(ZookeeperContext context, int clientPort) throws DubboTestException {
+ File sourceFile = context.getSourceFile().toFile();
+ Path targetPath = Paths.get(context.getSourceFile().getParent().toString(),
+ String.valueOf(clientPort));
+ // check if it's unpacked.
+ if (targetPath.toFile() != null && targetPath.toFile().isDirectory()) {
+ logger.info(String.format("The file has been unpacked, target path:%s", targetPath.toString()));
+ return;
+ }
+ try (FileInputStream fileInputStream = new FileInputStream(sourceFile);
+ GzipCompressorInputStream gzipCompressorInputStream = new GzipCompressorInputStream(fileInputStream);
+ TarArchiveInputStream tarArchiveInputStream = new TarArchiveInputStream(gzipCompressorInputStream, "UTF-8")) {
+ File targetFile = targetPath.toFile();
+ TarArchiveEntry entry;
+ while ((entry = tarArchiveInputStream.getNextTarEntry()) != null) {
+ if (entry.isDirectory()) {
+ continue;
+ }
+ File curFile = new File(targetFile, entry.getName());
+ File parent = curFile.getParentFile();
+ if (!parent.exists()) {
+ parent.mkdirs();
+ }
+ try (FileOutputStream outputStream = new FileOutputStream(curFile)) {
+ IOUtils.copy(tarArchiveInputStream, outputStream);
+ }
+ }
+ } catch (IOException e) {
+ throw new DubboTestException(String.format("Failed to unpack the zookeeper binary file"), e);
+ }
+ }
+
+ @Override
+ protected void doInitialize(ZookeeperContext context) throws DubboTestException {
+ for (int clientPort : context.getClientPorts()) {
+ this.unpack(context, clientPort);
+ // update file permission
+ Path zookeeperBin = Paths.get(context.getSourceFile().getParent().toString(),
+ String.valueOf(clientPort),
+ String.format("apache-zookeeper-%s-bin", context.getVersion()),
+ "bin");
+ for (File file : zookeeperBin.toFile().listFiles()) {
+ file.setExecutable(true, false);
+ file.setReadable(true, false);
+ file.setWritable(false, false);
+ }
+ }
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/ZookeeperInitializer.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/ZookeeperInitializer.java
new file mode 100644
index 0000000..c67fc8f
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/initializer/ZookeeperInitializer.java
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.initializer;
+
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.Context;
+import org.apache.dubbo.test.check.registrycenter.Initializer;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperContext;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+/**
+ * The implementation of {@link Initializer} to initialize zookeeper.
+ */
+public abstract class ZookeeperInitializer implements Initializer {
+
+ /**
+ * The {@link #INITIALIZED} for checking the {@link #initialize(Context)} method is called or not.
+ */
+ private final AtomicBoolean INITIALIZED = new AtomicBoolean(false);
+
+ @Override
+ public void initialize(Context context) throws DubboTestException {
+ if (!this.INITIALIZED.compareAndSet(false, true)) {
+ return;
+ }
+ this.doInitialize((ZookeeperContext) context);
+ }
+
+ /**
+ * Initialize the global context for zookeeper.
+ *
+ * @param context the global context for zookeeper.
+ * @throws DubboTestException when any exception occurred.
+ */
+ protected abstract void doInitialize(ZookeeperContext context) throws DubboTestException;
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/FindPidWindowsProcessor.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/FindPidWindowsProcessor.java
new file mode 100644
index 0000000..a6200dd
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/FindPidWindowsProcessor.java
@@ -0,0 +1,119 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.processor;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.utils.StringUtils;
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperWindowsContext;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+
+/**
+ * Create a {@link org.apache.dubbo.test.check.registrycenter.Processor} to find pid on Windows OS.
+ */
+public class FindPidWindowsProcessor extends ZookeeperWindowsProcessor {
+
+ private static final Logger logger = LoggerFactory.getLogger(FindPidWindowsProcessor.class);
+
+ @Override
+ protected void doProcess(ZookeeperWindowsContext context) throws DubboTestException {
+ for (int clientPort : context.getClientPorts()) {
+ this.findPid(context, clientPort);
+ }
+ }
+
+ /**
+ * Find the pid of zookeeper instance.
+ *
+ * @param context the global context.
+ * @param clientPort the client port of zookeeper instance.
+ */
+ private void findPid(ZookeeperWindowsContext context, int clientPort) {
+ logger.info(String.format("Find the pid of the zookeeper with port %d", clientPort));
+ Executor executor = new DefaultExecutor();
+ executor.setExitValues(null);
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ByteArrayOutputStream ins = new ByteArrayOutputStream();
+ ByteArrayInputStream in = new ByteArrayInputStream(ins.toByteArray());
+ executor.setStreamHandler(new PumpStreamHandler(out, null, in));
+ CommandLine cmdLine = new CommandLine("cmd.exe");
+ cmdLine.addArgument("/c");
+ cmdLine.addArgument("netstat -ano | findstr " + clientPort);
+ try {
+ executor.execute(cmdLine);
+ String result = out.toString();
+ logger.info(String.format("Find result: %s", result));
+ if (StringUtils.isNotEmpty(result)) {
+ String[] values = result.split("\\r\\n");
+ // values sample:
+ // Protocol Local address Foreign address Status PID
+ // TCP 127.0.0.1:2182 127.0.0.1:56672 ESTABLISHED 4020
+ // TCP 127.0.0.1:56672 127.0.0.1:2182 ESTABLISHED 1980
+ // TCP 127.0.0.1:56692 127.0.0.1:2182 ESTABLISHED 1980
+ // TCP 127.0.0.1:56723 127.0.0.1:2182 ESTABLISHED 1980
+ // TCP [::]:2182 [::]:0 LISTENING 4020
+ if (values != null && values.length > 0) {
+ for (int i = 0; i < values.length; i++) {
+ List<String> segments = Arrays.stream(values[i].trim().split(" "))
+ .filter(str -> !"".equals(str))
+ .collect(Collectors.toList());
+ // segments sample:
+ // TCP
+ // 127.0.0.1:2182
+ // 127.0.0.1:56672
+ // ESTABLISHED
+ // 4020
+ if (segments != null && segments.size() == 5) {
+ if (this.check(segments.get(1), clientPort)) {
+ int pid = Integer.valueOf(segments.get(segments.size() - 1).trim());
+ context.register(clientPort, pid);
+ return;
+ }
+ }
+ }
+ }
+ }
+ } catch (IOException e) {
+ throw new DubboTestException(String.format("Failed to find the PID of zookeeper with port %d", clientPort), e);
+ }
+ }
+
+ /**
+ * Checks if segment is valid ip and port pair.
+ *
+ * @param segment the segment to check
+ * @param clientPort the client port of zookeeper instance
+ * @return {@code true} if segment is valid pair of ip and port, otherwise {@code false}
+ */
+ private boolean check(String segment, int clientPort) {
+ return ("[::]:" + clientPort).equalsIgnoreCase(segment)
+ || ("0.0.0.0:" + clientPort).equalsIgnoreCase(segment)
+ || ("127.0.0.1:" + clientPort).equalsIgnoreCase(segment);
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/KillProcessWindowsProcessor.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/KillProcessWindowsProcessor.java
new file mode 100644
index 0000000..d38d8a8
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/KillProcessWindowsProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.processor;
+
+import org.apache.commons.exec.CommandLine;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.PumpStreamHandler;
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperWindowsContext;
+
+import java.io.IOException;
+
+/**
+ * Create a {@link org.apache.dubbo.test.check.registrycenter.Processor} to kill pid on Windows OS.
+ */
+public class KillProcessWindowsProcessor extends ZookeeperWindowsProcessor {
+
+ private static final Logger logger = LoggerFactory.getLogger(KillProcessWindowsProcessor.class);
+
+ @Override
+ protected void doProcess(ZookeeperWindowsContext context) throws DubboTestException {
+ for (int clientPort : context.getClientPorts()) {
+ Integer pid = context.getPid(clientPort);
+ if (pid == null) {
+ logger.info("There is no PID of zookeeper instance with the port " + clientPort);
+ continue;
+ }
+ logger.info(String.format("Kill the pid %d of the zookeeper with port %d", pid, clientPort));
+ Executor executor = new DefaultExecutor();
+ executor.setExitValues(null);
+ executor.setStreamHandler(new PumpStreamHandler(null, null, null));
+ CommandLine cmdLine = new CommandLine("cmd.exe");
+ cmdLine.addArgument("/c");
+ cmdLine.addArgument("taskkill /PID " + pid + " -t -f");
+ try {
+ executor.execute(cmdLine);
+ // clear pid
+ context.removePid(clientPort);
+ } catch (IOException e) {
+ throw new DubboTestException(String.format("Failed to kill the pid %d of zookeeper with port %d", pid, clientPort), e);
+ }
+ }
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ResetZookeeperProcessor.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ResetZookeeperProcessor.java
new file mode 100644
index 0000000..8ce3ee0
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ResetZookeeperProcessor.java
@@ -0,0 +1,55 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.processor;
+
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.RetryNTimes;
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.Context;
+import org.apache.dubbo.test.check.registrycenter.Processor;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperContext;
+
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Create {@link Process} to reset zookeeper.
+ */
+public class ResetZookeeperProcessor implements Processor {
+
+ @Override
+ public void process(Context context) throws DubboTestException {
+ ZookeeperContext zookeeperContext = (ZookeeperContext)context;
+ for (int clientPort : zookeeperContext.getClientPorts()) {
+ CuratorFramework client;
+ try {
+ CuratorFrameworkFactory.Builder builder = CuratorFrameworkFactory.builder()
+ .connectString("127.0.0.1:" + clientPort)
+ .retryPolicy(new RetryNTimes(1, 1000));
+ client = builder.build();
+ client.start();
+ boolean connected = client.blockUntilConnected(1000, TimeUnit.MILLISECONDS);
+ if (!connected) {
+ throw new IllegalStateException("zookeeper not connected");
+ }
+ client.delete().deletingChildrenIfNeeded().forPath("/dubbo");
+ } catch (Exception e) {
+ throw new DubboTestException(e.getMessage(), e);
+ }
+ }
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StartZookeeperUnixProcessor.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StartZookeeperUnixProcessor.java
new file mode 100644
index 0000000..b2688da
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StartZookeeperUnixProcessor.java
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.processor;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperContext;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * Create {@link Process} to start zookeeper on Unix OS.
+ */
+public class StartZookeeperUnixProcessor extends ZookeeperUnixProcessor {
+
+ private static final Logger logger = LoggerFactory.getLogger(StartZookeeperUnixProcessor.class);
+
+ @Override
+ protected Process doProcess(ZookeeperContext context, int clientPort) throws DubboTestException {
+ logger.info(String.format("The zookeeper-%d is starting...", clientPort));
+ List<String> commands = new ArrayList<>();
+ Path zookeeperBin = Paths.get(context.getSourceFile().getParent().toString(),
+ String.valueOf(clientPort),
+ String.format("apache-zookeeper-%s-bin", context.getVersion()),
+ "bin");
+ commands.add(Paths.get(zookeeperBin.toString(), "zkServer.sh")
+ .toAbsolutePath().toString());
+ commands.add("start");
+ commands.add(Paths.get(zookeeperBin.getParent().toString(),
+ "conf",
+ "zoo.cfg").toAbsolutePath().toString());
+ try {
+ return new ProcessBuilder().directory(zookeeperBin.getParent().toFile())
+ .command(commands).inheritIO().redirectOutput(ProcessBuilder.Redirect.PIPE).start();
+ } catch (IOException e) {
+ throw new DubboTestException(String.format("Failed to start zookeeper-%d", clientPort), e);
+ }
+ }
+
+ @Override
+ protected Pattern getPattern() {
+ return Pattern.compile(".*STARTED.*");
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StartZookeeperWindowsProcessor.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StartZookeeperWindowsProcessor.java
new file mode 100644
index 0000000..673d6fc
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StartZookeeperWindowsProcessor.java
@@ -0,0 +1,81 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.processor;
+
+import org.apache.commons.exec.Executor;
+import org.apache.commons.exec.DefaultExecutor;
+import org.apache.commons.exec.CommandLine;
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.Processor;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperWindowsContext;
+
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Create {@link Process} to start zookeeper on Windows OS.
+ */
+public class StartZookeeperWindowsProcessor extends ZookeeperWindowsProcessor {
+
+ private static final Logger logger = LoggerFactory.getLogger(StartZookeeperWindowsProcessor.class);
+
+ /**
+ * The {@link Processor} to find the pid of zookeeper instance.
+ */
+ private final Processor findPidProcessor = new FindPidWindowsProcessor();
+
+ /**
+ * The {@link Processor} to kill the pid of zookeeper instance.
+ */
+ private final Processor killPidProcessor = new KillProcessWindowsProcessor();
+
+ @Override
+ protected void doProcess(ZookeeperWindowsContext context) throws DubboTestException {
+ // find pid and save into global context.
+ this.findPidProcessor.process(context);
+ // kill pid of zookeeper instance if exists
+ this.killPidProcessor.process(context);
+ for (int clientPort : context.getClientPorts()) {
+ logger.info(String.format("The zookeeper-%d is starting...", clientPort));
+ Path zookeeperBin = Paths.get(context.getSourceFile().getParent().toString(),
+ String.valueOf(clientPort),
+ String.format("apache-zookeeper-%s-bin", context.getVersion()),
+ "bin");
+ Executor executor = new DefaultExecutor();
+ executor.setExitValues(null);
+ executor.setWatchdog(context.getWatchdog());
+ CommandLine cmdLine = new CommandLine("cmd.exe");
+ cmdLine.addArgument("/c");
+ cmdLine.addArgument(Paths.get(zookeeperBin.toString(), "zkServer.cmd")
+ .toAbsolutePath().toString());
+ context.getExecutorService().submit(() -> executor.execute(cmdLine));
+ }
+ try {
+ // TODO: Help me to optimize the ugly sleep.
+ // sleep to wait all of zookeeper instances are started successfully.
+ // The best way is to check the output log with the specified keywords,
+ // however, there maybe keep waiting for check when any exception occurred,
+ // because the output stream will be blocked to wait for continuous data without any break
+ TimeUnit.SECONDS.sleep(3);
+ } catch (InterruptedException e) {
+ // ignored
+ }
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StopZookeeperUnixProcessor.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StopZookeeperUnixProcessor.java
new file mode 100644
index 0000000..7748d02
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StopZookeeperUnixProcessor.java
@@ -0,0 +1,61 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.processor;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperContext;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.regex.Pattern;
+
+/**
+ * Create {@link Process} to stop zookeeper on Unix OS.
+ */
+public class StopZookeeperUnixProcessor extends ZookeeperUnixProcessor {
+
+ private static final Logger logger = LoggerFactory.getLogger(StopZookeeperUnixProcessor.class);
+
+ @Override
+ protected Process doProcess(ZookeeperContext context, int clientPort) throws DubboTestException {
+ logger.info(String.format("The zookeeper-%d is stopping...", clientPort));
+ List<String> commands = new ArrayList<>();
+ Path zookeeperBin = Paths.get(context.getSourceFile().getParent().toString(),
+ String.valueOf(clientPort),
+ String.format("apache-zookeeper-%s-bin", context.getVersion()),
+ "bin");
+ commands.add(Paths.get(zookeeperBin.toString(), "zkServer.sh")
+ .toAbsolutePath().toString());
+ commands.add("stop");
+ try {
+ return new ProcessBuilder().directory(zookeeperBin.getParent().toFile())
+ .command(commands).inheritIO().redirectOutput(ProcessBuilder.Redirect.PIPE).start();
+ } catch (IOException e) {
+ throw new DubboTestException(String.format("Failed to stop zookeeper-%d", clientPort), e);
+ }
+ }
+
+ @Override
+ protected Pattern getPattern() {
+ return Pattern.compile(".*STOPPED.*");
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StopZookeeperWindowsProcessor.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StopZookeeperWindowsProcessor.java
new file mode 100644
index 0000000..a671e68
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/StopZookeeperWindowsProcessor.java
@@ -0,0 +1,52 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.processor;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.Processor;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperWindowsContext;
+
+/**
+ * Create {@link Process} to stop zookeeper on Windows OS.
+ */
+public class StopZookeeperWindowsProcessor extends ZookeeperWindowsProcessor {
+
+ private static final Logger logger = LoggerFactory.getLogger(StopZookeeperWindowsProcessor.class);
+
+ /**
+ * The {@link Processor} to find the pid of zookeeper instance.
+ */
+ private final Processor findPidProcessor = new FindPidWindowsProcessor();
+
+ /**
+ * The {@link Processor} to kill the pid of zookeeper instance.
+ */
+ private final Processor killPidProcessor = new KillProcessWindowsProcessor();
+
+ @Override
+ protected void doProcess(ZookeeperWindowsContext context) throws DubboTestException {
+ logger.info("All of zookeeper instances are stopping...");
+ // find pid and save into global context.
+ this.findPidProcessor.process(context);
+ // kill pid of zookeeper instance if exists
+ this.killPidProcessor.process(context);
+ // destroy all resources
+ context.destroy();
+ }
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ZookeeperUnixProcessor.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ZookeeperUnixProcessor.java
new file mode 100644
index 0000000..38786db
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ZookeeperUnixProcessor.java
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.processor;
+
+import org.apache.dubbo.common.logger.Logger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.Context;
+import org.apache.dubbo.test.check.registrycenter.Processor;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperContext;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.regex.Pattern;
+
+/**
+ * The abstract implementation of {@link Processor} is to provide some common methods on Unix OS.
+ */
+public abstract class ZookeeperUnixProcessor implements Processor {
+
+ private static final Logger logger = LoggerFactory.getLogger(ZookeeperUnixProcessor.class);
+
+ @Override
+ public void process(Context context) throws DubboTestException {
+ ZookeeperContext zookeeperContext = (ZookeeperContext) context;
+ for (int clientPort : zookeeperContext.getClientPorts()) {
+ Process process = this.doProcess(zookeeperContext, clientPort);
+ this.logErrorStream(process.getErrorStream());
+ this.awaitProcessReady(process.getInputStream());
+ }
+ }
+
+ /**
+ * Prints the error log after run {@link Process}.
+ *
+ * @param errorStream the error stream.
+ */
+ private void logErrorStream(final InputStream errorStream) {
+ try (final BufferedReader reader = new BufferedReader(new InputStreamReader(errorStream))) {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ logger.error(line);
+ }
+ } catch (IOException e) {
+ /* eat quietly */
+ }
+ }
+
+ /**
+ * Wait until the server is started successfully.
+ *
+ * @param inputStream the log after run {@link Process}.
+ * @throws DubboTestException if cannot match the given pattern.
+ */
+ private void awaitProcessReady(final InputStream inputStream) throws DubboTestException {
+ final StringBuilder log = new StringBuilder();
+ try (final BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream))) {
+ String line;
+ while ((line = reader.readLine()) != null) {
+ if (this.getPattern().matcher(line).matches())
+ return;
+ log.append('\n').append(line);
+ }
+ } catch (IOException e) {
+ throw new DubboTestException("Failed to read the log after executed process.", e);
+ }
+ throw new DubboTestException("Ready pattern not found in log, log: " + log);
+ }
+
+ /**
+ * Use {@link Process} to handle the command.
+ *
+ * @param context the global zookeeper context.
+ * @param clientPort the client port of zookeeper.
+ * @return the instance of {@link Process}.
+ * @throws DubboTestException when any exception occurred.
+ */
+ protected abstract Process doProcess(ZookeeperContext context, int clientPort) throws DubboTestException;
+
+ /**
+ * Gets the pattern to check the server is ready or not.
+ */
+ protected abstract Pattern getPattern();
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ZookeeperWindowsProcessor.java b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ZookeeperWindowsProcessor.java
new file mode 100644
index 0000000..d364bd6
--- /dev/null
+++ b/dubbo-test/dubbo-test-check/src/main/java/org/apache/dubbo/test/check/registrycenter/processor/ZookeeperWindowsProcessor.java
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.dubbo.test.check.registrycenter.processor;
+
+import org.apache.dubbo.test.check.exception.DubboTestException;
+import org.apache.dubbo.test.check.registrycenter.Context;
+import org.apache.dubbo.test.check.registrycenter.Processor;
+import org.apache.dubbo.test.check.registrycenter.context.ZookeeperWindowsContext;
+/**
+ * The abstract implementation of {@link Processor} is to provide some common methods on Windows OS.
+ */
+public abstract class ZookeeperWindowsProcessor implements Processor {
+
+ @Override
+ public void process(Context context) throws DubboTestException {
+ ZookeeperWindowsContext zookeeperWindowsContext = (ZookeeperWindowsContext) context;
+ this.doProcess(zookeeperWindowsContext);
+ }
+
+ /**
+ * Use {@link Process} to handle the command.
+ *
+ * @param context the global zookeeper context.
+ * @throws DubboTestException when any exception occurred.
+ */
+ protected abstract void doProcess(ZookeeperWindowsContext context) throws DubboTestException;
+}
diff --git a/dubbo-test/dubbo-test-check/src/main/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener b/dubbo-test/dubbo-test-check/src/main/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener
index 0b6e457..1eb8e5b 100644
--- a/dubbo-test/dubbo-test-check/src/main/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener
+++ b/dubbo-test/dubbo-test-check/src/main/resources/META-INF/services/org.junit.platform.launcher.TestExecutionListener
@@ -1 +1,5 @@
+# DubboRegistryCenterStarted should be the first one because of the startup of zookeeper
+org.apache.dubbo.test.check.RegistryCenterStarted
org.apache.dubbo.test.check.DubboTestChecker
+# DubboRegistryCenterFinished should be the last one because of the shutdown of zookeeper
+org.apache.dubbo.test.check.RegistryCenterFinished
diff --git a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/EmbeddedZooKeeper.java b/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/EmbeddedZooKeeper.java
deleted file mode 100644
index c96f06f..0000000
--- a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/EmbeddedZooKeeper.java
+++ /dev/null
@@ -1,248 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.test.common;
-
-import org.apache.dubbo.common.utils.NetUtils;
-import org.apache.zookeeper.server.ServerConfig;
-import org.apache.zookeeper.server.ZooKeeperServerMain;
-import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import java.io.File;
-import java.lang.reflect.Method;
-import java.util.Properties;
-import java.util.UUID;
-
-/**
- * from: https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java
- * <p>
- * Helper class to start an embedded instance of standalone (non clustered) ZooKeeper.
- * <p>
- * NOTE: at least an external standalone server (if not an ensemble) are recommended, even for
- * {@link org.springframework.xd.dirt.server.singlenode.SingleNodeApplication}
- *
- * @author Patrick Peralta
- * @author Mark Fisher
- * @author David Turanski
- * @deprecated
- * @see org.apache.dubbo.test.common.registrycenter.ZookeeperSingleRegistryCenter
- * @see org.apache.dubbo.test.common.registrycenter.ZookeeperMultipleRegistryCenter
- */
-@Deprecated
-public class EmbeddedZooKeeper {
-
- /**
- * Logger.
- */
- private static final Logger logger = LoggerFactory.getLogger(EmbeddedZooKeeper.class);
-
- /**
- * ZooKeeper client port. This will be determined dynamically upon startup.
- */
- private final int clientPort;
-
- /**
- * Whether to auto-start. Default is true.
- */
- private boolean autoStartup = true;
-
- /**
- * Lifecycle phase. Default is 0.
- */
- private int phase = 0;
-
- /**
- * Thread for running the ZooKeeper server.
- */
- private volatile Thread zkServerThread;
-
- /**
- * ZooKeeper server.
- */
- private volatile ZooKeeperServerMain zkServer;
-
- /**
- * {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread.
- */
- private ErrorHandler errorHandler;
-
- private boolean daemon = true;
-
- /**
- * Construct an EmbeddedZooKeeper with a random port.
- */
- public EmbeddedZooKeeper() {
- // clientPort = SocketUtils.findAvailableTcpPort();
- clientPort = NetUtils.getAvailablePort();
- }
-
- /**
- * Construct an EmbeddedZooKeeper with the provided port.
- *
- * @param clientPort port for ZooKeeper server to bind to
- */
- public EmbeddedZooKeeper(int clientPort, boolean daemon) {
- this.clientPort = clientPort;
- this.daemon = daemon;
- }
-
- /**
- * Returns the port that clients should use to connect to this embedded server.
- *
- * @return dynamically determined client port
- */
- public int getClientPort() {
- return this.clientPort;
- }
-
- /**
- * Specify whether to start automatically. Default is true.
- *
- * @param autoStartup whether to start automatically
- */
- public void setAutoStartup(boolean autoStartup) {
- this.autoStartup = autoStartup;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isAutoStartup() {
- return this.autoStartup;
- }
-
- /**
- * Specify the lifecycle phase for the embedded server.
- *
- * @param phase the lifecycle phase
- */
- public void setPhase(int phase) {
- this.phase = phase;
- }
-
- /**
- * {@inheritDoc}
- */
- public int getPhase() {
- return this.phase;
- }
-
- /**
- * {@inheritDoc}
- */
- public boolean isRunning() {
- return (zkServerThread != null);
- }
-
- /**
- * Start the ZooKeeper server in a background thread.
- * <p>
- * Register an error handler via {@link #setErrorHandler} in order to handle
- * any exceptions thrown during startup or execution.
- */
- public synchronized void start() {
- if (zkServerThread == null) {
- zkServerThread = new Thread(new ServerRunnable(), "ZooKeeper Server Starter");
- zkServerThread.setDaemon(daemon);
- zkServerThread.start();
- }
- }
-
- /**
- * Shutdown the ZooKeeper server.
- */
- public synchronized void stop() {
- if (zkServerThread != null) {
- // The shutdown method is protected...thus this hack to invoke it.
- // This will log an exception on shutdown; see
- // https://issues.apache.org/jira/browse/ZOOKEEPER-1873 for details.
- try {
- Method shutdown = ZooKeeperServerMain.class.getDeclaredMethod("shutdown");
- shutdown.setAccessible(true);
- shutdown.invoke(zkServer);
- } catch (Exception e) {
- throw new RuntimeException(e);
- }
-
- // It is expected that the thread will exit after
- // the server is shutdown; this will block until
- // the shutdown is complete.
- try {
- zkServerThread.join(5000);
- zkServerThread = null;
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- logger.warn("Interrupted while waiting for embedded ZooKeeper to exit");
- // abandoning zk thread
- zkServerThread = null;
- }
- }
- }
-
- /**
- * Stop the server if running and invoke the callback when complete.
- */
- public void stop(Runnable callback) {
- stop();
- callback.run();
- }
-
- /**
- * Provide an {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread. If none
- * is provided, only error-level logging will occur.
- *
- * @param errorHandler the {@link ErrorHandler} to be invoked
- */
- public void setErrorHandler(ErrorHandler errorHandler) {
- this.errorHandler = errorHandler;
- }
-
- /**
- * Runnable implementation that starts the ZooKeeper server.
- */
- private class ServerRunnable implements Runnable {
-
- @Override
- public void run() {
- try {
- Properties properties = new Properties();
- File file = new File(System.getProperty("java.io.tmpdir")
- + File.separator + UUID.randomUUID());
- file.deleteOnExit();
- properties.setProperty("dataDir", file.getAbsolutePath());
- properties.setProperty("clientPort", String.valueOf(clientPort));
-
- QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
- quorumPeerConfig.parseProperties(properties);
-
- zkServer = new ZooKeeperServerMain();
- ServerConfig configuration = new ServerConfig();
- configuration.readFrom(quorumPeerConfig);
-
- zkServer.runFromConfig(configuration);
- } catch (Exception e) {
- if (errorHandler != null) {
- errorHandler.handleError(e);
- } else {
- logger.error("Exception running embedded ZooKeeper", e);
- }
- }
- }
- }
-
-}
diff --git a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/ZooKeeperServer.java b/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/ZooKeeperServer.java
deleted file mode 100644
index 846c2ac..0000000
--- a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/ZooKeeperServer.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.test.common;
-
-/**
- * Using this class as registry center is not very well because of time-consuming.
- * <p>The alternative is to use {@link org.apache.dubbo.test.common.registrycenter.ZookeeperSingleRegistryCenter}</p> or
- * {@link org.apache.dubbo.test.common.registrycenter.ZookeeperMultipleRegistryCenter}
- * @deprecated
- * @see org.apache.dubbo.test.common.registrycenter.ZookeeperSingleRegistryCenter
- * @see org.apache.dubbo.test.common.registrycenter.ZookeeperMultipleRegistryCenter
- */
-@Deprecated
-public class ZooKeeperServer {
-
- private static EmbeddedZooKeeper zookeeper1;
- private static EmbeddedZooKeeper zookeeper2;
-
- public static void start() {
- if (zookeeper1 == null) {
- zookeeper1 = new EmbeddedZooKeeper(2181, true);
- zookeeper1.start();
- }
- if (zookeeper2 == null) {
- zookeeper2 = new EmbeddedZooKeeper(2182, true);
- zookeeper2.start();
- }
- }
-
- public static void stop() {
- try {
- if (zookeeper1 != null) {
- zookeeper1.stop();
- }
- if (zookeeper2 != null) {
- zookeeper2.stop();
- }
- } finally {
- zookeeper1 = null;
- zookeeper2 = null;
- }
- }
-}
diff --git a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/AbstractRegistryCenter.java b/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/AbstractRegistryCenter.java
deleted file mode 100644
index cbf637a..0000000
--- a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/AbstractRegistryCenter.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.test.common.registrycenter;
-
-import org.apache.curator.test.InstanceSpec;
-
-import java.io.File;
-import java.util.HashMap;
-import java.util.Map;
-
-/**
- * The abstraction of {@link RegistryCenter} implements the basic methods.
- */
-abstract class AbstractRegistryCenter implements RegistryCenter {
-
- /**
- * The default data directory is null
- */
- private static final File DEFAULT_DATA_DIRECTORY = null;
-
- /**
- * The default election port is -1.
- */
- private static final int DEFAULT_ELECTION_PORT = -1;
-
- /**
- * The default quorum port is -1.
- */
- private static final int DEFAULT_QUORUM_PORT = -1;
-
- /**
- * The default value is true.
- */
- private static final boolean DEFAULT_DELETE_DATA_DIRECTORY_ON_CLOSE = true;
-
- /**
- * The default service id is -1.
- */
- private static final int DEFAULT_SERVER_ID = -1;
-
- /**
- * The default tick time is 5000
- */
- private static final int DEFAULT_TICK_TIME = 5 * 1000;
-
- /**
- * The default value is 60.
- */
- private static final int DEFAULT_MAX_CLIENT_CNXNS = 200;
-
- /**
- * The minimum session timeout.
- */
- private static final int DEFAULT_MINIMUM_SESSION_TIMEOUT = DEFAULT_TICK_TIME * 2;
-
- /**
- * The maximum session timeout.
- */
- private static final int DEFAULT_MAXIMUM_SESSION_TIMEOUT = 60 * 1000;
-
- /**
- * The default customer properties.
- */
- private static final Map<String, Object> DEFAULT_CUSTOM_PROPERTIES = new HashMap<>(2);
-
- /**
- * The default hostname.
- */
- private static final String DEFAULT_HOSTNAME = "127.0.0.1";
-
- static {
- DEFAULT_CUSTOM_PROPERTIES.put("minSessionTimeout", DEFAULT_MINIMUM_SESSION_TIMEOUT);
- DEFAULT_CUSTOM_PROPERTIES.put("maxSessionTimeout", DEFAULT_MAXIMUM_SESSION_TIMEOUT);
- }
-
- /**
- * Create an {@link InstanceSpec} instance to initialize {@link org.apache.curator.test.TestingServer}
- *
- * @param port the zookeeper server's port.
- */
- protected InstanceSpec createInstanceSpec(int port) {
- return new InstanceSpec(DEFAULT_DATA_DIRECTORY,
- port,
- DEFAULT_ELECTION_PORT,
- DEFAULT_QUORUM_PORT,
- DEFAULT_DELETE_DATA_DIRECTORY_ON_CLOSE,
- DEFAULT_SERVER_ID,
- DEFAULT_TICK_TIME,
- DEFAULT_MAX_CLIENT_CNXNS,
- DEFAULT_CUSTOM_PROPERTIES,
- DEFAULT_HOSTNAME);
- }
-}
diff --git a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/RegistryCenter.java b/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/RegistryCenter.java
deleted file mode 100644
index 8e9c569..0000000
--- a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/RegistryCenter.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.test.common.registrycenter;
-
-import org.apache.dubbo.rpc.RpcException;
-
-import java.util.List;
-
-/**
- * The mock registry center.
- */
-public interface RegistryCenter {
-
- /**
- * Start the registry center.
- *
- * @throws RpcException when an exception occurred
- */
- void startup() throws RpcException;
-
- /**
- * Returns the registry center instance.
- * <p>This method can be called only after {@link #startup()} is called</p>
- *
- * @throws RpcException when an exception occurred
- */
- List<Instance> getRegistryCenterInstance() throws RpcException;
-
- /**
- * Stop the registry center.
- *
- * @throws RpcException when an exception occurred
- */
- void shutdown() throws RpcException;
-
- /**
- * The registry center instance.
- */
- interface Instance {
-
- /**
- * Returns the registry center type.
- */
- String getType();
-
- /**
- * Returns the hostname of registry center.
- */
- String getHostname();
-
- /**
- * Returns the port of registry center.
- */
- int getPort();
- }
-}
diff --git a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/ZookeeperMultipleRegistryCenter.java b/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/ZookeeperMultipleRegistryCenter.java
deleted file mode 100644
index 761558a..0000000
--- a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/ZookeeperMultipleRegistryCenter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.test.common.registrycenter;
-
-/**
- * The default zookeeper multiple registry center.
- */
-public class ZookeeperMultipleRegistryCenter extends ZookeeperRegistryCenter {
-
- /**
- * Initialize {@link ZookeeperMultipleRegistryCenter} instance.
- *
- * @param port1 the zookeeper server's port.
- * @param port2 the zookeeper server's port.
- */
- public ZookeeperMultipleRegistryCenter(int port1, int port2) {
- super(port1, port2);
- }
-
- /**
- * Initialize {@link ZookeeperMultipleRegistryCenter} instance.
- */
- public ZookeeperMultipleRegistryCenter() {
- this(DEFAULT_PORT1, DEFAULT_PORT2);
- }
-
- private static final int DEFAULT_PORT1 = 2181;
- private static final int DEFAULT_PORT2 = 2182;
-}
diff --git a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/ZookeeperRegistryCenter.java b/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/ZookeeperRegistryCenter.java
deleted file mode 100644
index 4b2e3b6..0000000
--- a/dubbo-test/dubbo-test-common/src/main/java/org/apache/dubbo/test/common/registrycenter/ZookeeperRegistryCenter.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.test.common.registrycenter;
-
-import org.apache.curator.test.InstanceSpec;
-import org.apache.curator.test.TestingServer;
-import org.apache.dubbo.common.logger.Logger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.rpc.RpcException;
-
-import java.io.IOException;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-/**
- * The default implementation of registry center can support single and multiple registry center.
- * <p>Each port represents an instance. You can provide multiple ports to build multiple registry center,
- * if you want to create multiple registry center
- */
-class ZookeeperRegistryCenter extends AbstractRegistryCenter {
-
- /**
- * Initialize the default registry center.
- *
- * @param ports the registry center's ports.
- */
- public ZookeeperRegistryCenter(int... ports) {
- this.ports = ports;
- this.instanceSpecs = new ArrayList<>(this.ports.length);
- this.zookeeperServers = new ArrayList<>(this.ports.length);
- }
-
- private static final Logger logger = LoggerFactory.getLogger(ZookeeperRegistryCenter.class);
-
- /**
- * The type of the registry center.
- */
- private static final String DEFAULT_REGISTRY_CENTER_TYPE = "zookeeper";
-
- private int[] ports;
-
- private List<InstanceSpec> instanceSpecs;
-
- private List<TestingServer> zookeeperServers;
-
- private AtomicBoolean started = new AtomicBoolean(false);
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void startup() throws RpcException {
- try {
- if (started.compareAndSet(false, true)) {
- logger.info("The ZookeeperRegistryCenter is starting...");
- for (int port : this.ports) {
- InstanceSpec instanceSpec = this.createInstanceSpec(port);
- this.instanceSpecs.add(instanceSpec);
- this.zookeeperServers.add(new TestingServer(instanceSpec, true));
- }
- logger.info("The ZookeeperRegistryCenter is started successfully");
- }
- } catch (Exception exception) {
- started.set(false);
- throw new RpcException("Failed to initialize ZookeeperRegistryCenter instance", exception);
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public List<Instance> getRegistryCenterInstance() throws RpcException {
- this.startup();
- List<Instance> instances = new ArrayList<>(this.instanceSpecs.size());
- for (InstanceSpec instanceSpec : this.instanceSpecs) {
- instances.add(new Instance() {
- @Override
- public String getType() {
- return DEFAULT_REGISTRY_CENTER_TYPE;
- }
-
- @Override
- public String getHostname() {
- return instanceSpec.getHostname();
- }
-
- @Override
- public int getPort() {
- return instanceSpec.getPort();
- }
- });
- }
- return instances;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void shutdown() throws RpcException {
- logger.info("The ZookeeperRegistryCenter is stopping...");
- List<RpcException> exceptions = new ArrayList<>(this.zookeeperServers.size());
- for (TestingServer testingServer : this.zookeeperServers) {
- try {
- testingServer.close();
- logger.info(String.format("The zookeeper instance of %s is shutdown successfully",
- testingServer.getConnectString()));
- } catch (IOException exception) {
- RpcException rpcException = new RpcException(String.format("Failed to close zookeeper instance of %s",
- testingServer.getConnectString()),
- exception);
- exceptions.add(rpcException);
- logger.error(rpcException);
- }
- }
- this.instanceSpecs.clear();
- this.zookeeperServers.clear();
- if (!exceptions.isEmpty()) {
- logger.info("The ZookeeperRegistryCenter failed to close.");
- // throw any one of exceptions
- throw exceptions.get(0);
- } else {
- logger.info("The ZookeeperRegistryCenter close successfully.");
- }
- }
-}
diff --git a/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringAnnotationBeanTest.java b/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringAnnotationBeanTest.java
index 61376ce..7b3d28e 100644
--- a/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringAnnotationBeanTest.java
+++ b/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringAnnotationBeanTest.java
@@ -20,8 +20,6 @@ import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.test.common.api.DemoService;
-import org.apache.dubbo.test.common.registrycenter.RegistryCenter;
-import org.apache.dubbo.test.common.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.test.spring.context.MockSpringInitCustomizer;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
@@ -34,19 +32,14 @@ import org.springframework.context.annotation.PropertySource;
public class SpringAnnotationBeanTest {
- private static RegistryCenter registryCenter;
-
@BeforeAll
public static void beforeAll() {
- registryCenter = new ZookeeperSingleRegistryCenter();
- registryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll(){
DubboBootstrap.reset();
- registryCenter.shutdown();
}
@Test
diff --git a/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringJavaConfigBeanTest.java b/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringJavaConfigBeanTest.java
index 31239f9..8c4cce7 100644
--- a/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringJavaConfigBeanTest.java
+++ b/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringJavaConfigBeanTest.java
@@ -30,11 +30,10 @@ import org.apache.dubbo.config.spring.ReferenceBean;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.apache.dubbo.rpc.Constants;
import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.test.check.registrycenter.config.ZookeeperRegistryCenterConfig;
import org.apache.dubbo.test.common.SysProps;
import org.apache.dubbo.test.common.api.DemoService;
import org.apache.dubbo.test.common.impl.DemoServiceImpl;
-import org.apache.dubbo.test.common.registrycenter.RegistryCenter;
-import org.apache.dubbo.test.common.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.test.spring.context.MockSpringInitCustomizer;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
@@ -54,19 +53,14 @@ public class SpringJavaConfigBeanTest {
private static final String MY_PROTOCOL_ID = "myProtocol";
private static final String MY_REGISTRY_ID = "my-registry";
- private static RegistryCenter registryCenter;
-
@BeforeAll
public static void beforeAll() {
- registryCenter = new ZookeeperSingleRegistryCenter();
- registryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll(){
DubboBootstrap.reset();
- registryCenter.shutdown();
}
@BeforeEach
@@ -86,7 +80,7 @@ public class SpringJavaConfigBeanTest {
SysProps.setProperty("dubbo.application.qos-enable", "false");
SysProps.setProperty("dubbo.protocol.name", "dubbo");
SysProps.setProperty("dubbo.protocol.port", "2346");
- String registryAddress = "zookeeper://127.0.0.1:2181";
+ String registryAddress = ZookeeperRegistryCenterConfig.getConnectionAddress();
SysProps.setProperty("dubbo.registry.address", registryAddress);
SysProps.setProperty("dubbo.provider.group", "test");
diff --git a/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringXmlConfigTest.java b/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringXmlConfigTest.java
index 7d7eba1..5530de7 100644
--- a/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringXmlConfigTest.java
+++ b/dubbo-test/dubbo-test-spring/src/main/java/org/apache/dubbo/test/spring/SpringXmlConfigTest.java
@@ -21,8 +21,6 @@ import org.apache.dubbo.test.common.SysProps;
import org.apache.dubbo.test.common.api.DemoService;
import org.apache.dubbo.test.common.api.GreetingService;
import org.apache.dubbo.test.common.api.RestDemoService;
-import org.apache.dubbo.test.common.registrycenter.RegistryCenter;
-import org.apache.dubbo.test.common.registrycenter.ZookeeperSingleRegistryCenter;
import org.apache.dubbo.test.spring.context.MockSpringInitCustomizer;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.Assertions;
@@ -34,19 +32,14 @@ import static org.apache.dubbo.common.constants.CommonConstants.SHUTDOWN_WAIT_KE
public class SpringXmlConfigTest {
- private static RegistryCenter registryCenter;
-
@BeforeAll
public static void beforeAll() {
- registryCenter = new ZookeeperSingleRegistryCenter();
- registryCenter.startup();
DubboBootstrap.reset();
}
@AfterAll
public static void afterAll(){
DubboBootstrap.reset();
- registryCenter.shutdown();
}
@Test
diff --git a/dubbo-test/dubbo-test-spring/src/main/resources/demo-app.properties b/dubbo-test/dubbo-test-spring/src/main/resources/demo-app.properties
index f5bfdff..d486b16 100644
--- a/dubbo-test/dubbo-test-spring/src/main/resources/demo-app.properties
+++ b/dubbo-test/dubbo-test-spring/src/main/resources/demo-app.properties
@@ -1,11 +1,11 @@
dubbo.application.name=demo-app
-dubbo.registry.address=zookeeper://127.0.0.1:2181?registry-type=service
+dubbo.registry.address=${zookeeper.connection.address}?registry-type=service
-dubbo.config-center.address=zookeeper://127.0.0.1:2181
+dubbo.config-center.address=${zookeeper.connection.address}
-dubbo.metadata-report.address=zookeeper://127.0.0.1:2181
+dubbo.metadata-report.address=${zookeeper.connection.address}
dubbo.protocols.dubbo.port=-1
diff --git a/dubbo-test/dubbo-test-spring/src/main/resources/spring/dubbo-demo.xml b/dubbo-test/dubbo-test-spring/src/main/resources/spring/dubbo-demo.xml
index 05392da..e44a953 100644
--- a/dubbo-test/dubbo-test-spring/src/main/resources/spring/dubbo-demo.xml
+++ b/dubbo-test/dubbo-test-spring/src/main/resources/spring/dubbo-demo.xml
@@ -23,9 +23,9 @@
<dubbo:application name="demo-app" />
- <dubbo:config-center address="zookeeper://127.0.0.1:2181"/>
- <dubbo:metadata-report address="zookeeper://127.0.0.1:2181"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181?registry-type=service"/>
+ <dubbo:config-center address="${zookeeper.connection.address}"/>
+ <dubbo:metadata-report address="${zookeeper.connection.address}"/>
+ <dubbo:registry address="${zookeeper.connection.address}?registry-type=service"/>
<dubbo:protocol name="dubbo" port="-1"/>
<dubbo:protocol name="rest" port="-1"/>