You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by il...@apache.org on 2019/06/27 05:55:26 UTC

[dubbo-samples] branch master updated: integration test for dubbo-samples-metadata-report-local-annotaion

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 b458d0c  integration test for dubbo-samples-metadata-report-local-annotaion
b458d0c is described below

commit b458d0c8f9f21a8ad27b62b3a23fc90b412b5550
Author: Ian Luo <ia...@gmail.com>
AuthorDate: Thu Jun 27 13:54:16 2019 +0800

    integration test for dubbo-samples-metadata-report-local-annotaion
---
 .../pom.xml                                        | 391 +++++++--------------
 .../MetadataLocalAnnotationConsumer.java           |  31 +-
 .../MetadataLocalAnnotationProvider.java           |  41 +--
 .../metadatareport/local/annotation/ZKClean.java   |  45 ---
 .../metadatareport/local/annotation/ZkUtil.java    |  72 ++--
 .../local/annotation/action/AnnotationAction.java  |   4 +-
 .../local/annotation/api/AnnotationService.java    |   3 -
 .../annotation/impl/AnnotationServiceImpl.java     |   5 +-
 .../resources/spring/dubbo-consumer.properties     |   8 +-
 .../resources/spring/dubbo-provider.properties     |   8 +-
 .../local/annotation/MetadataIT.java               | 164 +++++++++
 11 files changed, 385 insertions(+), 387 deletions(-)

diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/pom.xml b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/pom.xml
index bf1ecdc..40c4315 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/pom.xml
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/pom.xml
@@ -30,295 +30,176 @@
     <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.annotation.MetadataLocalAnnotationProvider</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-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/MetadataLocalAnnotationConsumer.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/MetadataLocalAnnotationConsumer.java
index 6e4521f..163de59 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/MetadataLocalAnnotationConsumer.java
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/MetadataLocalAnnotationConsumer.java
@@ -19,38 +19,30 @@
 
 package org.apache.dubbo.samples.metadatareport.local.annotation;
 
-import org.apache.dubbo.common.Constants;
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.constants.CommonConstants;
 import org.apache.dubbo.config.MetadataReportConfig;
 import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-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.annotation.action.AnnotationAction;
 import org.apache.dubbo.samples.metadatareport.local.annotation.api.AnnotationService;
+
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.ComponentScan;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.PropertySource;
 
