You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by GitBox <gi...@apache.org> on 2021/08/17 00:46:34 UTC

[GitHub] [dubbo] shanuo0312 opened a new pull request #8525: service discovery registry process test

shanuo0312 opened a new pull request #8525:
URL: https://github.com/apache/dubbo/pull/8525


   ## What is the purpose of the change
   
   
   
   ## Brief changelog
   
   
   ## Verifying this change
   
   
   <!-- Follow this checklist to help us incorporate your contribution quickly and easily: -->
   
   ## Checklist
   - [x] Make sure there is a [GitHub_issue](https://github.com/apache/dubbo/issues) field for the change (usually before you start working on it). Trivial changes like typos do not require a GitHub issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue.
   - [ ] Each commit in the pull request should have a meaningful subject line and body.
   - [ ] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [ ] Check if is necessary to patch to Dubbo 3 if you are work on Dubbo 2.7
   - [ ] Write necessary unit-test to verify your logic correction, more mock a little better when cross module dependency exist. If the new feature or significant change is committed, please remember to add sample in [dubbo samples](https://github.com/apache/dubbo-samples) project.
   - [ ] Add some description to [dubbo-website](https://github.com/apache/dubbo-website) project if you are requesting to add a feature.
   - [ ] GitHub Actions works fine on your own branch.
   - [ ] If this contribution is large, please follow the [Software Donation Guide](https://github.com/apache/dubbo/wiki/Software-donation-guide).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] shanuo0312 closed pull request #8525: service discovery registry process test

Posted by GitBox <gi...@apache.org>.
shanuo0312 closed pull request #8525:
URL: https://github.com/apache/dubbo/pull/8525


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org


[GitHub] [dubbo] pinxiong commented on a change in pull request #8525: service discovery registry process test

Posted by GitBox <gi...@apache.org>.
pinxiong commented on a change in pull request #8525:
URL: https://github.com/apache/dubbo/pull/8525#discussion_r690009572



##########
File path: dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/serviceDiscoveryRegistry/SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
##########
@@ -0,0 +1,206 @@
+/*
+ * 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.integration.single.serviceDiscoveryRegistry;
+
+import com.alibaba.nacos.common.utils.MapUtil;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.config.*;

Review comment:
       See above first.
   
   Also, you need to remove import*

##########
File path: dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/serviceDiscoveryRegistry/SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
##########
@@ -0,0 +1,206 @@
+/*
+ * 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.integration.single.serviceDiscoveryRegistry;
+
+import com.alibaba.nacos.common.utils.MapUtil;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.config.*;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmService;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmServiceImpl;
+import org.apache.dubbo.integration.ServiceDiscoveryRegistryListener;
+import org.apache.dubbo.metadata.MetadataInfo;
+import org.apache.dubbo.metadata.WritableMetadataService;
+import org.apache.dubbo.registry.RegistryServiceListener;
+import org.apache.dubbo.registrycenter.DefaultMultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.DefaultSingleRegistryCenter;
+import org.apache.dubbo.registrycenter.MultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.SingleRegistryCenter;
+import org.apache.dubbo.rpc.ExporterListener;
+import org.apache.dubbo.rpc.Filter;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+
+import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
+
+/**
+ * The testcases are only for checking the process of saving metainfos for service-discovery-registry protocol.
+ */
+public class SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest implements IntegrationTest {
+
+    private static final Logger logger = LoggerFactory.getLogger(SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.class);
+
+    /**
+     * Define the provider application name.
+     */
+    private static String PROVIDER_APPLICATION_NAME = "single-registry-center-provider-for-service-discovery-registry-protocol";
+
+    /**
+     * Define the protocol's name.
+     */
+    private static String PROTOCOL_NAME = CommonConstants.DUBBO;
+    /**
+     * Define the protocol's port.
+     */
+    private static int PROTOCOL_PORT = 20880;
+
+    /**
+     * The name for getting the specified instance, which is loaded using SPI.
+     */
+    private static String SPI_NAME = "singleConfigCenterServiceDiscoveryRegistry";
+    /**
+     * Define the {@link ServiceConfig} instance.
+     */
+    private ServiceConfig<SingleRegistryCenterInjvmService> serviceConfig;

Review comment:
       Define a new service

##########
File path: dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/serviceDiscoveryRegistry/SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
##########
@@ -0,0 +1,206 @@
+/*
+ * 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.integration.single.serviceDiscoveryRegistry;
+
+import com.alibaba.nacos.common.utils.MapUtil;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.config.*;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmService;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmServiceImpl;
+import org.apache.dubbo.integration.ServiceDiscoveryRegistryListener;
+import org.apache.dubbo.metadata.MetadataInfo;
+import org.apache.dubbo.metadata.WritableMetadataService;
+import org.apache.dubbo.registry.RegistryServiceListener;
+import org.apache.dubbo.registrycenter.DefaultMultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.DefaultSingleRegistryCenter;
+import org.apache.dubbo.registrycenter.MultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.SingleRegistryCenter;
+import org.apache.dubbo.rpc.ExporterListener;
+import org.apache.dubbo.rpc.Filter;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+
+import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
+
+/**
+ * The testcases are only for checking the process of saving metainfos for service-discovery-registry protocol.
+ */
+public class SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest implements IntegrationTest {
+
+    private static final Logger logger = LoggerFactory.getLogger(SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.class);
+
+    /**
+     * Define the provider application name.
+     */
+    private static String PROVIDER_APPLICATION_NAME = "single-registry-center-provider-for-service-discovery-registry-protocol";
+
+    /**
+     * Define the protocol's name.
+     */
+    private static String PROTOCOL_NAME = CommonConstants.DUBBO;
+    /**
+     * Define the protocol's port.
+     */
+    private static int PROTOCOL_PORT = 20880;
+
+    /**
+     * The name for getting the specified instance, which is loaded using SPI.
+     */
+    private static String SPI_NAME = "singleConfigCenterServiceDiscoveryRegistry";
+    /**
+     * Define the {@link ServiceConfig} instance.
+     */
+    private ServiceConfig<SingleRegistryCenterInjvmService> serviceConfig;
+
+    /**
+     * The listener to mark is Called
+     */
+    private ServiceDiscoveryRegistryListener registryServiceListener;
+
+    /**
+     * the service to write meta info locally
+     */
+    private WritableMetadataService writableMetadataService;
+
+    /**
+     * Default a registry center.
+     */
+    private SingleRegistryCenter registryCenter;
+
+    @BeforeEach
+    public void setUp() throws Exception {
+        logger.info(getClass().getSimpleName() + " testcase is beginning...");
+        DubboBootstrap.reset();
+
+        //start all zookeeper services only once
+        registryCenter = new DefaultSingleRegistryCenter();
+        registryCenter.startup();
+
+        // initialize service config
+        serviceConfig = new ServiceConfig<SingleRegistryCenterInjvmService>();
+        serviceConfig.setInterface(SingleRegistryCenterInjvmService.class);
+        serviceConfig.setRef(new SingleRegistryCenterInjvmServiceImpl());
+        serviceConfig.setAsync(false);
+//        serviceConfig.setScope(SCOPE_LOCAL);
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance().registry(registryCenter.getRegistryConfig());
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance()
+            .application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
+            .protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
+            .service(serviceConfig);
+
+        writableMetadataService = WritableMetadataService.getDefaultExtension();
+    }
+
+    private void beforeServiceDiscoveryRegistry() {
+        // ---------------initialize--------------- //
+        registryServiceListener = (ServiceDiscoveryRegistryListener) ExtensionLoader.getExtensionLoader(RegistryServiceListener.class).getExtension(SPI_NAME);
+
+        // ---------------checkpoints--------------- //
+        // registryServiceListener onRegister is not called
+        Assertions.assertFalse(registryServiceListener.isRegisterHasCalled());
+        // registryServiceListener onSubscribe is not called
+        Assertions.assertFalse(registryServiceListener.isSubscribeHasCalled());
+        // exportedServiceURLs of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(CollectionUtils.isEmpty(writableMetadataService.getExportedURLs()));
+        // metadataInfos of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getMetadataInfos()));
+        // serviceToAppsMapping of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getCachedMapping()));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Test
+    @Override
+    public void integrate() {
+        beforeServiceDiscoveryRegistry();
+        DubboBootstrap.getInstance().start();
+        afterServiceDiscoveryRegistry();
+    }
+
+    private void afterServiceDiscoveryRegistry() {
+        // ---------------initialize--------------- //
+        registryServiceListener = (ServiceDiscoveryRegistryListener) ExtensionLoader.getExtensionLoader(RegistryServiceListener.class).getExtension(SPI_NAME);
+
+        // ---------------checkpoints--------------- //
+        // registryServiceListener onRegister is called
+        Assertions.assertTrue(registryServiceListener.isRegisterHasCalled());
+        // registryServiceListener onSubscribe is called
+        Assertions.assertTrue(registryServiceListener.isSubscribeHasCalled());
+        // exportedServiceURLs of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForExportedURLs(writableMetadataService.getExportedURLs()));
+        // metadataInfos of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForMetadataInfos(writableMetadataService.getMetadataInfos()));
+        // serviceToAppsMapping of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForServiceToAppsMapping(writableMetadataService.getCachedMapping()));
+    }
+
+    private Boolean isCorrectForExportedURLs(SortedSet<String> exportedURLs) {
+        if(CollectionUtils.isEmpty(exportedURLs)) {
+            return false;
+        }
+        if(!exportedURLs.toString().contains(PROVIDER_APPLICATION_NAME) || !exportedURLs.toString().contains("SingleRegistryCenterInjvmService")) {
+            return false;
+        }
+        return true;
+    }
+
+    private Boolean isCorrectForMetadataInfos(Map<String, MetadataInfo> metadataInfos) {

Review comment:
       Add the necessary comments

##########
File path: dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/serviceDiscoveryRegistry/SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
##########
@@ -0,0 +1,206 @@
+/*
+ * 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.integration.single.serviceDiscoveryRegistry;
+
+import com.alibaba.nacos.common.utils.MapUtil;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.config.*;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmService;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmServiceImpl;
+import org.apache.dubbo.integration.ServiceDiscoveryRegistryListener;
+import org.apache.dubbo.metadata.MetadataInfo;
+import org.apache.dubbo.metadata.WritableMetadataService;
+import org.apache.dubbo.registry.RegistryServiceListener;
+import org.apache.dubbo.registrycenter.DefaultMultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.DefaultSingleRegistryCenter;
+import org.apache.dubbo.registrycenter.MultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.SingleRegistryCenter;
+import org.apache.dubbo.rpc.ExporterListener;
+import org.apache.dubbo.rpc.Filter;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+
+import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
+
+/**
+ * The testcases are only for checking the process of saving metainfos for service-discovery-registry protocol.
+ */
+public class SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest implements IntegrationTest {
+
+    private static final Logger logger = LoggerFactory.getLogger(SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.class);
+
+    /**
+     * Define the provider application name.
+     */
+    private static String PROVIDER_APPLICATION_NAME = "single-registry-center-provider-for-service-discovery-registry-protocol";
+
+    /**
+     * Define the protocol's name.
+     */
+    private static String PROTOCOL_NAME = CommonConstants.DUBBO;
+    /**
+     * Define the protocol's port.
+     */
+    private static int PROTOCOL_PORT = 20880;
+
+    /**
+     * The name for getting the specified instance, which is loaded using SPI.
+     */
+    private static String SPI_NAME = "singleConfigCenterServiceDiscoveryRegistry";

Review comment:
       It's `RegistryCenter` not `ConfigCenter`

##########
File path: dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/serviceDiscoveryRegistry/SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
##########
@@ -0,0 +1,206 @@
+/*
+ * 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.integration.single.serviceDiscoveryRegistry;
+
+import com.alibaba.nacos.common.utils.MapUtil;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.config.*;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmService;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmServiceImpl;
+import org.apache.dubbo.integration.ServiceDiscoveryRegistryListener;
+import org.apache.dubbo.metadata.MetadataInfo;
+import org.apache.dubbo.metadata.WritableMetadataService;
+import org.apache.dubbo.registry.RegistryServiceListener;
+import org.apache.dubbo.registrycenter.DefaultMultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.DefaultSingleRegistryCenter;
+import org.apache.dubbo.registrycenter.MultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.SingleRegistryCenter;
+import org.apache.dubbo.rpc.ExporterListener;
+import org.apache.dubbo.rpc.Filter;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+
+import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
+
+/**
+ * The testcases are only for checking the process of saving metainfos for service-discovery-registry protocol.
+ */
+public class SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest implements IntegrationTest {
+
+    private static final Logger logger = LoggerFactory.getLogger(SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.class);
+
+    /**
+     * Define the provider application name.
+     */
+    private static String PROVIDER_APPLICATION_NAME = "single-registry-center-provider-for-service-discovery-registry-protocol";
+
+    /**
+     * Define the protocol's name.
+     */
+    private static String PROTOCOL_NAME = CommonConstants.DUBBO;
+    /**
+     * Define the protocol's port.
+     */
+    private static int PROTOCOL_PORT = 20880;
+
+    /**
+     * The name for getting the specified instance, which is loaded using SPI.
+     */
+    private static String SPI_NAME = "singleConfigCenterServiceDiscoveryRegistry";
+    /**
+     * Define the {@link ServiceConfig} instance.
+     */
+    private ServiceConfig<SingleRegistryCenterInjvmService> serviceConfig;
+
+    /**
+     * The listener to mark is Called
+     */
+    private ServiceDiscoveryRegistryListener registryServiceListener;
+
+    /**
+     * the service to write meta info locally
+     */
+    private WritableMetadataService writableMetadataService;
+
+    /**
+     * Default a registry center.
+     */
+    private SingleRegistryCenter registryCenter;
+
+    @BeforeEach
+    public void setUp() throws Exception {
+        logger.info(getClass().getSimpleName() + " testcase is beginning...");
+        DubboBootstrap.reset();
+
+        //start all zookeeper services only once
+        registryCenter = new DefaultSingleRegistryCenter();
+        registryCenter.startup();
+
+        // initialize service config
+        serviceConfig = new ServiceConfig<SingleRegistryCenterInjvmService>();
+        serviceConfig.setInterface(SingleRegistryCenterInjvmService.class);
+        serviceConfig.setRef(new SingleRegistryCenterInjvmServiceImpl());
+        serviceConfig.setAsync(false);
+//        serviceConfig.setScope(SCOPE_LOCAL);
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance().registry(registryCenter.getRegistryConfig());
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance()
+            .application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
+            .protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
+            .service(serviceConfig);
+
+        writableMetadataService = WritableMetadataService.getDefaultExtension();
+    }
+
+    private void beforeServiceDiscoveryRegistry() {
+        // ---------------initialize--------------- //
+        registryServiceListener = (ServiceDiscoveryRegistryListener) ExtensionLoader.getExtensionLoader(RegistryServiceListener.class).getExtension(SPI_NAME);
+
+        // ---------------checkpoints--------------- //
+        // registryServiceListener onRegister is not called
+        Assertions.assertFalse(registryServiceListener.isRegisterHasCalled());
+        // registryServiceListener onSubscribe is not called
+        Assertions.assertFalse(registryServiceListener.isSubscribeHasCalled());
+        // exportedServiceURLs of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(CollectionUtils.isEmpty(writableMetadataService.getExportedURLs()));
+        // metadataInfos of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getMetadataInfos()));
+        // serviceToAppsMapping of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getCachedMapping()));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Test
+    @Override
+    public void integrate() {
+        beforeServiceDiscoveryRegistry();
+        DubboBootstrap.getInstance().start();
+        afterServiceDiscoveryRegistry();
+    }
+
+    private void afterServiceDiscoveryRegistry() {
+        // ---------------initialize--------------- //
+        registryServiceListener = (ServiceDiscoveryRegistryListener) ExtensionLoader.getExtensionLoader(RegistryServiceListener.class).getExtension(SPI_NAME);

Review comment:
       Why is this method called twice

##########
File path: dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/serviceDiscoveryRegistry/SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
##########
@@ -0,0 +1,206 @@
+/*
+ * 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.integration.single.serviceDiscoveryRegistry;
+
+import com.alibaba.nacos.common.utils.MapUtil;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.config.*;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmService;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmServiceImpl;
+import org.apache.dubbo.integration.ServiceDiscoveryRegistryListener;
+import org.apache.dubbo.metadata.MetadataInfo;
+import org.apache.dubbo.metadata.WritableMetadataService;
+import org.apache.dubbo.registry.RegistryServiceListener;
+import org.apache.dubbo.registrycenter.DefaultMultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.DefaultSingleRegistryCenter;
+import org.apache.dubbo.registrycenter.MultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.SingleRegistryCenter;
+import org.apache.dubbo.rpc.ExporterListener;
+import org.apache.dubbo.rpc.Filter;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+
+import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
+
+/**
+ * The testcases are only for checking the process of saving metainfos for service-discovery-registry protocol.
+ */
+public class SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest implements IntegrationTest {
+
+    private static final Logger logger = LoggerFactory.getLogger(SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.class);
+
+    /**
+     * Define the provider application name.
+     */
+    private static String PROVIDER_APPLICATION_NAME = "single-registry-center-provider-for-service-discovery-registry-protocol";
+
+    /**
+     * Define the protocol's name.
+     */
+    private static String PROTOCOL_NAME = CommonConstants.DUBBO;
+    /**
+     * Define the protocol's port.
+     */
+    private static int PROTOCOL_PORT = 20880;
+
+    /**
+     * The name for getting the specified instance, which is loaded using SPI.
+     */
+    private static String SPI_NAME = "singleConfigCenterServiceDiscoveryRegistry";
+    /**
+     * Define the {@link ServiceConfig} instance.
+     */
+    private ServiceConfig<SingleRegistryCenterInjvmService> serviceConfig;
+
+    /**
+     * The listener to mark is Called
+     */
+    private ServiceDiscoveryRegistryListener registryServiceListener;
+
+    /**
+     * the service to write meta info locally
+     */
+    private WritableMetadataService writableMetadataService;
+
+    /**
+     * Default a registry center.
+     */
+    private SingleRegistryCenter registryCenter;
+
+    @BeforeEach
+    public void setUp() throws Exception {
+        logger.info(getClass().getSimpleName() + " testcase is beginning...");
+        DubboBootstrap.reset();
+
+        //start all zookeeper services only once
+        registryCenter = new DefaultSingleRegistryCenter();
+        registryCenter.startup();
+
+        // initialize service config
+        serviceConfig = new ServiceConfig<SingleRegistryCenterInjvmService>();
+        serviceConfig.setInterface(SingleRegistryCenterInjvmService.class);
+        serviceConfig.setRef(new SingleRegistryCenterInjvmServiceImpl());
+        serviceConfig.setAsync(false);
+//        serviceConfig.setScope(SCOPE_LOCAL);
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance().registry(registryCenter.getRegistryConfig());
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance()
+            .application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
+            .protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
+            .service(serviceConfig);
+
+        writableMetadataService = WritableMetadataService.getDefaultExtension();
+    }
+
+    private void beforeServiceDiscoveryRegistry() {
+        // ---------------initialize--------------- //
+        registryServiceListener = (ServiceDiscoveryRegistryListener) ExtensionLoader.getExtensionLoader(RegistryServiceListener.class).getExtension(SPI_NAME);
+
+        // ---------------checkpoints--------------- //
+        // registryServiceListener onRegister is not called
+        Assertions.assertFalse(registryServiceListener.isRegisterHasCalled());
+        // registryServiceListener onSubscribe is not called
+        Assertions.assertFalse(registryServiceListener.isSubscribeHasCalled());
+        // exportedServiceURLs of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(CollectionUtils.isEmpty(writableMetadataService.getExportedURLs()));
+        // metadataInfos of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getMetadataInfos()));
+        // serviceToAppsMapping of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getCachedMapping()));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Test
+    @Override
+    public void integrate() {
+        beforeServiceDiscoveryRegistry();
+        DubboBootstrap.getInstance().start();
+        afterServiceDiscoveryRegistry();
+    }
+
+    private void afterServiceDiscoveryRegistry() {
+        // ---------------initialize--------------- //
+        registryServiceListener = (ServiceDiscoveryRegistryListener) ExtensionLoader.getExtensionLoader(RegistryServiceListener.class).getExtension(SPI_NAME);
+
+        // ---------------checkpoints--------------- //
+        // registryServiceListener onRegister is called
+        Assertions.assertTrue(registryServiceListener.isRegisterHasCalled());
+        // registryServiceListener onSubscribe is called
+        Assertions.assertTrue(registryServiceListener.isSubscribeHasCalled());
+        // exportedServiceURLs of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForExportedURLs(writableMetadataService.getExportedURLs()));
+        // metadataInfos of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForMetadataInfos(writableMetadataService.getMetadataInfos()));
+        // serviceToAppsMapping of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForServiceToAppsMapping(writableMetadataService.getCachedMapping()));
+    }
+
+    private Boolean isCorrectForExportedURLs(SortedSet<String> exportedURLs) {
+        if(CollectionUtils.isEmpty(exportedURLs)) {
+            return false;
+        }
+        if(!exportedURLs.toString().contains(PROVIDER_APPLICATION_NAME) || !exportedURLs.toString().contains("SingleRegistryCenterInjvmService")) {
+            return false;
+        }
+        return true;
+    }
+
+    private Boolean isCorrectForMetadataInfos(Map<String, MetadataInfo> metadataInfos) {
+        if(MapUtil.isEmpty(metadataInfos)) {
+            return false;
+        }
+        if(!metadataInfos.toString().contains(PROVIDER_APPLICATION_NAME) || !metadataInfos.toString().contains("SingleRegistryCenterInjvmService")) {
+            return false;
+        }
+        return true;
+    }
+
+    private Boolean isCorrectForServiceToAppsMapping(Map<String, Set<String>> serviceToAppsMapping) {

Review comment:
       It's unnecessary

##########
File path: dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/serviceDiscoveryRegistry/SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
##########
@@ -0,0 +1,206 @@
+/*
+ * 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.integration.single.serviceDiscoveryRegistry;
+
+import com.alibaba.nacos.common.utils.MapUtil;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.config.*;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmService;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmServiceImpl;
+import org.apache.dubbo.integration.ServiceDiscoveryRegistryListener;
+import org.apache.dubbo.metadata.MetadataInfo;
+import org.apache.dubbo.metadata.WritableMetadataService;
+import org.apache.dubbo.registry.RegistryServiceListener;
+import org.apache.dubbo.registrycenter.DefaultMultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.DefaultSingleRegistryCenter;
+import org.apache.dubbo.registrycenter.MultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.SingleRegistryCenter;
+import org.apache.dubbo.rpc.ExporterListener;
+import org.apache.dubbo.rpc.Filter;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+
+import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
+
+/**
+ * The testcases are only for checking the process of saving metainfos for service-discovery-registry protocol.
+ */
+public class SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest implements IntegrationTest {
+
+    private static final Logger logger = LoggerFactory.getLogger(SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.class);
+
+    /**
+     * Define the provider application name.
+     */
+    private static String PROVIDER_APPLICATION_NAME = "single-registry-center-provider-for-service-discovery-registry-protocol";
+
+    /**
+     * Define the protocol's name.
+     */
+    private static String PROTOCOL_NAME = CommonConstants.DUBBO;
+    /**
+     * Define the protocol's port.
+     */
+    private static int PROTOCOL_PORT = 20880;
+
+    /**
+     * The name for getting the specified instance, which is loaded using SPI.
+     */
+    private static String SPI_NAME = "singleConfigCenterServiceDiscoveryRegistry";
+    /**
+     * Define the {@link ServiceConfig} instance.
+     */
+    private ServiceConfig<SingleRegistryCenterInjvmService> serviceConfig;
+
+    /**
+     * The listener to mark is Called
+     */
+    private ServiceDiscoveryRegistryListener registryServiceListener;
+
+    /**
+     * the service to write meta info locally
+     */
+    private WritableMetadataService writableMetadataService;
+
+    /**
+     * Default a registry center.
+     */
+    private SingleRegistryCenter registryCenter;
+
+    @BeforeEach
+    public void setUp() throws Exception {
+        logger.info(getClass().getSimpleName() + " testcase is beginning...");
+        DubboBootstrap.reset();
+
+        //start all zookeeper services only once
+        registryCenter = new DefaultSingleRegistryCenter();
+        registryCenter.startup();
+
+        // initialize service config
+        serviceConfig = new ServiceConfig<SingleRegistryCenterInjvmService>();
+        serviceConfig.setInterface(SingleRegistryCenterInjvmService.class);
+        serviceConfig.setRef(new SingleRegistryCenterInjvmServiceImpl());
+        serviceConfig.setAsync(false);
+//        serviceConfig.setScope(SCOPE_LOCAL);
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance().registry(registryCenter.getRegistryConfig());
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance()
+            .application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
+            .protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
+            .service(serviceConfig);
+
+        writableMetadataService = WritableMetadataService.getDefaultExtension();
+    }
+
+    private void beforeServiceDiscoveryRegistry() {
+        // ---------------initialize--------------- //
+        registryServiceListener = (ServiceDiscoveryRegistryListener) ExtensionLoader.getExtensionLoader(RegistryServiceListener.class).getExtension(SPI_NAME);
+
+        // ---------------checkpoints--------------- //
+        // registryServiceListener onRegister is not called
+        Assertions.assertFalse(registryServiceListener.isRegisterHasCalled());
+        // registryServiceListener onSubscribe is not called
+        Assertions.assertFalse(registryServiceListener.isSubscribeHasCalled());
+        // exportedServiceURLs of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(CollectionUtils.isEmpty(writableMetadataService.getExportedURLs()));
+        // metadataInfos of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getMetadataInfos()));
+        // serviceToAppsMapping of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getCachedMapping()));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Test
+    @Override
+    public void integrate() {
+        beforeServiceDiscoveryRegistry();
+        DubboBootstrap.getInstance().start();
+        afterServiceDiscoveryRegistry();
+    }
+
+    private void afterServiceDiscoveryRegistry() {
+        // ---------------initialize--------------- //
+        registryServiceListener = (ServiceDiscoveryRegistryListener) ExtensionLoader.getExtensionLoader(RegistryServiceListener.class).getExtension(SPI_NAME);
+
+        // ---------------checkpoints--------------- //
+        // registryServiceListener onRegister is called
+        Assertions.assertTrue(registryServiceListener.isRegisterHasCalled());
+        // registryServiceListener onSubscribe is called
+        Assertions.assertTrue(registryServiceListener.isSubscribeHasCalled());
+        // exportedServiceURLs of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForExportedURLs(writableMetadataService.getExportedURLs()));
+        // metadataInfos of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForMetadataInfos(writableMetadataService.getMetadataInfos()));
+        // serviceToAppsMapping of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForServiceToAppsMapping(writableMetadataService.getCachedMapping()));
+    }
+
+    private Boolean isCorrectForExportedURLs(SortedSet<String> exportedURLs) {

Review comment:
       Add the necessary comments

##########
File path: dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/ServiceDiscoveryRegistryListener.java
##########
@@ -0,0 +1,95 @@
+/*
+ * 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.integration;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.Activate;
+import org.apache.dubbo.registry.Registry;
+import org.apache.dubbo.registry.RegistryServiceListener;
+
+@Activate(group = CommonConstants.PROVIDER, order = 1000)
+public class ServiceDiscoveryRegistryListener implements RegistryServiceListener {

Review comment:
       You'd better create a new package named `servicediscoveryregistry` and move all created files into it. Also, all created class should keep the same style, including but not limited to class name, field name etc.

##########
File path: dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/serviceDiscoveryRegistry/SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
##########
@@ -0,0 +1,206 @@
+/*
+ * 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.integration.single.serviceDiscoveryRegistry;
+
+import com.alibaba.nacos.common.utils.MapUtil;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.config.*;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmService;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmServiceImpl;
+import org.apache.dubbo.integration.ServiceDiscoveryRegistryListener;
+import org.apache.dubbo.metadata.MetadataInfo;
+import org.apache.dubbo.metadata.WritableMetadataService;
+import org.apache.dubbo.registry.RegistryServiceListener;
+import org.apache.dubbo.registrycenter.DefaultMultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.DefaultSingleRegistryCenter;
+import org.apache.dubbo.registrycenter.MultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.SingleRegistryCenter;
+import org.apache.dubbo.rpc.ExporterListener;
+import org.apache.dubbo.rpc.Filter;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+
+import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
+
+/**
+ * The testcases are only for checking the process of saving metainfos for service-discovery-registry protocol.
+ */
+public class SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest implements IntegrationTest {
+
+    private static final Logger logger = LoggerFactory.getLogger(SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.class);
+
+    /**
+     * Define the provider application name.
+     */
+    private static String PROVIDER_APPLICATION_NAME = "single-registry-center-provider-for-service-discovery-registry-protocol";
+
+    /**
+     * Define the protocol's name.
+     */
+    private static String PROTOCOL_NAME = CommonConstants.DUBBO;
+    /**
+     * Define the protocol's port.
+     */
+    private static int PROTOCOL_PORT = 20880;
+
+    /**
+     * The name for getting the specified instance, which is loaded using SPI.
+     */
+    private static String SPI_NAME = "singleConfigCenterServiceDiscoveryRegistry";
+    /**
+     * Define the {@link ServiceConfig} instance.
+     */
+    private ServiceConfig<SingleRegistryCenterInjvmService> serviceConfig;
+
+    /**
+     * The listener to mark is Called
+     */
+    private ServiceDiscoveryRegistryListener registryServiceListener;
+
+    /**
+     * the service to write meta info locally
+     */
+    private WritableMetadataService writableMetadataService;
+
+    /**
+     * Default a registry center.
+     */
+    private SingleRegistryCenter registryCenter;
+
+    @BeforeEach
+    public void setUp() throws Exception {
+        logger.info(getClass().getSimpleName() + " testcase is beginning...");
+        DubboBootstrap.reset();
+
+        //start all zookeeper services only once
+        registryCenter = new DefaultSingleRegistryCenter();
+        registryCenter.startup();
+
+        // initialize service config
+        serviceConfig = new ServiceConfig<SingleRegistryCenterInjvmService>();
+        serviceConfig.setInterface(SingleRegistryCenterInjvmService.class);
+        serviceConfig.setRef(new SingleRegistryCenterInjvmServiceImpl());
+        serviceConfig.setAsync(false);
+//        serviceConfig.setScope(SCOPE_LOCAL);
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance().registry(registryCenter.getRegistryConfig());
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance()
+            .application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
+            .protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
+            .service(serviceConfig);
+
+        writableMetadataService = WritableMetadataService.getDefaultExtension();
+    }
+
+    private void beforeServiceDiscoveryRegistry() {
+        // ---------------initialize--------------- //
+        registryServiceListener = (ServiceDiscoveryRegistryListener) ExtensionLoader.getExtensionLoader(RegistryServiceListener.class).getExtension(SPI_NAME);
+
+        // ---------------checkpoints--------------- //
+        // registryServiceListener onRegister is not called
+        Assertions.assertFalse(registryServiceListener.isRegisterHasCalled());
+        // registryServiceListener onSubscribe is not called
+        Assertions.assertFalse(registryServiceListener.isSubscribeHasCalled());
+        // exportedServiceURLs of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(CollectionUtils.isEmpty(writableMetadataService.getExportedURLs()));
+        // metadataInfos of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getMetadataInfos()));
+        // serviceToAppsMapping of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getCachedMapping()));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Test
+    @Override
+    public void integrate() {
+        beforeServiceDiscoveryRegistry();
+        DubboBootstrap.getInstance().start();
+        afterServiceDiscoveryRegistry();
+    }
+
+    private void afterServiceDiscoveryRegistry() {

Review comment:
       You'd better describe the idea of verification

##########
File path: dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/integration/single/serviceDiscoveryRegistry/SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.java
##########
@@ -0,0 +1,206 @@
+/*
+ * 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.integration.single.serviceDiscoveryRegistry;
+
+import com.alibaba.nacos.common.utils.MapUtil;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.config.*;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.integration.IntegrationTest;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmService;
+import org.apache.dubbo.integration.single.injvm.SingleRegistryCenterInjvmServiceImpl;
+import org.apache.dubbo.integration.ServiceDiscoveryRegistryListener;
+import org.apache.dubbo.metadata.MetadataInfo;
+import org.apache.dubbo.metadata.WritableMetadataService;
+import org.apache.dubbo.registry.RegistryServiceListener;
+import org.apache.dubbo.registrycenter.DefaultMultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.DefaultSingleRegistryCenter;
+import org.apache.dubbo.registrycenter.MultipleRegistryCenter;
+import org.apache.dubbo.registrycenter.SingleRegistryCenter;
+import org.apache.dubbo.rpc.ExporterListener;
+import org.apache.dubbo.rpc.Filter;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Set;
+import java.util.SortedSet;
+
+import static org.apache.dubbo.rpc.Constants.SCOPE_LOCAL;
+
+/**
+ * The testcases are only for checking the process of saving metainfos for service-discovery-registry protocol.
+ */
+public class SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest implements IntegrationTest {
+
+    private static final Logger logger = LoggerFactory.getLogger(SingleRegistryCenterServiceDiscoveryRegistryIntegrationTest.class);
+
+    /**
+     * Define the provider application name.
+     */
+    private static String PROVIDER_APPLICATION_NAME = "single-registry-center-provider-for-service-discovery-registry-protocol";
+
+    /**
+     * Define the protocol's name.
+     */
+    private static String PROTOCOL_NAME = CommonConstants.DUBBO;
+    /**
+     * Define the protocol's port.
+     */
+    private static int PROTOCOL_PORT = 20880;
+
+    /**
+     * The name for getting the specified instance, which is loaded using SPI.
+     */
+    private static String SPI_NAME = "singleConfigCenterServiceDiscoveryRegistry";
+    /**
+     * Define the {@link ServiceConfig} instance.
+     */
+    private ServiceConfig<SingleRegistryCenterInjvmService> serviceConfig;
+
+    /**
+     * The listener to mark is Called
+     */
+    private ServiceDiscoveryRegistryListener registryServiceListener;
+
+    /**
+     * the service to write meta info locally
+     */
+    private WritableMetadataService writableMetadataService;
+
+    /**
+     * Default a registry center.
+     */
+    private SingleRegistryCenter registryCenter;
+
+    @BeforeEach
+    public void setUp() throws Exception {
+        logger.info(getClass().getSimpleName() + " testcase is beginning...");
+        DubboBootstrap.reset();
+
+        //start all zookeeper services only once
+        registryCenter = new DefaultSingleRegistryCenter();
+        registryCenter.startup();
+
+        // initialize service config
+        serviceConfig = new ServiceConfig<SingleRegistryCenterInjvmService>();
+        serviceConfig.setInterface(SingleRegistryCenterInjvmService.class);
+        serviceConfig.setRef(new SingleRegistryCenterInjvmServiceImpl());
+        serviceConfig.setAsync(false);
+//        serviceConfig.setScope(SCOPE_LOCAL);
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance().registry(registryCenter.getRegistryConfig());
+
+        // initailize bootstrap
+        DubboBootstrap.getInstance()
+            .application(new ApplicationConfig(PROVIDER_APPLICATION_NAME))
+            .protocol(new ProtocolConfig(PROTOCOL_NAME, PROTOCOL_PORT))
+            .service(serviceConfig);
+
+        writableMetadataService = WritableMetadataService.getDefaultExtension();
+    }
+
+    private void beforeServiceDiscoveryRegistry() {
+        // ---------------initialize--------------- //
+        registryServiceListener = (ServiceDiscoveryRegistryListener) ExtensionLoader.getExtensionLoader(RegistryServiceListener.class).getExtension(SPI_NAME);
+
+        // ---------------checkpoints--------------- //
+        // registryServiceListener onRegister is not called
+        Assertions.assertFalse(registryServiceListener.isRegisterHasCalled());
+        // registryServiceListener onSubscribe is not called
+        Assertions.assertFalse(registryServiceListener.isSubscribeHasCalled());
+        // exportedServiceURLs of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(CollectionUtils.isEmpty(writableMetadataService.getExportedURLs()));
+        // metadataInfos of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getMetadataInfos()));
+        // serviceToAppsMapping of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(MapUtil.isEmpty(writableMetadataService.getCachedMapping()));
+    }
+
+    /**
+     * {@inheritDoc}
+     */
+    @Test
+    @Override
+    public void integrate() {
+        beforeServiceDiscoveryRegistry();
+        DubboBootstrap.getInstance().start();
+        afterServiceDiscoveryRegistry();
+    }
+
+    private void afterServiceDiscoveryRegistry() {
+        // ---------------initialize--------------- //
+        registryServiceListener = (ServiceDiscoveryRegistryListener) ExtensionLoader.getExtensionLoader(RegistryServiceListener.class).getExtension(SPI_NAME);
+
+        // ---------------checkpoints--------------- //
+        // registryServiceListener onRegister is called
+        Assertions.assertTrue(registryServiceListener.isRegisterHasCalled());
+        // registryServiceListener onSubscribe is called
+        Assertions.assertTrue(registryServiceListener.isSubscribeHasCalled());
+        // exportedServiceURLs of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForExportedURLs(writableMetadataService.getExportedURLs()));
+        // metadataInfos of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForMetadataInfos(writableMetadataService.getMetadataInfos()));
+        // serviceToAppsMapping of InMemoryWritableMetadataService is empty
+        Assertions.assertTrue(isCorrectForServiceToAppsMapping(writableMetadataService.getCachedMapping()));
+    }
+
+    private Boolean isCorrectForExportedURLs(SortedSet<String> exportedURLs) {
+        if(CollectionUtils.isEmpty(exportedURLs)) {
+            return false;
+        }
+        if(!exportedURLs.toString().contains(PROVIDER_APPLICATION_NAME) || !exportedURLs.toString().contains("SingleRegistryCenterInjvmService")) {
+            return false;
+        }
+        return true;
+    }
+
+    private Boolean isCorrectForMetadataInfos(Map<String, MetadataInfo> metadataInfos) {
+        if(MapUtil.isEmpty(metadataInfos)) {
+            return false;
+        }
+        if(!metadataInfos.toString().contains(PROVIDER_APPLICATION_NAME) || !metadataInfos.toString().contains("SingleRegistryCenterInjvmService")) {
+            return false;
+        }
+        return true;
+    }
+
+    private Boolean isCorrectForServiceToAppsMapping(Map<String, Set<String>> serviceToAppsMapping) {
+        return true;
+    }
+
+    @AfterEach
+    public void tearDown() throws IOException {
+        DubboBootstrap.reset();
+        PROVIDER_APPLICATION_NAME = null;
+        serviceConfig = null;
+        Assertions.assertTrue(registryServiceListener.isUnRegisterHasCalled());
+        Assertions.assertTrue(registryServiceListener.isUnSubscribeHasCalled());
+        logger.info(getClass().getSimpleName() + " testcase is ending...");
+        // destroy registry center
+        registryCenter.shutdown();
+        registryCenter = null;

Review comment:
       Release all defined private variables




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org

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



---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org