dubbo-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From i...@apache.org
Subject [dubbo-samples] branch master updated: integration test for dubbo-samples-metadata-report-local-properties
Date Thu, 27 Jun 2019 05:04:51 GMT
This is an automated email from the ASF dual-hosted git repository.

iluo 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 cf43c00  integration test for dubbo-samples-metadata-report-local-properties
cf43c00 is described below

commit cf43c00af50ce6c595297f13779d9689feb6c6c0
Author: Ian Luo <ian.luo@gmail.com>
AuthorDate: Thu Jun 27 13:03:33 2019 +0800

    integration test for dubbo-samples-metadata-report-local-properties
---
 .../pom.xml                                        | 392 +++++++--------------
 ...r.java => MetadataLocalPropertiesConsumer.java} |  33 +-
 ...r.java => MetadataLocalPropertiesProvider.java} |  33 +-
 .../MetadataLocalpropertiesConsumer.java           |  64 ----
 .../metadatareport/local/properties/ZKClean.java   |  45 ---
 .../metadatareport/local/properties/ZkUtil.java    |  71 ++--
 .../local/properties/impl/DemoServiceImpl.java     |   4 +-
 .../META-INF/spring/metadata-consumer.xml          |  34 --
 .../META-INF/spring/metadata-provider.xml          |  36 --
 .../main/resources/spring/metadata-consumer.xml    |  32 ++
 .../main/resources/spring/metadata-provider.xml    |  33 ++
 .../local/properties/MetadataIT.java               | 152 ++++++++
 12 files changed, 431 insertions(+), 498 deletions(-)

diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/pom.xml b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/pom.xml
index b10693c..b715f55 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/pom.xml
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/pom.xml
@@ -30,295 +30,177 @@
     <properties>
         <source.level>1.8</source.level>
         <target.level>1.8</target.level>
+        <dubbo.version>2.7.2</dubbo.version>
         <spring.version>4.3.16.RELEASE</spring.version>
-        <dubbo.version>2.7.0</dubbo.version>
-        <dubbo.rpc.version>2.7.0</dubbo.rpc.version>
-        <zookeeper.version>3.4.13</zookeeper.version>
-        <curator.version>4.0.1</curator.version>
-        <validation-api.version>1.1.0.Final</validation-api.version>
-        <hibernate-validator.version>4.2.0.Final</hibernate-validator.version>
-        <resteasy.version>3.0.19.Final</resteasy.version>
-        <curator-client.version>4.0.1</curator-client.version>
-        <swagger.version>1.5.19</swagger.version>
-        <tomcat.version>7.0.88</tomcat.version>
-        <servlet.version>3.0.1</servlet.version>
-        <maven_checkstyle_version>3.0.0</maven_checkstyle_version>
-        <apache-rat-plugin.version>0.12</apache-rat-plugin.version>
-        <spring-boot.version>1.5.13.RELEASE</spring-boot.version>
+        <junit.version>4.12</junit.version>
+        <docker-maven-plugin.version>0.30.0</docker-maven-plugin.version>
+        <jib-maven-plugin.version>1.2.0</jib-maven-plugin.version>
+        <maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
+        <maven-failsafe-plugin.version>2.21.0</maven-failsafe-plugin.version>
+        <image.name>${artifactId}:${dubbo.version}</image.name>
+        <dubbo.port>20880</dubbo.port>
+        <zookeeper.port>2181</zookeeper.port>
+        <main-class>org.apache.dubbo.samples.metadatareport.local.properties.MetadataLocalPropertiesProvider
+        </main-class>
     </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>
