Dubbo smaples reactor grpc test case conversion (#253)

diff --git a/dubbo-samples-grpc/dubbo-samples-reactor/case-configuration.yml b/dubbo-samples-grpc/dubbo-samples-reactor/case-configuration.yml
new file mode 100644
index 0000000..e72d6d3
--- /dev/null
+++ b/dubbo-samples-grpc/dubbo-samples-reactor/case-configuration.yml
@@ -0,0 +1,24 @@
+# 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.
+
+from: app-builtin-zookeeper.yml
+
+props:
+  project_name: dubbo-samples-reactor-grpc
+  main_class: org.apache.dubbo.samples.basic.BasicProvider
+  zookeeper_port: 2181
+  dubbo_port: 50051
+
diff --git a/dubbo-samples-grpc/dubbo-samples-reactor/case-versions.conf b/dubbo-samples-grpc/dubbo-samples-reactor/case-versions.conf
new file mode 100644
index 0000000..978f7e7
--- /dev/null
+++ b/dubbo-samples-grpc/dubbo-samples-reactor/case-versions.conf
@@ -0,0 +1,6 @@
+
+# Supported component versions of the test case
+
+# Spring app
+dubbo.version=2.7*, 3.*
+spring.version=4.*, 5.*
diff --git a/dubbo-samples-grpc/dubbo-samples-reactor/pom.xml b/dubbo-samples-grpc/dubbo-samples-reactor/pom.xml
index cfa6a5a..73864d6 100644
--- a/dubbo-samples-grpc/dubbo-samples-reactor/pom.xml
+++ b/dubbo-samples-grpc/dubbo-samples-reactor/pom.xml
@@ -30,28 +30,45 @@
         <target.level>1.8</target.level>
         <dubbo.version>2.7.7</dubbo.version>
         <junit.version>4.12</junit.version>
-        <spring-test.version>4.3.16.RELEASE</spring-test.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>
-        <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.BasicProvider</main-class>
-        <spring-boot.version>1.5.13.RELEASE</spring-boot.version>
+        <spring.version>4.3.16.RELEASE</spring.version>
         <grpc.version>1.19.0</grpc.version>
-        <dubbo.compiler.version>0.0.1</dubbo.compiler.version>
-        <reactive.grpc.version>1.0.0</reactive.grpc.version>
     </properties>
 
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.springframework</groupId>
+                <artifactId>spring-framework-bom</artifactId>
+                <version>${spring.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+
+            <dependency>
+                <groupId>org.apache.dubbo</groupId>
+                <artifactId>dubbo-bom</artifactId>
+                <version>${dubbo.version}</version>
+                <type>pom</type>
+                <scope>import</scope>
+            </dependency>
+
+            <dependency>
+                <groupId>org.apache.dubbo</groupId>
+                <artifactId>dubbo-dependencies-zookeeper</artifactId>
+                <version>${dubbo.version}</version>
+                <type>pom</type>
+            </dependency>
+
+        </dependencies>
+    </dependencyManagement>
+
     <dependencies>
+
         <dependency>
             <groupId>org.apache.dubbo</groupId>
             <artifactId>dubbo</artifactId>
-            <version>${dubbo.version}</version>
         </dependency>
+
         <dependency>
             <groupId>io.grpc</groupId>
             <artifactId>grpc-netty</artifactId>
@@ -69,9 +86,15 @@
         </dependency>
         <dependency>
             <groupId>io.grpc</groupId>
+            <artifactId>grpc-core</artifactId>
+            <version>${grpc.version}</version>
+        </dependency>
+        <dependency>
+            <groupId>io.grpc</groupId>
             <artifactId>grpc-stub</artifactId>
             <version>${grpc.version}</version>
         </dependency>
+
         <dependency>
             <groupId>com.google.protobuf</groupId>
             <artifactId>protobuf-java-util</artifactId>
@@ -81,66 +104,29 @@
         <dependency>
             <groupId>com.salesforce.servicelibs</groupId>
             <artifactId>reactor-grpc-stub</artifactId>
-            <version>${reactive.grpc.version}</version>
+            <version>1.0.0</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>
+            <version>4.12</version>
             <scope>test</scope>
         </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>
 
-    <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>
@@ -153,7 +139,7 @@
             <plugin>
                 <groupId>org.apache.maven.plugins</groupId>
                 <artifactId>maven-compiler-plugin</artifactId>
-                <version>${maven-compiler-plugin.version}</version>
+                <version>3.7.0</version>
                 <configuration>
                     <source>${source.level}</source>
                     <target>${target.level}</target>
@@ -174,7 +160,7 @@
                             <id>reactor-dubbo-grpc</id>
                             <groupId>org.apache.dubbo</groupId>
                             <artifactId>dubbo-compiler</artifactId>
-                            <version>${dubbo.compiler.version}</version>
+                            <version>0.0.1</version>
                             <mainClass>org.apache.dubbo.gen.grpc.reactive.ReactorDubboGrpcGenerator</mainClass>
                         </protocPlugin>
                     </protocPlugins>
diff --git a/dubbo-samples-grpc/dubbo-samples-reactor/src/main/java/org/apache/dubbo/samples/basic/BasicProvider.java b/dubbo-samples-grpc/dubbo-samples-reactor/src/main/java/org/apache/dubbo/samples/basic/BasicProvider.java
index d122e07..ed745e6 100644
--- a/dubbo-samples-grpc/dubbo-samples-reactor/src/main/java/org/apache/dubbo/samples/basic/BasicProvider.java
+++ b/dubbo-samples-grpc/dubbo-samples-reactor/src/main/java/org/apache/dubbo/samples/basic/BasicProvider.java
@@ -26,6 +26,9 @@
 public class BasicProvider {
 
     public static void main(String[] args) throws Exception {
+
+        new EmbeddedZooKeeper(2181, true).start();
+
         ClassPathXmlApplicationContext context =
                 new ClassPathXmlApplicationContext("spring/dubbo-demo-provider.xml");
         context.start();
diff --git a/dubbo-samples-grpc/dubbo-samples-reactor/src/test/java/org/apache/dubbo/samples/ReactorGrpcIT.java b/dubbo-samples-grpc/dubbo-samples-reactor/src/test/java/org/apache/dubbo/samples/ReactorGrpcIT.java
index b9b070a..ea2b5f7 100644
--- a/dubbo-samples-grpc/dubbo-samples-reactor/src/test/java/org/apache/dubbo/samples/ReactorGrpcIT.java
+++ b/dubbo-samples-grpc/dubbo-samples-reactor/src/test/java/org/apache/dubbo/samples/ReactorGrpcIT.java
@@ -17,39 +17,21 @@
 
 package org.apache.dubbo.samples;
 
+import io.grpc.examples.helloworld.HelloReply;
 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;
+import reactor.core.publisher.Mono;
 
 @RunWith(SpringJUnit4ClassRunner.class)
-@ContextConfiguration(locations = {"classpath*:spring/dubbo-demo-consumer.xml", "classpath*:spring/dubbo-demo-provider.xml"})
+@ContextConfiguration(locations = {"classpath*:spring/dubbo-demo-consumer.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")
@@ -57,9 +39,20 @@
 
     @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);
+
+        HelloRequest helloRequest = HelloRequest.newBuilder().setName("world!").build();
+
+        Mono<HelloReply> mono =  greeter.sayHello(helloRequest);
+
+        mono.subscribe(
+
+                reply -> {
+                    String message = reply.getMessage();
+                    Assert.assertTrue(message.startsWith("Hello world!"));
+                }
+
+        );
+        Thread.sleep(1000);
     }
 }