You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by al...@apache.org on 2022/12/13 12:25:41 UTC

[dubbo-samples] branch master updated: Add test cases to verify 9806 11096 (#620)

This is an automated email from the ASF dual-hosted git repository.

albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git


The following commit(s) were added to refs/heads/master by this push:
     new 520c2c73 Add test cases to verify 9806 11096 (#620)
520c2c73 is described below

commit 520c2c73a91859bf61e1a81404db2806b66323f5
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Tue Dec 13 20:25:33 2022 +0800

    Add test cases to verify 9806 11096 (#620)
---
 .../case-configuration.yml                         |  33 +++
 .../dubbo-samples-test-11096/case-versions.conf    |  24 ++
 99-integration/dubbo-samples-test-11096/pom.xml    | 126 ++++++++++
 .../java/org/apache/dubbo/samples/FakeMain.java    |  25 ++
 .../org/apache/dubbo/samples/test/DemoService.java |  26 ++
 .../apache/dubbo/samples/test/DemoServiceImpl.java |  29 +++
 .../org/apache/dubbo/samples/test/MetadataIT.java  | 272 +++++++++++++++++++++
 .../dubbo-samples-test-9806/case-configuration.yml |  33 +++
 .../dubbo-samples-test-9806/case-versions.conf     |  24 ++
 99-integration/dubbo-samples-test-9806/pom.xml     | 126 ++++++++++
 .../java/org/apache/dubbo/samples/FakeMain.java    |  25 ++
 .../org/apache/dubbo/samples/test/DemoService.java |  26 ++
 .../apache/dubbo/samples/test/DemoServiceImpl.java |  29 +++
 .../org/apache/dubbo/samples/test/MetadataIT.java  | 139 +++++++++++
 99-integration/pom.xml                             |   2 +
 15 files changed, 939 insertions(+)

diff --git a/99-integration/dubbo-samples-test-11096/case-configuration.yml b/99-integration/dubbo-samples-test-11096/case-configuration.yml
new file mode 100644
index 00000000..28d68fcf
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11096/case-configuration.yml
@@ -0,0 +1,33 @@
+# 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.
+
+
+# local call through injvm, start test container only
+services:
+  zookeeper:
+    image: zookeeper:latest
+
+  dubbo-samples-test-11096-test:
+    type: test
+    basedir: .
+    tests:
+      - "**/*IT.class"
+    systemProps:
+      - zookeeper.address=zookeeper
+    waitPortsBeforeRun:
+      - zookeeper:2181
+    depends_on:
+      - zookeeper
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-test-11096/case-versions.conf b/99-integration/dubbo-samples-test-11096/case-versions.conf
new file mode 100644
index 00000000..901e42fb
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11096/case-versions.conf
@@ -0,0 +1,24 @@
+#
+#
+#   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.
+#
+
+
+# Supported component versions of the test case
+
+# Spring app
+dubbo.version=[ >= 3.1.0 ]
+spring.version=4.*, 5.*
diff --git a/99-integration/dubbo-samples-test-11096/pom.xml b/99-integration/dubbo-samples-test-11096/pom.xml
new file mode 100644
index 00000000..5df73be0
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11096/pom.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache</groupId>
+        <artifactId>apache</artifactId>
+        <version>23</version>
+        <relativePath/>
+    </parent>
+
+    <groupId>org.apache.dubbo</groupId>
+    <artifactId>dubbo-samples-test-11096</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <name>Dubbo Samples Test For Issue 11096</name>
+    <description>Dubbo Samples Test For Issue 11096</description>
+
+    <properties>
+        <source.level>1.8</source.level>
+        <target.level>1.8</target.level>
+        <dubbo.version>3.1.3</dubbo.version>
+        <spring.version>4.3.16.RELEASE</spring.version>
+        <junit.version>4.12</junit.version>
+        <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring-framework-bom</artifactId>
+                <version>${spring.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.dubbo</groupId>
+                <artifactId>dubbo-bom</artifactId>
+                <version>${dubbo.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.dubbo</groupId>
+                <artifactId>dubbo-dependencies-zookeeper</artifactId>
+                <version>${dubbo.version}</version>
+                <type>pom</type>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-dependencies-zookeeper</artifactId>
+            <type>pom</type>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <profiles>
+        <!-- For jdk 11 above JavaEE annotation -->
+        <profile>
+            <id>javax.annotation</id>
+            <activation>
+                <jdk>[1.11,)</jdk>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>javax.annotation</groupId>
+                    <artifactId>javax.annotation-api</artifactId>
+                    <version>1.3.2</version>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>${maven-compiler-plugin.version}</version>
+                <configuration>
+                    <source>${source.level}</source>
+                    <target>${target.level}</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-test-11096/src/main/java/org/apache/dubbo/samples/FakeMain.java b/99-integration/dubbo-samples-test-11096/src/main/java/org/apache/dubbo/samples/FakeMain.java
new file mode 100644
index 00000000..acd29c76
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11096/src/main/java/org/apache/dubbo/samples/FakeMain.java
@@ -0,0 +1,25 @@
+/*
+ *
+ *   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.samples;
+
+public class FakeMain {
+    public static void main(String[] args) {
+
+    }
+}
diff --git a/99-integration/dubbo-samples-test-11096/src/test/java/org/apache/dubbo/samples/test/DemoService.java b/99-integration/dubbo-samples-test-11096/src/test/java/org/apache/dubbo/samples/test/DemoService.java
new file mode 100644
index 00000000..d61f54ab
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11096/src/test/java/org/apache/dubbo/samples/test/DemoService.java
@@ -0,0 +1,26 @@
+/*
+ *
+ *   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.samples.test;
+
+public interface DemoService {
+
+    String sayHello(String name);
+
+}
diff --git a/99-integration/dubbo-samples-test-11096/src/test/java/org/apache/dubbo/samples/test/DemoServiceImpl.java b/99-integration/dubbo-samples-test-11096/src/test/java/org/apache/dubbo/samples/test/DemoServiceImpl.java
new file mode 100644
index 00000000..d5489f66
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11096/src/test/java/org/apache/dubbo/samples/test/DemoServiceImpl.java
@@ -0,0 +1,29 @@
+/*
+ *
+ *   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.samples.test;
+
+public class DemoServiceImpl implements DemoService {
+
+    @Override
+    public String sayHello(String name) {
+        return "Hello " + name;
+    }
+
+}
diff --git a/99-integration/dubbo-samples-test-11096/src/test/java/org/apache/dubbo/samples/test/MetadataIT.java b/99-integration/dubbo-samples-test-11096/src/test/java/org/apache/dubbo/samples/test/MetadataIT.java
new file mode 100644
index 00000000..a9947cea
--- /dev/null
+++ b/99-integration/dubbo-samples-test-11096/src/test/java/org/apache/dubbo/samples/test/MetadataIT.java
@@ -0,0 +1,272 @@
+/*
+ *
+ *   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.samples.test;
+
+import org.apache.dubbo.config.MetadataReportConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.ServiceConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.metadata.report.MetadataReport;
+import org.apache.dubbo.metadata.report.MetadataReportInstance;
+import org.apache.dubbo.metadata.report.support.AbstractMetadataReport;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.FrameworkModel;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.Map;
+
+public class MetadataIT {
+
+    @Test
+    public void test1() {
+        ApplicationModel applicationModel = FrameworkModel.defaultModel().newApplication();
+
+        ServiceConfig<DemoService> serviceConfig = new ServiceConfig<>();
+        serviceConfig.setInterface(DemoService.class);
+        serviceConfig.setRef(new DemoServiceImpl());
+
+        RegistryConfig registryConfig = new RegistryConfig();
+        registryConfig.setAddress("zookeeper://" + System.getProperty("zookeeper.address", "127.0.0.1") + ":2181");
+
+        MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
+        metadataReportConfig.setCycleReport(false);
+
+        DubboBootstrap dubboBootstrap = DubboBootstrap.getInstance(applicationModel);
+        dubboBootstrap.application("metadata-test")
+                .registry(registryConfig)
+                .service(serviceConfig)
+                .metadataReport(metadataReportConfig);
+        dubboBootstrap.start();
+
+        Assert.assertTrue(dubboBootstrap.isInitialized());
+        Assert.assertTrue(dubboBootstrap.isStarted());
+
+        MetadataReportInstance metadataReportInstance = applicationModel.getBeanFactory().getBean(MetadataReportInstance.class);
+        Assert.assertNotNull(metadataReportInstance);
+        Map<String, MetadataReport> metadataReports = metadataReportInstance.getMetadataReports(true);
+        Assert.assertNotNull(metadataReports);
+        Assert.assertEquals(1, metadataReports.size());
+        applicationModel.destroy();
+    }
+
+    @Test
+    public void test2() {
+        ApplicationModel applicationModel = FrameworkModel.defaultModel().newApplication();
+
+        ServiceConfig<DemoService> serviceConfig = new ServiceConfig<>();
+        serviceConfig.setInterface(DemoService.class);
+        serviceConfig.setRef(new DemoServiceImpl());
+
+        RegistryConfig registryConfig = new RegistryConfig();
+        registryConfig.setAddress("zookeeper://" + System.getProperty("zookeeper.address", "127.0.0.1") + ":2181");
+
+        MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
+        metadataReportConfig.setRetryPeriod(1000);
+
+        DubboBootstrap dubboBootstrap = DubboBootstrap.getInstance(applicationModel);
+        dubboBootstrap.application("metadata-test")
+                .registry(registryConfig)
+                .service(serviceConfig)
+                .metadataReport(metadataReportConfig);
+        dubboBootstrap.start();
+
+        Assert.assertTrue(dubboBootstrap.isInitialized());
+        Assert.assertTrue(dubboBootstrap.isStarted());
+
+        MetadataReportInstance metadataReportInstance = applicationModel.getBeanFactory().getBean(MetadataReportInstance.class);
+        Assert.assertNotNull(metadataReportInstance);
+        Map<String, MetadataReport> metadataReports = metadataReportInstance.getMetadataReports(true);
+        Assert.assertNotNull(metadataReports);
+        Assert.assertEquals(1, metadataReports.size());
+        applicationModel.destroy();
+    }
+
+    @Test
+    public void test3() {
+        ApplicationModel applicationModel = FrameworkModel.defaultModel().newApplication();
+
+        ServiceConfig<DemoService> serviceConfig = new ServiceConfig<>();
+        serviceConfig.setInterface(DemoService.class);
+        serviceConfig.setRef(new DemoServiceImpl());
+
+        RegistryConfig registryConfig = new RegistryConfig();
+        registryConfig.setAddress("zookeeper://" + System.getProperty("zookeeper.address", "127.0.0.1") + ":2181");
+        registryConfig.setUseAsMetadataCenter(false);
+
+        MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
+        metadataReportConfig.setRetryPeriod(1000);
+
+        DubboBootstrap dubboBootstrap = DubboBootstrap.getInstance(applicationModel);
+        dubboBootstrap.application("metadata-test")
+                .registry(registryConfig)
+                .service(serviceConfig)
+                .metadataReport(metadataReportConfig);
+
+        dubboBootstrap.start();
+
+        Assert.assertTrue(dubboBootstrap.isInitialized());
+        Assert.assertTrue(dubboBootstrap.isStarted());
+
+        MetadataReportInstance metadataReportInstance = applicationModel.getBeanFactory().getBean(MetadataReportInstance.class);
+        Assert.assertNotNull(metadataReportInstance);
+        Map<String, MetadataReport> metadataReports = metadataReportInstance.getMetadataReports(true);
+        Assert.assertNotNull(metadataReports);
+        Assert.assertEquals(0, metadataReports.size());
+        applicationModel.destroy();
+    }
+
+    @Test
+    public void test4() {
+        ApplicationModel applicationModel = FrameworkModel.defaultModel().newApplication();
+
+        ServiceConfig<DemoService> serviceConfig = new ServiceConfig<>();
+        serviceConfig.setInterface(DemoService.class);
+        serviceConfig.setRef(new DemoServiceImpl());
+
+        RegistryConfig registryConfig = new RegistryConfig();
+        registryConfig.setAddress("zookeeper://" + System.getProperty("zookeeper.address", "127.0.0.1") + ":2181");
+        registryConfig.setUseAsMetadataCenter(false);
+
+        MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
+        metadataReportConfig.setAddress("10.0.0.0");
+
+        DubboBootstrap dubboBootstrap = DubboBootstrap.getInstance(applicationModel);
+        dubboBootstrap.application("metadata-test")
+                .registry(registryConfig)
+                .service(serviceConfig)
+                .metadataReport(metadataReportConfig);
+
+        try {
+            dubboBootstrap.start();
+            Assert.fail();
+        } catch (IllegalArgumentException e) {
+            Assert.assertTrue(e.getMessage().contains("Please specify valid protocol or address for metadata report"));
+        }
+
+        applicationModel.destroy();
+    }
+
+    @Test
+    public void test5() {
+        ApplicationModel applicationModel = FrameworkModel.defaultModel().newApplication();
+
+        ServiceConfig<DemoService> serviceConfig = new ServiceConfig<>();
+        serviceConfig.setInterface(DemoService.class);
+        serviceConfig.setRef(new DemoServiceImpl());
+
+        RegistryConfig registryConfig = new RegistryConfig();
+        registryConfig.setAddress("zookeeper://" + System.getProperty("zookeeper.address", "127.0.0.1") + ":2181");
+        registryConfig.setUseAsMetadataCenter(false);
+
+        MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
+        metadataReportConfig.setAddress("10.0.0.0");
+        metadataReportConfig.setReportMetadata(false);
+        metadataReportConfig.setReportDefinition(false);
+
+        DubboBootstrap dubboBootstrap = DubboBootstrap.getInstance(applicationModel);
+        dubboBootstrap.application("metadata-test")
+                .registry(registryConfig)
+                .service(serviceConfig)
+                .metadataReport(metadataReportConfig);
+
+        dubboBootstrap.start();
+
+        Assert.assertTrue(dubboBootstrap.isInitialized());
+        Assert.assertTrue(dubboBootstrap.isStarted());
+
+        MetadataReportInstance metadataReportInstance = applicationModel.getBeanFactory().getBean(MetadataReportInstance.class);
+        Assert.assertNotNull(metadataReportInstance);
+        Map<String, MetadataReport> metadataReports = metadataReportInstance.getMetadataReports(true);
+        Assert.assertNotNull(metadataReports);
+        Assert.assertEquals(0, metadataReports.size());
+        applicationModel.destroy();
+    }
+
+    @Test
+    public void test6() {
+        ApplicationModel applicationModel = FrameworkModel.defaultModel().newApplication();
+
+        ServiceConfig<DemoService> serviceConfig = new ServiceConfig<>();
+        serviceConfig.setInterface(DemoService.class);
+        serviceConfig.setRef(new DemoServiceImpl());
+
+        RegistryConfig registryConfig = new RegistryConfig();
+        registryConfig.setAddress("zookeeper://" + System.getProperty("zookeeper.address", "127.0.0.1") + ":2181");
+
+        MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
+        metadataReportConfig.setCycleReport(false);
+
+        DubboBootstrap dubboBootstrap = DubboBootstrap.getInstance(applicationModel);
+        dubboBootstrap.application("metadata-test")
+                .registry(registryConfig)
+                .service(serviceConfig)
+                .metadataReport(metadataReportConfig);
+
+        dubboBootstrap.start();
+
+        Assert.assertTrue(dubboBootstrap.isInitialized());
+        Assert.assertTrue(dubboBootstrap.isStarted());
+
+        MetadataReportInstance metadataReportInstance = applicationModel.getBeanFactory().getBean(MetadataReportInstance.class);
+        Assert.assertNotNull(metadataReportInstance);
+        Map<String, MetadataReport> metadataReports = metadataReportInstance.getMetadataReports(true);
+        Assert.assertNotNull(metadataReports);
+        Assert.assertEquals(1, metadataReports.size());
+        AbstractMetadataReport report = (AbstractMetadataReport) metadataReports.entrySet().iterator().next().getValue();
+        Assert.assertFalse(report.getUrl().getParameter("cycle-report", true));
+        applicationModel.destroy();
+    }
+
+    @Test
+    public void test7() {
+        ApplicationModel applicationModel = FrameworkModel.defaultModel().newApplication();
+
+        ServiceConfig<DemoService> serviceConfig = new ServiceConfig<>();
+        serviceConfig.setInterface(DemoService.class);
+        serviceConfig.setRef(new DemoServiceImpl());
+
+        RegistryConfig registryConfig = new RegistryConfig();
+        registryConfig.setAddress("zookeeper://" + System.getProperty("zookeeper.address", "127.0.0.1") + ":2181");
+
+        MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
+        metadataReportConfig.setReportMetadata(false);
+
+        DubboBootstrap dubboBootstrap = DubboBootstrap.getInstance(applicationModel);
+        dubboBootstrap.application("metadata-test")
+                .registry(registryConfig)
+                .service(serviceConfig)
+                .metadataReport(metadataReportConfig);
+
+        dubboBootstrap.start();
+
+        Assert.assertTrue(dubboBootstrap.isInitialized());
+        Assert.assertTrue(dubboBootstrap.isStarted());
+
+        MetadataReportInstance metadataReportInstance = applicationModel.getBeanFactory().getBean(MetadataReportInstance.class);
+        Assert.assertNotNull(metadataReportInstance);
+        Map<String, MetadataReport> metadataReports = metadataReportInstance.getMetadataReports(true);
+        Assert.assertNotNull(metadataReports);
+        Assert.assertEquals(1, metadataReports.size());
+        AbstractMetadataReport report = (AbstractMetadataReport) metadataReports.entrySet().iterator().next().getValue();
+        Assert.assertFalse(report.shouldReportMetadata());
+        applicationModel.destroy();
+    }
+}
diff --git a/99-integration/dubbo-samples-test-9806/case-configuration.yml b/99-integration/dubbo-samples-test-9806/case-configuration.yml
new file mode 100644
index 00000000..77a72d4b
--- /dev/null
+++ b/99-integration/dubbo-samples-test-9806/case-configuration.yml
@@ -0,0 +1,33 @@
+# 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.
+
+
+# local call through injvm, start test container only
+services:
+  zookeeper:
+    image: zookeeper:latest
+
+  dubbo-samples-test-9806-test:
+    type: test
+    basedir: .
+    tests:
+      - "**/*IT.class"
+    systemProps:
+      - zookeeper.address=zookeeper
+    waitPortsBeforeRun:
+      - zookeeper:2181
+    depends_on:
+      - zookeeper
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-test-9806/case-versions.conf b/99-integration/dubbo-samples-test-9806/case-versions.conf
new file mode 100644
index 00000000..901e42fb
--- /dev/null
+++ b/99-integration/dubbo-samples-test-9806/case-versions.conf
@@ -0,0 +1,24 @@
+#
+#
+#   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.
+#
+
+
+# Supported component versions of the test case
+
+# Spring app
+dubbo.version=[ >= 3.1.0 ]
+spring.version=4.*, 5.*
diff --git a/99-integration/dubbo-samples-test-9806/pom.xml b/99-integration/dubbo-samples-test-9806/pom.xml
new file mode 100644
index 00000000..a75bbd11
--- /dev/null
+++ b/99-integration/dubbo-samples-test-9806/pom.xml
@@ -0,0 +1,126 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache</groupId>
+        <artifactId>apache</artifactId>
+        <version>23</version>
+        <relativePath/>
+    </parent>
+
+    <groupId>org.apache.dubbo</groupId>
+    <artifactId>dubbo-samples-test-9806</artifactId>
+
+    <name>Dubbo Samples Test For Issue 9806</name>
+    <description>Dubbo Samples Test For Issue 9806</description>
+    <version>1.0-SNAPSHOT</version>
+
+    <properties>
+        <source.level>1.8</source.level>
+        <target.level>1.8</target.level>
+        <dubbo.version>3.1.3</dubbo.version>
+        <spring.version>4.3.16.RELEASE</spring.version>
+        <junit.version>4.12</junit.version>
+        <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+    </properties>
+
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring-framework-bom</artifactId>
+                <version>${spring.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.dubbo</groupId>
+                <artifactId>dubbo-bom</artifactId>
+                <version>${dubbo.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.dubbo</groupId>
+                <artifactId>dubbo-dependencies-zookeeper</artifactId>
+                <version>${dubbo.version}</version>
+                <type>pom</type>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo</artifactId>
+        </dependency>
+
+        <dependency>
+            <groupId>org.apache.dubbo</groupId>
+            <artifactId>dubbo-dependencies-zookeeper</artifactId>
+            <type>pom</type>
+        </dependency>
+
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework</groupId>
+            <artifactId>spring-test</artifactId>
+            <scope>test</scope>
+        </dependency>
+    </dependencies>
+
+    <profiles>
+        <!-- For jdk 11 above JavaEE annotation -->
+        <profile>
+            <id>javax.annotation</id>
+            <activation>
+                <jdk>[1.11,)</jdk>
+            </activation>
+            <dependencies>
+                <dependency>
+                    <groupId>javax.annotation</groupId>
+                    <artifactId>javax.annotation-api</artifactId>
+                    <version>1.3.2</version>
+                </dependency>
+            </dependencies>
+        </profile>
+    </profiles>
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.apache.maven.plugins</groupId>
+                <artifactId>maven-compiler-plugin</artifactId>
+                <version>${maven-compiler-plugin.version}</version>
+                <configuration>
+                    <source>${source.level}</source>
+                    <target>${target.level}</target>
+                </configuration>
+            </plugin>
+        </plugins>
+    </build>
+</project>
\ No newline at end of file
diff --git a/99-integration/dubbo-samples-test-9806/src/main/java/org/apache/dubbo/samples/FakeMain.java b/99-integration/dubbo-samples-test-9806/src/main/java/org/apache/dubbo/samples/FakeMain.java
new file mode 100644
index 00000000..acd29c76
--- /dev/null
+++ b/99-integration/dubbo-samples-test-9806/src/main/java/org/apache/dubbo/samples/FakeMain.java
@@ -0,0 +1,25 @@
+/*
+ *
+ *   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.samples;
+
+public class FakeMain {
+    public static void main(String[] args) {
+
+    }
+}
diff --git a/99-integration/dubbo-samples-test-9806/src/test/java/org/apache/dubbo/samples/test/DemoService.java b/99-integration/dubbo-samples-test-9806/src/test/java/org/apache/dubbo/samples/test/DemoService.java
new file mode 100644
index 00000000..d61f54ab
--- /dev/null
+++ b/99-integration/dubbo-samples-test-9806/src/test/java/org/apache/dubbo/samples/test/DemoService.java
@@ -0,0 +1,26 @@
+/*
+ *
+ *   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.samples.test;
+
+public interface DemoService {
+
+    String sayHello(String name);
+
+}
diff --git a/99-integration/dubbo-samples-test-9806/src/test/java/org/apache/dubbo/samples/test/DemoServiceImpl.java b/99-integration/dubbo-samples-test-9806/src/test/java/org/apache/dubbo/samples/test/DemoServiceImpl.java
new file mode 100644
index 00000000..d5489f66
--- /dev/null
+++ b/99-integration/dubbo-samples-test-9806/src/test/java/org/apache/dubbo/samples/test/DemoServiceImpl.java
@@ -0,0 +1,29 @@
+/*
+ *
+ *   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.samples.test;
+
+public class DemoServiceImpl implements DemoService {
+
+    @Override
+    public String sayHello(String name) {
+        return "Hello " + name;
+    }
+
+}
diff --git a/99-integration/dubbo-samples-test-9806/src/test/java/org/apache/dubbo/samples/test/MetadataIT.java b/99-integration/dubbo-samples-test-9806/src/test/java/org/apache/dubbo/samples/test/MetadataIT.java
new file mode 100644
index 00000000..5c9ea365
--- /dev/null
+++ b/99-integration/dubbo-samples-test-9806/src/test/java/org/apache/dubbo/samples/test/MetadataIT.java
@@ -0,0 +1,139 @@
+/*
+ *
+ *   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.samples.test;
+
+import org.apache.dubbo.config.MetadataReportConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.ServiceConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.metadata.report.MetadataReport;
+import org.apache.dubbo.metadata.report.MetadataReportInstance;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.FrameworkModel;
+
+import org.junit.Assert;
+import org.junit.Test;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MetadataIT {
+
+    @Test
+    public void test1() {
+        ApplicationModel applicationModel = FrameworkModel.defaultModel().newApplication();
+
+        ServiceConfig<DemoService> serviceConfig = new ServiceConfig<>();
+        serviceConfig.setInterface(DemoService.class);
+        serviceConfig.setRef(new DemoServiceImpl());
+
+        RegistryConfig registryConfig = new RegistryConfig();
+        registryConfig.setAddress("zookeeper://" + System.getProperty("zookeeper.address", "127.0.0.1") + ":2181");
+        registryConfig.setUseAsMetadataCenter(false);
+
+        MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
+        metadataReportConfig.setAddress(System.getProperty("zookeeper.address", "127.0.0.1"));
+        metadataReportConfig.setPort(Integer.parseInt(System.getProperty("zookeeper.port", "2181")));
+        metadataReportConfig.setProtocol("zookeeper");
+
+        DubboBootstrap dubboBootstrap = DubboBootstrap.getInstance(applicationModel);
+        dubboBootstrap.application("metadata-test")
+                .registry(registryConfig)
+                .service(serviceConfig)
+                .metadataReport(metadataReportConfig);
+        dubboBootstrap.start();
+
+        Assert.assertTrue(dubboBootstrap.isInitialized());
+        Assert.assertTrue(dubboBootstrap.isStarted());
+
+        MetadataReportInstance metadataReportInstance = applicationModel.getBeanFactory().getBean(MetadataReportInstance.class);
+        Assert.assertNotNull(metadataReportInstance);
+        Map<String, MetadataReport> metadataReports = metadataReportInstance.getMetadataReports(true);
+        Assert.assertNotNull(metadataReports);
+        Assert.assertEquals(1, metadataReports.size());
+        applicationModel.destroy();
+    }
+
+    @Test
+    public void test2() {
+        ApplicationModel applicationModel = FrameworkModel.defaultModel().newApplication();
+
+        ServiceConfig<DemoService> serviceConfig = new ServiceConfig<>();
+        serviceConfig.setInterface(DemoService.class);
+        serviceConfig.setRef(new DemoServiceImpl());
+
+        RegistryConfig registryConfig = new RegistryConfig();
+        registryConfig.setAddress("zookeeper://" + System.getProperty("zookeeper.address", "127.0.0.1") + ":2181");
+        registryConfig.setUseAsMetadataCenter(false);
+
+        MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
+        metadataReportConfig.setAddress(System.getProperty("zookeeper.address", "127.0.0.1"));
+        metadataReportConfig.setPort(Integer.parseInt(System.getProperty("zookeeper.port", "2181")));
+
+        DubboBootstrap dubboBootstrap = DubboBootstrap.getInstance(applicationModel);
+        dubboBootstrap.application("metadata-test")
+                .registry(registryConfig)
+                .service(serviceConfig)
+                .metadataReport(metadataReportConfig);
+
+        try {
+            dubboBootstrap.start();
+            Assert.fail();
+        } catch (IllegalArgumentException e) {
+            Assert.assertTrue(e.getMessage().contains("Please specify valid protocol or address for metadata report"));
+        }
+
+        applicationModel.destroy();
+    }
+
+    @Test
+    public void test3() {
+        ApplicationModel applicationModel = FrameworkModel.defaultModel().newApplication();
+
+        ServiceConfig<DemoService> serviceConfig = new ServiceConfig<>();
+        serviceConfig.setInterface(DemoService.class);
+        serviceConfig.setRef(new DemoServiceImpl());
+
+        RegistryConfig registryConfig = new RegistryConfig();
+        registryConfig.setAddress("zookeeper://" + System.getProperty("zookeeper.address", "127.0.0.1") + ":2181");
+        registryConfig.setUseAsMetadataCenter(false);
+
+        MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
+        metadataReportConfig.setAddress(System.getProperty("zookeeper.address", "127.0.0.1"));
+        metadataReportConfig.setPort(2183);
+        metadataReportConfig.setProtocol("zookeeper");
+        metadataReportConfig.setParameters(new HashMap<>());
+        metadataReportConfig.getParameters().put("timeout", "1000");
+
+        DubboBootstrap dubboBootstrap = DubboBootstrap.getInstance(applicationModel);
+        dubboBootstrap.application("metadata-test")
+                .registry(registryConfig)
+                .service(serviceConfig)
+                .metadataReport(metadataReportConfig);
+
+        try {
+            dubboBootstrap.start();
+            Assert.fail();
+        } catch (IllegalStateException e) {
+            Assert.assertTrue(e.getMessage().contains("zookeeper not connected"));
+        }
+
+        applicationModel.destroy();
+    }
+}
diff --git a/99-integration/pom.xml b/99-integration/pom.xml
index 2338f1b6..ed019a25 100644
--- a/99-integration/pom.xml
+++ b/99-integration/pom.xml
@@ -40,6 +40,8 @@
         <module>dubbo-samples-sd-merge</module>
         <module>dubbo-samples-sd-version</module>
         <module>dubbo-samples-switch-serialization-thread</module>
+        <module>dubbo-samples-test-9806</module>
         <module>dubbo-samples-test-10704</module>
+        <module>dubbo-samples-test-11096</module>
     </modules>
 </project>
\ No newline at end of file


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