You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by li...@apache.org on 2019/12/11 02:40:20 UTC
[dubbo-samples] branch master updated: optimize integration test
process
This is an automated email from the ASF dual-hosted git repository.
liujun 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 440e360 optimize integration test process
440e360 is described below
commit 440e3609c375813cea3aff5576efeb22eab5f786
Author: ken.lj <ke...@gmail.com>
AuthorDate: Tue Dec 10 17:40:54 2019 +0800
optimize integration test process
---
.../java/org/apache/dubbo/samples/ZKTools.java | 2 +-
java/dubbo-samples-context/pom.xml | 103 +--------
.../resources/spring/dubbo-context-consumer.xml | 2 +-
.../resources/spring/dubbo-context-provider.xml | 4 +-
.../dubbo/samples/context/ContextServiceIT.java | 13 +-
.../apache/dubbo/samples/basic/DemoServiceIT.java | 1 +
java/dubbo-samples-grpc/README.md | 42 +++-
.../dubbo-samples-original/pom.xml | 129 +++--------
.../main/resources/spring/dubbo-demo-consumer.xml | 6 +-
.../main/resources/spring/dubbo-demo-provider.xml | 10 +-
.../helloworld/ReactorDubboGreeterGrpc.java | 216 +++++++++--------
.../dubbo-samples-reactor/pom.xml | 111 +--------
.../main/resources/spring/dubbo-demo-consumer.xml | 2 +-
.../main/resources/spring/dubbo-demo-provider.xml | 4 +-
.../org/apache/dubbo/samples/ReactorGrpcIT.java | 65 ++++++
.../examples/helloworld/RxDubboGreeterGrpc.java | 110 +++++----
.../dubbo-samples-rxjava/pom.xml | 112 +--------
.../main/resources/spring/dubbo-demo-consumer.xml | 2 +-
.../main/resources/spring/dubbo-demo-provider.xml | 4 +-
.../java/org/apache/dubbo/samples/RxGrpcIT.java | 65 ++++++
.../src/test/proto/helloworld.proto | 37 +++
.../dubbo-samples-grpc-ssl-consumer}/pom.xml | 109 ++-------
.../dubbo/samples/basic/SslBasicConsumer.java | 74 ++++++
.../src/main/proto/helloworld.proto | 37 +++
.../src/main/proto/route_guide.proto | 115 +++++++++
.../src/main/resources/certs/ca.key | 16 ++
.../src/main/resources/certs/ca.pem | 15 ++
.../src/main/resources/certs/client.key | 16 ++
.../src/main/resources/certs/client.pem | 18 ++
.../src/main/resources/certs/server0.key | 16 ++
.../src/main/resources/certs/server0.pem | 18 ++
.../src/main/resources/log4j.properties | 26 +++
.../dubbo-samples-grpc-ssl-provider}/pom.xml | 108 ++-------
.../dubbo/samples/basic/EmbeddedZooKeeper.java | 256 +++++++++++++++++++++
.../dubbo/samples/basic/SslBasicProvider.java | 80 +++++++
.../basic/impl/helloworld/GrpcGreeterImpl.java} | 33 ++-
.../src/main/proto/helloworld.proto | 37 +++
.../src/main/proto/route_guide.proto | 115 +++++++++
.../src/main/resources/certs/ca.key | 16 ++
.../src/main/resources/certs/ca.pem | 15 ++
.../src/main/resources/certs/client.key | 16 ++
.../src/main/resources/certs/client.pem | 18 ++
.../src/main/resources/certs/server0.key | 16 ++
.../src/main/resources/certs/server0.pem | 18 ++
.../src/main/resources/log4j.properties | 26 +++
.../{ => dubbo-samples-ssl}/pom.xml | 31 +--
java/dubbo-samples-grpc/pom.xml | 1 +
java/dubbo-samples-protobuf/pom.xml | 1 +
.../org/apache/dubbo/demo/DemoServiceDubbo.java | 56 ++---
.../org/apache/dubbo/demo/DemoServiceDubbo.java | 56 ++---
.../protobuf-provider/pom.xml | 15 ++
.../src/main/resources/spring/dubbo-provider.xml | 4 +-
.../org/apache/dubbo/samples/DubboProtobufIT.java} | 24 +-
.../resources/spring/dubbo-consumer.xml} | 9 +-
.../sentinel/provider/ProviderConfiguration.java | 4 +-
java/dubbo-samples-ssl/README.md | 41 ++++
.../dubbo-samples-ssl-consumer/pom.xml | 153 ++++++++++++
.../dubbo/samples/basic/SslBasicConsumer.java | 72 ++++++
.../dubbo/samples/basic/api/DemoService.java | 28 +++
.../src/main/resources/certs/ca.key | 16 ++
.../src/main/resources/certs/ca.pem | 15 ++
.../src/main/resources/certs/client.key | 16 ++
.../src/main/resources/certs/client.pem | 18 ++
.../src/main/resources/certs/server0.key | 16 ++
.../src/main/resources/certs/server0.pem | 18 ++
.../src/main/resources/log4j.properties | 26 +++
.../dubbo-samples-ssl-provider/pom.xml | 154 +++++++++++++
.../dubbo/samples/basic/EmbeddedZooKeeper.java | 256 +++++++++++++++++++++
.../dubbo/samples/basic/SslBasicProvider.java | 79 +++++++
.../dubbo/samples/basic/api/DemoService.java | 28 +++
.../dubbo/samples/basic/impl/DemoServiceImpl.java | 41 ++++
.../src/main/resources/certs/ca.key | 16 ++
.../src/main/resources/certs/ca.pem | 15 ++
.../src/main/resources/certs/client.key | 16 ++
.../src/main/resources/certs/client.pem | 18 ++
.../src/main/resources/certs/server0.key | 16 ++
.../src/main/resources/certs/server0.pem | 18 ++
.../src/main/resources/log4j.properties | 26 +++
.../pom.xml | 31 +--
java/pom.xml | 1 +
80 files changed, 2683 insertions(+), 906 deletions(-)
diff --git a/java/dubbo-samples-configcenter/dubbo-samples-configcenter-api/src/main/java/org/apache/dubbo/samples/ZKTools.java b/java/dubbo-samples-configcenter/dubbo-samples-configcenter-api/src/main/java/org/apache/dubbo/samples/ZKTools.java
index aff867d..cd9fbea 100644
--- a/java/dubbo-samples-configcenter/dubbo-samples-configcenter-api/src/main/java/org/apache/dubbo/samples/ZKTools.java
+++ b/java/dubbo-samples-configcenter/dubbo-samples-configcenter-api/src/main/java/org/apache/dubbo/samples/ZKTools.java
@@ -32,7 +32,7 @@ public class ZKTools {
}
public static void generateDubboPropertiesForGlobal() {
- String str = "dubbo.registry.address=zookeeper://" + zookeeperHost + ":2181\n";
+ String str = "dubbo.registry.address=zookeeper://" + zookeeperHost + ":2182\n";
System.out.println(str);
diff --git a/java/dubbo-samples-context/pom.xml b/java/dubbo-samples-context/pom.xml
index 72c0bd6..fb29626 100644
--- a/java/dubbo-samples-context/pom.xml
+++ b/java/dubbo-samples-context/pom.xml
@@ -31,8 +31,6 @@
<dubbo.version>2.7.5-SNAPSHOT</dubbo.version>
<spring.version>4.3.16.RELEASE</spring.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>${project.artifactId}:${dubbo.version}</image.name>
@@ -69,6 +67,14 @@
<version>${spring.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>1.12.3</version>
+ <scope>test</scope>
+ </dependency>
+
</dependencies>
<profiles>
@@ -77,96 +83,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-maven-address-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>local-address</goal>
- </goals>
- <configuration>
- <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>${java-image.name}</image>
- </from>
- <to>
- <image>${image.name}</image>
- </to>
- <container>
- <mainClass>${main-class}</mainClass>
- <ports>
- <port>${dubbo.port}</port>
- <port>${zookeeper.port}</port>
- </ports>
- <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>
@@ -177,9 +93,6 @@
<goal>verify</goal>
</goals>
<configuration>
- <systemPropertyVariables>
- <zookeeper.address>${dubbo-local-address}</zookeeper.address>
- </systemPropertyVariables>
<includes>
<include>**/*IT.java</include>
</includes>
diff --git a/java/dubbo-samples-context/src/main/resources/spring/dubbo-context-consumer.xml b/java/dubbo-samples-context/src/main/resources/spring/dubbo-context-consumer.xml
index 6e596c1..21e1087 100644
--- a/java/dubbo-samples-context/src/main/resources/spring/dubbo-context-consumer.xml
+++ b/java/dubbo-samples-context/src/main/resources/spring/dubbo-context-consumer.xml
@@ -32,6 +32,6 @@
<!-- generate proxy for the remote service, then demoService can be used in the same way as the
local regular interface -->
- <dubbo:reference id="demoService" check="false" interface="org.apache.dubbo.samples.context.api.ContextService"/>
+ <dubbo:reference scope="remote" id="contextService" check="false" interface="org.apache.dubbo.samples.context.api.ContextService"/>
</beans>
diff --git a/java/dubbo-samples-context/src/main/resources/spring/dubbo-context-provider.xml b/java/dubbo-samples-context/src/main/resources/spring/dubbo-context-provider.xml
index 71b450c..ea83535 100644
--- a/java/dubbo-samples-context/src/main/resources/spring/dubbo-context-provider.xml
+++ b/java/dubbo-samples-context/src/main/resources/spring/dubbo-context-provider.xml
@@ -29,8 +29,8 @@
<dubbo:protocol name="dubbo" port="20890"/>
- <bean id="contextService" class="org.apache.dubbo.samples.context.impl.ContextServiceImpl"/>
+ <bean id="contextServiceImpl" class="org.apache.dubbo.samples.context.impl.ContextServiceImpl"/>
- <dubbo:service interface="org.apache.dubbo.samples.context.api.ContextService" ref="contextService"/>
+ <dubbo:service interface="org.apache.dubbo.samples.context.api.ContextService" ref="contextServiceImpl"/>
</beans>
diff --git a/java/dubbo-samples-context/src/test/java/org/apache/dubbo/samples/context/ContextServiceIT.java b/java/dubbo-samples-context/src/test/java/org/apache/dubbo/samples/context/ContextServiceIT.java
index 0dbb1d7..aa13fa9 100644
--- a/java/dubbo-samples-context/src/test/java/org/apache/dubbo/samples/context/ContextServiceIT.java
+++ b/java/dubbo-samples-context/src/test/java/org/apache/dubbo/samples/context/ContextServiceIT.java
@@ -20,15 +20,24 @@ package org.apache.dubbo.samples.context;
import org.apache.dubbo.samples.context.api.ContextService;
import org.junit.Assert;
+import org.junit.ClassRule;
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 org.testcontainers.containers.FixedHostPortGenericContainer;
+import org.testcontainers.containers.GenericContainer;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath*:/spring/dubbo-context-consumer.xml"})
+@ContextConfiguration(locations = {"classpath*:/spring/dubbo-context-consumer.xml", "classpath*:/spring/dubbo-context-provider.xml"})
public class ContextServiceIT {
+
+ @ClassRule
+ public static GenericContainer zookeeper = new FixedHostPortGenericContainer("zookeeper:3.4.9")
+ .withFixedExposedPort(2181, 2181);
+
+
@Autowired
private ContextService contextService;
@@ -37,7 +46,7 @@ public class ContextServiceIT {
String result = contextService.sayHello("dubbo");
Assert.assertTrue(result.startsWith("Hello dubbo, response from"));
Assert.assertTrue(result.contains("isProviderSide: true"));
- Assert.assertTrue(result.contains("local: context-provider"));
+ Assert.assertTrue(result.contains("local: context-"));
// Assert.assertTrue(result.contains("remote: context-consumer"));
}
}
diff --git a/java/dubbo-samples-environment-keys/src/test/java/org/apache/dubbo/samples/basic/DemoServiceIT.java b/java/dubbo-samples-environment-keys/src/test/java/org/apache/dubbo/samples/basic/DemoServiceIT.java
index 6d7d7ec..430eda6 100644
--- a/java/dubbo-samples-environment-keys/src/test/java/org/apache/dubbo/samples/basic/DemoServiceIT.java
+++ b/java/dubbo-samples-environment-keys/src/test/java/org/apache/dubbo/samples/basic/DemoServiceIT.java
@@ -30,6 +30,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:spring/dubbo-demo-consumer.xml")
public class DemoServiceIT {
+
@Autowired
@Qualifier("demoService")
private DemoService service;
diff --git a/java/dubbo-samples-grpc/README.md b/java/dubbo-samples-grpc/README.md
index 4667015..4f67b11 100644
--- a/java/dubbo-samples-grpc/README.md
+++ b/java/dubbo-samples-grpc/README.md
@@ -1 +1,41 @@
-Run `mvn clean compile` first to call protobuf to generate the Dubbo customized Java stubs before run any samples.
\ No newline at end of file
+
+## How to run
+
+This sample needs TLS cert files to run.
+
+> This sample has test certs provided in the resources/certs directory, you can use the directory or generate by yourself.
+
+Here's the procedures of how to run.
+
+First, we need to build the executable jar for consumer and provider respectively.
+
+```shell
+$ cd dubbo-samples-ssl
+$ mvn clean package
+```
+
+Then, start the provider
+
+```sh
+$ # enter the target directory
+$ cd ./dubbo-samples-grpc-ssl-provider/target
+$ # run
+$ java "-Ddubbo.ssl.server-key-cert-chain-path={your absolute path to}/certs/server0.pem" "-Ddubbo.ssl.server-private-key-path={your absolute path to}/certs/server0.key" -jar dubbo-samples-grpc-ssl-provider-1.0-SNAPSHOT-exec.jar
+```
+
+Finally, start the consumer
+
+```sh
+$ # enter the target directory
+$ cd ./dubbo-samples-grpc-ssl-consumer/target
+$ # run
+$ java "-Ddubbo.ssl.client-trust-cert-collection-path={your absolute path to}/certs/ca.pem" -jar dubbo-samples-grpc-ssl-consumer-1.0-SNAPSHOT-exec.jar
+```
+
+For example, in my own environment, I run
+
+```sh
+$ java "-Ddubbo.ssl.server-key-cert-chain-path=/Users/ken.lj/aliware/dubboprojects/codebase/dubbo-samples/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/server0.pem" "-Ddubbo.ssl.server-private-key-path=/Users/ken.lj/aliware/dubboprojects/codebase/dubbo-samples/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/server0.key" -jar dubbo-samples-grpc-ssl-provider-1.0-SNAPSHOT-exec.jar
+$ # and
+$ java "-Ddubbo.ssl.client-trust-cert-collection-path=/Users/ken.lj/aliware/dubboprojects/codebase/dubbo-samples/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/ca.pem" -jar dubbo-samples-grpc-ssl-consumer-1.0-SNAPSHOT-exec.jar
+```
diff --git a/java/dubbo-samples-grpc/dubbo-samples-original/pom.xml b/java/dubbo-samples-grpc/dubbo-samples-original/pom.xml
index 060565d..1d19ad6 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-original/pom.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-original/pom.xml
@@ -97,6 +97,13 @@
<version>${spring-test.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>1.12.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
@@ -105,89 +112,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-maven-address-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>local-address</goal>
- </goals>
- <configuration>
- <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>${java-image.name}</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>
- </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>
@@ -198,9 +122,6 @@
<goal>verify</goal>
</goals>
<configuration>
- <systemPropertyVariables>
- <zookeeper.address>${dubbo-local-address}</zookeeper.address>
- </systemPropertyVariables>
<includes>
<include>**/*IT.java</include>
</includes>
@@ -256,6 +177,8 @@
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
+ <goal>test-compile</goal>
+ <goal>test-compile-custom</goal>
</goals>
</execution>
</executions>
@@ -278,22 +201,24 @@
</executions>
</plugin>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>${spring-boot.version}</version>
- <configuration>
- <mainClass>${main-class}</mainClass>
- <layout>JAR</layout>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
+<!-- https://stackoverflow.com/questions/40664101/maven-integration-test-doesnt-find-my-class-in-same-package-structure-->
+<!-- <plugin>-->
+<!-- <groupId>org.springframework.boot</groupId>-->
+<!-- <artifactId>spring-boot-maven-plugin</artifactId>-->
+<!-- <version>${spring-boot.version}</version>-->
+<!-- <configuration>-->
+<!-- <mainClass>${main-class}</mainClass>-->
+<!-- <layout>JAR</layout>-->
+<!-- </configuration>-->
+<!-- <executions>-->
+<!-- <execution>-->
+<!-- <goals>-->
+<!-- <goal>repackage</goal>-->
+<!-- </goals>-->
+<!-- </execution>-->
+<!-- </executions>-->
+<!-- </plugin>-->
+
</plugins>
</build>
diff --git a/java/dubbo-samples-grpc/dubbo-samples-original/src/main/resources/spring/dubbo-demo-consumer.xml b/java/dubbo-samples-grpc/dubbo-samples-original/src/main/resources/spring/dubbo-demo-consumer.xml
index fb11ecd..314ea46 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-original/src/main/resources/spring/dubbo-demo-consumer.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-original/src/main/resources/spring/dubbo-demo-consumer.xml
@@ -25,10 +25,10 @@
<dubbo:application name="demo-consumer"/>
- <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}"/>
- <dubbo:reference id="greeter" interface="io.grpc.examples.helloworld.DubboGreeterGrpc$IGreeter" protocol="grpc"/>
- <dubbo:reference id="routeguide" interface="io.grpc.examples.routeguide.DubboRouteGuideGrpc$IRouteGuide"
+ <dubbo:reference scope="remote" id="greeter" interface="io.grpc.examples.helloworld.DubboGreeterGrpc$IGreeter" protocol="grpc"/>
+ <dubbo:reference scope="remote" id="routeguide" interface="io.grpc.examples.routeguide.DubboRouteGuideGrpc$IRouteGuide"
protocol="grpc"/>
</beans>
diff --git a/java/dubbo-samples-grpc/dubbo-samples-original/src/main/resources/spring/dubbo-demo-provider.xml b/java/dubbo-samples-grpc/dubbo-samples-original/src/main/resources/spring/dubbo-demo-provider.xml
index b734ac0..bd0225f 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-original/src/main/resources/spring/dubbo-demo-provider.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-original/src/main/resources/spring/dubbo-demo-provider.xml
@@ -27,12 +27,12 @@
<dubbo:protocol id="grpc" name="grpc"/>
- <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
+ <dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:${zookeeper.port:2181}"/>
- <bean id="greeter" class="org.apache.dubbo.samples.basic.impl.helloworld.GrpcGreeterImpl"/>
- <dubbo:service interface="io.grpc.examples.helloworld.DubboGreeterGrpc$IGreeter" ref="greeter" protocol="grpc"/>
+ <bean id="greeterImpl" class="org.apache.dubbo.samples.basic.impl.helloworld.GrpcGreeterImpl"/>
+ <dubbo:service interface="io.grpc.examples.helloworld.DubboGreeterGrpc$IGreeter" ref="greeterImpl" protocol="grpc"/>
- <bean id="routeguide" class="org.apache.dubbo.samples.basic.impl.routeguide.RouteGuideImpl"/>
- <dubbo:service interface="io.grpc.examples.routeguide.DubboRouteGuideGrpc$IRouteGuide" ref="routeguide" protocol="grpc"/>
+ <bean id="routeguideImpl" class="org.apache.dubbo.samples.basic.impl.routeguide.RouteGuideImpl"/>
+ <dubbo:service interface="io.grpc.examples.routeguide.DubboRouteGuideGrpc$IRouteGuide" ref="routeguideImpl" protocol="grpc"/>
</beans>
diff --git a/java/dubbo-samples-grpc/dubbo-samples-reactor/build/generated/source/proto/main/java/io/grpc/examples/helloworld/ReactorDubboGreeterGrpc.java b/java/dubbo-samples-grpc/dubbo-samples-reactor/build/generated/source/proto/main/java/io/grpc/examples/helloworld/ReactorDubboGreeterGrpc.java
index 03f2a7e..72a5ba3 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-reactor/build/generated/source/proto/main/java/io/grpc/examples/helloworld/ReactorDubboGreeterGrpc.java
+++ b/java/dubbo-samples-grpc/dubbo-samples-reactor/build/generated/source/proto/main/java/io/grpc/examples/helloworld/ReactorDubboGreeterGrpc.java
@@ -1,176 +1,174 @@
- package io.grpc.examples.helloworld;
+package io.grpc.examples.helloworld;
import org.apache.dubbo.common.URL;
import org.apache.dubbo.config.ReferenceConfigBase;
import java.util.concurrent.TimeUnit;
-import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
-import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
-
import static io.grpc.examples.helloworld.GreeterGrpc.getServiceDescriptor;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
-import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
-import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
-import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
+import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
@javax.annotation.Generated(
-value = "by ReactorDubboGrpc generator",
-comments = "Source: helloworld.proto")
+ value = "by ReactorDubboGrpc generator",
+ comments = "Source: helloworld.proto")
public final class ReactorDubboGreeterGrpc {
-private ReactorDubboGreeterGrpc() {}
-
-public static ReactorDubboGreeterStub getDubboStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions, URL url, ReferenceConfigBase<?> referenceConfig) {
-return new ReactorDubboGreeterStub(channel, callOptions, url, referenceConfig);
-}
-
- /**
- * <pre>
- * The greeting service definition.
- * </pre>
- */
-public static final class ReactorDubboGreeterStub implements IReactorGreeter {
-
-protected URL url;
-protected ReferenceConfigBase<?> referenceConfig;
+ private static final int METHODID_SAY_HELLO = 0;
-protected GreeterGrpc.GreeterStub stub;
+ private ReactorDubboGreeterGrpc() {
+ }
-public ReactorDubboGreeterStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions, URL url, ReferenceConfigBase<?> referenceConfig) {
-this.url = url;
-this.referenceConfig = referenceConfig;
-stub = GreeterGrpc.newStub(channel).build(channel, callOptions);
-}
+ public static ReactorDubboGreeterStub getDubboStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions, URL url, ReferenceConfigBase<?> referenceConfig) {
+ return new ReactorDubboGreeterStub(channel, callOptions, url, referenceConfig);
+ }
+ public interface IReactorGreeter {
/**
* <pre>
* Sends a greeting
* </pre>
*/
- public reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloRequest> reactorRequest) {
- GreeterGrpc.GreeterStub localStub = stub.withDeadlineAfter(url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS);
- return com.salesforce.reactorgrpc.stub.ClientCalls.oneToOne(reactorRequest, localStub::sayHello);
- }
+ public reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloRequest> reactorRequest);
/**
* <pre>
* Sends a greeting
* </pre>
*/
- public reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(io.grpc.examples.helloworld.HelloRequest reactorRequest) {
- GreeterGrpc.GreeterStub localStub = stub.withDeadlineAfter(url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS);
- return com.salesforce.reactorgrpc.stub.ClientCalls.oneToOne(reactor.core.publisher.Mono.just(reactorRequest), localStub::sayHello);
+ public reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(io.grpc.examples.helloworld.HelloRequest reactorRequest);
+
}
-}
+ /**
+ * <pre>
+ * The greeting service definition.
+ * </pre>
+ */
+ public static final class ReactorDubboGreeterStub implements IReactorGreeter {
+
+ protected URL url;
+ protected ReferenceConfigBase<?> referenceConfig;
+
+ protected GreeterGrpc.GreeterStub stub;
+
+ public ReactorDubboGreeterStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions, URL url, ReferenceConfigBase<?> referenceConfig) {
+ this.url = url;
+ this.referenceConfig = referenceConfig;
+ stub = GreeterGrpc.newStub(channel).build(channel, callOptions);
+ }
-public interface IReactorGreeter {
/**
* <pre>
* Sends a greeting
* </pre>
*/
- public reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloRequest> reactorRequest);
+ public reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloRequest> reactorRequest) {
+ GreeterGrpc.GreeterStub localStub = stub.withDeadlineAfter(url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS);
+ return com.salesforce.reactorgrpc.stub.ClientCalls.oneToOne(reactorRequest, localStub::sayHello);
+ }
/**
* <pre>
* Sends a greeting
* </pre>
*/
- public reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(io.grpc.examples.helloworld.HelloRequest reactorRequest);
+ public reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(io.grpc.examples.helloworld.HelloRequest reactorRequest) {
+ GreeterGrpc.GreeterStub localStub = stub.withDeadlineAfter(url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS);
+ return com.salesforce.reactorgrpc.stub.ClientCalls.oneToOne(reactor.core.publisher.Mono.just(reactorRequest), localStub::sayHello);
+ }
-}
+ }
/**
* <pre>
* The greeting service definition.
* </pre>
*/
-public static abstract class GreeterImplBase implements IReactorGreeter, io.grpc.BindableService {
+ public static abstract class GreeterImplBase implements IReactorGreeter, io.grpc.BindableService {
-private IReactorGreeter proxiedImpl;
+ private IReactorGreeter proxiedImpl;
-public final void setProxiedImpl(IReactorGreeter proxiedImpl) {
-this.proxiedImpl = proxiedImpl;
-}
+ public final void setProxiedImpl(IReactorGreeter proxiedImpl) {
+ this.proxiedImpl = proxiedImpl;
+ }
/**
* <pre>
* Sends a greeting
* </pre>
*/
- public final reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(io.grpc.examples.helloworld.HelloRequest reactorRequest) {
- throw new UnsupportedOperationException("No need to override this method, extend XxxImplBase and override all methods it allows.");
- }
+ public final reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(io.grpc.examples.helloworld.HelloRequest reactorRequest) {
+ throw new UnsupportedOperationException("No need to override this method, extend XxxImplBase and override all methods it allows.");
+ }
/**
* <pre>
* Sends a greeting
* </pre>
*/
- public reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloRequest> request) {
- throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED);
- }
-
-@java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
-return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
- .addMethod(
- io.grpc.examples.helloworld.GreeterGrpc.getSayHelloMethod(),
- asyncUnaryCall(
- new MethodHandlers<
- io.grpc.examples.helloworld.HelloRequest,
- io.grpc.examples.helloworld.HelloReply>(
- proxiedImpl, METHODID_SAY_HELLO)))
-.build();
-}
-}
-
- private static final int METHODID_SAY_HELLO = 0;
-
-private static final class MethodHandlers
-<Req, Resp> implements
-io.grpc.stub.ServerCalls.UnaryMethod
-<Req, Resp>,
-io.grpc.stub.ServerCalls.ServerStreamingMethod
-<Req, Resp>,
-io.grpc.stub.ServerCalls.ClientStreamingMethod
-<Req, Resp>,
-io.grpc.stub.ServerCalls.BidiStreamingMethod
-<Req, Resp> {
-private final IReactorGreeter serviceImpl;
-private final int methodId;
-
-MethodHandlers(IReactorGreeter serviceImpl, int methodId) {
-this.serviceImpl = serviceImpl;
-this.methodId = methodId;
-}
-
-@java.lang.Override
-@java.lang.SuppressWarnings("unchecked")
-public void invoke(Req request, io.grpc.stub.StreamObserver
-<Resp> responseObserver) {
- switch (methodId) {
- case METHODID_SAY_HELLO:
- com.salesforce.reactorgrpc.stub.ServerCalls.oneToOne((io.grpc.examples.helloworld.HelloRequest) request,
- (io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply>) responseObserver,
- serviceImpl::sayHello);
- break;
- default:
- throw new java.lang.AssertionError();
- }
+ public reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloReply> sayHello(reactor.core.publisher.Mono<io.grpc.examples.helloworld.HelloRequest> request) {
+ throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED);
+ }
+
+ @java.lang.Override
+ public final io.grpc.ServerServiceDefinition bindService() {
+ return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
+ .addMethod(
+ io.grpc.examples.helloworld.GreeterGrpc.getSayHelloMethod(),
+ asyncUnaryCall(
+ new MethodHandlers<
+ io.grpc.examples.helloworld.HelloRequest,
+ io.grpc.examples.helloworld.HelloReply>(
+ proxiedImpl, METHODID_SAY_HELLO)))
+ .build();
+ }
}
- @java.lang.Override
- @java.lang.SuppressWarnings("unchecked")
- public io.grpc.stub.StreamObserver
- <Req> invoke(io.grpc.stub.StreamObserver
- <Resp> responseObserver) {
+ private static final class MethodHandlers
+ <Req, Resp> implements
+ io.grpc.stub.ServerCalls.UnaryMethod
+ <Req, Resp>,
+ io.grpc.stub.ServerCalls.ServerStreamingMethod
+ <Req, Resp>,
+ io.grpc.stub.ServerCalls.ClientStreamingMethod
+ <Req, Resp>,
+ io.grpc.stub.ServerCalls.BidiStreamingMethod
+ <Req, Resp> {
+ private final IReactorGreeter serviceImpl;
+ private final int methodId;
+
+ MethodHandlers(IReactorGreeter serviceImpl, int methodId) {
+ this.serviceImpl = serviceImpl;
+ this.methodId = methodId;
+ }
+
+ @java.lang.Override
+ @java.lang.SuppressWarnings("unchecked")
+ public void invoke(Req request, io.grpc.stub.StreamObserver
+ <Resp> responseObserver) {
switch (methodId) {
- default:
- throw new java.lang.AssertionError();
- }
- }
+ case METHODID_SAY_HELLO:
+ com.salesforce.reactorgrpc.stub.ServerCalls.oneToOne((io.grpc.examples.helloworld.HelloRequest) request,
+ (io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply>) responseObserver,
+ serviceImpl::sayHello);
+ break;
+ default:
+ throw new java.lang.AssertionError();
}
+ }
+ @java.lang.Override
+ @java.lang.SuppressWarnings("unchecked")
+ public io.grpc.stub.StreamObserver
+ <Req> invoke(io.grpc.stub.StreamObserver
+ <Resp> responseObserver) {
+ switch (methodId) {
+ default:
+ throw new java.lang.AssertionError();
}
+ }
+ }
+
+}
diff --git a/java/dubbo-samples-grpc/dubbo-samples-reactor/pom.xml b/java/dubbo-samples-grpc/dubbo-samples-reactor/pom.xml
index 16c5ef3..11af5b5 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-reactor/pom.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-reactor/pom.xml
@@ -104,6 +104,13 @@
<version>${spring-test.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>1.12.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
@@ -112,89 +119,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-maven-address-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>local-address</goal>
- </goals>
- <configuration>
- <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>${java-image.name}</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>
- </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>
@@ -205,9 +129,6 @@
<goal>verify</goal>
</goals>
<configuration>
- <systemPropertyVariables>
- <zookeeper.address>${dubbo-local-address}</zookeeper.address>
- </systemPropertyVariables>
<includes>
<include>**/*IT.java</include>
</includes>
@@ -263,6 +184,8 @@
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
+ <goal>test-compile</goal>
+ <goal>test-compile-custom</goal>
</goals>
</execution>
</executions>
@@ -285,22 +208,6 @@
</executions>
</plugin>
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>${spring-boot.version}</version>
- <configuration>
- <mainClass>${main-class}</mainClass>
- <layout>JAR</layout>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
diff --git a/java/dubbo-samples-grpc/dubbo-samples-reactor/src/main/resources/spring/dubbo-demo-consumer.xml b/java/dubbo-samples-grpc/dubbo-samples-reactor/src/main/resources/spring/dubbo-demo-consumer.xml
index 1497dbc..7f96c37 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-reactor/src/main/resources/spring/dubbo-demo-consumer.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-reactor/src/main/resources/spring/dubbo-demo-consumer.xml
@@ -27,6 +27,6 @@
<dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <dubbo:reference id="greeter" interface="io.grpc.examples.helloworld.ReactorDubboGreeterGrpc$IReactorGreeter" protocol="grpc"/>
+ <dubbo:reference scope="remote" id="greeter" interface="io.grpc.examples.helloworld.ReactorDubboGreeterGrpc$IReactorGreeter" protocol="grpc"/>
</beans>
diff --git a/java/dubbo-samples-grpc/dubbo-samples-reactor/src/main/resources/spring/dubbo-demo-provider.xml b/java/dubbo-samples-grpc/dubbo-samples-reactor/src/main/resources/spring/dubbo-demo-provider.xml
index 874a06b..b061e22 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-reactor/src/main/resources/spring/dubbo-demo-provider.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-reactor/src/main/resources/spring/dubbo-demo-provider.xml
@@ -29,7 +29,7 @@
<dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <bean id="greeter" class="org.apache.dubbo.samples.basic.impl.helloworld.GrpcGreeterImpl"/>
- <dubbo:service interface="io.grpc.examples.helloworld.ReactorDubboGreeterGrpc$IReactorGreeter" ref="greeter" protocol="grpc"/>
+ <bean id="greeterImpl" class="org.apache.dubbo.samples.basic.impl.helloworld.GrpcGreeterImpl"/>
+ <dubbo:service interface="io.grpc.examples.helloworld.ReactorDubboGreeterGrpc$IReactorGreeter" ref="greeterImpl" protocol="grpc"/>
</beans>
diff --git a/java/dubbo-samples-grpc/dubbo-samples-reactor/src/test/java/org/apache/dubbo/samples/ReactorGrpcIT.java b/java/dubbo-samples-grpc/dubbo-samples-reactor/src/test/java/org/apache/dubbo/samples/ReactorGrpcIT.java
new file mode 100644
index 0000000..b9b070a
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-reactor/src/test/java/org/apache/dubbo/samples/ReactorGrpcIT.java
@@ -0,0 +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
+ *
+ * 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;
+
+import io.grpc.examples.helloworld.HelloRequest;
+import io.grpc.examples.helloworld.ReactorDubboGreeterGrpc;
+import org.junit.Assert;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.testcontainers.containers.FixedHostPortGenericContainer;
+import org.testcontainers.containers.GenericContainer;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath*:spring/dubbo-demo-consumer.xml", "classpath*:spring/dubbo-demo-provider.xml"})
+public class ReactorGrpcIT {
+//
+// static {
+// try {
+// GenericContainer zookeeper = new GenericContainer<>("zookeeper:3.4.9")
+// .withExposedPorts(2181).waitFor();
+//
+// System.setProperty("zookeeper.address", zookeeper.getContainerIpAddress());
+// System.setProperty("zookeeper.port", zookeeper.getFirstMappedPort() + "");
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
+//
+ // port mapping, https://github.com/testcontainers/testcontainers-java/issues/256
+ @ClassRule
+ public static GenericContainer zookeeper = new FixedHostPortGenericContainer("zookeeper:3.4.9")
+ .withFixedExposedPort(2181, 2181);
+
+ @Autowired
+ @Qualifier("greeter")
+ private ReactorDubboGreeterGrpc.IReactorGreeter greeter;
+
+ @Test
+ public void testGreeting() throws Exception {
+ greeter.sayHello(HelloRequest.newBuilder().setName("world!").build())
+ .subscribe(reply -> Assert.assertTrue(reply.getMessage().startsWith("Hello world!")));
+ Thread.sleep(100);
+ }
+}
+
diff --git a/java/dubbo-samples-grpc/dubbo-samples-rxjava/build/generated/source/proto/main/java/io/grpc/examples/helloworld/RxDubboGreeterGrpc.java b/java/dubbo-samples-grpc/dubbo-samples-rxjava/build/generated/source/proto/main/java/io/grpc/examples/helloworld/RxDubboGreeterGrpc.java
index 3508d61..4487b9f 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-rxjava/build/generated/source/proto/main/java/io/grpc/examples/helloworld/RxDubboGreeterGrpc.java
+++ b/java/dubbo-samples-grpc/dubbo-samples-rxjava/build/generated/source/proto/main/java/io/grpc/examples/helloworld/RxDubboGreeterGrpc.java
@@ -5,26 +5,42 @@ import org.apache.dubbo.config.ReferenceConfigBase;
import java.util.concurrent.TimeUnit;
-import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
-import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
-
import static io.grpc.examples.helloworld.GreeterGrpc.getServiceDescriptor;
import static io.grpc.stub.ServerCalls.asyncUnaryCall;
-import static io.grpc.stub.ServerCalls.asyncServerStreamingCall;
-import static io.grpc.stub.ServerCalls.asyncClientStreamingCall;
-import static io.grpc.stub.ServerCalls.asyncBidiStreamingCall;
+import static org.apache.dubbo.common.constants.CommonConstants.DEFAULT_TIMEOUT;
+import static org.apache.dubbo.common.constants.CommonConstants.TIMEOUT_KEY;
@javax.annotation.Generated(
-value = "by RxDubboGrpc generator",
-comments = "Source: helloworld.proto")
+ value = "by RxDubboGrpc generator",
+ comments = "Source: helloworld.proto")
public final class RxDubboGreeterGrpc {
- private RxDubboGreeterGrpc() {}
+ private static final int METHODID_SAY_HELLO = 0;
+
+ private RxDubboGreeterGrpc() {
+ }
public static RxDubboGreeterStub getDubboStub(io.grpc.Channel channel, io.grpc.CallOptions callOptions, URL url, ReferenceConfigBase<?> referenceConfig) {
return new RxDubboGreeterStub(channel, callOptions, url, referenceConfig);
}
+ public interface IRxGreeter {
+ /**
+ * <pre>
+ * Sends a greeting
+ * </pre>
+ */
+ public io.reactivex.Single<io.grpc.examples.helloworld.HelloReply> sayHello(io.reactivex.Single<io.grpc.examples.helloworld.HelloRequest> rxRequest);
+
+ /**
+ * <pre>
+ * Sends a greeting
+ * </pre>
+ */
+ public io.reactivex.Single<io.grpc.examples.helloworld.HelloReply> sayHello(io.grpc.examples.helloworld.HelloRequest rxRequest);
+
+ }
+
/**
* <pre>
* The greeting service definition.
@@ -50,12 +66,12 @@ public final class RxDubboGreeterGrpc {
*/
public io.reactivex.Single<io.grpc.examples.helloworld.HelloReply> sayHello(io.reactivex.Single<io.grpc.examples.helloworld.HelloRequest> rxRequest) {
return com.salesforce.rxgrpc.stub.ClientCalls.oneToOne(rxRequest,
- new com.salesforce.reactivegrpc.common.BiConsumer<io.grpc.examples.helloworld.HelloRequest, io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply>>() {
- @java.lang.Override
- public void accept(io.grpc.examples.helloworld.HelloRequest request, io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply> observer) {
- stub.withDeadlineAfter(url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS).sayHello(request, observer);
- }
- });
+ new com.salesforce.reactivegrpc.common.BiConsumer<io.grpc.examples.helloworld.HelloRequest, io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply>>() {
+ @java.lang.Override
+ public void accept(io.grpc.examples.helloworld.HelloRequest request, io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply> observer) {
+ stub.withDeadlineAfter(url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS).sayHello(request, observer);
+ }
+ });
}
/**
@@ -65,34 +81,16 @@ public final class RxDubboGreeterGrpc {
*/
public io.reactivex.Single<io.grpc.examples.helloworld.HelloReply> sayHello(io.grpc.examples.helloworld.HelloRequest rxRequest) {
return com.salesforce.rxgrpc.stub.ClientCalls.oneToOne(io.reactivex.Single.just(rxRequest),
- new com.salesforce.reactivegrpc.common.BiConsumer<io.grpc.examples.helloworld.HelloRequest, io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply>>() {
- @java.lang.Override
- public void accept(io.grpc.examples.helloworld.HelloRequest request, io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply> observer) {
- stub.withDeadlineAfter(url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS).sayHello(request, observer);
- }
- });
+ new com.salesforce.reactivegrpc.common.BiConsumer<io.grpc.examples.helloworld.HelloRequest, io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply>>() {
+ @java.lang.Override
+ public void accept(io.grpc.examples.helloworld.HelloRequest request, io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply> observer) {
+ stub.withDeadlineAfter(url.getParameter(TIMEOUT_KEY, DEFAULT_TIMEOUT), TimeUnit.MILLISECONDS).sayHello(request, observer);
+ }
+ });
}
}
- public interface IRxGreeter {
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- public io.reactivex.Single<io.grpc.examples.helloworld.HelloReply> sayHello(io.reactivex.Single<io.grpc.examples.helloworld.HelloRequest> rxRequest);
-
- /**
- * <pre>
- * Sends a greeting
- * </pre>
- */
- public io.reactivex.Single<io.grpc.examples.helloworld.HelloReply> sayHello(io.grpc.examples.helloworld.HelloRequest rxRequest);
-
- }
-
-
/**
* <pre>
* The greeting service definition.
@@ -105,7 +103,8 @@ public final class RxDubboGreeterGrpc {
public final void setProxiedImpl(IRxGreeter proxiedImpl) {
this.proxiedImpl = proxiedImpl;
}
- /**
+
+ /**
* <pre>
* Sends a greeting
* </pre>
@@ -123,7 +122,8 @@ public final class RxDubboGreeterGrpc {
throw new io.grpc.StatusRuntimeException(io.grpc.Status.UNIMPLEMENTED);
}
- @java.lang.Override public final io.grpc.ServerServiceDefinition bindService() {
+ @java.lang.Override
+ public final io.grpc.ServerServiceDefinition bindService() {
return io.grpc.ServerServiceDefinition.builder(getServiceDescriptor())
.addMethod(
io.grpc.examples.helloworld.GreeterGrpc.getSayHelloMethod(),
@@ -136,13 +136,16 @@ public final class RxDubboGreeterGrpc {
}
}
- private static final int METHODID_SAY_HELLO = 0;
-
- private static final class MethodHandlers<Req, Resp> implements
- io.grpc.stub.ServerCalls.UnaryMethod<Req, Resp>,
- io.grpc.stub.ServerCalls.ServerStreamingMethod<Req, Resp>,
- io.grpc.stub.ServerCalls.ClientStreamingMethod<Req, Resp>,
- io.grpc.stub.ServerCalls.BidiStreamingMethod<Req, Resp> {
+ private static final class MethodHandlers
+ <Req, Resp> implements
+ io.grpc.stub.ServerCalls.UnaryMethod
+ <Req, Resp>,
+ io.grpc.stub.ServerCalls.ServerStreamingMethod
+ <Req, Resp>,
+ io.grpc.stub.ServerCalls.ClientStreamingMethod
+ <Req, Resp>,
+ io.grpc.stub.ServerCalls.BidiStreamingMethod
+ <Req, Resp> {
private final IRxGreeter serviceImpl;
private final int methodId;
@@ -153,12 +156,15 @@ public final class RxDubboGreeterGrpc {
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
- public void invoke(Req request, io.grpc.stub.StreamObserver<Resp> responseObserver) {
+ public void invoke(Req request, io.grpc.stub.StreamObserver
+ <Resp> responseObserver) {
switch (methodId) {
case METHODID_SAY_HELLO:
com.salesforce.rxgrpc.stub.ServerCalls.oneToOne((io.grpc.examples.helloworld.HelloRequest) request,
(io.grpc.stub.StreamObserver<io.grpc.examples.helloworld.HelloReply>) responseObserver,
- new com.salesforce.reactivegrpc.common.Function<io.reactivex.Single<io.grpc.examples.helloworld.HelloRequest>, io.reactivex.Single<io.grpc.examples.helloworld.HelloReply>>() {
+ new com.salesforce.reactivegrpc.common.Function
+ <io.reactivex.Single
+ <io.grpc.examples.helloworld.HelloRequest>, io.reactivex.Single<io.grpc.examples.helloworld.HelloReply>>() {
@java.lang.Override
public io.reactivex.Single<io.grpc.examples.helloworld.HelloReply> apply(io.reactivex.Single<io.grpc.examples.helloworld.HelloRequest> single) {
return serviceImpl.sayHello(single);
@@ -172,7 +178,9 @@ public final class RxDubboGreeterGrpc {
@java.lang.Override
@java.lang.SuppressWarnings("unchecked")
- public io.grpc.stub.StreamObserver<Req> invoke(io.grpc.stub.StreamObserver<Resp> responseObserver) {
+ public io.grpc.stub.StreamObserver
+ <Req> invoke(io.grpc.stub.StreamObserver
+ <Resp> responseObserver) {
switch (methodId) {
default:
throw new java.lang.AssertionError();
diff --git a/java/dubbo-samples-grpc/dubbo-samples-rxjava/pom.xml b/java/dubbo-samples-grpc/dubbo-samples-rxjava/pom.xml
index 201a585..02e98aa 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-rxjava/pom.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-rxjava/pom.xml
@@ -104,6 +104,13 @@
<version>${spring-test.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>1.12.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
@@ -112,89 +119,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-maven-address-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>local-address</goal>
- </goals>
- <configuration>
- <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>${java-image.name}</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>
- </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>
@@ -205,9 +129,6 @@
<goal>verify</goal>
</goals>
<configuration>
- <systemPropertyVariables>
- <zookeeper.address>${dubbo-local-address}</zookeeper.address>
- </systemPropertyVariables>
<includes>
<include>**/*IT.java</include>
</includes>
@@ -263,6 +184,8 @@
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
+ <goal>test-compile</goal>
+ <goal>test-compile-custom</goal>
</goals>
</execution>
</executions>
@@ -284,23 +207,6 @@
</execution>
</executions>
</plugin>
-
- <plugin>
- <groupId>org.springframework.boot</groupId>
- <artifactId>spring-boot-maven-plugin</artifactId>
- <version>${spring-boot.version}</version>
- <configuration>
- <mainClass>${main-class}</mainClass>
- <layout>JAR</layout>
- </configuration>
- <executions>
- <execution>
- <goals>
- <goal>repackage</goal>
- </goals>
- </execution>
- </executions>
- </plugin>
</plugins>
</build>
diff --git a/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/main/resources/spring/dubbo-demo-consumer.xml b/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/main/resources/spring/dubbo-demo-consumer.xml
index 094d0e4..ac249bd 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/main/resources/spring/dubbo-demo-consumer.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/main/resources/spring/dubbo-demo-consumer.xml
@@ -27,6 +27,6 @@
<dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <dubbo:reference id="greeter" interface="io.grpc.examples.helloworld.RxDubboGreeterGrpc$IRxGreeter" protocol="grpc"/>
+ <dubbo:reference scope="remote" id="greeter" interface="io.grpc.examples.helloworld.RxDubboGreeterGrpc$IRxGreeter" protocol="grpc"/>
</beans>
diff --git a/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/main/resources/spring/dubbo-demo-provider.xml b/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/main/resources/spring/dubbo-demo-provider.xml
index c2c2077..a20e905 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/main/resources/spring/dubbo-demo-provider.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/main/resources/spring/dubbo-demo-provider.xml
@@ -29,7 +29,7 @@
<dubbo:registry address="zookeeper://${zookeeper.address:127.0.0.1}:2181"/>
- <bean id="greeter" class="org.apache.dubbo.samples.basic.impl.helloworld.GrpcGreeterImpl"/>
- <dubbo:service interface="io.grpc.examples.helloworld.RxDubboGreeterGrpc$IRxGreeter" ref="greeter" protocol="grpc"/>
+ <bean id="greeterImpl" class="org.apache.dubbo.samples.basic.impl.helloworld.GrpcGreeterImpl"/>
+ <dubbo:service interface="io.grpc.examples.helloworld.RxDubboGreeterGrpc$IRxGreeter" ref="greeterImpl" protocol="grpc"/>
</beans>
diff --git a/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/test/java/org/apache/dubbo/samples/RxGrpcIT.java b/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/test/java/org/apache/dubbo/samples/RxGrpcIT.java
new file mode 100644
index 0000000..093b258
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/test/java/org/apache/dubbo/samples/RxGrpcIT.java
@@ -0,0 +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
+ *
+ * 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;
+
+import io.grpc.examples.helloworld.HelloRequest;
+import io.grpc.examples.helloworld.RxDubboGreeterGrpc;
+import org.junit.Assert;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Qualifier;
+import org.springframework.test.context.ContextConfiguration;
+import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.testcontainers.containers.FixedHostPortGenericContainer;
+import org.testcontainers.containers.GenericContainer;
+
+@RunWith(SpringJUnit4ClassRunner.class)
+@ContextConfiguration(locations = {"classpath*:spring/dubbo-demo-consumer.xml", "classpath*:spring/dubbo-demo-provider.xml"})
+public class RxGrpcIT {
+//
+// static {
+// try {
+// GenericContainer zookeeper = new GenericContainer<>("zookeeper:3.4.9")
+// .withExposedPorts(2181).waitFor();
+//
+// System.setProperty("zookeeper.address", zookeeper.getContainerIpAddress());
+// System.setProperty("zookeeper.port", zookeeper.getFirstMappedPort() + "");
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
+// }
+//
+ // port mapping, https://github.com/testcontainers/testcontainers-java/issues/256
+ @ClassRule
+ public static GenericContainer zookeeper = new FixedHostPortGenericContainer("zookeeper:3.4.9")
+ .withFixedExposedPort(2181, 2181);
+
+ @Autowired
+ @Qualifier("greeter")
+ private RxDubboGreeterGrpc.IRxGreeter greeter;
+
+ @Test
+ public void testGreeting() throws Exception {
+ greeter.sayHello(HelloRequest.newBuilder().setName("world!").build())
+ .subscribe(reply -> Assert.assertTrue(reply.getMessage().startsWith("Hello world!")));
+ Thread.sleep(100);
+ }
+}
+
diff --git a/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/test/proto/helloworld.proto b/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/test/proto/helloworld.proto
new file mode 100644
index 0000000..c60d941
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-rxjava/src/test/proto/helloworld.proto
@@ -0,0 +1,37 @@
+// Copyright 2015 The gRPC Authors
+//
+// Licensed 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.
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "io.grpc.examples.helloworld";
+option java_outer_classname = "HelloWorldProto";
+option objc_class_prefix = "HLW";
+
+package helloworld;
+
+// The greeting service definition.
+service Greeter {
+ // Sends a greeting
+ rpc SayHello (HelloRequest) returns (HelloReply) {}
+}
+
+// The request message containing the user's name.
+message HelloRequest {
+ string name = 1;
+}
+
+// The response message containing the greetings
+message HelloReply {
+ string message = 1;
+}
diff --git a/java/dubbo-samples-grpc/dubbo-samples-original/pom.xml b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/pom.xml
similarity index 68%
copy from java/dubbo-samples-grpc/dubbo-samples-original/pom.xml
copy to java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/pom.xml
index 060565d..f4ef09b 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-original/pom.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/pom.xml
@@ -23,7 +23,7 @@
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-samples-original-grpc</artifactId>
+ <artifactId>dubbo-samples-grpc-ssl-consumer</artifactId>
<properties>
<source.level>1.8</source.level>
@@ -35,7 +35,7 @@
<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>${project.artifactId}:${dubbo.version}</image.name>
+ <image.name>${artifactId}:${dubbo.version}</image.name>
<java-image.name>openjdk:8</java-image.name>
<dubbo.port>20880</dubbo.port>
<zookeeper.port>2181</zookeeper.port>
@@ -97,6 +97,13 @@
<version>${spring-test.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>1.12.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
@@ -105,89 +112,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-maven-address-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>local-address</goal>
- </goals>
- <configuration>
- <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>${java-image.name}</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>
- </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>
@@ -198,9 +122,6 @@
<goal>verify</goal>
</goals>
<configuration>
- <systemPropertyVariables>
- <zookeeper.address>${dubbo-local-address}</zookeeper.address>
- </systemPropertyVariables>
<includes>
<include>**/*IT.java</include>
</includes>
@@ -256,6 +177,8 @@
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
+ <goal>test-compile</goal>
+ <goal>test-compile-custom</goal>
</goals>
</execution>
</executions>
@@ -277,23 +200,25 @@
</execution>
</executions>
</plugin>
-
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
- <version>${spring-boot.version}</version>
<configuration>
- <mainClass>${main-class}</mainClass>
- <layout>JAR</layout>
+ <executable>true</executable>
+ <mainClass>org.apache.dubbo.samples.basic.SslBasicConsumer</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
+ <configuration>
+ <classifier>exec</classifier>
+ </configuration>
</execution>
</executions>
</plugin>
+
</plugins>
</build>
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/java/org/apache/dubbo/samples/basic/SslBasicConsumer.java b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/java/org/apache/dubbo/samples/basic/SslBasicConsumer.java
new file mode 100644
index 0000000..66572ab
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/java/org/apache/dubbo/samples/basic/SslBasicConsumer.java
@@ -0,0 +1,74 @@
+/*
+ *
+ * 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.basic;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.SslConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+
+import io.grpc.examples.helloworld.HelloReply;
+import io.grpc.examples.helloworld.HelloRequest;
+
+import static io.grpc.examples.helloworld.DubboGreeterGrpc.IGreeter;
+
+public class SslBasicConsumer {
+
+ private static final String ROOT_DIR = System.getProperty("user.dir");
+
+ public static void main(String[] args) {
+ SslConfig sslConfig = new SslConfig();
+ if (args.length > 0) {
+ if (args.length != 1 && args.length != 3) {
+ System.out.println(
+ "USAGE: BasicConsumer [trustCertCollectionFilePath [certChainFilePath privateKeyFilePath]]\n " +
+ "Specify 'certChainFilePath' and 'privateKeyFilePath' only if you need Mutual TLS.");
+ System.exit(0);
+ }
+
+ switch (args.length) {
+ case 1:
+ sslConfig.setClientTrustCertCollectionPath(args[0]);
+ break;
+ case 3:
+ sslConfig.setClientTrustCertCollectionPath(args[0]);
+ sslConfig.setClientKeyCertChainPath(args[1]);
+ sslConfig.setClientPrivateKeyPath(args[2]);
+ }
+ }
+
+ DubboBootstrap bootstrap = DubboBootstrap.getInstance()
+ .application(new ApplicationConfig("first-dubbo-consumer"))
+ .registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
+ .ssl(sslConfig);
+
+ ReferenceConfig<IGreeter> reference = new ReferenceConfig<>();
+ reference.setInterface(IGreeter.class);
+
+ bootstrap.reference(reference);
+
+ bootstrap.start();
+
+ IGreeter service = bootstrap.getCache().get(reference);
+ HelloReply helloReply = service.sayHello(HelloRequest.newBuilder().setName("dubbo").build());
+ System.out.println(helloReply.getMessage());
+ }
+}
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/proto/helloworld.proto b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/proto/helloworld.proto
new file mode 100644
index 0000000..c60d941
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/proto/helloworld.proto
@@ -0,0 +1,37 @@
+// Copyright 2015 The gRPC Authors
+//
+// Licensed 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.
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "io.grpc.examples.helloworld";
+option java_outer_classname = "HelloWorldProto";
+option objc_class_prefix = "HLW";
+
+package helloworld;
+
+// The greeting service definition.
+service Greeter {
+ // Sends a greeting
+ rpc SayHello (HelloRequest) returns (HelloReply) {}
+}
+
+// The request message containing the user's name.
+message HelloRequest {
+ string name = 1;
+}
+
+// The response message containing the greetings
+message HelloReply {
+ string message = 1;
+}
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/proto/route_guide.proto b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/proto/route_guide.proto
new file mode 100644
index 0000000..3c179f2
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/proto/route_guide.proto
@@ -0,0 +1,115 @@
+// Copyright 2015 The gRPC Authors
+//
+// Licensed 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.
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "io.grpc.examples.routeguide";
+option java_outer_classname = "RouteGuideProto";
+option objc_class_prefix = "RTG";
+
+package routeguide;
+
+// Interface exported by the server.
+service RouteGuide {
+ // A simple RPC.
+ //
+ // Obtains the feature at a given position.
+ //
+ // A feature with an empty name is returned if there's no feature at the given
+ // position.
+ rpc GetFeature(Point) returns (Feature) {}
+
+ // A server-to-client streaming RPC.
+ //
+ // Obtains the Features available within the given Rectangle. Results are
+ // streamed rather than returned at once (e.g. in a response message with a
+ // repeated field), as the rectangle may cover a large area and contain a
+ // huge number of features.
+ rpc ListFeatures(Rectangle) returns (stream Feature) {}
+
+ // A client-to-server streaming RPC.
+ //
+ // Accepts a stream of Points on a route being traversed, returning a
+ // RouteSummary when traversal is completed.
+ rpc RecordRoute(stream Point) returns (RouteSummary) {}
+
+ // A Bidirectional streaming RPC.
+ //
+ // Accepts a stream of RouteNotes sent while a route is being traversed,
+ // while receiving other RouteNotes (e.g. from other users).
+ rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
+}
+
+// Points are represented as latitude-longitude pairs in the E7 representation
+// (degrees multiplied by 10**7 and rounded to the nearest integer).
+// Latitudes should be in the range +/- 90 degrees and longitude should be in
+// the range +/- 180 degrees (inclusive).
+message Point {
+ int32 latitude = 1;
+ int32 longitude = 2;
+}
+
+// A latitude-longitude rectangle, represented as two diagonally opposite
+// points "lo" and "hi".
+message Rectangle {
+ // One corner of the rectangle.
+ Point lo = 1;
+
+ // The other corner of the rectangle.
+ Point hi = 2;
+}
+
+// A feature names something at a given point.
+//
+// If a feature could not be named, the name is empty.
+message Feature {
+ // The name of the feature.
+ string name = 1;
+
+ // The point where the feature is detected.
+ Point location = 2;
+}
+
+// Not used in the RPC. Instead, this is here for the form serialized to disk.
+message FeatureDatabase {
+ repeated Feature feature = 1;
+}
+
+// A RouteNote is a message sent while at a given point.
+message RouteNote {
+ // The location from which the message is sent.
+ Point location = 1;
+
+ // The message to be sent.
+ string message = 2;
+}
+
+// A RouteSummary is received in response to a RecordRoute rpc.
+//
+// It contains the number of individual points received, the number of
+// detected features, and the total distance covered as the cumulative sum of
+// the distance between each point.
+message RouteSummary {
+ // The number of points received.
+ int32 point_count = 1;
+
+ // The number of known features passed while traversing the route.
+ int32 feature_count = 2;
+
+ // The distance covered in metres.
+ int32 distance = 3;
+
+ // The duration of the traversal in seconds.
+ int32 elapsed_time = 4;
+}
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/ca.key b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/ca.key
new file mode 100644
index 0000000..03c4f95
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/ca.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAMBA3wVeTGHZR1Ry
+e/i+J8a2cu5gXwFV6TnObzGM7bLFCO5i9v4mLo4iFzPsHmWDUxKS3Y8iXbu0eYBl
+LoNY0lSvxDx33O+DuwMmVN+DzSD+Eod9zfvwOWHsazYCZT2PhNxnVWIuJXViY4JA
+HUGodjx+QAi6yCAurUZGvYXGgZSBAgMBAAECgYAxRi8i9BlFlufGSBVoGmydbJOm
+bwLKl9dP3o33ODSP9hok5y6A0w5plWk3AJSF1hPLleK9VcSKYGYnt0clmPVHF35g
+bx2rVK8dOT0mn7rz9Zr70jcSz1ETA2QonHZ+Y+niLmcic9At6hRtWiewblUmyFQm
+GwggIzi7LOyEUHrEcQJBAOXxyQvnLvtKzXiqcsW/K6rExqVJVk+KF0fzzVyMzTJx
+HRBxUVgvGdEJT7j+7P2kcTyafve0BBzDSPIaDyiJ+Y0CQQDWCb7jASFSbu5M3Zcd
+Gkr4ZKN1XO3VLQX10b22bQYdF45hrTN2tnzRvVUR4q86VVnXmiGiTqmLkXcA2WWf
+pHfFAkAhv9olUBo6MeF0i3frBEMRfm41hk0PwZHnMqZ6pgPcGnQMnMU2rzsXzkkQ
+OwJnvAIOxhJKovZTjmofdqmw5odlAkBYVUdRWjsNUTjJwj3GRf6gyq/nFMYWz3EB
+RWFdM1ttkDYzu45ctO2IhfHg4sPceDMO1s6AtKQmNI9/azkUjITdAkApNa9yFRzc
+TBaDNPd5KVd58LVIzoPQ6i7uMHteLXJUWqSroji6S3s4gKMFJ/dO+ZXIlgQgfJJJ
+ZDL4cdrdkeoM
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/ca.pem b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/ca.pem
new file mode 100644
index 0000000..6c8511a
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/ca.pem
@@ -0,0 +1,15 @@
+-----BEGIN CERTIFICATE-----
+MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
+BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
+aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla
+Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0
+YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT
+BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7
++L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu
+g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd
+Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV
+HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau
+sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m
+oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG
+Dfcog5wrJytaQ6UA0wE=
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/client.key b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/client.key
new file mode 100644
index 0000000..f48d073
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/client.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAOxUR9uhvhbeVUIM
+s5WbH0px0mehl2+6sZpNjzvE2KimZpHzMJHukVH0Ffkvhs0b8+S5Ut9VNUAqd3IM
+JCCAEGtRNoQhM1t9Yr2zAckSvbRacp+FL/Cj9eDmyo00KsVGaeefA4Dh4OW+ZhkT
+NKcldXqkSuj1sEf244JZYuqZp6/tAgMBAAECgYEAi2NSVqpZMafE5YYUTcMGe6QS
+k2jtpsqYgggI2RnLJ/2tNZwYI5pwP8QVSbnMaiF4gokD5hGdrNDfTnb2v+yIwYEH
+0w8+oG7Z81KodsiZSIDJfTGsAZhVNwOz9y0VD8BBZZ1/274Zh52AUKLjZS/ZwIbS
+W2ywya855dPnH/wj+0ECQQD9X8D920kByTNHhBG18biAEZ4pxs9f0OAG8333eVcI
+w2lJDLsYDZrCB2ocgA3lUdozlzPC7YDYw8reg0tkiRY5AkEA7sdNzOeQsQRn7++5
+0bP9DtT/iON1gbfxRzCfCfXdoOtfQWIzTePWtURt9X/5D9NofI0Rg5W2oGy/MLe5
+/sXHVQJBAIup5XrJDkQywNZyAUU2ecn2bCWBFjwtqd+LBmuMciI9fOKsZtEKZrz/
+U0lkeMRoSwvXE8wmGLjjrAbdfohrXFkCQQDZEx/LtIl6JINJQiswVe0tWr6k+ASP
+1WXoTm+HYpoF/XUvv9LccNF1IazFj34hwRQwhx7w/V52Ieb+p0jUMYGxAkEAjDhd
+9pBO1fKXWiXzi9ZKfoyTNcUq3eBSVKwPG2nItg5ycXengjT5sgcWDnciIzW7BIVI
+JiqOszq9GWESErAatg==
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/client.pem b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/client.pem
new file mode 100644
index 0000000..913649b
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/client.pem
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC6TCCAlKgAwIBAgIBCjANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTEwMDEwOTU4WhcNMjUxMTA3
+MDEwOTU4WjBaMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8G
+A1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRMwEQYDVQQDDAp0ZXN0Y2xp
+ZW50MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDsVEfbob4W3lVCDLOVmx9K
+cdJnoZdvurGaTY87xNiopmaR8zCR7pFR9BX5L4bNG/PkuVLfVTVAKndyDCQggBBr
+UTaEITNbfWK9swHJEr20WnKfhS/wo/Xg5sqNNCrFRmnnnwOA4eDlvmYZEzSnJXV6
+pEro9bBH9uOCWWLqmaev7QIDAQABo4HCMIG/MAkGA1UdEwQCMAAwCwYDVR0PBAQD
+AgXgMB0GA1UdDgQWBBQAdbW5Vml/CnYwqdP3mOHDARU+8zBwBgNVHSMEaTBnoVqk
+WDBWMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMY
+SW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2GCCQCRxhke
+HRoqBzAJBgNVHREEAjAAMAkGA1UdEgQCMAAwDQYJKoZIhvcNAQELBQADgYEAf4MM
+k+sdzd720DfrQ0PF2gDauR3M9uBubozDuMuF6ufAuQBJSKGQEGibXbUelrwHmnql
+UjTyfolVcxEBVaF4VFHmn7u6vP7S1NexIDdNUHcULqxIb7Tzl8JYq8OOHD2rQy4H
+s8BXaVIzw4YcaCGAMS0iDX052Sy7e2JhP8Noxvo=
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/server0.key b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/server0.key
new file mode 100644
index 0000000..add153c
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/server0.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANOmffupIGC8YDau
+rOF4eKnHwPszgpkkhWzKsVxhNDBxCVYx4TEjG0XWIO0iyRXupZbUC+7N/8HnEVNa
+8F1jYhng14Iiq99cNQbbnuHHhIztmpocrJTxmnhGzoAnRa1Tb+GnAuRoIHRA/V2c
+VUE9tbikQugFx/SPgXAw6tfWB+YvAgMBAAECgYEAoEq9qzUBgoHoVEGiSPiWWe8g
+5p6yUA1qx2QTQyWTAwT4z0DjjfVKmG99bFsl8+hTnJFnoCp/gnjflEOROwkjp5kG
+m0drqOPx1jeipJjpXYTBu49h+WpZ1PF+KhVtxsIm3OOCvh67iWaKyyOVb5Og8aiR
+jl6dn/TdG/dlGD8AfUECQQDuNMle6p0oU8amC6O9wIMBroxx2nFstzE6O35PLEzG
+/tj0kxxn9Jp2TS9mGaLCzSuXmpjlF4+NOWiBPkrLC2TfAkEA43Xg7uEUkaJAz2/W
+m1lIBTLt+4rIQY/2emh33bDcA+rv8rwwrMMIv17/xPx7bs49YqGG5xufD+Rwl6TL
+qFXYsQJAPrOwagax1aKvwJeBw3oAQhoTKAkLIEXcdGqipe6QSzVcIIz0xjxxyEAr
+AOIwoLxnBCISqwMXq2H4K0UdZPMb2wJAdhdYLY1L6YRMk6XjzImg25oidisKZweA
+FvMv8DgHMj2CUAqmVrt3SivfLH1M9C09L3zfFhOAFHcsgX58gav4MQJBANSBnrHj
+tIq4l8z79CPUIuu3QyeEh+XwY8s5qE5CNTck0U59lzp9NvENHbkx3KO896TTerko
++8bXHMLkJkHPXms=
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/server0.pem b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/server0.pem
new file mode 100644
index 0000000..9458954
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/certs/server0.pem
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC8zCCAlygAwIBAgIBCzANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTEwMDExNDU1WhcNMjUxMTA3
+MDExNDU1WjBkMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8G
+A1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMR0wGwYDVQQDDBQqLnRlc3Qu
+Z29vZ2xlLmNvbS5hdTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA06Z9+6kg
+YLxgNq6s4Xh4qcfA+zOCmSSFbMqxXGE0MHEJVjHhMSMbRdYg7SLJFe6lltQL7s3/
+wecRU1rwXWNiGeDXgiKr31w1Btue4ceEjO2amhyslPGaeEbOgCdFrVNv4acC5Ggg
+dED9XZxVQT21uKRC6AXH9I+BcDDq19YH5i8CAwEAAaOBwjCBvzAJBgNVHRMEAjAA
+MAsGA1UdDwQEAwIF4DAdBgNVHQ4EFgQUbyZIbUvqmePzv40xa0mMaDxLToYwcAYD
+VR0jBGkwZ6FapFgwVjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
+ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEPMA0GA1UEAxMGdGVz
+dGNhggkAkcYZHh0aKgcwCQYDVR0RBAIwADAJBgNVHRIEAjAAMA0GCSqGSIb3DQEB
+CwUAA4GBAJ21MwMf4WwAjafPKn+8Ng7ordtdp6tlkjt+Xub4l4zMr6FCp6dc/Ceh
+6Hj43zYcKpAe5I6eaVcMc9qcYfUb9i4NVX82dMQpAwpNHgqTzqYt6GYEjF3YhKA7
+uOFdA0OvOFJa14SNdNRk9E1Cd/tElXnLnSE4DOguMNvXz8mRKfnD
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/log4j.properties b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/log4j.properties
new file mode 100644
index 0000000..d6ecd5c
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-consumer/src/main/resources/log4j.properties
@@ -0,0 +1,26 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/java/dubbo-samples-grpc/dubbo-samples-original/pom.xml b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/pom.xml
similarity index 68%
copy from java/dubbo-samples-grpc/dubbo-samples-original/pom.xml
copy to java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/pom.xml
index 060565d..18ae5a6 100644
--- a/java/dubbo-samples-grpc/dubbo-samples-original/pom.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/pom.xml
@@ -23,7 +23,7 @@
<modelVersion>4.0.0</modelVersion>
- <artifactId>dubbo-samples-original-grpc</artifactId>
+ <artifactId>dubbo-samples-grpc-ssl-provider</artifactId>
<properties>
<source.level>1.8</source.level>
@@ -35,7 +35,7 @@
<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>${project.artifactId}:${dubbo.version}</image.name>
+ <image.name>${artifactId}:${dubbo.version}</image.name>
<java-image.name>openjdk:8</java-image.name>
<dubbo.port>20880</dubbo.port>
<zookeeper.port>2181</zookeeper.port>
@@ -97,6 +97,13 @@
<version>${spring-test.version}</version>
<scope>test</scope>
</dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>1.12.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
<profiles>
@@ -105,89 +112,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.apache.dubbo</groupId>
- <artifactId>dubbo-maven-address-plugin</artifactId>
- <version>1.0-SNAPSHOT</version>
- <executions>
- <execution>
- <goals>
- <goal>local-address</goal>
- </goals>
- <configuration>
- <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>${java-image.name}</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>
- </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>
@@ -198,9 +122,6 @@
<goal>verify</goal>
</goals>
<configuration>
- <systemPropertyVariables>
- <zookeeper.address>${dubbo-local-address}</zookeeper.address>
- </systemPropertyVariables>
<includes>
<include>**/*IT.java</include>
</includes>
@@ -256,6 +177,8 @@
<goals>
<goal>compile</goal>
<goal>compile-custom</goal>
+ <goal>test-compile</goal>
+ <goal>test-compile-custom</goal>
</goals>
</execution>
</executions>
@@ -281,19 +204,22 @@
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
- <version>${spring-boot.version}</version>
<configuration>
- <mainClass>${main-class}</mainClass>
- <layout>JAR</layout>
+ <executable>true</executable>
+ <mainClass>org.apache.dubbo.samples.basic.SslBasicProvider</mainClass>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
+ <configuration>
+ <classifier>exec</classifier>
+ </configuration>
</execution>
</executions>
</plugin>
+
</plugins>
</build>
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/EmbeddedZooKeeper.java b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/EmbeddedZooKeeper.java
new file mode 100644
index 0000000..13504d5
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/EmbeddedZooKeeper.java
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * Licensed 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.basic;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Properties;
+import java.util.UUID;
+
+import org.apache.zookeeper.server.ServerConfig;
+import org.apache.zookeeper.server.ZooKeeperServerMain;
+import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.context.SmartLifecycle;
+import org.springframework.util.ErrorHandler;
+import org.springframework.util.SocketUtils;
+
+/**
+ * from: https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java
+ *
+ * Helper class to start an embedded instance of standalone (non clustered) ZooKeeper.
+ *
+ * NOTE: at least an external standalone server (if not an ensemble) are recommended, even for
+ * {@link org.springframework.xd.dirt.server.singlenode.SingleNodeApplication}
+ *
+ * @author Patrick Peralta
+ * @author Mark Fisher
+ * @author David Turanski
+ */
+public class EmbeddedZooKeeper implements SmartLifecycle {
+
+ /**
+ * Logger.
+ */
+ private static final Logger logger = LoggerFactory.getLogger(EmbeddedZooKeeper.class);
+
+ /**
+ * ZooKeeper client port. This will be determined dynamically upon startup.
+ */
+ private final int clientPort;
+
+ /**
+ * Whether to auto-start. Default is true.
+ */
+ private boolean autoStartup = true;
+
+ /**
+ * Lifecycle phase. Default is 0.
+ */
+ private int phase = 0;
+
+ /**
+ * Thread for running the ZooKeeper server.
+ */
+ private volatile Thread zkServerThread;
+
+ /**
+ * ZooKeeper server.
+ */
+ private volatile ZooKeeperServerMain zkServer;
+
+ /**
+ * {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread.
+ */
+ private ErrorHandler errorHandler;
+
+ private boolean daemon = true;
+
+ /**
+ * Construct an EmbeddedZooKeeper with a random port.
+ */
+ public EmbeddedZooKeeper() {
+ clientPort = SocketUtils.findAvailableTcpPort();
+ }
+
+ /**
+ * Construct an EmbeddedZooKeeper with the provided port.
+ *
+ * @param clientPort port for ZooKeeper server to bind to
+ */
+ public EmbeddedZooKeeper(int clientPort, boolean daemon) {
+ this.clientPort = clientPort;
+ this.daemon = daemon;
+ }
+
+ /**
+ * Returns the port that clients should use to connect to this embedded server.
+ *
+ * @return dynamically determined client port
+ */
+ public int getClientPort() {
+ return this.clientPort;
+ }
+
+ /**
+ * Specify whether to start automatically. Default is true.
+ *
+ * @param autoStartup whether to start automatically
+ */
+ public void setAutoStartup(boolean autoStartup) {
+ this.autoStartup = autoStartup;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAutoStartup() {
+ return this.autoStartup;
+ }
+
+ /**
+ * Specify the lifecycle phase for the embedded server.
+ *
+ * @param phase the lifecycle phase
+ */
+ public void setPhase(int phase) {
+ this.phase = phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getPhase() {
+ return this.phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isRunning() {
+ return (zkServerThread != null);
+ }
+
+ /**
+ * Start the ZooKeeper server in a background thread.
+ * <p>
+ * Register an error handler via {@link #setErrorHandler} in order to handle
+ * any exceptions thrown during startup or execution.
+ */
+ @Override
+ public synchronized void start() {
+ if (zkServerThread == null) {
+ zkServerThread = new Thread(new ServerRunnable(), "ZooKeeper Server Starter");
+ zkServerThread.setDaemon(daemon);
+ zkServerThread.start();
+ }
+ }
+
+ /**
+ * Shutdown the ZooKeeper server.
+ */
+ @Override
+ public synchronized void stop() {
+ if (zkServerThread != null) {
+ // The shutdown method is protected...thus this hack to invoke it.
+ // This will log an exception on shutdown; see
+ // https://issues.apache.org/jira/browse/ZOOKEEPER-1873 for details.
+ try {
+ Method shutdown = ZooKeeperServerMain.class.getDeclaredMethod("shutdown");
+ shutdown.setAccessible(true);
+ shutdown.invoke(zkServer);
+ }
+
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ // It is expected that the thread will exit after
+ // the server is shutdown; this will block until
+ // the shutdown is complete.
+ try {
+ zkServerThread.join(5000);
+ zkServerThread = null;
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ logger.warn("Interrupted while waiting for embedded ZooKeeper to exit");
+ // abandoning zk thread
+ zkServerThread = null;
+ }
+ }
+ }
+
+ /**
+ * Stop the server if running and invoke the callback when complete.
+ */
+ @Override
+ public void stop(Runnable callback) {
+ stop();
+ callback.run();
+ }
+
+ /**
+ * Provide an {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread. If none
+ * is provided, only error-level logging will occur.
+ *
+ * @param errorHandler the {@link ErrorHandler} to be invoked
+ */
+ public void setErrorHandler(ErrorHandler errorHandler) {
+ this.errorHandler = errorHandler;
+ }
+
+ /**
+ * Runnable implementation that starts the ZooKeeper server.
+ */
+ private class ServerRunnable implements Runnable {
+
+ @Override
+ public void run() {
+ try {
+ Properties properties = new Properties();
+ File file = new File(System.getProperty("java.io.tmpdir")
+ + File.separator + UUID.randomUUID());
+ file.deleteOnExit();
+ properties.setProperty("dataDir", file.getAbsolutePath());
+ properties.setProperty("clientPort", String.valueOf(clientPort));
+
+ QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
+ quorumPeerConfig.parseProperties(properties);
+
+ zkServer = new ZooKeeperServerMain();
+ ServerConfig configuration = new ServerConfig();
+ configuration.readFrom(quorumPeerConfig);
+
+ zkServer.runFromConfig(configuration);
+ }
+ catch (Exception e) {
+ if (errorHandler != null) {
+ errorHandler.handleError(e);
+ }
+ else {
+ logger.error("Exception running embedded ZooKeeper", e);
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/SslBasicProvider.java b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/SslBasicProvider.java
new file mode 100644
index 0000000..bdfed3f
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/SslBasicProvider.java
@@ -0,0 +1,80 @@
+/*
+ *
+ * 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.basic;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.ServiceConfig;
+import org.apache.dubbo.config.SslConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.samples.basic.impl.helloworld.GrpcGreeterImpl;
+
+import java.util.concurrent.CountDownLatch;
+
+import static io.grpc.examples.helloworld.DubboGreeterGrpc.IGreeter;
+
+public class SslBasicProvider {
+
+ private static final String ROOT_DIR = System.getProperty("user.dir");
+
+ public static void main(String[] args) throws Exception {
+ new EmbeddedZooKeeper(2181, false).start();
+ // wait for embedded zookeeper start completely.
+ Thread.sleep(1000);
+
+ SslConfig sslConfig = new SslConfig();
+ if (args.length > 0) {
+ if (args.length < 2 || args.length > 3) {
+ System.out.println(
+ "USAGE: BasicProvider certChainFilePath privateKeyFilePath " +
+ "[trustCertCollectionFilePath]\n Specify 'trustCertCollectionFilePath' only if you want " +
+ "need Mutual TLS.");
+ System.exit(0);
+ }
+
+
+ sslConfig.setServerKeyCertChainPath(args[0]);
+ sslConfig.setServerPrivateKeyPath(args[1]);
+ if (args.length == 3) {
+ sslConfig.setServerTrustCertCollectionPath(args[2]);
+ }
+ }
+
+ ProtocolConfig protocolConfig = new ProtocolConfig("grpc");
+ protocolConfig.setSslEnabled(true);
+
+ DubboBootstrap bootstrap = DubboBootstrap.getInstance();
+ bootstrap.application(new ApplicationConfig("ssl-provider"))
+ .registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
+ .protocol(protocolConfig)
+ .ssl(sslConfig);
+
+ ServiceConfig<IGreeter> service = new ServiceConfig<>();
+ service.setInterface(IGreeter.class);
+ service.setRef(new GrpcGreeterImpl());
+
+ bootstrap.service(service);
+ bootstrap.start();
+
+ System.out.println("dubbo service started");
+ new CountDownLatch(1).await();
+ }
+}
diff --git a/java/dubbo-samples-environment-keys/src/test/java/org/apache/dubbo/samples/basic/DemoServiceIT.java b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/impl/helloworld/GrpcGreeterImpl.java
similarity index 50%
copy from java/dubbo-samples-environment-keys/src/test/java/org/apache/dubbo/samples/basic/DemoServiceIT.java
copy to java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/impl/helloworld/GrpcGreeterImpl.java
index 6d7d7ec..ac7c576 100644
--- a/java/dubbo-samples-environment-keys/src/test/java/org/apache/dubbo/samples/basic/DemoServiceIT.java
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/impl/helloworld/GrpcGreeterImpl.java
@@ -14,28 +14,21 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
+package org.apache.dubbo.samples.basic.impl.helloworld;
-package org.apache.dubbo.samples.basic;
+import io.grpc.examples.helloworld.DubboGreeterGrpc;
+import io.grpc.examples.helloworld.HelloReply;
+import io.grpc.examples.helloworld.HelloRequest;
+import io.grpc.stub.StreamObserver;
-import org.apache.dubbo.samples.basic.api.DemoService;
+public class GrpcGreeterImpl extends DubboGreeterGrpc.GreeterImplBase {
-import org.junit.Assert;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.beans.factory.annotation.Qualifier;
-import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
-
-@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "classpath*:spring/dubbo-demo-consumer.xml")
-public class DemoServiceIT {
- @Autowired
- @Qualifier("demoService")
- private DemoService service;
-
- @Test
- public void testGreeting() throws Exception {
- Assert.assertTrue(service.sayHello("dubbo").startsWith("Hello dubbo"));
+ @Override
+ public void sayHello(HelloRequest request, StreamObserver<HelloReply> responseObserver) {
+ System.out.println("Executing thread is " + Thread.currentThread().getName());
+ HelloReply reply = HelloReply.newBuilder().setMessage("Hello " + request.getName()).build();
+ responseObserver.onNext(reply);
+ responseObserver.onCompleted();
}
+
}
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/proto/helloworld.proto b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/proto/helloworld.proto
new file mode 100644
index 0000000..c60d941
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/proto/helloworld.proto
@@ -0,0 +1,37 @@
+// Copyright 2015 The gRPC Authors
+//
+// Licensed 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.
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "io.grpc.examples.helloworld";
+option java_outer_classname = "HelloWorldProto";
+option objc_class_prefix = "HLW";
+
+package helloworld;
+
+// The greeting service definition.
+service Greeter {
+ // Sends a greeting
+ rpc SayHello (HelloRequest) returns (HelloReply) {}
+}
+
+// The request message containing the user's name.
+message HelloRequest {
+ string name = 1;
+}
+
+// The response message containing the greetings
+message HelloReply {
+ string message = 1;
+}
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/proto/route_guide.proto b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/proto/route_guide.proto
new file mode 100644
index 0000000..3c179f2
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/proto/route_guide.proto
@@ -0,0 +1,115 @@
+// Copyright 2015 The gRPC Authors
+//
+// Licensed 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.
+syntax = "proto3";
+
+option java_multiple_files = true;
+option java_package = "io.grpc.examples.routeguide";
+option java_outer_classname = "RouteGuideProto";
+option objc_class_prefix = "RTG";
+
+package routeguide;
+
+// Interface exported by the server.
+service RouteGuide {
+ // A simple RPC.
+ //
+ // Obtains the feature at a given position.
+ //
+ // A feature with an empty name is returned if there's no feature at the given
+ // position.
+ rpc GetFeature(Point) returns (Feature) {}
+
+ // A server-to-client streaming RPC.
+ //
+ // Obtains the Features available within the given Rectangle. Results are
+ // streamed rather than returned at once (e.g. in a response message with a
+ // repeated field), as the rectangle may cover a large area and contain a
+ // huge number of features.
+ rpc ListFeatures(Rectangle) returns (stream Feature) {}
+
+ // A client-to-server streaming RPC.
+ //
+ // Accepts a stream of Points on a route being traversed, returning a
+ // RouteSummary when traversal is completed.
+ rpc RecordRoute(stream Point) returns (RouteSummary) {}
+
+ // A Bidirectional streaming RPC.
+ //
+ // Accepts a stream of RouteNotes sent while a route is being traversed,
+ // while receiving other RouteNotes (e.g. from other users).
+ rpc RouteChat(stream RouteNote) returns (stream RouteNote) {}
+}
+
+// Points are represented as latitude-longitude pairs in the E7 representation
+// (degrees multiplied by 10**7 and rounded to the nearest integer).
+// Latitudes should be in the range +/- 90 degrees and longitude should be in
+// the range +/- 180 degrees (inclusive).
+message Point {
+ int32 latitude = 1;
+ int32 longitude = 2;
+}
+
+// A latitude-longitude rectangle, represented as two diagonally opposite
+// points "lo" and "hi".
+message Rectangle {
+ // One corner of the rectangle.
+ Point lo = 1;
+
+ // The other corner of the rectangle.
+ Point hi = 2;
+}
+
+// A feature names something at a given point.
+//
+// If a feature could not be named, the name is empty.
+message Feature {
+ // The name of the feature.
+ string name = 1;
+
+ // The point where the feature is detected.
+ Point location = 2;
+}
+
+// Not used in the RPC. Instead, this is here for the form serialized to disk.
+message FeatureDatabase {
+ repeated Feature feature = 1;
+}
+
+// A RouteNote is a message sent while at a given point.
+message RouteNote {
+ // The location from which the message is sent.
+ Point location = 1;
+
+ // The message to be sent.
+ string message = 2;
+}
+
+// A RouteSummary is received in response to a RecordRoute rpc.
+//
+// It contains the number of individual points received, the number of
+// detected features, and the total distance covered as the cumulative sum of
+// the distance between each point.
+message RouteSummary {
+ // The number of points received.
+ int32 point_count = 1;
+
+ // The number of known features passed while traversing the route.
+ int32 feature_count = 2;
+
+ // The distance covered in metres.
+ int32 distance = 3;
+
+ // The duration of the traversal in seconds.
+ int32 elapsed_time = 4;
+}
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/ca.key b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/ca.key
new file mode 100644
index 0000000..03c4f95
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/ca.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAMBA3wVeTGHZR1Ry
+e/i+J8a2cu5gXwFV6TnObzGM7bLFCO5i9v4mLo4iFzPsHmWDUxKS3Y8iXbu0eYBl
+LoNY0lSvxDx33O+DuwMmVN+DzSD+Eod9zfvwOWHsazYCZT2PhNxnVWIuJXViY4JA
+HUGodjx+QAi6yCAurUZGvYXGgZSBAgMBAAECgYAxRi8i9BlFlufGSBVoGmydbJOm
+bwLKl9dP3o33ODSP9hok5y6A0w5plWk3AJSF1hPLleK9VcSKYGYnt0clmPVHF35g
+bx2rVK8dOT0mn7rz9Zr70jcSz1ETA2QonHZ+Y+niLmcic9At6hRtWiewblUmyFQm
+GwggIzi7LOyEUHrEcQJBAOXxyQvnLvtKzXiqcsW/K6rExqVJVk+KF0fzzVyMzTJx
+HRBxUVgvGdEJT7j+7P2kcTyafve0BBzDSPIaDyiJ+Y0CQQDWCb7jASFSbu5M3Zcd
+Gkr4ZKN1XO3VLQX10b22bQYdF45hrTN2tnzRvVUR4q86VVnXmiGiTqmLkXcA2WWf
+pHfFAkAhv9olUBo6MeF0i3frBEMRfm41hk0PwZHnMqZ6pgPcGnQMnMU2rzsXzkkQ
+OwJnvAIOxhJKovZTjmofdqmw5odlAkBYVUdRWjsNUTjJwj3GRf6gyq/nFMYWz3EB
+RWFdM1ttkDYzu45ctO2IhfHg4sPceDMO1s6AtKQmNI9/azkUjITdAkApNa9yFRzc
+TBaDNPd5KVd58LVIzoPQ6i7uMHteLXJUWqSroji6S3s4gKMFJ/dO+ZXIlgQgfJJJ
+ZDL4cdrdkeoM
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/ca.pem b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/ca.pem
new file mode 100644
index 0000000..6c8511a
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/ca.pem
@@ -0,0 +1,15 @@
+-----BEGIN CERTIFICATE-----
+MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
+BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
+aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla
+Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0
+YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT
+BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7
++L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu
+g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd
+Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV
+HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau
+sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m
+oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG
+Dfcog5wrJytaQ6UA0wE=
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/client.key b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/client.key
new file mode 100644
index 0000000..f48d073
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/client.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAOxUR9uhvhbeVUIM
+s5WbH0px0mehl2+6sZpNjzvE2KimZpHzMJHukVH0Ffkvhs0b8+S5Ut9VNUAqd3IM
+JCCAEGtRNoQhM1t9Yr2zAckSvbRacp+FL/Cj9eDmyo00KsVGaeefA4Dh4OW+ZhkT
+NKcldXqkSuj1sEf244JZYuqZp6/tAgMBAAECgYEAi2NSVqpZMafE5YYUTcMGe6QS
+k2jtpsqYgggI2RnLJ/2tNZwYI5pwP8QVSbnMaiF4gokD5hGdrNDfTnb2v+yIwYEH
+0w8+oG7Z81KodsiZSIDJfTGsAZhVNwOz9y0VD8BBZZ1/274Zh52AUKLjZS/ZwIbS
+W2ywya855dPnH/wj+0ECQQD9X8D920kByTNHhBG18biAEZ4pxs9f0OAG8333eVcI
+w2lJDLsYDZrCB2ocgA3lUdozlzPC7YDYw8reg0tkiRY5AkEA7sdNzOeQsQRn7++5
+0bP9DtT/iON1gbfxRzCfCfXdoOtfQWIzTePWtURt9X/5D9NofI0Rg5W2oGy/MLe5
+/sXHVQJBAIup5XrJDkQywNZyAUU2ecn2bCWBFjwtqd+LBmuMciI9fOKsZtEKZrz/
+U0lkeMRoSwvXE8wmGLjjrAbdfohrXFkCQQDZEx/LtIl6JINJQiswVe0tWr6k+ASP
+1WXoTm+HYpoF/XUvv9LccNF1IazFj34hwRQwhx7w/V52Ieb+p0jUMYGxAkEAjDhd
+9pBO1fKXWiXzi9ZKfoyTNcUq3eBSVKwPG2nItg5ycXengjT5sgcWDnciIzW7BIVI
+JiqOszq9GWESErAatg==
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/client.pem b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/client.pem
new file mode 100644
index 0000000..913649b
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/client.pem
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC6TCCAlKgAwIBAgIBCjANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTEwMDEwOTU4WhcNMjUxMTA3
+MDEwOTU4WjBaMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8G
+A1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRMwEQYDVQQDDAp0ZXN0Y2xp
+ZW50MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDsVEfbob4W3lVCDLOVmx9K
+cdJnoZdvurGaTY87xNiopmaR8zCR7pFR9BX5L4bNG/PkuVLfVTVAKndyDCQggBBr
+UTaEITNbfWK9swHJEr20WnKfhS/wo/Xg5sqNNCrFRmnnnwOA4eDlvmYZEzSnJXV6
+pEro9bBH9uOCWWLqmaev7QIDAQABo4HCMIG/MAkGA1UdEwQCMAAwCwYDVR0PBAQD
+AgXgMB0GA1UdDgQWBBQAdbW5Vml/CnYwqdP3mOHDARU+8zBwBgNVHSMEaTBnoVqk
+WDBWMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMY
+SW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2GCCQCRxhke
+HRoqBzAJBgNVHREEAjAAMAkGA1UdEgQCMAAwDQYJKoZIhvcNAQELBQADgYEAf4MM
+k+sdzd720DfrQ0PF2gDauR3M9uBubozDuMuF6ufAuQBJSKGQEGibXbUelrwHmnql
+UjTyfolVcxEBVaF4VFHmn7u6vP7S1NexIDdNUHcULqxIb7Tzl8JYq8OOHD2rQy4H
+s8BXaVIzw4YcaCGAMS0iDX052Sy7e2JhP8Noxvo=
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/server0.key b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/server0.key
new file mode 100644
index 0000000..add153c
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/server0.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANOmffupIGC8YDau
+rOF4eKnHwPszgpkkhWzKsVxhNDBxCVYx4TEjG0XWIO0iyRXupZbUC+7N/8HnEVNa
+8F1jYhng14Iiq99cNQbbnuHHhIztmpocrJTxmnhGzoAnRa1Tb+GnAuRoIHRA/V2c
+VUE9tbikQugFx/SPgXAw6tfWB+YvAgMBAAECgYEAoEq9qzUBgoHoVEGiSPiWWe8g
+5p6yUA1qx2QTQyWTAwT4z0DjjfVKmG99bFsl8+hTnJFnoCp/gnjflEOROwkjp5kG
+m0drqOPx1jeipJjpXYTBu49h+WpZ1PF+KhVtxsIm3OOCvh67iWaKyyOVb5Og8aiR
+jl6dn/TdG/dlGD8AfUECQQDuNMle6p0oU8amC6O9wIMBroxx2nFstzE6O35PLEzG
+/tj0kxxn9Jp2TS9mGaLCzSuXmpjlF4+NOWiBPkrLC2TfAkEA43Xg7uEUkaJAz2/W
+m1lIBTLt+4rIQY/2emh33bDcA+rv8rwwrMMIv17/xPx7bs49YqGG5xufD+Rwl6TL
+qFXYsQJAPrOwagax1aKvwJeBw3oAQhoTKAkLIEXcdGqipe6QSzVcIIz0xjxxyEAr
+AOIwoLxnBCISqwMXq2H4K0UdZPMb2wJAdhdYLY1L6YRMk6XjzImg25oidisKZweA
+FvMv8DgHMj2CUAqmVrt3SivfLH1M9C09L3zfFhOAFHcsgX58gav4MQJBANSBnrHj
+tIq4l8z79CPUIuu3QyeEh+XwY8s5qE5CNTck0U59lzp9NvENHbkx3KO896TTerko
++8bXHMLkJkHPXms=
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/server0.pem b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/server0.pem
new file mode 100644
index 0000000..9458954
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/certs/server0.pem
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC8zCCAlygAwIBAgIBCzANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTEwMDExNDU1WhcNMjUxMTA3
+MDExNDU1WjBkMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8G
+A1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMR0wGwYDVQQDDBQqLnRlc3Qu
+Z29vZ2xlLmNvbS5hdTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA06Z9+6kg
+YLxgNq6s4Xh4qcfA+zOCmSSFbMqxXGE0MHEJVjHhMSMbRdYg7SLJFe6lltQL7s3/
+wecRU1rwXWNiGeDXgiKr31w1Btue4ceEjO2amhyslPGaeEbOgCdFrVNv4acC5Ggg
+dED9XZxVQT21uKRC6AXH9I+BcDDq19YH5i8CAwEAAaOBwjCBvzAJBgNVHRMEAjAA
+MAsGA1UdDwQEAwIF4DAdBgNVHQ4EFgQUbyZIbUvqmePzv40xa0mMaDxLToYwcAYD
+VR0jBGkwZ6FapFgwVjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
+ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEPMA0GA1UEAxMGdGVz
+dGNhggkAkcYZHh0aKgcwCQYDVR0RBAIwADAJBgNVHRIEAjAAMA0GCSqGSIb3DQEB
+CwUAA4GBAJ21MwMf4WwAjafPKn+8Ng7ordtdp6tlkjt+Xub4l4zMr6FCp6dc/Ceh
+6Hj43zYcKpAe5I6eaVcMc9qcYfUb9i4NVX82dMQpAwpNHgqTzqYt6GYEjF3YhKA7
+uOFdA0OvOFJa14SNdNRk9E1Cd/tElXnLnSE4DOguMNvXz8mRKfnD
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/log4j.properties b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/log4j.properties
new file mode 100644
index 0000000..d6ecd5c
--- /dev/null
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/dubbo-samples-grpc-ssl-provider/src/main/resources/log4j.properties
@@ -0,0 +1,26 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/java/dubbo-samples-grpc/pom.xml b/java/dubbo-samples-grpc/dubbo-samples-ssl/pom.xml
similarity index 61%
copy from java/dubbo-samples-grpc/pom.xml
copy to java/dubbo-samples-grpc/dubbo-samples-ssl/pom.xml
index 702943a..bff9f0d 100644
--- a/java/dubbo-samples-grpc/pom.xml
+++ b/java/dubbo-samples-grpc/dubbo-samples-ssl/pom.xml
@@ -18,33 +18,16 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
<groupId>org.apache.dubbo</groupId>
<version>1.0-SNAPSHOT</version>
- <artifactId>dubbo-samples-grpc</artifactId>
- <packaging>pom</packaging>
- <modules>
- <module>dubbo-samples-original</module>
- <module>dubbo-samples-reactor</module>
- <module>dubbo-samples-rxjava</module>
- </modules>
+ <modelVersion>4.0.0</modelVersion>
- <repositories>
- <repository>
- <id>apache.snapshots.https</id>
- <name>Apache Development Snapshot Repository</name>
- <url>https://repository.apache.org/content/repositories/snapshots</url>
- <layout>default</layout>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- </snapshots>
- </repository>
- </repositories>
+ <packaging>pom</packaging>
+ <artifactId>dubbo-samples-grpc-ssl</artifactId>
+ <modules>
+ <module>dubbo-samples-grpc-ssl-provider</module>
+ <module>dubbo-samples-grpc-ssl-consumer</module>
+ </modules>
</project>
diff --git a/java/dubbo-samples-grpc/pom.xml b/java/dubbo-samples-grpc/pom.xml
index 702943a..57ee3a3 100644
--- a/java/dubbo-samples-grpc/pom.xml
+++ b/java/dubbo-samples-grpc/pom.xml
@@ -29,6 +29,7 @@
<module>dubbo-samples-original</module>
<module>dubbo-samples-reactor</module>
<module>dubbo-samples-rxjava</module>
+ <module>dubbo-samples-ssl</module>
</modules>
<repositories>
diff --git a/java/dubbo-samples-protobuf/pom.xml b/java/dubbo-samples-protobuf/pom.xml
index b359962..92fef0e 100644
--- a/java/dubbo-samples-protobuf/pom.xml
+++ b/java/dubbo-samples-protobuf/pom.xml
@@ -120,6 +120,7 @@
<execution>
<goals>
<goal>compile</goal>
+ <goal>test-compile</goal>
</goals>
</execution>
</executions>
diff --git a/java/dubbo-samples-protobuf/protobuf-consumer/build/generated/source/proto/main/java/org/apache/dubbo/demo/DemoServiceDubbo.java b/java/dubbo-samples-protobuf/protobuf-consumer/build/generated/source/proto/main/java/org/apache/dubbo/demo/DemoServiceDubbo.java
index 8e9fa01..b47fafa 100644
--- a/java/dubbo-samples-protobuf/protobuf-consumer/build/generated/source/proto/main/java/org/apache/dubbo/demo/DemoServiceDubbo.java
+++ b/java/dubbo-samples-protobuf/protobuf-consumer/build/generated/source/proto/main/java/org/apache/dubbo/demo/DemoServiceDubbo.java
@@ -1,4 +1,4 @@
-package org.apache.dubbo.demo;
+ package org.apache.dubbo.demo;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -7,40 +7,40 @@ import java.util.concurrent.atomic.AtomicBoolean;
value = "by Dubbo generator",
comments = "Source: DemoService.proto")
public final class DemoServiceDubbo {
- private static final AtomicBoolean registered = new AtomicBoolean();
-
- private static Class<?> init() {
- Class<?> clazz = null;
- try {
- clazz = Class.forName(DemoServiceDubbo.class.getName());
- if (registered.compareAndSet(false, true)) {
- org.apache.dubbo.common.serialize.protobuf.support.ProtobufUtils.marshaller(
- org.apache.dubbo.demo.HelloReply.getDefaultInstance());
- org.apache.dubbo.common.serialize.protobuf.support.ProtobufUtils.marshaller(
- org.apache.dubbo.demo.HelloRequest.getDefaultInstance());
- }
- } catch (ClassNotFoundException e) {
- // ignore
- }
- return clazz;
- }
+private static final AtomicBoolean registered = new AtomicBoolean();
+
+private static Class<?> init() {
+Class<?> clazz = null;
+try {
+clazz = Class.forName(DemoServiceDubbo.class.getName());
+if (registered.compareAndSet(false, true)) {
+ org.apache.dubbo.common.serialize.protobuf.support.ProtobufUtils.marshaller(
+ org.apache.dubbo.demo.HelloReply.getDefaultInstance());
+ org.apache.dubbo.common.serialize.protobuf.support.ProtobufUtils.marshaller(
+ org.apache.dubbo.demo.HelloRequest.getDefaultInstance());
+}
+} catch (ClassNotFoundException e) {
+// ignore
+}
+return clazz;
+}
- private DemoServiceDubbo() {}
+private DemoServiceDubbo() {}
- public static final String SERVICE_NAME = "org.apache.dubbo.demo.DemoService";
+public static final String SERVICE_NAME = "org.apache.dubbo.demo.DemoService";
- /**
- * Code generated for Dubbo
- */
- public interface IDemoService {
+/**
+* Code generated for Dubbo
+*/
+public interface IDemoService {
- static Class<?> clazz = init();
+static Class<?> clazz = init();
- org.apache.dubbo.demo.HelloReply sayHello(org.apache.dubbo.demo.HelloRequest request);
+ org.apache.dubbo.demo.HelloReply sayHello(org.apache.dubbo.demo.HelloRequest request);
- CompletableFuture<org.apache.dubbo.demo.HelloReply> sayHelloAsync(org.apache.dubbo.demo.HelloRequest request);
+ CompletableFuture<org.apache.dubbo.demo.HelloReply> sayHelloAsync(org.apache.dubbo.demo.HelloRequest request);
- }
+}
}
diff --git a/java/dubbo-samples-protobuf/protobuf-provider/build/generated/source/proto/main/java/org/apache/dubbo/demo/DemoServiceDubbo.java b/java/dubbo-samples-protobuf/protobuf-provider/build/generated/source/proto/main/java/org/apache/dubbo/demo/DemoServiceDubbo.java
index 8e9fa01..b47fafa 100644
--- a/java/dubbo-samples-protobuf/protobuf-provider/build/generated/source/proto/main/java/org/apache/dubbo/demo/DemoServiceDubbo.java
+++ b/java/dubbo-samples-protobuf/protobuf-provider/build/generated/source/proto/main/java/org/apache/dubbo/demo/DemoServiceDubbo.java
@@ -1,4 +1,4 @@
-package org.apache.dubbo.demo;
+ package org.apache.dubbo.demo;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -7,40 +7,40 @@ import java.util.concurrent.atomic.AtomicBoolean;
value = "by Dubbo generator",
comments = "Source: DemoService.proto")
public final class DemoServiceDubbo {
- private static final AtomicBoolean registered = new AtomicBoolean();
-
- private static Class<?> init() {
- Class<?> clazz = null;
- try {
- clazz = Class.forName(DemoServiceDubbo.class.getName());
- if (registered.compareAndSet(false, true)) {
- org.apache.dubbo.common.serialize.protobuf.support.ProtobufUtils.marshaller(
- org.apache.dubbo.demo.HelloReply.getDefaultInstance());
- org.apache.dubbo.common.serialize.protobuf.support.ProtobufUtils.marshaller(
- org.apache.dubbo.demo.HelloRequest.getDefaultInstance());
- }
- } catch (ClassNotFoundException e) {
- // ignore
- }
- return clazz;
- }
+private static final AtomicBoolean registered = new AtomicBoolean();
+
+private static Class<?> init() {
+Class<?> clazz = null;
+try {
+clazz = Class.forName(DemoServiceDubbo.class.getName());
+if (registered.compareAndSet(false, true)) {
+ org.apache.dubbo.common.serialize.protobuf.support.ProtobufUtils.marshaller(
+ org.apache.dubbo.demo.HelloReply.getDefaultInstance());
+ org.apache.dubbo.common.serialize.protobuf.support.ProtobufUtils.marshaller(
+ org.apache.dubbo.demo.HelloRequest.getDefaultInstance());
+}
+} catch (ClassNotFoundException e) {
+// ignore
+}
+return clazz;
+}
- private DemoServiceDubbo() {}
+private DemoServiceDubbo() {}
- public static final String SERVICE_NAME = "org.apache.dubbo.demo.DemoService";
+public static final String SERVICE_NAME = "org.apache.dubbo.demo.DemoService";
- /**
- * Code generated for Dubbo
- */
- public interface IDemoService {
+/**
+* Code generated for Dubbo
+*/
+public interface IDemoService {
- static Class<?> clazz = init();
+static Class<?> clazz = init();
- org.apache.dubbo.demo.HelloReply sayHello(org.apache.dubbo.demo.HelloRequest request);
+ org.apache.dubbo.demo.HelloReply sayHello(org.apache.dubbo.demo.HelloRequest request);
- CompletableFuture<org.apache.dubbo.demo.HelloReply> sayHelloAsync(org.apache.dubbo.demo.HelloRequest request);
+ CompletableFuture<org.apache.dubbo.demo.HelloReply> sayHelloAsync(org.apache.dubbo.demo.HelloRequest request);
- }
+}
}
diff --git a/java/dubbo-samples-protobuf/protobuf-provider/pom.xml b/java/dubbo-samples-protobuf/protobuf-provider/pom.xml
index 2318b82..1ac69e6 100644
--- a/java/dubbo-samples-protobuf/protobuf-provider/pom.xml
+++ b/java/dubbo-samples-protobuf/protobuf-provider/pom.xml
@@ -28,6 +28,7 @@
<name>${project.artifactId}</name>
<description>The demo provider module of dubbo project</description>
<properties>
+ <spring-test.version>4.3.16.RELEASE</spring-test.version>
<skip_maven_deploy>true</skip_maven_deploy>
<slf4j-log4j12.version>1.7.25</slf4j-log4j12.version>
</properties>
@@ -102,5 +103,19 @@
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
</dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring-test.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.testcontainers</groupId>
+ <artifactId>testcontainers</artifactId>
+ <version>1.12.3</version>
+ <scope>test</scope>
+ </dependency>
</dependencies>
</project>
diff --git a/java/dubbo-samples-protobuf/protobuf-provider/src/main/resources/spring/dubbo-provider.xml b/java/dubbo-samples-protobuf/protobuf-provider/src/main/resources/spring/dubbo-provider.xml
index 5e9a2fd..cc9788d 100644
--- a/java/dubbo-samples-protobuf/protobuf-provider/src/main/resources/spring/dubbo-provider.xml
+++ b/java/dubbo-samples-protobuf/protobuf-provider/src/main/resources/spring/dubbo-provider.xml
@@ -27,9 +27,9 @@
<dubbo:protocol name="dubbo"/>
- <bean id="demoService" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>
+ <bean id="demoServiceImpl" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>
<dubbo:service serialization="protobuf" interface="org.apache.dubbo.demo.DemoServiceDubbo$IDemoService"
- ref="demoService"/>
+ ref="demoServiceImpl"/>
</beans>
diff --git a/java/dubbo-samples-environment-keys/src/test/java/org/apache/dubbo/samples/basic/DemoServiceIT.java b/java/dubbo-samples-protobuf/protobuf-provider/src/test/java/org/apache/dubbo/samples/DubboProtobufIT.java
similarity index 57%
copy from java/dubbo-samples-environment-keys/src/test/java/org/apache/dubbo/samples/basic/DemoServiceIT.java
copy to java/dubbo-samples-protobuf/protobuf-provider/src/test/java/org/apache/dubbo/samples/DubboProtobufIT.java
index 6d7d7ec..b7ddd8d 100644
--- a/java/dubbo-samples-environment-keys/src/test/java/org/apache/dubbo/samples/basic/DemoServiceIT.java
+++ b/java/dubbo-samples-protobuf/protobuf-provider/src/test/java/org/apache/dubbo/samples/DubboProtobufIT.java
@@ -15,27 +15,39 @@
* limitations under the License.
*/
-package org.apache.dubbo.samples.basic;
+package org.apache.dubbo.samples;
-import org.apache.dubbo.samples.basic.api.DemoService;
+import org.apache.dubbo.demo.DemoServiceDubbo;
+import org.apache.dubbo.demo.HelloReply;
+import org.apache.dubbo.demo.HelloRequest;
import org.junit.Assert;
+import org.junit.ClassRule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
+import org.testcontainers.containers.FixedHostPortGenericContainer;
+import org.testcontainers.containers.GenericContainer;
@RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = "classpath*:spring/dubbo-demo-consumer.xml")
-public class DemoServiceIT {
+@ContextConfiguration(locations = {"classpath*:spring/dubbo-consumer.xml", "classpath*:spring/dubbo-provider.xml"})
+public class DubboProtobufIT {
+ // port mapping, https://github.com/testcontainers/testcontainers-java/issues/256
+ @ClassRule
+ public static GenericContainer zookeeper = new FixedHostPortGenericContainer("zookeeper:3.4.9")
+ .withFixedExposedPort(2181, 2181);
+
@Autowired
@Qualifier("demoService")
- private DemoService service;
+ private DemoServiceDubbo.IDemoService demoService;
@Test
public void testGreeting() throws Exception {
- Assert.assertTrue(service.sayHello("dubbo").startsWith("Hello dubbo"));
+ HelloReply helloReply = demoService.sayHello(HelloRequest.newBuilder().setName("world").build());
+ Assert.assertTrue(helloReply.getMessage().startsWith("Hello world"));
}
}
+
diff --git a/java/dubbo-samples-protobuf/protobuf-provider/src/main/resources/spring/dubbo-provider.xml b/java/dubbo-samples-protobuf/protobuf-provider/src/test/resources/spring/dubbo-consumer.xml
similarity index 80%
copy from java/dubbo-samples-protobuf/protobuf-provider/src/main/resources/spring/dubbo-provider.xml
copy to java/dubbo-samples-protobuf/protobuf-provider/src/test/resources/spring/dubbo-consumer.xml
index 5e9a2fd..59c58ff 100644
--- a/java/dubbo-samples-protobuf/protobuf-provider/src/main/resources/spring/dubbo-provider.xml
+++ b/java/dubbo-samples-protobuf/protobuf-provider/src/test/resources/spring/dubbo-consumer.xml
@@ -21,15 +21,10 @@
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">
- <dubbo:application name="demo-provider"/>
+ <dubbo:application name="demo-consumer"/>
<dubbo:registry address="zookeeper://127.0.0.1:2181"/>
- <dubbo:protocol name="dubbo"/>
-
- <bean id="demoService" class="org.apache.dubbo.demo.provider.DemoServiceImpl"/>
-
- <dubbo:service serialization="protobuf" interface="org.apache.dubbo.demo.DemoServiceDubbo$IDemoService"
- ref="demoService"/>
+ <dubbo:reference scope="remote" id="demoService" check="false" interface="org.apache.dubbo.demo.DemoServiceDubbo$IDemoService"/>
</beans>
diff --git a/java/dubbo-samples-sentinel/src/main/java/org/apache/samples/sentinel/provider/ProviderConfiguration.java b/java/dubbo-samples-sentinel/src/main/java/org/apache/samples/sentinel/provider/ProviderConfiguration.java
index 7139c01..6c87897 100644
--- a/java/dubbo-samples-sentinel/src/main/java/org/apache/samples/sentinel/provider/ProviderConfiguration.java
+++ b/java/dubbo-samples-sentinel/src/main/java/org/apache/samples/sentinel/provider/ProviderConfiguration.java
@@ -21,13 +21,15 @@ import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.config.spring.context.annotation.DubboComponentScan;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.apache.dubbo.config.spring.context.annotation.EnableDubboLifecycle;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
-@DubboComponentScan
+@EnableDubbo
public class ProviderConfiguration {
@Value("zookeeper://${zookeeper.address:127.0.0.1}:2181")
private String zookeeperAddress;
diff --git a/java/dubbo-samples-ssl/README.md b/java/dubbo-samples-ssl/README.md
new file mode 100644
index 0000000..d6be2c5
--- /dev/null
+++ b/java/dubbo-samples-ssl/README.md
@@ -0,0 +1,41 @@
+
+## How to run
+
+This sample needs TLS cert files to run.
+
+> This sample has test certs provided in the resources/certs directory, you can use the directory or generate by yourself.
+
+Here's the procedures of how to run.
+
+First, we need to build the executable jar for consumer and provider respectively.
+
+```shell
+$ cd dubbo-samples-ssl
+$ mvn clean package
+```
+
+Then, start the provider
+
+```sh
+$ # enter the target directory
+$ cd ./dubbo-samples-ssl-provider/target
+$ # run
+$ java "-Ddubbo.ssl.server-key-cert-chain-path={your absolute path to}/certs/server0.pem" "-Ddubbo.ssl.server-private-key-path={your absolute path to}/certs/server0.key" -jar dubbo-samples-ssl-provider-1.0-SNAPSHOT-exec.jar
+```
+
+Finally, start the consumer
+
+```sh
+$ # enter the target directory
+$ cd ./dubbo-samples-ssl-consumer/target
+$ # run
+$ java "-Ddubbo.ssl.client-trust-cert-collection-path={your absolute path to}/certs/ca.pem" -jar dubbo-samples-ssl-consumer-1.0-SNAPSHOT-exec.jar
+```
+
+For example, in my own environment, I run
+
+```sh
+$ java "-Ddubbo.ssl.server-key-cert-chain-path=/Users/ken.lj/aliware/dubboprojects/codebase/dubbo-samples/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/server0.pem" "-Ddubbo.ssl.server-private-key-path=/Users/ken.lj/aliware/dubboprojects/codebase/dubbo-samples/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/server0.key" -jar dubbo-samples-ssl-provider-1.0-SNAPSHOT-exec.jar
+$ # and
+$ java "-Ddubbo.ssl.client-trust-cert-collection-path=/Users/ken.lj/aliware/dubboprojects/codebase/dubbo-samples/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/ca.pem" -jar dubbo-samples-ssl-consumer-1.0-SNAPSHOT-exec.jar
+```
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/pom.xml b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/pom.xml
new file mode 100644
index 0000000..36a21c9
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/pom.xml
@@ -0,0 +1,153 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>dubbo-samples-ssl-consumer</artifactId>
+
+ <properties>
+ <source.level>1.8</source.level>
+ <target.level>1.8</target.level>
+ <dubbo.version>2.7.5-SNAPSHOT</dubbo.version>
+ <junit.version>4.12</junit.version>
+ <spring-test.version>4.3.16.RELEASE</spring-test.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>
+ <java-image.name>openjdk:8</java-image.name>
+ <dubbo.port>20880</dubbo.port>
+ <zookeeper.port>2181</zookeeper.port>
+ <main-class>org.apache.dubbo.samples.basic.SslBasicProvider</main-class>
+ </properties>
+
+ <dependencies>
+ <!-- It's totally optional, add tcnative with embedded boringSSL support -->
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-tcnative-boringssl-static</artifactId>
+ <version>2.0.26.Final</version> <!-- See table for correct version -->
+<!-- <classifier>${os.detected.classifier}</classifier>-->
+<!-- <scope>runtime</scope>-->
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ <version>4.1.36.Final</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring-test.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>dubbo-integration-test</id>
+ <build>
+ <plugins>
+ <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>
+ <includes>
+ <include>**/*IT.java</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.6.1</version>
+ </extension>
+ </extensions>
+
+ <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>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <executable>true</executable>
+ <mainClass>org.apache.dubbo.samples.basic.SslBasicProvider</mainClass>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ <configuration>
+ <classifier>exec</classifier>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/java/org/apache/dubbo/samples/basic/SslBasicConsumer.java b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/java/org/apache/dubbo/samples/basic/SslBasicConsumer.java
new file mode 100644
index 0000000..1144e94
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/java/org/apache/dubbo/samples/basic/SslBasicConsumer.java
@@ -0,0 +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
+ *
+ * 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.basic;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.SslConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.samples.basic.api.DemoService;
+
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SslBasicConsumer {
+
+ private static final String ROOT_DIR = System.getProperty("user.dir");
+
+ public static void main(String[] args) {
+ SslConfig sslConfig = new SslConfig();
+ if (args.length > 0) {
+ if (args.length != 1 && args.length != 3) {
+ System.out.println(
+ "USAGE: BasicConsumer [trustCertCollectionFilePath [certChainFilePath privateKeyFilePath]]\n " +
+ "Specify 'certChainFilePath' and 'privateKeyFilePath' only if you need Mutual TLS.");
+ System.exit(0);
+ }
+
+ switch (args.length) {
+ case 1:
+ sslConfig.setClientTrustCertCollectionPath(args[0]);
+ break;
+ case 3:
+ sslConfig.setClientTrustCertCollectionPath(args[0]);
+ sslConfig.setClientKeyCertChainPath(args[1]);
+ sslConfig.setClientPrivateKeyPath(args[2]);
+ }
+ }
+
+ DubboBootstrap bootstrap = DubboBootstrap.getInstance()
+ .application(new ApplicationConfig("first-dubbo-consumer"))
+ .registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
+ .ssl(sslConfig);
+
+ ReferenceConfig<DemoService> reference = new ReferenceConfig<>();
+ reference.setInterface(DemoService.class);
+
+ bootstrap.reference(reference);
+
+ bootstrap.start();
+
+ DemoService service = bootstrap.getCache().get(reference);
+ String message = service.sayHello("dubbo");
+ System.out.println(message);
+ }
+}
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/java/org/apache/dubbo/samples/basic/api/DemoService.java b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/java/org/apache/dubbo/samples/basic/api/DemoService.java
new file mode 100644
index 0000000..1080104
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/java/org/apache/dubbo/samples/basic/api/DemoService.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * 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.basic.api;
+
+public interface DemoService {
+
+ String sayHello(String name);
+
+ void testVoid();
+
+}
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/ca.key b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/ca.key
new file mode 100644
index 0000000..03c4f95
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/ca.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAMBA3wVeTGHZR1Ry
+e/i+J8a2cu5gXwFV6TnObzGM7bLFCO5i9v4mLo4iFzPsHmWDUxKS3Y8iXbu0eYBl
+LoNY0lSvxDx33O+DuwMmVN+DzSD+Eod9zfvwOWHsazYCZT2PhNxnVWIuJXViY4JA
+HUGodjx+QAi6yCAurUZGvYXGgZSBAgMBAAECgYAxRi8i9BlFlufGSBVoGmydbJOm
+bwLKl9dP3o33ODSP9hok5y6A0w5plWk3AJSF1hPLleK9VcSKYGYnt0clmPVHF35g
+bx2rVK8dOT0mn7rz9Zr70jcSz1ETA2QonHZ+Y+niLmcic9At6hRtWiewblUmyFQm
+GwggIzi7LOyEUHrEcQJBAOXxyQvnLvtKzXiqcsW/K6rExqVJVk+KF0fzzVyMzTJx
+HRBxUVgvGdEJT7j+7P2kcTyafve0BBzDSPIaDyiJ+Y0CQQDWCb7jASFSbu5M3Zcd
+Gkr4ZKN1XO3VLQX10b22bQYdF45hrTN2tnzRvVUR4q86VVnXmiGiTqmLkXcA2WWf
+pHfFAkAhv9olUBo6MeF0i3frBEMRfm41hk0PwZHnMqZ6pgPcGnQMnMU2rzsXzkkQ
+OwJnvAIOxhJKovZTjmofdqmw5odlAkBYVUdRWjsNUTjJwj3GRf6gyq/nFMYWz3EB
+RWFdM1ttkDYzu45ctO2IhfHg4sPceDMO1s6AtKQmNI9/azkUjITdAkApNa9yFRzc
+TBaDNPd5KVd58LVIzoPQ6i7uMHteLXJUWqSroji6S3s4gKMFJ/dO+ZXIlgQgfJJJ
+ZDL4cdrdkeoM
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/ca.pem b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/ca.pem
new file mode 100644
index 0000000..6c8511a
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/ca.pem
@@ -0,0 +1,15 @@
+-----BEGIN CERTIFICATE-----
+MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
+BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
+aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla
+Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0
+YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT
+BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7
++L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu
+g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd
+Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV
+HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau
+sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m
+oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG
+Dfcog5wrJytaQ6UA0wE=
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/client.key b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/client.key
new file mode 100644
index 0000000..f48d073
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/client.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAOxUR9uhvhbeVUIM
+s5WbH0px0mehl2+6sZpNjzvE2KimZpHzMJHukVH0Ffkvhs0b8+S5Ut9VNUAqd3IM
+JCCAEGtRNoQhM1t9Yr2zAckSvbRacp+FL/Cj9eDmyo00KsVGaeefA4Dh4OW+ZhkT
+NKcldXqkSuj1sEf244JZYuqZp6/tAgMBAAECgYEAi2NSVqpZMafE5YYUTcMGe6QS
+k2jtpsqYgggI2RnLJ/2tNZwYI5pwP8QVSbnMaiF4gokD5hGdrNDfTnb2v+yIwYEH
+0w8+oG7Z81KodsiZSIDJfTGsAZhVNwOz9y0VD8BBZZ1/274Zh52AUKLjZS/ZwIbS
+W2ywya855dPnH/wj+0ECQQD9X8D920kByTNHhBG18biAEZ4pxs9f0OAG8333eVcI
+w2lJDLsYDZrCB2ocgA3lUdozlzPC7YDYw8reg0tkiRY5AkEA7sdNzOeQsQRn7++5
+0bP9DtT/iON1gbfxRzCfCfXdoOtfQWIzTePWtURt9X/5D9NofI0Rg5W2oGy/MLe5
+/sXHVQJBAIup5XrJDkQywNZyAUU2ecn2bCWBFjwtqd+LBmuMciI9fOKsZtEKZrz/
+U0lkeMRoSwvXE8wmGLjjrAbdfohrXFkCQQDZEx/LtIl6JINJQiswVe0tWr6k+ASP
+1WXoTm+HYpoF/XUvv9LccNF1IazFj34hwRQwhx7w/V52Ieb+p0jUMYGxAkEAjDhd
+9pBO1fKXWiXzi9ZKfoyTNcUq3eBSVKwPG2nItg5ycXengjT5sgcWDnciIzW7BIVI
+JiqOszq9GWESErAatg==
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/client.pem b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/client.pem
new file mode 100644
index 0000000..913649b
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/client.pem
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC6TCCAlKgAwIBAgIBCjANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTEwMDEwOTU4WhcNMjUxMTA3
+MDEwOTU4WjBaMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8G
+A1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRMwEQYDVQQDDAp0ZXN0Y2xp
+ZW50MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDsVEfbob4W3lVCDLOVmx9K
+cdJnoZdvurGaTY87xNiopmaR8zCR7pFR9BX5L4bNG/PkuVLfVTVAKndyDCQggBBr
+UTaEITNbfWK9swHJEr20WnKfhS/wo/Xg5sqNNCrFRmnnnwOA4eDlvmYZEzSnJXV6
+pEro9bBH9uOCWWLqmaev7QIDAQABo4HCMIG/MAkGA1UdEwQCMAAwCwYDVR0PBAQD
+AgXgMB0GA1UdDgQWBBQAdbW5Vml/CnYwqdP3mOHDARU+8zBwBgNVHSMEaTBnoVqk
+WDBWMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMY
+SW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2GCCQCRxhke
+HRoqBzAJBgNVHREEAjAAMAkGA1UdEgQCMAAwDQYJKoZIhvcNAQELBQADgYEAf4MM
+k+sdzd720DfrQ0PF2gDauR3M9uBubozDuMuF6ufAuQBJSKGQEGibXbUelrwHmnql
+UjTyfolVcxEBVaF4VFHmn7u6vP7S1NexIDdNUHcULqxIb7Tzl8JYq8OOHD2rQy4H
+s8BXaVIzw4YcaCGAMS0iDX052Sy7e2JhP8Noxvo=
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/server0.key b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/server0.key
new file mode 100644
index 0000000..add153c
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/server0.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANOmffupIGC8YDau
+rOF4eKnHwPszgpkkhWzKsVxhNDBxCVYx4TEjG0XWIO0iyRXupZbUC+7N/8HnEVNa
+8F1jYhng14Iiq99cNQbbnuHHhIztmpocrJTxmnhGzoAnRa1Tb+GnAuRoIHRA/V2c
+VUE9tbikQugFx/SPgXAw6tfWB+YvAgMBAAECgYEAoEq9qzUBgoHoVEGiSPiWWe8g
+5p6yUA1qx2QTQyWTAwT4z0DjjfVKmG99bFsl8+hTnJFnoCp/gnjflEOROwkjp5kG
+m0drqOPx1jeipJjpXYTBu49h+WpZ1PF+KhVtxsIm3OOCvh67iWaKyyOVb5Og8aiR
+jl6dn/TdG/dlGD8AfUECQQDuNMle6p0oU8amC6O9wIMBroxx2nFstzE6O35PLEzG
+/tj0kxxn9Jp2TS9mGaLCzSuXmpjlF4+NOWiBPkrLC2TfAkEA43Xg7uEUkaJAz2/W
+m1lIBTLt+4rIQY/2emh33bDcA+rv8rwwrMMIv17/xPx7bs49YqGG5xufD+Rwl6TL
+qFXYsQJAPrOwagax1aKvwJeBw3oAQhoTKAkLIEXcdGqipe6QSzVcIIz0xjxxyEAr
+AOIwoLxnBCISqwMXq2H4K0UdZPMb2wJAdhdYLY1L6YRMk6XjzImg25oidisKZweA
+FvMv8DgHMj2CUAqmVrt3SivfLH1M9C09L3zfFhOAFHcsgX58gav4MQJBANSBnrHj
+tIq4l8z79CPUIuu3QyeEh+XwY8s5qE5CNTck0U59lzp9NvENHbkx3KO896TTerko
++8bXHMLkJkHPXms=
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/server0.pem b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/server0.pem
new file mode 100644
index 0000000..9458954
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/certs/server0.pem
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC8zCCAlygAwIBAgIBCzANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTEwMDExNDU1WhcNMjUxMTA3
+MDExNDU1WjBkMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8G
+A1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMR0wGwYDVQQDDBQqLnRlc3Qu
+Z29vZ2xlLmNvbS5hdTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA06Z9+6kg
+YLxgNq6s4Xh4qcfA+zOCmSSFbMqxXGE0MHEJVjHhMSMbRdYg7SLJFe6lltQL7s3/
+wecRU1rwXWNiGeDXgiKr31w1Btue4ceEjO2amhyslPGaeEbOgCdFrVNv4acC5Ggg
+dED9XZxVQT21uKRC6AXH9I+BcDDq19YH5i8CAwEAAaOBwjCBvzAJBgNVHRMEAjAA
+MAsGA1UdDwQEAwIF4DAdBgNVHQ4EFgQUbyZIbUvqmePzv40xa0mMaDxLToYwcAYD
+VR0jBGkwZ6FapFgwVjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
+ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEPMA0GA1UEAxMGdGVz
+dGNhggkAkcYZHh0aKgcwCQYDVR0RBAIwADAJBgNVHRIEAjAAMA0GCSqGSIb3DQEB
+CwUAA4GBAJ21MwMf4WwAjafPKn+8Ng7ordtdp6tlkjt+Xub4l4zMr6FCp6dc/Ceh
+6Hj43zYcKpAe5I6eaVcMc9qcYfUb9i4NVX82dMQpAwpNHgqTzqYt6GYEjF3YhKA7
+uOFdA0OvOFJa14SNdNRk9E1Cd/tElXnLnSE4DOguMNvXz8mRKfnD
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/log4j.properties b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/log4j.properties
new file mode 100644
index 0000000..d6ecd5c
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-consumer/src/main/resources/log4j.properties
@@ -0,0 +1,26 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/pom.xml b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/pom.xml
new file mode 100644
index 0000000..178cdf2
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/pom.xml
@@ -0,0 +1,154 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or more
+ contributor license agreements. See the NOTICE file distributed with
+ this work for additional information regarding copyright ownership.
+ The ASF licenses this file to You under the Apache License, Version 2.0
+ (the "License"); you may not use this file except in compliance with
+ the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <groupId>org.apache.dubbo</groupId>
+ <version>1.0-SNAPSHOT</version>
+
+ <modelVersion>4.0.0</modelVersion>
+
+ <artifactId>dubbo-samples-ssl-provider</artifactId>
+
+ <properties>
+ <source.level>1.8</source.level>
+ <target.level>1.8</target.level>
+ <dubbo.version>2.7.5-SNAPSHOT</dubbo.version>
+ <junit.version>4.12</junit.version>
+ <spring-test.version>4.3.16.RELEASE</spring-test.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>
+ <java-image.name>openjdk:8</java-image.name>
+ <dubbo.port>20880</dubbo.port>
+ <zookeeper.port>2181</zookeeper.port>
+ <main-class>org.apache.dubbo.samples.basic.SslBasicProvider</main-class>
+ </properties>
+
+ <dependencies>
+ <!-- It's totally optional, add tcnative with embedded boringSSL support -->
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-tcnative-boringssl-static</artifactId>
+ <version>2.0.26.Final</version> <!-- See table for correct version -->
+<!-- <classifier>${os.detected.classifier}</classifier>-->
+<!-- <scope>runtime</scope>-->
+ </dependency>
+ <dependency>
+ <groupId>io.netty</groupId>
+ <artifactId>netty-all</artifactId>
+ <version>4.1.36.Final</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-dependencies-zookeeper</artifactId>
+ <version>${dubbo.version}</version>
+ <type>pom</type>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>${junit.version}</version>
+ <scope>test</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-test</artifactId>
+ <version>${spring-test.version}</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>dubbo-integration-test</id>
+ <build>
+ <plugins>
+ <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>
+ <includes>
+ <include>**/*IT.java</include>
+ </includes>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+
+ <build>
+ <extensions>
+ <extension>
+ <groupId>kr.motd.maven</groupId>
+ <artifactId>os-maven-plugin</artifactId>
+ <version>1.6.1</version>
+ </extension>
+ </extensions>
+
+ <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>
+
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ <configuration>
+ <executable>true</executable>
+ <mainClass>org.apache.dubbo.samples.basic.SslBasicProvider</mainClass>
+ </configuration>
+ <executions>
+ <execution>
+ <goals>
+ <goal>repackage</goal>
+ </goals>
+ <configuration>
+ <classifier>exec</classifier>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+</project>
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/EmbeddedZooKeeper.java b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/EmbeddedZooKeeper.java
new file mode 100644
index 0000000..13504d5
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/EmbeddedZooKeeper.java
@@ -0,0 +1,256 @@
+/*
+ * Copyright 2014 the original author or authors.
+ *
+ * Licensed 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.basic;
+
+import java.io.File;
+import java.lang.reflect.Method;
+import java.util.Properties;
+import java.util.UUID;
+
+import org.apache.zookeeper.server.ServerConfig;
+import org.apache.zookeeper.server.ZooKeeperServerMain;
+import org.apache.zookeeper.server.quorum.QuorumPeerConfig;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import org.springframework.context.SmartLifecycle;
+import org.springframework.util.ErrorHandler;
+import org.springframework.util.SocketUtils;
+
+/**
+ * from: https://github.com/spring-projects/spring-xd/blob/v1.3.1.RELEASE/spring-xd-dirt/src/main/java/org/springframework/xd/dirt/zookeeper/ZooKeeperUtils.java
+ *
+ * Helper class to start an embedded instance of standalone (non clustered) ZooKeeper.
+ *
+ * NOTE: at least an external standalone server (if not an ensemble) are recommended, even for
+ * {@link org.springframework.xd.dirt.server.singlenode.SingleNodeApplication}
+ *
+ * @author Patrick Peralta
+ * @author Mark Fisher
+ * @author David Turanski
+ */
+public class EmbeddedZooKeeper implements SmartLifecycle {
+
+ /**
+ * Logger.
+ */
+ private static final Logger logger = LoggerFactory.getLogger(EmbeddedZooKeeper.class);
+
+ /**
+ * ZooKeeper client port. This will be determined dynamically upon startup.
+ */
+ private final int clientPort;
+
+ /**
+ * Whether to auto-start. Default is true.
+ */
+ private boolean autoStartup = true;
+
+ /**
+ * Lifecycle phase. Default is 0.
+ */
+ private int phase = 0;
+
+ /**
+ * Thread for running the ZooKeeper server.
+ */
+ private volatile Thread zkServerThread;
+
+ /**
+ * ZooKeeper server.
+ */
+ private volatile ZooKeeperServerMain zkServer;
+
+ /**
+ * {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread.
+ */
+ private ErrorHandler errorHandler;
+
+ private boolean daemon = true;
+
+ /**
+ * Construct an EmbeddedZooKeeper with a random port.
+ */
+ public EmbeddedZooKeeper() {
+ clientPort = SocketUtils.findAvailableTcpPort();
+ }
+
+ /**
+ * Construct an EmbeddedZooKeeper with the provided port.
+ *
+ * @param clientPort port for ZooKeeper server to bind to
+ */
+ public EmbeddedZooKeeper(int clientPort, boolean daemon) {
+ this.clientPort = clientPort;
+ this.daemon = daemon;
+ }
+
+ /**
+ * Returns the port that clients should use to connect to this embedded server.
+ *
+ * @return dynamically determined client port
+ */
+ public int getClientPort() {
+ return this.clientPort;
+ }
+
+ /**
+ * Specify whether to start automatically. Default is true.
+ *
+ * @param autoStartup whether to start automatically
+ */
+ public void setAutoStartup(boolean autoStartup) {
+ this.autoStartup = autoStartup;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isAutoStartup() {
+ return this.autoStartup;
+ }
+
+ /**
+ * Specify the lifecycle phase for the embedded server.
+ *
+ * @param phase the lifecycle phase
+ */
+ public void setPhase(int phase) {
+ this.phase = phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public int getPhase() {
+ return this.phase;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isRunning() {
+ return (zkServerThread != null);
+ }
+
+ /**
+ * Start the ZooKeeper server in a background thread.
+ * <p>
+ * Register an error handler via {@link #setErrorHandler} in order to handle
+ * any exceptions thrown during startup or execution.
+ */
+ @Override
+ public synchronized void start() {
+ if (zkServerThread == null) {
+ zkServerThread = new Thread(new ServerRunnable(), "ZooKeeper Server Starter");
+ zkServerThread.setDaemon(daemon);
+ zkServerThread.start();
+ }
+ }
+
+ /**
+ * Shutdown the ZooKeeper server.
+ */
+ @Override
+ public synchronized void stop() {
+ if (zkServerThread != null) {
+ // The shutdown method is protected...thus this hack to invoke it.
+ // This will log an exception on shutdown; see
+ // https://issues.apache.org/jira/browse/ZOOKEEPER-1873 for details.
+ try {
+ Method shutdown = ZooKeeperServerMain.class.getDeclaredMethod("shutdown");
+ shutdown.setAccessible(true);
+ shutdown.invoke(zkServer);
+ }
+
+ catch (Exception e) {
+ throw new RuntimeException(e);
+ }
+
+ // It is expected that the thread will exit after
+ // the server is shutdown; this will block until
+ // the shutdown is complete.
+ try {
+ zkServerThread.join(5000);
+ zkServerThread = null;
+ }
+ catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ logger.warn("Interrupted while waiting for embedded ZooKeeper to exit");
+ // abandoning zk thread
+ zkServerThread = null;
+ }
+ }
+ }
+
+ /**
+ * Stop the server if running and invoke the callback when complete.
+ */
+ @Override
+ public void stop(Runnable callback) {
+ stop();
+ callback.run();
+ }
+
+ /**
+ * Provide an {@link ErrorHandler} to be invoked if an Exception is thrown from the ZooKeeper server thread. If none
+ * is provided, only error-level logging will occur.
+ *
+ * @param errorHandler the {@link ErrorHandler} to be invoked
+ */
+ public void setErrorHandler(ErrorHandler errorHandler) {
+ this.errorHandler = errorHandler;
+ }
+
+ /**
+ * Runnable implementation that starts the ZooKeeper server.
+ */
+ private class ServerRunnable implements Runnable {
+
+ @Override
+ public void run() {
+ try {
+ Properties properties = new Properties();
+ File file = new File(System.getProperty("java.io.tmpdir")
+ + File.separator + UUID.randomUUID());
+ file.deleteOnExit();
+ properties.setProperty("dataDir", file.getAbsolutePath());
+ properties.setProperty("clientPort", String.valueOf(clientPort));
+
+ QuorumPeerConfig quorumPeerConfig = new QuorumPeerConfig();
+ quorumPeerConfig.parseProperties(properties);
+
+ zkServer = new ZooKeeperServerMain();
+ ServerConfig configuration = new ServerConfig();
+ configuration.readFrom(quorumPeerConfig);
+
+ zkServer.runFromConfig(configuration);
+ }
+ catch (Exception e) {
+ if (errorHandler != null) {
+ errorHandler.handleError(e);
+ }
+ else {
+ logger.error("Exception running embedded ZooKeeper", e);
+ }
+ }
+ }
+ }
+
+}
\ No newline at end of file
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/SslBasicProvider.java b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/SslBasicProvider.java
new file mode 100644
index 0000000..acbf725
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/SslBasicProvider.java
@@ -0,0 +1,79 @@
+/*
+ *
+ * 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.basic;
+
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ProtocolConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.ServiceConfig;
+import org.apache.dubbo.config.SslConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.samples.basic.api.DemoService;
+import org.apache.dubbo.samples.basic.impl.DemoServiceImpl;
+
+import java.util.concurrent.CountDownLatch;
+
+public class SslBasicProvider {
+
+ private static final String ROOT_DIR = System.getProperty("user.dir");
+
+ public static void main(String[] args) throws Exception {
+ new EmbeddedZooKeeper(2181, false).start();
+ // wait for embedded zookeeper start completely.
+ Thread.sleep(1000);
+
+ SslConfig sslConfig = new SslConfig();
+ if (args.length > 0) {
+ if (args.length < 2 || args.length > 3) {
+ System.out.println(
+ "USAGE: BasicProvider certChainFilePath privateKeyFilePath " +
+ "[trustCertCollectionFilePath]\n Specify 'trustCertCollectionFilePath' only if you want " +
+ "need Mutual TLS.");
+ System.exit(0);
+ }
+
+
+ sslConfig.setServerKeyCertChainPath(args[0]);
+ sslConfig.setServerPrivateKeyPath(args[1]);
+ if (args.length == 3) {
+ sslConfig.setServerTrustCertCollectionPath(args[2]);
+ }
+ }
+
+ ProtocolConfig protocolConfig = new ProtocolConfig("dubbo");
+ protocolConfig.setSslEnabled(true);
+
+ DubboBootstrap bootstrap = DubboBootstrap.getInstance();
+ bootstrap.application(new ApplicationConfig("ssl-provider"))
+ .registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
+ .protocol(protocolConfig)
+ .ssl(sslConfig);
+
+ ServiceConfig<DemoService> service = new ServiceConfig<>();
+ service.setInterface(DemoService.class);
+ service.setRef(new DemoServiceImpl());
+
+ bootstrap.service(service);
+ bootstrap.start();
+
+ System.out.println("dubbo service started");
+ new CountDownLatch(1).await();
+ }
+}
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/api/DemoService.java b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/api/DemoService.java
new file mode 100644
index 0000000..1080104
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/api/DemoService.java
@@ -0,0 +1,28 @@
+/*
+ *
+ * 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.basic.api;
+
+public interface DemoService {
+
+ String sayHello(String name);
+
+ void testVoid();
+
+}
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/impl/DemoServiceImpl.java b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/impl/DemoServiceImpl.java
new file mode 100644
index 0000000..b6e1086
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/java/org/apache/dubbo/samples/basic/impl/DemoServiceImpl.java
@@ -0,0 +1,41 @@
+/*
+ *
+ * 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.basic.impl;
+
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.samples.basic.api.DemoService;
+
+import java.text.SimpleDateFormat;
+import java.util.Date;
+
+public class DemoServiceImpl implements DemoService {
+
+ @Override
+ public String sayHello(String name) {
+ System.out.println("[" + new SimpleDateFormat("HH:mm:ss").format(new Date()) + "] Hello " + name +
+ ", request from consumer: " + RpcContext.getContext().getRemoteAddress());
+ return "Hello " + name + ", response from provider: " + RpcContext.getContext().getLocalAddress();
+ }
+
+ @Override
+ public void testVoid() {
+
+ }
+}
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/ca.key b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/ca.key
new file mode 100644
index 0000000..03c4f95
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/ca.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAMBA3wVeTGHZR1Ry
+e/i+J8a2cu5gXwFV6TnObzGM7bLFCO5i9v4mLo4iFzPsHmWDUxKS3Y8iXbu0eYBl
+LoNY0lSvxDx33O+DuwMmVN+DzSD+Eod9zfvwOWHsazYCZT2PhNxnVWIuJXViY4JA
+HUGodjx+QAi6yCAurUZGvYXGgZSBAgMBAAECgYAxRi8i9BlFlufGSBVoGmydbJOm
+bwLKl9dP3o33ODSP9hok5y6A0w5plWk3AJSF1hPLleK9VcSKYGYnt0clmPVHF35g
+bx2rVK8dOT0mn7rz9Zr70jcSz1ETA2QonHZ+Y+niLmcic9At6hRtWiewblUmyFQm
+GwggIzi7LOyEUHrEcQJBAOXxyQvnLvtKzXiqcsW/K6rExqVJVk+KF0fzzVyMzTJx
+HRBxUVgvGdEJT7j+7P2kcTyafve0BBzDSPIaDyiJ+Y0CQQDWCb7jASFSbu5M3Zcd
+Gkr4ZKN1XO3VLQX10b22bQYdF45hrTN2tnzRvVUR4q86VVnXmiGiTqmLkXcA2WWf
+pHfFAkAhv9olUBo6MeF0i3frBEMRfm41hk0PwZHnMqZ6pgPcGnQMnMU2rzsXzkkQ
+OwJnvAIOxhJKovZTjmofdqmw5odlAkBYVUdRWjsNUTjJwj3GRf6gyq/nFMYWz3EB
+RWFdM1ttkDYzu45ctO2IhfHg4sPceDMO1s6AtKQmNI9/azkUjITdAkApNa9yFRzc
+TBaDNPd5KVd58LVIzoPQ6i7uMHteLXJUWqSroji6S3s4gKMFJ/dO+ZXIlgQgfJJJ
+ZDL4cdrdkeoM
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/ca.pem b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/ca.pem
new file mode 100644
index 0000000..6c8511a
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/ca.pem
@@ -0,0 +1,15 @@
+-----BEGIN CERTIFICATE-----
+MIICSjCCAbOgAwIBAgIJAJHGGR4dGioHMA0GCSqGSIb3DQEBCwUAMFYxCzAJBgNV
+BAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX
+aWRnaXRzIFB0eSBMdGQxDzANBgNVBAMTBnRlc3RjYTAeFw0xNDExMTEyMjMxMjla
+Fw0yNDExMDgyMjMxMjlaMFYxCzAJBgNVBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0
+YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBXaWRnaXRzIFB0eSBMdGQxDzANBgNVBAMT
+BnRlc3RjYTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAwEDfBV5MYdlHVHJ7
++L4nxrZy7mBfAVXpOc5vMYztssUI7mL2/iYujiIXM+weZYNTEpLdjyJdu7R5gGUu
+g1jSVK/EPHfc74O7AyZU34PNIP4Sh33N+/A5YexrNgJlPY+E3GdVYi4ldWJjgkAd
+Qah2PH5ACLrIIC6tRka9hcaBlIECAwEAAaMgMB4wDAYDVR0TBAUwAwEB/zAOBgNV
+HQ8BAf8EBAMCAgQwDQYJKoZIhvcNAQELBQADgYEAHzC7jdYlzAVmddi/gdAeKPau
+sPBG/C2HCWqHzpCUHcKuvMzDVkY/MP2o6JIW2DBbY64bO/FceExhjcykgaYtCH/m
+oIU63+CFOTtR7otyQAWHqXa7q4SbCDlG7DyRFxqG0txPtGvy12lgldA2+RgcigQG
+Dfcog5wrJytaQ6UA0wE=
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/client.key b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/client.key
new file mode 100644
index 0000000..f48d073
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/client.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICeQIBADANBgkqhkiG9w0BAQEFAASCAmMwggJfAgEAAoGBAOxUR9uhvhbeVUIM
+s5WbH0px0mehl2+6sZpNjzvE2KimZpHzMJHukVH0Ffkvhs0b8+S5Ut9VNUAqd3IM
+JCCAEGtRNoQhM1t9Yr2zAckSvbRacp+FL/Cj9eDmyo00KsVGaeefA4Dh4OW+ZhkT
+NKcldXqkSuj1sEf244JZYuqZp6/tAgMBAAECgYEAi2NSVqpZMafE5YYUTcMGe6QS
+k2jtpsqYgggI2RnLJ/2tNZwYI5pwP8QVSbnMaiF4gokD5hGdrNDfTnb2v+yIwYEH
+0w8+oG7Z81KodsiZSIDJfTGsAZhVNwOz9y0VD8BBZZ1/274Zh52AUKLjZS/ZwIbS
+W2ywya855dPnH/wj+0ECQQD9X8D920kByTNHhBG18biAEZ4pxs9f0OAG8333eVcI
+w2lJDLsYDZrCB2ocgA3lUdozlzPC7YDYw8reg0tkiRY5AkEA7sdNzOeQsQRn7++5
+0bP9DtT/iON1gbfxRzCfCfXdoOtfQWIzTePWtURt9X/5D9NofI0Rg5W2oGy/MLe5
+/sXHVQJBAIup5XrJDkQywNZyAUU2ecn2bCWBFjwtqd+LBmuMciI9fOKsZtEKZrz/
+U0lkeMRoSwvXE8wmGLjjrAbdfohrXFkCQQDZEx/LtIl6JINJQiswVe0tWr6k+ASP
+1WXoTm+HYpoF/XUvv9LccNF1IazFj34hwRQwhx7w/V52Ieb+p0jUMYGxAkEAjDhd
+9pBO1fKXWiXzi9ZKfoyTNcUq3eBSVKwPG2nItg5ycXengjT5sgcWDnciIzW7BIVI
+JiqOszq9GWESErAatg==
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/client.pem b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/client.pem
new file mode 100644
index 0000000..913649b
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/client.pem
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC6TCCAlKgAwIBAgIBCjANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTEwMDEwOTU4WhcNMjUxMTA3
+MDEwOTU4WjBaMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8G
+A1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMRMwEQYDVQQDDAp0ZXN0Y2xp
+ZW50MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDsVEfbob4W3lVCDLOVmx9K
+cdJnoZdvurGaTY87xNiopmaR8zCR7pFR9BX5L4bNG/PkuVLfVTVAKndyDCQggBBr
+UTaEITNbfWK9swHJEr20WnKfhS/wo/Xg5sqNNCrFRmnnnwOA4eDlvmYZEzSnJXV6
+pEro9bBH9uOCWWLqmaev7QIDAQABo4HCMIG/MAkGA1UdEwQCMAAwCwYDVR0PBAQD
+AgXgMB0GA1UdDgQWBBQAdbW5Vml/CnYwqdP3mOHDARU+8zBwBgNVHSMEaTBnoVqk
+WDBWMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMY
+SW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2GCCQCRxhke
+HRoqBzAJBgNVHREEAjAAMAkGA1UdEgQCMAAwDQYJKoZIhvcNAQELBQADgYEAf4MM
+k+sdzd720DfrQ0PF2gDauR3M9uBubozDuMuF6ufAuQBJSKGQEGibXbUelrwHmnql
+UjTyfolVcxEBVaF4VFHmn7u6vP7S1NexIDdNUHcULqxIb7Tzl8JYq8OOHD2rQy4H
+s8BXaVIzw4YcaCGAMS0iDX052Sy7e2JhP8Noxvo=
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/server0.key b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/server0.key
new file mode 100644
index 0000000..add153c
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/server0.key
@@ -0,0 +1,16 @@
+-----BEGIN PRIVATE KEY-----
+MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBANOmffupIGC8YDau
+rOF4eKnHwPszgpkkhWzKsVxhNDBxCVYx4TEjG0XWIO0iyRXupZbUC+7N/8HnEVNa
+8F1jYhng14Iiq99cNQbbnuHHhIztmpocrJTxmnhGzoAnRa1Tb+GnAuRoIHRA/V2c
+VUE9tbikQugFx/SPgXAw6tfWB+YvAgMBAAECgYEAoEq9qzUBgoHoVEGiSPiWWe8g
+5p6yUA1qx2QTQyWTAwT4z0DjjfVKmG99bFsl8+hTnJFnoCp/gnjflEOROwkjp5kG
+m0drqOPx1jeipJjpXYTBu49h+WpZ1PF+KhVtxsIm3OOCvh67iWaKyyOVb5Og8aiR
+jl6dn/TdG/dlGD8AfUECQQDuNMle6p0oU8amC6O9wIMBroxx2nFstzE6O35PLEzG
+/tj0kxxn9Jp2TS9mGaLCzSuXmpjlF4+NOWiBPkrLC2TfAkEA43Xg7uEUkaJAz2/W
+m1lIBTLt+4rIQY/2emh33bDcA+rv8rwwrMMIv17/xPx7bs49YqGG5xufD+Rwl6TL
+qFXYsQJAPrOwagax1aKvwJeBw3oAQhoTKAkLIEXcdGqipe6QSzVcIIz0xjxxyEAr
+AOIwoLxnBCISqwMXq2H4K0UdZPMb2wJAdhdYLY1L6YRMk6XjzImg25oidisKZweA
+FvMv8DgHMj2CUAqmVrt3SivfLH1M9C09L3zfFhOAFHcsgX58gav4MQJBANSBnrHj
+tIq4l8z79CPUIuu3QyeEh+XwY8s5qE5CNTck0U59lzp9NvENHbkx3KO896TTerko
++8bXHMLkJkHPXms=
+-----END PRIVATE KEY-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/server0.pem b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/server0.pem
new file mode 100644
index 0000000..9458954
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/certs/server0.pem
@@ -0,0 +1,18 @@
+-----BEGIN CERTIFICATE-----
+MIIC8zCCAlygAwIBAgIBCzANBgkqhkiG9w0BAQsFADBWMQswCQYDVQQGEwJBVTET
+MBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50ZXJuZXQgV2lkZ2l0cyBQ
+dHkgTHRkMQ8wDQYDVQQDEwZ0ZXN0Y2EwHhcNMTUxMTEwMDExNDU1WhcNMjUxMTA3
+MDExNDU1WjBkMQswCQYDVQQGEwJBVTETMBEGA1UECAwKU29tZS1TdGF0ZTEhMB8G
+A1UECgwYSW50ZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMR0wGwYDVQQDDBQqLnRlc3Qu
+Z29vZ2xlLmNvbS5hdTCBnzANBgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEA06Z9+6kg
+YLxgNq6s4Xh4qcfA+zOCmSSFbMqxXGE0MHEJVjHhMSMbRdYg7SLJFe6lltQL7s3/
+wecRU1rwXWNiGeDXgiKr31w1Btue4ceEjO2amhyslPGaeEbOgCdFrVNv4acC5Ggg
+dED9XZxVQT21uKRC6AXH9I+BcDDq19YH5i8CAwEAAaOBwjCBvzAJBgNVHRMEAjAA
+MAsGA1UdDwQEAwIF4DAdBgNVHQ4EFgQUbyZIbUvqmePzv40xa0mMaDxLToYwcAYD
+VR0jBGkwZ6FapFgwVjELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUx
+ITAfBgNVBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZDEPMA0GA1UEAxMGdGVz
+dGNhggkAkcYZHh0aKgcwCQYDVR0RBAIwADAJBgNVHRIEAjAAMA0GCSqGSIb3DQEB
+CwUAA4GBAJ21MwMf4WwAjafPKn+8Ng7ordtdp6tlkjt+Xub4l4zMr6FCp6dc/Ceh
+6Hj43zYcKpAe5I6eaVcMc9qcYfUb9i4NVX82dMQpAwpNHgqTzqYt6GYEjF3YhKA7
+uOFdA0OvOFJa14SNdNRk9E1Cd/tElXnLnSE4DOguMNvXz8mRKfnD
+-----END CERTIFICATE-----
diff --git a/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/log4j.properties b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/log4j.properties
new file mode 100644
index 0000000..d6ecd5c
--- /dev/null
+++ b/java/dubbo-samples-ssl/dubbo-samples-ssl-provider/src/main/resources/log4j.properties
@@ -0,0 +1,26 @@
+#
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements. See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.
+# The ASF licenses this file to You under the Apache License, Version 2.0
+# (the "License"); you may not use this file except in compliance with
+# the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+#
+
+###set log levels###
+log4j.rootLogger=info, stdout
+###output to the console###
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target=System.out
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=[%d{dd/MM/yy hh:mm:ss:sss z}] %t %5p %c{2}: %m%n
\ No newline at end of file
diff --git a/java/dubbo-samples-grpc/pom.xml b/java/dubbo-samples-ssl/pom.xml
similarity index 61%
copy from java/dubbo-samples-grpc/pom.xml
copy to java/dubbo-samples-ssl/pom.xml
index 702943a..30ed591 100644
--- a/java/dubbo-samples-grpc/pom.xml
+++ b/java/dubbo-samples-ssl/pom.xml
@@ -18,33 +18,16 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
- <modelVersion>4.0.0</modelVersion>
-
<groupId>org.apache.dubbo</groupId>
<version>1.0-SNAPSHOT</version>
- <artifactId>dubbo-samples-grpc</artifactId>
- <packaging>pom</packaging>
- <modules>
- <module>dubbo-samples-original</module>
- <module>dubbo-samples-reactor</module>
- <module>dubbo-samples-rxjava</module>
- </modules>
+ <modelVersion>4.0.0</modelVersion>
- <repositories>
- <repository>
- <id>apache.snapshots.https</id>
- <name>Apache Development Snapshot Repository</name>
- <url>https://repository.apache.org/content/repositories/snapshots</url>
- <layout>default</layout>
- <releases>
- <enabled>false</enabled>
- </releases>
- <snapshots>
- <enabled>true</enabled>
- <updatePolicy>never</updatePolicy>
- </snapshots>
- </repository>
- </repositories>
+ <packaging>pom</packaging>
+ <artifactId>dubbo-samples-ssl</artifactId>
+ <modules>
+ <module>dubbo-samples-ssl-provider</module>
+ <module>dubbo-samples-ssl-consumer</module>
+ </modules>
</project>
diff --git a/java/pom.xml b/java/pom.xml
index 8860000..b3840de 100644
--- a/java/pom.xml
+++ b/java/pom.xml
@@ -79,6 +79,7 @@
<module>dubbo-samples-grpc</module>
<module>dubbo-samples-cloud-native</module>
<module>dubbo-samples-protobuf</module>
+ <module>dubbo-samples-ssl</module>
</modules>
<repositories>
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org