-                <!-- Import dependency management from Spring Boot -->
-                <groupId>org.springframework.boot</groupId>
-                <artifactId>spring-boot-dependencies</artifactId>
-                <version>${spring-boot.version}</version>
-                <type>pom</type>
-                <scope>import</scope>
-            </dependency>
-            <dependency>
-                <groupId>io.netty</groupId>
-                <artifactId>netty-all</artifactId>
-                <version>4.1.16.Final</version>
-            </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</artifactId>
-                <version>${dubbo.version}</version>
-                <exclusions>
-                    <exclusion>
-                        <groupId>org.apache.thrift</groupId>
-                        <artifactId>libthrift</artifactId>
-                    </exclusion>
-                </exclusions>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.dubbo</groupId>
-                <artifactId>dubbo-rpc-rest</artifactId>
-                <version>${dubbo.rpc.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.zookeeper</groupId>
-                <artifactId>zookeeper</artifactId>
-                <version>${zookeeper.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.curator</groupId>
-                <artifactId>curator-framework</artifactId>
-                <version>${curator.version}</version>
-                <exclusions>
-                    <exclusion>
-                        <groupId>org.apache.zookeeper</groupId>
-                        <artifactId>zookeeper</artifactId>
-                    </exclusion>
-                </exclusions>
-            </dependency>
-            <dependency>
-                <groupId>javax.validation</groupId>
-                <artifactId>validation-api</artifactId>
-                <version>${validation-api.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.hibernate</groupId>
-                <artifactId>hibernate-validator</artifactId>
-                <version>${hibernate-validator.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.jboss.resteasy</groupId>
-                <artifactId>resteasy-jackson-provider</artifactId>
-                <version>${resteasy.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.curator</groupId>
-                <artifactId>curator-client</artifactId>
-                <version>${curator-client.version}</version>
-                <exclusions>
-                    <exclusion>
-                        <groupId>org.apache.zookeeper</groupId>
-                        <artifactId>zookeeper</artifactId>
-                    </exclusion>
-                </exclusions>
-            </dependency>
-            <dependency>
-                <groupId>javax.servlet</groupId>
-                <artifactId>javax.servlet-api</artifactId>
-                <version>${servlet.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.tomcat.embed</groupId>
-                <artifactId>tomcat-embed-core</artifactId>
-                <version>${tomcat.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>org.apache.tomcat.embed</groupId>
-                <artifactId>tomcat-embed-logging-juli</artifactId>
-                <version>${tomcat.version}</version>
-            </dependency>
-            <!-- swagger -->
-            <dependency>
-                <groupId>io.swagger</groupId>
-                <artifactId>swagger-annotations</artifactId>
-                <version>${swagger.version}</version>
-            </dependency>
-            <dependency>
-                <groupId>io.swagger</groupId>
-                <artifactId>swagger-jaxrs</artifactId>
-                <version>${swagger.version}</version>
-            </dependency>
-        </dependencies>
-    </dependencyManagement>
-
     <dependencies>
         <dependency>
-            <groupId>org.apache.curator</groupId>
-            <artifactId>curator-framework</artifactId>
-            <exclusions>
-                <exclusion>
-                    <groupId>io.netty</groupId>
-                    <artifactId>netty</artifactId>
-                </exclusion>
-                <exclusion>
-                    <groupId>org.apache.zookeeper</groupId>
-                    <artifactId>zookeeper</artifactId>
-                </exclusion>
-            </exclusions>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.zookeeper</groupId>
-            <artifactId>zookeeper</artifactId>
-        </dependency>
-        <dependency>
             <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo</artifactId>
+            <version>${dubbo.version}</version>
         </dependency>
+
         <dependency>
             <groupId>org.apache.dubbo</groupId>
-            <artifactId>dubbo-configcenter-zookeeper</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>io.netty</groupId>
-            <artifactId>netty-all</artifactId>
+            <artifactId>dubbo-dependencies-zookeeper</artifactId>
+            <version>${dubbo.version}</version>
+            <type>pom</type>
         </dependency>
+
         <dependency>
-            <groupId>org.slf4j</groupId>
-            <artifactId>slf4j-simple</artifactId>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>${junit.version}</version>
+            <scope>test</scope>
         </dependency>
+
         <dependency>
             <groupId>org.springframework</groupId>
-            <artifactId>spring-context</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.dubbo</groupId>
-            <artifactId>dubbo-configcenter-zookeeper</artifactId>
+            <artifactId>spring-test</artifactId>
+            <version>${spring.version}</version>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 
-    <build>
-        <pluginManagement>
-            <plugins>
-                <plugin>
-                    <groupId>org.springframework.boot</groupId>
-                    <artifactId>spring-boot-maven-plugin</artifactId>
-                    <version>${spring-boot.version}</version>
-                </plugin>
-            </plugins>
-        </pluginManagement>
-        <plugins>
-            <plugin>
-                <groupId>org.apache.maven.plugins</groupId>
-                <artifactId>maven-compiler-plugin</artifactId>
-                <version>3.7.0</version>
-                <configuration>
-                    <source>${source.level}</source>
-                    <target>${target.level}</target>
-                </configuration>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.rat</groupId>
-                <artifactId>apache-rat-plugin</artifactId>
-                <version>${apache-rat-plugin.version}</version>
-                <executions>
-                    <execution>
-                        <id>verify.rat</id>
-                        <phase>verify</phase>
-                        <goals>
-                            <goal>check</goal>
-                        </goals>
-                        <configuration>
-                            <excludes>
-                                <exclude>**/*.versionsBackup</exclude>
-                                <exclude>**/.idea/</exclude>
-                                <exclude>**/*.iml</exclude>
-                                <exclude>**/*.txt</exclude>
-                                <exclude>**/*.load</exclude>
-                                <exclude>**/*.flex</exclude>
-                                <exclude>**/*.fc</exclude>
-                                <exclude>**/*.javascript</exclude>
-                                <exclude>**/*.properties</exclude>
-                                <exclude>**/*.thrift</exclude>
-                                <exclude>**/*.sh</exclude>
-                                <exclude>**/*.bat</exclude>
-                                <exclude>**/*.md</exclude>
-                                <exclude>.git/</exclude>
-                                <exclude>.gitignore</exclude>
-                                <!-- ASF jenkins box puts the Maven repo in our root directory. -->
-                                <exclude>.repository/</exclude>
-                                <exclude>**/.settings/*</exclude>
-                                <exclude>**/.classpath</exclude>
-                                <exclude>**/.project</exclude>
-                                <exclude>**/target/**</exclude>
-                                <exclude>**/*.log</exclude>
-                                <exclude>CODE_OF_CONDUCT.md</exclude>
-                                <exclude>.codecov.yml</exclude>
-                                <exclude>.travis.yml</exclude>
-                                <exclude>PULL_REQUEST_TEMPLATE.md</exclude>
-                                <exclude>CONTRIBUTING.md</exclude>
-                                <exclude>README.md</exclude>
-                                <exclude>**/codestyle/*</exclude>
-                                <exclude>**/resources/META-INF/**</exclude>
-                                <exclude>**/webapp/swagger/**</exclude>
-                                <exclude>**/org/apache/dubbo/samples/rpc/nativethrift/api/DemoService.java</exclude>
-                            </excludes>
-                        </configuration>
-                    </execution>
-                </executions>
-            </plugin>
-        </plugins>
-    </build>
-
     <profiles>
         <profile>
-            <id>checkstyle</id>
-            <activation>
-                <jdk>[1.8,)</jdk>
-            </activation>
+            <id>dubbo-integration-test</id>
             <build>
                 <plugins>
                     <plugin>
-                        <groupId>org.apache.maven.plugins</groupId>
-                        <artifactId>maven-checkstyle-plugin</artifactId>
-                        <version>${maven_checkstyle_version}</version>
-                        <dependencies>
-                            <dependency>
-                                <groupId>com.puppycrawl.tools</groupId>
-                                <artifactId>checkstyle</artifactId>
-                                <version>8.9</version>
-                            </dependency>
-                        </dependencies>
+                        <groupId>org.apache.dubbo</groupId>
+                        <artifactId>dubbo-maven-address-plugin</artifactId>
+                        <version>1.0-SNAPSHOT</version>
                         <executions>
                             <execution>
-                                <id>checkstyle-validation</id>
-                                <phase>validate</phase>
+                                <goals>
+                                    <goal>local-address</goal>
+                                </goals>
                                 <configuration>
-                                    <configLocation>../../codestyle/checkstyle.xml</configLocation>
-                                    <suppressionsLocation>../../codestyle/checkstyle-suppressions.xml</suppressionsLocation>
-                                    <encoding>UTF-8</encoding>
-                                    <consoleOutput>true</consoleOutput>
-                                    <failOnViolation>true</failOnViolation>
+                                    <localAddress>dubbo-local-address</localAddress>
                                 </configuration>
+                                <phase>initialize</phase>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                    <plugin>
+                        <groupId>com.google.cloud.tools</groupId>
+                        <artifactId>jib-maven-plugin</artifactId>
+                        <version>${jib-maven-plugin.version}</version>
+                        <configuration>
+                            <from>
+                                <image>openjdk:8</image>
+                            </from>
+                            <to>
+                                <image>${image.name}</image>
+                            </to>
+                            <container>
+                                <mainClass>${main-class}</mainClass>
+                                <environment>
+                                    <DUBBO_IP_TO_REGISTRY>${dubbo-local-address}</DUBBO_IP_TO_REGISTRY>
+                                </environment>
+                                <jvmFlags>
+                                    <jvmFlag>-Dzookeeper.address=${dubbo-local-address}</jvmFlag>
+                                </jvmFlags>
+                            </container>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <phase>package</phase>
                                 <goals>
-                                    <goal>check</goal>
+                                    <goal>dockerBuild</goal>
                                 </goals>
                             </execution>
                         </executions>
                     </plugin>
+
+                    <plugin>
+                        <groupId>io.fabric8</groupId>
+                        <artifactId>docker-maven-plugin</artifactId>
+                        <version>${docker-maven-plugin.version}</version>
+                        <configuration>
+                            <images>
+                                <image>
+                                    <name>${image.name}</name>
+                                    <run>
+                                        <ports>
+                                            <port>${dubbo.port}:${dubbo.port}</port>
+                                            <port>${zookeeper.port}:${zookeeper.port}</port>
+                                        </ports>
+                                        <wait>
+                                            <log>dubbo service started</log>
+                                        </wait>
+                                    </run>
+                                </image>
+                            </images>
+                        </configuration>
+                        <executions>
+                            <execution>
+                                <id>start</id>
+                                <phase>pre-integration-test</phase>
+                                <goals>
+                                    <goal>start</goal>
+                                </goals>
+                            </execution>
+                            <execution>
+                                <id>stop</id>
+                                <phase>post-integration-test</phase>
+                                <goals>
+                                    <goal>stop</goal>
+                                </goals>
+                            </execution>
+                        </executions>
+                    </plugin>
+
+                    <plugin>
+                        <groupId>org.apache.maven.plugins</groupId>
+                        <artifactId>maven-failsafe-plugin</artifactId>
+                        <version>${maven-failsafe-plugin.version}</version>
+                        <executions>
+                            <execution>
+                                <goals>
+                                    <goal>integration-test</goal>
+                                    <goal>verify</goal>
+                                </goals>
+                                <configuration>
+                                    <systemPropertyVariables>
+                                        <zookeeper.address>${dubbo-local-address}</zookeeper.address>
+                                    </systemPropertyVariables>
+                                    <includes>
+                                        <include>**/*IT.java</include>
+                                    </includes>
+                                </configuration>
+                            </execution>
+                        </executions>
+                    </plugin>
                 </plugins>
             </build>
         </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>
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalpropertiesProvider.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalPropertiesConsumer.java
similarity index 53%
copy from dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalpropertiesProvider.java
copy to dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalPropertiesConsumer.java
index 8ea4eab..570e41e 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalpropertiesProvider.java
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalPropertiesConsumer.java
@@ -19,38 +19,31 @@
 
 package org.apache.dubbo.samples.metadatareport.local.properties;
 
-import org.apache.dubbo.common.Constants;
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionLoader;
-import org.apache.dubbo.metadata.identifier.MetadataIdentifier;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter;
+import org.apache.dubbo.common.constants.CommonConstants;
 import org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService;
+
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class MetadataLocalpropertiesProvider {
+public class MetadataLocalPropertiesConsumer {
 
     public static void main(String[] args) throws Exception {
-        EmbeddedZooKeeper embeddedZooKeeper = new EmbeddedZooKeeper(2181, false);
-        embeddedZooKeeper.start();
-
-        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/metadata-provider.xml"});
+        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/metadata-consumer.xml");
         context.start();
 
+        DemoService demoService = (DemoService) context.getBean("demoService");
+
         printServiceData();
-        System.in.read(); // press any key to exit
-        embeddedZooKeeper.stop();
+
+        String hello = demoService.sayHello("world");
+        System.out.println(hello);
     }
 
-    private static void printServiceData() throws InterruptedException {
-        // get service data(provider) from zookeeper .
+    private static void printServiceData() throws Exception {
         Thread.sleep(3000);
-        ZookeeperClient zookeeperClient = ExtensionLoader.getExtensionLoader(ZookeeperTransporter.class).getExtension("curator").connect(new URL("zookeeper", "127.0.0.1", 2181));
-        String data = zookeeperClient.getContent(ZkUtil.getNodePath(new MetadataIdentifier(DemoService.class.getName(), null, null, Constants.PROVIDER_SIDE, "metadatareport-local-properties-provider2")));
         System.out.println("*********************************************************");
-        System.out.println("Dubbo store metadata into special store(as zk,redis) when local xml:");
-        System.out.println(data);
+        System.out.println("service metadata:");
+        System.out.println(ZkUtil.getMetadata("/dubbo", DemoService.class.getName(), CommonConstants.CONSUMER_SIDE,
+                "metadatareport-local-properties-consumer"));
         System.out.println("*********************************************************");
     }
-
 }
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalpropertiesProvider.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalPropertiesProvider.java
similarity index 53%
rename from dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalpropertiesProvider.java
rename to dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalPropertiesProvider.java
index 8ea4eab..e7a05ee 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalpropertiesProvider.java
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalPropertiesProvider.java
@@ -19,38 +19,33 @@
 
 package org.apache.dubbo.samples.metadatareport.local.properties;
 
-import org.apache.dubbo.common.Constants;
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionLoader;
-import org.apache.dubbo.metadata.identifier.MetadataIdentifier;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter;
+import org.apache.dubbo.common.constants.CommonConstants;
 import org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService;
+
 import org.springframework.context.support.ClassPathXmlApplicationContext;
 
-public class MetadataLocalpropertiesProvider {
+import java.util.concurrent.CountDownLatch;
+
+public class MetadataLocalPropertiesProvider {
 
     public static void main(String[] args) throws Exception {
-        EmbeddedZooKeeper embeddedZooKeeper = new EmbeddedZooKeeper(2181, false);
-        embeddedZooKeeper.start();
+        new EmbeddedZooKeeper(2181, false).start();
 
-        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/metadata-provider.xml"});
+        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/metadata-provider.xml");
         context.start();
 
         printServiceData();
-        System.in.read(); // press any key to exit
-        embeddedZooKeeper.stop();
+
+        System.out.println("dubbo service started");
+        new CountDownLatch(1).await();
     }
 
-    private static void printServiceData() throws InterruptedException {
-        // get service data(provider) from zookeeper .
+    private static void printServiceData() throws Exception {
         Thread.sleep(3000);
-        ZookeeperClient zookeeperClient = ExtensionLoader.getExtensionLoader(ZookeeperTransporter.class).getExtension("curator").connect(new URL("zookeeper", "127.0.0.1", 2181));
-        String data = zookeeperClient.getContent(ZkUtil.getNodePath(new MetadataIdentifier(DemoService.class.getName(), null, null, Constants.PROVIDER_SIDE, "metadatareport-local-properties-provider2")));
         System.out.println("*********************************************************");
-        System.out.println("Dubbo store metadata into special store(as zk,redis) when local xml:");
-        System.out.println(data);
+        System.out.println("service metadata:");
+        System.out.println(ZkUtil.getMetadata("/dubbo", DemoService.class.getName(), CommonConstants.PROVIDER_SIDE,
+                "metadatareport-local-properties-provider2"));
         System.out.println("*********************************************************");
     }
-
 }
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalpropertiesConsumer.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalpropertiesConsumer.java
deleted file mode 100644
index 197cdff..0000000
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataLocalpropertiesConsumer.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- *
- *   Licensed to the Apache Software Foundation (ASF) under one or more
- *   contributor license agreements.  See the NOTICE file distributed with
- *   this work for additional information regarding copyright ownership.
- *   The ASF licenses this file to You under the Apache License, Version 2.0
- *   (the "License"); you may not use this file except in compliance with
- *   the License.  You may obtain a copy of the License at
- *
- *       http://www.apache.org/licenses/LICENSE-2.0
- *
- *   Unless required by applicable law or agreed to in writing, software
- *   distributed under the License is distributed on an "AS IS" BASIS,
- *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- *   See the License for the specific language governing permissions and
- *   limitations under the License.
- *
- */
-
-package org.apache.dubbo.samples.metadatareport.local.properties;
-
-import org.apache.dubbo.common.Constants;
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionLoader;
-import org.apache.dubbo.metadata.identifier.MetadataIdentifier;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter;
-import org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
-
-public class MetadataLocalpropertiesConsumer {
-
-    public static void main(String[] args) throws InterruptedException {
-        ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/metadata-consumer.xml"});
-        context.start();
-
-        DemoService demoService = (DemoService) context.getBean("demoService"); // get remote service proxy
-
-        printServiceData();
-
-        while (true) {
-            try {
-                Thread.sleep(1000);
-                String hello = demoService.sayHello("world"); // call remote method
-                System.out.println(hello); // get result
-
-            } catch (Throwable throwable) {
-                throwable.printStackTrace();
-            }
-        }
-
-    }
-
-    private static void printServiceData() throws InterruptedException {
-        // get service data(consumer) from zookeeper.
-        Thread.sleep(3000);
-        ZookeeperClient zookeeperClient = ExtensionLoader.getExtensionLoader(ZookeeperTransporter.class).getExtension("curator").connect(new URL("zookeeper", "127.0.0.1", 2181));
-        String data = zookeeperClient.getContent(ZkUtil.getNodePath(new MetadataIdentifier(DemoService.class.getName(), null, null, Constants.CONSUMER_SIDE, "metadatareport-local-properties-consumer")));
-        System.out.println("*********************************************************");
-        System.out.println("Dubbo store consumer param into special store(as zk,redis) when local xml:");
-        System.out.println(data);
-        System.out.println("*********************************************************");
-    }
-}
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/ZKClean.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/ZKClean.java
deleted file mode 100644
index 27241ff..0000000
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/ZKClean.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *     http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.samples.metadatareport.local.properties;
-
-import org.apache.curator.framework.CuratorFramework;
-import org.apache.curator.framework.CuratorFrameworkFactory;
-import org.apache.curator.retry.ExponentialBackoffRetry;
-
-/**
- *
- */
-public class ZKClean {
-    private static CuratorFramework client;
-
-    public static void main(String[] args) throws Exception {
-        client = CuratorFrameworkFactory.newClient("127.0.0.1:2181", 60 * 1000, 60 * 1000,
-                new ExponentialBackoffRetry(1000, 3));
-        client.start();
-
-        removeGlobalConfig();
-    }
-
-    private static void removeGlobalConfig() {
-        try {
-            client.delete().forPath("/dubbo/config/dubbo/dubbo.properties");
-        } catch (Exception e) {
-            e.printStackTrace();
-        }
-    }
-
-}
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/ZkUtil.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/ZkUtil.java
index 25aacc8..4011269 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/ZkUtil.java
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/ZkUtil.java
@@ -1,39 +1,64 @@
 /*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
  *
- *   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.
+ *     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.metadatareport.local.properties;
 
-import org.apache.dubbo.common.Constants;
 import org.apache.dubbo.metadata.identifier.MetadataIdentifier;
 
-/**
- * 2018/11/8
- */
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.ExponentialBackoffRetry;
+
+import static org.apache.dubbo.common.constants.CommonConstants.PATH_SEPARATOR;
+
 public class ZkUtil {
+    private static String zookeeperHost = System.getProperty("zookeeper.address", "127.0.0.1");
+    private static CuratorFramework client;
+
+    static {
+        initClient();
+    }
 
-    static String toRootDir(String root) {
-        if (root.equals(Constants.PATH_SEPARATOR)) {
+    public static void initClient() {
+        client = CuratorFrameworkFactory.newClient(zookeeperHost + ":2181", 60 * 1000, 60 * 1000,
+                new ExponentialBackoffRetry(1000, 3));
+        client.start();
+    }
+
+    public static String getMetadata(String root, String serviceInterface, String side, String app) throws Exception {
+        String path = getNodePath(root, new MetadataIdentifier(serviceInterface, null, null, side, app));
+        return new String(client.getData().forPath(path));
+    }
+
+    public static String getNodePath(String root, MetadataIdentifier metadataIdentifier) {
+        return toRootDir(root) + metadataIdentifier.getUniqueKey(MetadataIdentifier.KeyTypeEnum.PATH);
+    }
+
+    private static String toRootDir(String root) {
+        if (root.equals(PATH_SEPARATOR)) {
             return root;
         }
-        return root + Constants.PATH_SEPARATOR;
+        return root + PATH_SEPARATOR;
     }
 
-    public static String getNodePath(MetadataIdentifier metadataIdentifier) {
-        return toRootDir("/dubbo") + metadataIdentifier.getUniqueKey(MetadataIdentifier.KeyTypeEnum.PATH) + Constants.PATH_SEPARATOR + "service.data";
+    private static void removeGlobalConfig() {
+        try {
+            client.delete().forPath("/dubbo/config/dubbo/dubbo.properties");
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
     }
 }
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/impl/DemoServiceImpl.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/impl/DemoServiceImpl.java
index 9b79699..e87b776 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/impl/DemoServiceImpl.java
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/java/org/apache/dubbo/samples/metadatareport/local/properties/impl/DemoServiceImpl.java
@@ -30,8 +30,8 @@ public class DemoServiceImpl implements DemoService {
 
     @Override
     public String sayHello(String name) {
-        System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] Hello " + name + ", request from consumer: " + RpcContext
-                .getContext().getRemoteAddress());
+        System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] Hello " + name +
+                ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
         return "Hello " + name + ", response from provider: " + RpcContext.getContext().getLocalAddress();
     }
 
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/META-INF/spring/metadata-consumer.xml b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/META-INF/spring/metadata-consumer.xml
deleted file mode 100644
index 9aee649..0000000
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/META-INF/spring/metadata-consumer.xml
+++ /dev/null
@@ -1,34 +0,0 @@
-<?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.
-  ~
-  -->
-
-<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
-       xmlns="http://www.springframework.org/schema/beans"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
-       http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
-
-    <!-- optional -->
-    <dubbo:application name="metadatareport-local-properties-consumer"/>
-
-    <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
-
-    <dubbo:reference id="demoService" interface="org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService"/>
-
-</beans>
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/META-INF/spring/metadata-provider.xml b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/META-INF/spring/metadata-provider.xml
deleted file mode 100644
index 3b3eee9..0000000
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/META-INF/spring/metadata-provider.xml
+++ /dev/null
@@ -1,36 +0,0 @@
-<?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.
-  ~
-  -->
-
-<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
-       xmlns="http://www.springframework.org/schema/beans"
-       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
-       http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
-
-    <!-- optional -->
-    <dubbo:application name="metadatareport-local-properties-provider2"/>
-
-    <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
-
-    <bean id="demoService" class="org.apache.dubbo.samples.metadatareport.local.properties.impl.DemoServiceImpl"/>
-    <dubbo:service async="true" interface="org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService"
-                   ref="demoService"/>
-
-</beans>
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/spring/metadata-consumer.xml b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/spring/metadata-consumer.xml
new file mode 100644
index 0000000..a5cd6e6
--- /dev/null
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/spring/metadata-consumer.xml
@@ -0,0 +1,32 @@
+<?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.
+  -->
+
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+       xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+       http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+    <context:property-placeholder/>
+
+    <dubbo:application name="metadatareport-local-properties-consumer"/>
+
+    <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+
+    <dubbo:reference id="demoService"
+                     interface="org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService"/>
+</beans>
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/spring/metadata-provider.xml b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/spring/metadata-provider.xml
new file mode 100644
index 0000000..de5fa2c
--- /dev/null
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/main/resources/spring/metadata-provider.xml
@@ -0,0 +1,33 @@
+<?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.
+  -->
+
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+       xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
+       xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+       http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+    <context:property-placeholder/>
+
+    <dubbo:application name="metadatareport-local-properties-provider2"/>
+
+    <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+
+    <bean id="demoService" class="org.apache.dubbo.samples.metadatareport.local.properties.impl.DemoServiceImpl"/>
+    <dubbo:service interface="org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService"
+                   ref="demoService"/>
+</beans>
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/test/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataIT.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/test/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataIT.java
new file mode 100644
index 0000000..c06b6fc
--- /dev/null
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/src/test/java/org/apache/dubbo/samples/metadatareport/local/properties/MetadataIT.java
@@ -0,0 +1,152 @@
+/*
+ * 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.metadatareport.local.properties;
+
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.metadata.definition.model.FullServiceDefinition;
+import org.apache.dubbo.metadata.definition.model.MethodDefinition;
+import org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService;
+
+import com.google.gson.Gson;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+
+import java.util.List;
+import java.util.Map;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath:/spring/metadata-consumer.xml"})
+public class MetadataIT {
+    @Autowired
+    private DemoService demoService;
+
+    @BeforeClass
+    public static void setUp() throws Exception {
+        Thread.sleep(2000);
+    }
+
+    /**
+     * <pre>
+     * {
+     *   "parameters": {
+     *     "side": "provider",
+     *     "release": "2.7.2",
+     *     "methods": "sayHello",
+     *     "deprecated": "false",
+     *     "dubbo": "2.0.2",
+     *     "interface": "org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService",
+     *     "generic": "false",
+     *     "async": "true",
+     *     "application": "metadatareport-local-properties-provider2",
+     *     "dynamic": "true",
+     *     "register": "true",
+     *     "bean.name": "org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService",
+     *     "anyhost": "true"
+     *   },
+     *   "canonicalName": "org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService",
+     *   "codeSource": "file:/Users/iluo/github/dubbo/incubator-dubbo-samples/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-properties/target/classes/",
+     *   "methods": [
+     *     {
+     *       "name": "sayHello",
+     *       "parameterTypes": [
+     *         "java.lang.String"
+     *       ],
+     *       "returnType": "java.lang.String"
+     *     }
+     *   ],
+     *   "types": [
+     *     {
+     *       "type": "char"
+     *     },
+     *     {
+     *       "type": "int"
+     *     },
+     *     {
+     *       "type": "java.lang.String",
+     *       "properties": {
+     *         "value": {
+     *           "type": "char[]"
+     *         },
+     *         "hash": {
+     *           "type": "int"
+     *         }
+     *       }
+     *     }
+     *   ]
+     * }
+     * </pre>
+     */
+    @Test
+    public void testProviderMetadata() throws Exception {
+        String result = ZkUtil.getMetadata("/dubbo", DemoService.class.getName(), CommonConstants.PROVIDER_SIDE,
+                "metadatareport-local-properties-provider2");
+        Gson gson = new Gson();
+        FullServiceDefinition definition = gson.fromJson(result, FullServiceDefinition.class);
+        Map<String, String> parameters = definition.getParameters();
+        Assert.assertEquals("provider", parameters.get("side"));
+        Assert.assertEquals("sayHello", parameters.get("methods"));
+        Assert.assertEquals(DemoService.class.getCanonicalName(), parameters.get("interface"));
+        Assert.assertEquals("false", parameters.get("generic"));
+        Assert.assertEquals("metadatareport-local-properties-provider2", parameters.get("application"));
+        Assert.assertEquals("true", parameters.get("dynamic"));
+        Assert.assertEquals("true", parameters.get("register"));
+        Assert.assertEquals("true", parameters.get("anyhost"));
+        Assert.assertEquals(DemoService.class.getCanonicalName(), definition.getCanonicalName());
+        List<MethodDefinition> methods = definition.getMethods();
+        Assert.assertEquals(1, methods.size());
+        MethodDefinition method = methods.get(0);
+        Assert.assertEquals("sayHello", method.getName());
+        String[] parameterTypes = method.getParameterTypes();
+        Assert.assertEquals(1, parameterTypes.length);
+        Assert.assertEquals("java.lang.String", parameterTypes[0]);
+        Assert.assertEquals("java.lang.String", method.getReturnType());
+    }
+
+    /**
+     * <pre>
+     * {
+     *   "side": "consumer",
+     *   "application": "metadatareport-local-properties-consumer",
+     *   "release": "2.7.2",
+     *   "methods": "sayHello",
+     *   "lazy": "false",
+     *   "sticky": "false",
+     *   "dubbo": "2.0.2",
+     *   "interface": "org.apache.dubbo.samples.metadatareport.local.properties.api.DemoService"
+     * }
+     * </pre>
+     */
+    @Test
+    public void testConsumerMetadata() throws Exception {
+        String result = ZkUtil.getMetadata("/dubbo", DemoService.class.getName(), CommonConstants.CONSUMER_SIDE,
+                "metadatareport-local-properties-consumer");
+        Gson gson = new Gson();
+        Map<String, String> map = gson.fromJson(result, Map.class);
+        Assert.assertEquals("consumer", map.get("side"));
+        Assert.assertEquals("metadatareport-local-properties-consumer", map.get("application"));
+        Assert.assertEquals("sayHello", map.get("methods"));
+        Assert.assertEquals("false", map.get("lazy"));
+        Assert.assertEquals("false", map.get("sticky"));
+        Assert.assertEquals(DemoService.class.getName(), map.get("interface"));
+    }
+}


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


Mime
View raw message