-/**
- * CallbackConsumer
- */
 public class MetadataLocalAnnotationConsumer {
 
     public static void main(String[] args) throws Exception {
         AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
         context.start();
 
-        // get service data(consumer) from zookeeper.
         printServiceData();
 
-        final AnnotationAction annotationAction = (AnnotationAction) context.getBean("annotationAction");
+        AnnotationAction annotationAction = context.getBean("annotationAction", AnnotationAction.class);
         String hello = annotationAction.doSayHello("world");
         System.out.println("result :" + hello);
-        System.in.read();
     }
 
     @Configuration
@@ -58,22 +50,23 @@ public class MetadataLocalAnnotationConsumer {
     @PropertySource("classpath:/spring/dubbo-consumer.properties")
     @ComponentScan(value = {"org.apache.dubbo.samples.metadatareport.local.annotation.action"})
     static public class ConsumerConfiguration {
+        @Value("zookeeper://${zookeeper.address:127.0.0.1}:2181")
+        private String zookeeperAddress;
+
         @Bean
         public MetadataReportConfig metadataReportConfig() {
             MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
-            metadataReportConfig.setAddress("zookeeper://127.0.0.1:2181");
+            metadataReportConfig.setAddress(zookeeperAddress);
             return metadataReportConfig;
         }
     }
 
-    private static void printServiceData() throws InterruptedException {
-        // get service data(consumer) 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(AnnotationService.class.getName(), "1.1.8", "d-test", Constants.CONSUMER_SIDE, "metadatareport-local-annotaion-consumer")));
         System.out.println("*********************************************************");
-        System.out.println("Dubbo store consumer param into special store(as zk,redis)  when local annotation:");
-        System.out.println(data);
+        System.out.println("service metadata:");
+        System.out.println(ZkUtil.getMetadata("/dubbo", AnnotationService.class.getName(), "1.1.8", "d-test",
+                CommonConstants.CONSUMER_SIDE, "metadatareport-local-annotation-consumer"));
         System.out.println("*********************************************************");
     }
 }
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/MetadataLocalAnnotationProvider.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/MetadataLocalAnnotationProvider.java
index de7ba8b..95af793 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/MetadataLocalAnnotationProvider.java
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/MetadataLocalAnnotationProvider.java
@@ -20,65 +20,62 @@
 package org.apache.dubbo.samples.metadatareport.local.annotation;
 
 
-import org.apache.dubbo.common.Constants;
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionLoader;
+import org.apache.dubbo.common.constants.CommonConstants;
 import org.apache.dubbo.config.MetadataReportConfig;
 import org.apache.dubbo.config.ProviderConfig;
 import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-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.annotation.api.AnnotationService;
+
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.AnnotationConfigApplicationContext;
 import org.springframework.context.annotation.Bean;
 import org.springframework.context.annotation.Configuration;
 import org.springframework.context.annotation.PropertySource;
 
-/**
- *
- */
+import java.util.concurrent.CountDownLatch;
+
 public class MetadataLocalAnnotationProvider {
 
     public static void main(String[] args) throws Exception {
-        EmbeddedZooKeeper embeddedZooKeeper = new EmbeddedZooKeeper(2181, false);
-        embeddedZooKeeper.start();
+        new EmbeddedZooKeeper(2181, false).start();
 
         AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ProviderConfiguration.class);
         context.start();
-        // get service data(provider) from zookeeper .
+
         printServiceData();
-        System.in.read();
-        embeddedZooKeeper.stop();
+
+        System.out.println("dubbo service started");
+        new CountDownLatch(1).await();
     }
 
     @Configuration
     @EnableDubbo(scanBasePackages = "org.apache.dubbo.samples.metadatareport.local.annotation.impl")
     @PropertySource("classpath:/spring/dubbo-provider.properties")
     static public class ProviderConfiguration {
+        @Value("zookeeper://${zookeeper.address:127.0.0.1}:2181")
+        private String zookeeperAddress;
+
         @Bean
         public ProviderConfig providerConfig() {
             ProviderConfig providerConfig = new ProviderConfig();
             providerConfig.setTimeout(1000);
             return providerConfig;
         }
+
         @Bean
         public MetadataReportConfig metadataReportConfig() {
             MetadataReportConfig metadataReportConfig = new MetadataReportConfig();
-            metadataReportConfig.setAddress("zookeeper://127.0.0.1:2181");
+            metadataReportConfig.setAddress(zookeeperAddress);
             return metadataReportConfig;
         }
     }
 
-    private static void printServiceData() throws InterruptedException {
-        // get service data(provider) from zookeeper .
-        // async store
+    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(AnnotationService.class.getName(), "1.1.8", "d-test", Constants.PROVIDER_SIDE, "metadatareport-local-annotaion-provider")));
         System.out.println("*********************************************************");
