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/07/01 08:55:12 UTC

[dubbo-samples] branch master updated: integration test for dubbo-samples-simplified-registry-annotation

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 d3fb346  integration test for dubbo-samples-simplified-registry-annotation
d3fb346 is described below

commit d3fb3461a2aa1d6cf8821b4ae6145b4f81dafeba
Author: Ian Luo <ia...@gmail.com>
AuthorDate: Mon Jul 1 16:53:45 2019 +0800

    integration test for dubbo-samples-simplified-registry-annotation
---
 .../pom.xml                                        | 395 +++++++--------------
 .../SimpleRegistryAnnotationConsumer.java          |  40 +--
 .../SimpleRegistryAnnotationProvider.java          |  47 ++-
 .../samples/simplified/annotation/ZKClean.java     |  45 ---
 .../samples/simplified/annotation/ZkUtil.java      |  71 ++--
 .../annotation/action/AnnotationAction.java        |   5 +-
 .../annotation/api/AnnotationService.java          |   3 -
 .../annotation/impl/AnnotationServiceImpl.java     |   3 -
 .../simplified/annotation/AnnotationServiceIT.java |  69 ++++
 9 files changed, 293 insertions(+), 385 deletions(-)

diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/pom.xml b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/pom.xml
index 5c433aa..9b2b2dc 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/pom.xml
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/pom.xml
@@ -29,298 +29,160 @@
 
     <artifactId>dubbo-samples-simplified-registry-annotation</artifactId>
 
-
     <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.simplified.annotation.SimpleRegistryAnnotationProvider</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>
-        </dependency>
-        <dependency>
-            <groupId>org.apache.dubbo</groupId>
-            <artifactId>dubbo-metadata-report-api</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>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>check</goal>
+                                    <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>
@@ -329,4 +191,17 @@
         </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-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/SimpleRegistryAnnotationConsumer.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/SimpleRegistryAnnotationConsumer.java
index e842b46..76e68dc 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/SimpleRegistryAnnotationConsumer.java
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/SimpleRegistryAnnotationConsumer.java
@@ -19,15 +19,12 @@
 
 package org.apache.dubbo.samples.simplified.annotation;
 
-import org.apache.dubbo.common.Constants;
 import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionLoader;
 import org.apache.dubbo.config.RegistryConfig;
 import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter;
 import org.apache.dubbo.samples.simplified.annotation.action.AnnotationAction;
 
+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;
@@ -36,22 +33,19 @@ import org.springframework.context.annotation.PropertySource;
 
 import java.util.List;
 
