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:32:47 UTC
[dubbo-samples] branch master updated: integration test for
dubbo-samples-simplified-registry-nosimple
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 8f5c099 integration test for dubbo-samples-simplified-registry-nosimple
8f5c099 is described below
commit 8f5c099f159b22cc9614b869cdbc34d3473c3936
Author: Ian Luo <ia...@gmail.com>
AuthorDate: Mon Jul 1 16:31:29 2019 +0800
integration test for dubbo-samples-simplified-registry-nosimple
---
.../pom.xml | 396 +++++++--------------
.../nosimple/NoSimpleRegistryConsumer.java | 44 +--
.../nosimple/NoSimpleRegistryProvider.java | 39 +-
.../simplified/registry/nosimple/ZKClean.java | 45 ---
.../simplified/registry/nosimple/ZkUtil.java | 65 ++--
.../META-INF/spring/simplified-provider.xml | 37 --
.../src/main/resources/dubbo.properties | 19 -
.../{META-INF => }/spring/simplified-consumer.xml | 10 +-
.../main/resources/spring/simplified-provider.xml | 35 ++
.../registry/nosimple/DemoServiceIT.java | 69 ++++
10 files changed, 324 insertions(+), 435 deletions(-)
diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/pom.xml b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/pom.xml
index f9dcf80..6922132 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/pom.xml
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/pom.xml
@@ -28,302 +28,180 @@
<packaging>jar</packaging>
<artifactId>dubbo-samples-simplified-registry-nosimple</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.registry.nosimple.NoSimpleRegistryProvider</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>check</goal>
+ <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-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/NoSimpleRegistryConsumer.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/NoSimpleRegistryConsumer.java
index d982d1e..192cb6f 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/NoSimpleRegistryConsumer.java
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/NoSimpleRegistryConsumer.java
@@ -19,53 +19,41 @@
package org.apache.dubbo.samples.simplified.registry.nosimple;
-import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionLoader;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter;
import org.apache.dubbo.samples.simplified.registry.nosimple.api.DemoService;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.List;
+import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
+
public class NoSimpleRegistryConsumer {
public static void main(String[] args) {
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/simplified-consumer.xml"});
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/simplified-consumer.xml");
context.start();
- DemoService demoService = (DemoService) context.getBean("demoService"); // get remote service proxy
+ DemoService demoService = context.getBean("demoService", DemoService.class);
printServiceData();
- while (true) {
- try {
- Thread.sleep(1000);
- String hello = demoService.sayHello("world"); // call remote method
- System.out.println(hello); // get result
-
- } catch (Throwable throwable) {
- throwable.printStackTrace();
- }
- }
-
+ String hello = demoService.sayHello("world");
+ System.out.println(hello);
}
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 contain 'retries':" + urls.get(0).contains("retries"));
- System.out.println("simple contain 'owner':" + urls.get(0).contains("owner"));
- System.out.println("simple contain 'actives':" + urls.get(0).contains("actives"));
- System.out.println("simple 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("contains 'retries':" + urls.get(0).contains("retries"));
+ System.out.println("contains 'owner':" + urls.get(0).contains("owner"));
+ System.out.println("contains 'actives':" + urls.get(0).contains("actives"));
+ System.out.println("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-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/NoSimpleRegistryProvider.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/NoSimpleRegistryProvider.java
index d25a468..590570d 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/NoSimpleRegistryProvider.java
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/NoSimpleRegistryProvider.java
@@ -19,45 +19,40 @@
package org.apache.dubbo.samples.simplified.registry.nosimple;
-import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.extension.ExtensionLoader;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperClient;
-import org.apache.dubbo.remoting.zookeeper.ZookeeperTransporter;
import org.springframework.context.support.ClassPathXmlApplicationContext;
import java.util.List;
+import java.util.concurrent.CountDownLatch;
+
+import static org.apache.dubbo.common.constants.CommonConstants.RELEASE_KEY;
public class NoSimpleRegistryProvider {
public static void main(String[] args) throws Exception {
- EmbeddedZooKeeper embeddedZooKeeper = new EmbeddedZooKeeper(2181, false);
- embeddedZooKeeper.start();
+ new EmbeddedZooKeeper(2181, false).start();
- ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[]{"META-INF/spring/simplified-provider.xml"});
+ ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("spring/simplified-provider.xml");
context.start();
printServiceData();
- System.in.read(); // press any key to exit
- embeddedZooKeeper.stop();
+
+ System.out.println("dubbo service started");
+ new CountDownLatch(1).await();
}
private static void printServiceData() {
- // 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 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("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-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/ZKClean.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/ZKClean.java
deleted file mode 100644
index 02fe75e..0000000
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/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.registry.nosimple;
-
-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-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/ZkUtil.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/ZkUtil.java
index 588202d..5b16f6d 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/ZkUtil.java
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/java/org/apache/dubbo/samples/simplified/registry/nosimple/ZkUtil.java
@@ -1,31 +1,47 @@
/*
+ * 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.registry.nosimple;
-import org.apache.dubbo.common.Constants;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.samples.simplified.registry.nosimple.api.DemoService;
-/**
- * 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";
@@ -33,15 +49,24 @@ public class ZkUtil {
private static String toServicePath() {
String name = DemoService.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) {
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-nosimple/src/main/resources/META-INF/spring/simplified-provider.xml b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/META-INF/spring/simplified-provider.xml
deleted file mode 100644
index 6ad286f..0000000
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/META-INF/spring/simplified-provider.xml
+++ /dev/null
@@ -1,37 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- ~
- ~ Licensed to the Apache Software Foundation (ASF) under one or more
- ~ contributor license agreements. See the NOTICE file distributed with
- ~ this work for additional information regarding copyright ownership.
- ~ The ASF licenses this file to You under the Apache License, Version 2.0
- ~ (the "License"); you may not use this file except in compliance with
- ~ the License. You may obtain a copy of the License at
- ~
- ~ http://www.apache.org/licenses/LICENSE-2.0
- ~
- ~ Unless required by applicable law or agreed to in writing, software
- ~ distributed under the License is distributed on an "AS IS" BASIS,
- ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- ~ See the License for the specific language governing permissions and
- ~ limitations under the License.
- ~
- -->
-
-<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans"
- xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
- http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
-
- <!-- optional -->
- <dubbo:application name="simplified-registry-nosimple-provider"/>
-
- <dubbo:registry address="zookeeper://127.0.0.1:2181"/>
-
- <bean id="demoService" class="org.apache.dubbo.samples.simplified.registry.nosimple.impl.DemoServiceImpl"/>
- <dubbo:service async="true" interface="org.apache.dubbo.samples.simplified.registry.nosimple.api.DemoService"
- version="1.2.3" group="dubbo-simple" ref="demoService"
- executes="4500" retries="7" owner="vict" timeout="5300"/>
-
-</beans>
diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/dubbo.properties b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/dubbo.properties
deleted file mode 100644
index a6b12ae..0000000
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/dubbo.properties
+++ /dev/null
@@ -1,19 +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.
-#
-#
-
diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/META-INF/spring/simplified-consumer.xml b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/spring/simplified-consumer.xml
similarity index 77%
rename from dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/META-INF/spring/simplified-consumer.xml
rename to dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/spring/simplified-consumer.xml
index a5b0280..9ff56df 100644
--- a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/META-INF/spring/simplified-consumer.xml
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/spring/simplified-consumer.xml
@@ -20,16 +20,16 @@
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
- xmlns="http://www.springframework.org/schema/beans"
+ xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
- http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd">
+ http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder/>
- <!-- optional -->
<dubbo:application name="simplified-registry-nosimple-consumer"/>
- <dubbo:registry address="zookeeper://127.0.0.1:2181" username="xxx" password="yyy" check="true"/>
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181" username="xxx" password="yyy"
+ check="true"/>
<dubbo:reference id="demoService" interface="org.apache.dubbo.samples.simplified.registry.nosimple.api.DemoService"
owner="vvv" retries="4" actives="6" timeout="4500" version="1.2.3" group="dubbo-simple"/>
-
</beans>
diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/spring/simplified-provider.xml b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/spring/simplified-provider.xml
new file mode 100644
index 0000000..883c030
--- /dev/null
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/main/resources/spring/simplified-provider.xml
@@ -0,0 +1,35 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ ~ Licensed to the Apache Software Foundation (ASF) under one or more
+ ~ contributor license agreements. See the NOTICE file distributed with
+ ~ this work for additional information regarding copyright ownership.
+ ~ The ASF licenses this file to You under the Apache License, Version 2.0
+ ~ (the "License"); you may not use this file except in compliance with
+ ~ the License. You may obtain a copy of the License at
+ ~
+ ~ http://www.apache.org/licenses/LICENSE-2.0
+ ~
+ ~ Unless required by applicable law or agreed to in writing, software
+ ~ distributed under the License is distributed on an "AS IS" BASIS,
+ ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ ~ See the License for the specific language governing permissions and
+ ~ limitations under the License.
+ -->
+
+<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xmlns:dubbo="http://dubbo.apache.org/schema/dubbo"
+ xmlns="http://www.springframework.org/schema/beans" xmlns:context="http://www.springframework.org/schema/context"
+ xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.3.xsd
+ http://dubbo.apache.org/schema/dubbo http://dubbo.apache.org/schema/dubbo/dubbo.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd">
+ <context:property-placeholder/>
+
+ <dubbo:application name="simplified-registry-nosimple-provider"/>
+
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+
+ <bean id="demoService" class="org.apache.dubbo.samples.simplified.registry.nosimple.impl.DemoServiceImpl"/>
+ <dubbo:service async="true" interface="org.apache.dubbo.samples.simplified.registry.nosimple.api.DemoService"
+ version="1.2.3" group="dubbo-simple" ref="demoService"
+ executes="4500" retries="7" owner="vict" timeout="5300"/>
+
+</beans>
diff --git a/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/test/java/org/apache/dubbo/samples/simplified/registry/nosimple/DemoServiceIT.java b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/test/java/org/apache/dubbo/samples/simplified/registry/nosimple/DemoServiceIT.java
new file mode 100644
index 0000000..debd4ac
--- /dev/null
+++ b/dubbo-samples-simplified-registry/dubbo-samples-simplified-registry-nosimple/src/test/java/org/apache/dubbo/samples/simplified/registry/nosimple/DemoServiceIT.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.registry.nosimple;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.samples.simplified.registry.nosimple.api.DemoService;
+
+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(locations = {"classpath:/spring/simplified-consumer.xml"})
+public class DemoServiceIT {
+ @Autowired
+ private DemoService demoService;
+
+ @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.assertTrue(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.assertTrue(url.contains("retries"));
+ Assert.assertTrue(url.contains("timeout"));
+ Assert.assertTrue(url.contains("owner"));
+ Assert.assertTrue(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