-        System.out.println("Dubbo store metadata into special store(as zk,redis) when local annotation:");
-        System.out.println(data);
+        System.out.println("service metadata:");
+        System.out.println(ZkUtil.getMetadata("/dubbo", AnnotationService.class.getName(), "1.1.8", "d-test",
+                CommonConstants.PROVIDER_SIDE, "metadatareport-local-annotaion-provider"));
         System.out.println("*********************************************************");
     }
 
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/ZKClean.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/ZKClean.java
deleted file mode 100644
index 1f3d9ff..0000000
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/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.annotation;
-
-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-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/ZkUtil.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/ZkUtil.java
index 41a1f77..44f7a26 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/ZkUtil.java
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/ZkUtil.java
@@ -1,39 +1,65 @@
 /*
+ * 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.annotation;
 
-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 version, String group,
+                                     String side, String app) throws Exception {
+        String path = getNodePath(root, new MetadataIdentifier(serviceInterface, version, group, 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-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/action/AnnotationAction.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/action/AnnotationAction.java
index 858f73e..a24a8cd 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/action/AnnotationAction.java
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/action/AnnotationAction.java
@@ -21,11 +21,9 @@ package org.apache.dubbo.samples.metadatareport.local.annotation.action;
 
 import org.apache.dubbo.config.annotation.Reference;
 import org.apache.dubbo.samples.metadatareport.local.annotation.api.AnnotationService;
+
 import org.springframework.stereotype.Component;
 
-/**
- * AnnotationAction
- */
 @Component("annotationAction")
 public class AnnotationAction {
 
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/api/AnnotationService.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/api/AnnotationService.java
index bf82352..65910e8 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/api/AnnotationService.java
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/api/AnnotationService.java
@@ -19,9 +19,6 @@
 
 package org.apache.dubbo.samples.metadatareport.local.annotation.api;
 
-/**
- * AsyncService
- */
 public interface AnnotationService {
 
     String sayHello(String name);
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/impl/AnnotationServiceImpl.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/impl/AnnotationServiceImpl.java
index 569fde1..3f41bd5 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/impl/AnnotationServiceImpl.java
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/java/org/apache/dubbo/samples/metadatareport/local/annotation/impl/AnnotationServiceImpl.java
@@ -22,15 +22,12 @@ package org.apache.dubbo.samples.metadatareport.local.annotation.impl;
 import org.apache.dubbo.config.annotation.Service;
 import org.apache.dubbo.samples.metadatareport.local.annotation.api.AnnotationService;
 
-/**
- * AsyncServiceImpl
- */
 @Service(version = "1.1.8", group = "d-test")
 public class AnnotationServiceImpl implements AnnotationService {
 
     @Override
     public String sayHello(String name) {
-        System.out.println("async provider received: " + name);
+        System.out.println("received: " + name);
         return "annotation: hello, " + name;
     }
 
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/resources/spring/dubbo-consumer.properties b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/resources/spring/dubbo-consumer.properties
index 6a589aa..09442d2 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/resources/spring/dubbo-consumer.properties
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/resources/spring/dubbo-consumer.properties
@@ -16,9 +16,5 @@
 #   limitations under the License.
 #
 #
-dubbo.registry.address=zookeeper://127.0.0.1:2181
-dubbo.application.name=metadatareport-local-annotaion-consumer
-# The common part, for example registry, protocol can be stored under the global group in ConfigCenter
-#dubbo.registry.address=zookeeper://127.0.0.1:2181
-# The application specific part, can be stored under the app group in the ConfigCenter
-#dubbo.consumer.timeout=3000
+dubbo.registry.address=zookeeper://${zookeeper.address:127.0.0.1}:2181
+dubbo.application.name=metadatareport-local-annotation-consumer
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/resources/spring/dubbo-provider.properties b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/resources/spring/dubbo-provider.properties
index 185798c..8b9f0fb 100644
--- a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/resources/spring/dubbo-provider.properties
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/main/resources/spring/dubbo-provider.properties
@@ -17,10 +17,4 @@
 #
 #
 dubbo.application.name=metadatareport-local-annotaion-provider
-dubbo.registry.address=zookeeper://127.0.0.1:2181
-
-# The common part, for example registry, protocol can be stored under the global group in ConfigCenter
-# The application specific part, can be stored under the app group in the ConfigCenter
-#dubbo.registry.address=zookeeper://127.0.0.1:2181
-#dubbo.protocol.name=dubbo
-#dubbo.protocol.port=20880
+dubbo.registry.address=zookeeper://${zookeeper.address:127.0.0.1}:2181
diff --git a/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/test/java/org/apache/dubbo/samples/metadatareport/local/annotation/MetadataIT.java b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/test/java/org/apache/dubbo/samples/metadatareport/local/annotation/MetadataIT.java
new file mode 100644
index 0000000..cf22e07
--- /dev/null
+++ b/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/src/test/java/org/apache/dubbo/samples/metadatareport/local/annotation/MetadataIT.java
@@ -0,0 +1,164 @@
+/*
+ * 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.annotation;
+
+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.annotation.action.AnnotationAction;
+import org.apache.dubbo.samples.metadatareport.local.annotation.api.AnnotationService;
+
+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(classes = {MetadataLocalAnnotationConsumer.ConsumerConfiguration.class})
+public class MetadataIT {
+    @Autowired
+    private AnnotationAction action;
+
+    @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.annotation.api.AnnotationService",
+     *     "version": "1.1.8",
+     *     "timeout": "1000",
+     *     "generic": "false",
+     *     "revision": "1.1.8",
+     *     "application": "metadatareport-local-annotaion-provider",
+     *     "dynamic": "true",
+     *     "register": "true",
+     *     "bean.name": "ServiceBean:org.apache.dubbo.samples.metadatareport.local.annotation.api.AnnotationService:1.1.8:d-test",
+     *     "group": "d-test",
+     *     "anyhost": "true"
+     *   },
+     *   "canonicalName": "org.apache.dubbo.samples.metadatareport.local.annotation.api.AnnotationService",
+     *   "codeSource": "file:/github/dubbo/incubator-dubbo-samples/dubbo-samples-metadata-report/dubbo-samples-metadata-report-local-annotaion/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", AnnotationService.class.getName(), "1.1.8", "d-test",
+                CommonConstants.PROVIDER_SIDE, "metadatareport-local-annotaion-provider");
+        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("1000", parameters.get("timeout"));
+        Assert.assertEquals("1.1.8", parameters.get("version"));
+        Assert.assertEquals("d-test", parameters.get("group"));
+        Assert.assertEquals(AnnotationService.class.getCanonicalName(), parameters.get("interface"));
+        Assert.assertEquals("false", parameters.get("generic"));
+        Assert.assertEquals("metadatareport-local-annotaion-provider", parameters.get("application"));
+        Assert.assertEquals("true", parameters.get("dynamic"));
+        Assert.assertEquals("true", parameters.get("register"));
+        Assert.assertEquals("true", parameters.get("anyhost"));
+        Assert.assertEquals(AnnotationService.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-annotation-consumer",
+     *   "release": "2.7.2",
+     *   "methods": "sayHello",
+     *   "lazy": "false",
+     *   "sticky": "false",
+     *   "dubbo": "2.0.2",
+     *   "interface": "org.apache.dubbo.samples.metadatareport.local.annotation.api.AnnotationService",
+     *   "version": "1.1.8",
+     *   "revision": "1.1.8",
+     *   "group": "d-test"
+     * }
+     * </pre>
+     */
+    @Test
+    public void testConsumerMetadata() throws Exception {
+        String result = ZkUtil.getMetadata("/dubbo", AnnotationService.class.getName(), "1.1.8", "d-test",
+                CommonConstants.CONSUMER_SIDE, "metadatareport-local-annotation-consumer");
+        Gson gson = new Gson();
+        Map<String, String> map = gson.fromJson(result, Map.class);
+        Assert.assertEquals("consumer", map.get("side"));
+        Assert.assertEquals("metadatareport-local-annotation-consumer", map.get("application"));
+        Assert.assertEquals("sayHello", map.get("methods"));
+        Assert.assertEquals("false", map.get("lazy"));
+        Assert.assertEquals("false", map.get("sticky"));
+        Assert.assertEquals("1.1.8", map.get("version"));
+        Assert.assertEquals("d-test", map.get("group"));
+        Assert.assertEquals(AnnotationService.class.getName(), map.get("interface"));
+    }
+}


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