-/**
- * CallbackConsumer
- */
+import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
+
 public class SimpleRegistryAnnotationConsumer {
 
     public static void main(String[] args) throws Exception {
         AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext(ConsumerConfiguration.class);
         context.start();
 
-        final AnnotationAction annotationAction = (AnnotationAction) context.getBean("annotationAction");
-        // get service data(consumer) from zookeeper.
+        AnnotationAction annotationAction = context.getBean("annotationAction", AnnotationAction.class);
         printServiceData();
 
         String hello = annotationAction.doSayHello("world");
         System.out.println("result :" + hello);
-        System.in.read();
     }
 
     @Configuration
@@ -59,28 +53,30 @@ public class SimpleRegistryAnnotationConsumer {
     @PropertySource("classpath:/spring/dubbo-consumer.properties")
     @ComponentScan(value = {"org.apache.dubbo.samples.simplified.annotation.action"})
     static public class ConsumerConfiguration {
+        @Value("zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}")
+        private String zookeeperAddress;
+
         @Bean
         public RegistryConfig registryConfig() {
             RegistryConfig registryConfig = new RegistryConfig();
-            registryConfig.setAddress("zookeeper://127.0.0.1:2181");
+            registryConfig.setAddress(zookeeperAddress);
             registryConfig.setSimplified(true);
             return registryConfig;
         }
     }
 
     private static void printServiceData() {
-        ZookeeperClient zookeeperClient = ExtensionLoader.getExtensionLoader(ZookeeperTransporter.class).getExtension("curator").connect(new URL("zookeeper", "127.0.0.1", 2181));
-        List<String> urls = zookeeperClient.getChildren(ZkUtil.toUrlPath("consumers"));
+        List<String> urls = ZkUtil.getChildren(ZkUtil.toUrlPath("consumers"));
         System.out.println("*********************************************************");
-        System.out.println(urls);
-        System.out.println("simple donot contain 'retries':" + !urls.get(0).contains("retries"));
-        System.out.println("simple donot contain 'owner':" + !urls.get(0).contains("owner"));
-        System.out.println("simple donot contain 'actives':" + !urls.get(0).contains("actives"));
-        System.out.println("simple donot contain 'timeout':" + !urls.get(0).contains("timeout"));
-        System.out.println("simple contain 'application':" + urls.get(0).contains("application"));
-        System.out.println("simple contain 'version':" + urls.get(0).contains("version"));
-        System.out.println("simple contain 'group':" + urls.get(0).contains("group"));
-        System.out.println("simple contain 'specVersion(default)':" + urls.get(0).contains(Constants.RELEASE_KEY));
+        urls.stream().map(URL::decode).forEach(System.out::println);
+        System.out.println("not contains 'retries':" + !urls.get(0).contains("retries"));
+        System.out.println("not contains 'owner':" + !urls.get(0).contains("owner"));
+        System.out.println("not contains 'actives':" + !urls.get(0).contains("actives"));
+        System.out.println("not contains 'timeout':" + !urls.get(0).contains("timeout"));
+        System.out.println("contains 'application':" + urls.get(0).contains("application"));
+        System.out.println("contains 'version':" + urls.get(0).contains("version"));
+        System.out.println("contains 'group':" + urls.get(0).contains("group"));
+        System.out.println("contains 'specVersion(default)':" + urls.get(0).contains(RELEASE_KEY));
         System.out.println("*********************************************************");
     }
 }
diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/SimpleRegistryAnnotationProvider.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/SimpleRegistryAnnotationProvider.java
index f5990a1..33fe700 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/SimpleRegistryAnnotationProvider.java
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/SimpleRegistryAnnotationProvider.java
@@ -20,43 +20,43 @@
 package org.apache.dubbo.samples.simplified.annotation;
 
 
-import org.apache.dubbo.common.Constants;
 import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionLoader;
 import org.apache.dubbo.config.ProviderConfig;
 import org.apache.dubbo.config.RegistryConfig;
 import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter;
 
+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.List;
+import java.util.concurrent.CountDownLatch;
+
+import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
 
-/**
- *
- */
 public class SimpleRegistryAnnotationProvider {
 
     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.simplified.annotation.impl")
     @PropertySource("classpath:/spring/dubbo-provider.properties")
     static public class ProviderConfiguration {
+        @Value("zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}")
+        private String zookeeperAddress;
+
         @Bean
         public ProviderConfig providerConfig() {
             ProviderConfig providerConfig = new ProviderConfig();
@@ -67,7 +67,7 @@ public class SimpleRegistryAnnotationProvider {
         @Bean
         public RegistryConfig registryConfig() {
             RegistryConfig registryConfig = new RegistryConfig();
-            registryConfig.setAddress("zookeeper://127.0.0.1:2181");
+            registryConfig.setAddress(zookeeperAddress);
             registryConfig.setSimplified(true);
             registryConfig.setExtraKeys("retries,owner");
             return registryConfig;
@@ -75,19 +75,16 @@ public class SimpleRegistryAnnotationProvider {
     }
 
     private static void printServiceData() {
-        // get service data(provider) from zookeeper .
-        ZookeeperClient zookeeperClient = ExtensionLoader.getExtensionLoader(ZookeeperTransporter.class).getExtension("curator").connect(new URL("zookeeper", "127.0.0.1", 2181));
-        List<String> urls = zookeeperClient.getChildren(ZkUtil.toUrlPath("providers"));
+        List<String> urls = ZkUtil.getChildren(ZkUtil.toUrlPath("providers"));
         System.out.println("*********************************************************");
-        System.out.println(urls);
-        System.out.println("simple donot contain 'executes':" + !urls.get(0).contains("executes"));
-        System.out.println("simple contain 'retries':" + urls.get(0).contains("retries"));
-        System.out.println("simple contain 'owner':" + urls.get(0).contains("owner"));
-        System.out.println("simple contain 'timeout(default)':" + urls.get(0).contains("timeout"));
-        System.out.println("simple contain 'version(default)':" + urls.get(0).contains("version"));
-        System.out.println("simple contain 'group(default)':" + urls.get(0).contains("group"));
-        System.out.println("simple contain 'specVersion(default)':" + urls.get(0).contains(Constants.RELEASE_KEY));
+        urls.stream().map(URL::decode).forEach(System.out::println);
+        System.out.println("not contains 'executes':" + !urls.get(0).contains("executes"));
+        System.out.println("contains 'retries':" + urls.get(0).contains("retries"));
+        System.out.println("contains 'owner':" + urls.get(0).contains("owner"));
+        System.out.println("contains 'timeout(default)':" + urls.get(0).contains("timeout"));
+        System.out.println("contains 'version(default)':" + urls.get(0).contains("version"));
+        System.out.println("contains 'group(default)':" + urls.get(0).contains("group"));
+        System.out.println("contains 'specVersion(default)':" + urls.get(0).contains(RELEASE_KEY));
         System.out.println("*********************************************************");
     }
-
 }
diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/ZKClean.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/ZKClean.java
deleted file mode 100644
index 6e33942..0000000
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/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.simplified.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-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/ZkUtil.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/ZkUtil.java
index 08778bf..a3e58f9 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/ZkUtil.java
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/ZkUtil.java
@@ -1,47 +1,72 @@
 /*
+ * 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.simplified.annotation;
 
-import org.apache.dubbo.common.Constants;
 import org.apache.dubbo.common.URL;
 import org.apache.dubbo.samples.simplified.annotation.api.AnnotationService;
 
-/**
- * 2018/11/8
- */
+import org.apache.curator.framework.CuratorFramework;
+import org.apache.curator.framework.CuratorFrameworkFactory;
+import org.apache.curator.retry.ExponentialBackoffRetry;
+
+import java.util.Collections;
+import java.util.List;
+
+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();
+    }
+
+    private static void initClient() {
+        client = CuratorFrameworkFactory.newClient(zookeeperHost + ":2181", 60 * 1000, 60 * 1000,
+                new ExponentialBackoffRetry(1000, 3));
+        client.start();
+    }
+
     private static String toRootDir() {
         return "/dubbo";
     }
 
     private static String toServicePath() {
         String name = AnnotationService.class.getName();
-        return toRootDir() + Constants.PATH_SEPARATOR + URL.encode(name);
+        return toRootDir() + PATH_SEPARATOR + URL.encode(name);
     }
 
     private static String toCategoryPath(String side) {
-        return toServicePath() + Constants.PATH_SEPARATOR + side;
+        return toServicePath() + PATH_SEPARATOR + side;
     }
 
     public static String toUrlPath(String side) {
-        String r = toCategoryPath(side);
-        System.out.println(r);
-        return r;
+        return toCategoryPath(side);
     }
+
+    public static List<String> getChildren(String path) {
+        try {
+            return client.getChildren().forPath(path);
+        } catch (Exception e) {
+            e.printStackTrace();
+            return Collections.emptyList();
+        }
+    }
+
 }
diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/action/AnnotationAction.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/action/AnnotationAction.java
index 29e3df8..33f67bd 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/action/AnnotationAction.java
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/action/AnnotationAction.java
@@ -21,11 +21,9 @@ package org.apache.dubbo.samples.simplified.annotation.action;
 
 import org.apache.dubbo.config.annotation.Reference;
 import org.apache.dubbo.samples.simplified.annotation.api.AnnotationService;
+
 import org.springframework.stereotype.Component;
 
-/**
- * AnnotationAction
- */
 @Component("annotationAction")
 public class AnnotationAction {
 
@@ -35,5 +33,4 @@ public class AnnotationAction {
     public String doSayHello(String name) {
         return annotationService.sayHello(name);
     }
-
 }
diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/api/AnnotationService.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/api/AnnotationService.java
index 930a5d1..005b516 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/api/AnnotationService.java
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/api/AnnotationService.java
@@ -19,9 +19,6 @@
 
 package org.apache.dubbo.samples.simplified.annotation.api;
 
-/**
- * AsyncService
- */
 public interface AnnotationService {
 
     String sayHello(String name);
diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/impl/AnnotationServiceImpl.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/impl/AnnotationServiceImpl.java
index 0e678c1..39ecf1c 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/impl/AnnotationServiceImpl.java
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/main/java/org/apache/dubbo/samples/simplified/annotation/impl/AnnotationServiceImpl.java
@@ -22,9 +22,6 @@ package org.apache.dubbo.samples.simplified.annotation.impl;
 import org.apache.dubbo.config.annotation.Service;
 import org.apache.dubbo.samples.simplified.annotation.api.AnnotationService;
 
-/**
- * AsyncServiceImpl
- */
 @Service(version = "1.1.8", group = "d-test", executes = 4500, retries = 7, owner = "victanno", timeout = 5300)
 public class AnnotationServiceImpl implements AnnotationService {
 
diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/test/java/org/apache/dubbo/samples/simplified/annotation/AnnotationServiceIT.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/test/java/org/apache/dubbo/samples/simplified/annotation/AnnotationServiceIT.java
new file mode 100644
index 0000000..85eda03
--- /dev/null
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-annotation/src/test/java/org/apache/dubbo/samples/simplified/annotation/AnnotationServiceIT.java
@@ -0,0 +1,69 @@
+/*
+ * 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.simplified.annotation;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.samples.simplified.annotation.action.AnnotationAction;
+
+import org.junit.Assert;
+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;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(classes = {SimpleRegistryAnnotationConsumer.ConsumerConfiguration.class})
+public class AnnotationServiceIT {
+    @Autowired
+    private AnnotationAction annotationAction;
+
+    @Test
+    public void verifyProvider() throws Exception {
+        List<String> urls = ZkUtil.getChildren(ZkUtil.toUrlPath("providers"));
+        urls.stream().map(URL::decode).forEach(System.out::println);
+        Assert.assertEquals(1, urls.size());
+        String url = urls.get(0);
+        Assert.assertTrue(url.contains("retries"));
+        Assert.assertTrue(url.contains("owner"));
+        Assert.assertTrue(url.contains("timeout"));
+        Assert.assertTrue(url.contains("version"));
+        Assert.assertTrue(url.contains("group"));
+        Assert.assertTrue(url.contains("release"));
+        Assert.assertFalse(url.contains("executes"));
+    }
+
+    @Test
+    public void verifyConsumer() throws Exception {
+        List<String> urls = ZkUtil.getChildren(ZkUtil.toUrlPath("consumers"));
+        urls.stream().map(URL::decode).forEach(System.out::println);
+        Assert.assertEquals(1, urls.size());
+        String url = urls.get(0);
+
+        Assert.assertFalse(url.contains("retries"));
+        Assert.assertFalse(url.contains("timeout"));
+        Assert.assertFalse(url.contains("owner"));
+        Assert.assertFalse(url.contains("actives"));
+        Assert.assertTrue(url.contains("application"));
+        Assert.assertTrue(url.contains("version"));
+        Assert.assertTrue(url.contains("group"));
+        Assert.assertTrue(url.contains("release"));
+    }
+}


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