Add pb test
diff --git a/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/GenericTest.java b/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/GenericTest.java
index 9aa713a..6fa9925 100644
--- a/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/GenericTest.java
+++ b/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/GenericTest.java
@@ -24,7 +24,7 @@
ref.setGeneric("true");
ref.setLazy(true);
DubboBootstrap bootstrap = DubboBootstrap.getInstance();
- bootstrap.application(new ApplicationConfig("generic-consumer"))
+ bootstrap.application(new ApplicationConfig("demo-consumer"))
.registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
.reference(ref)
.start();
diff --git a/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/PbTest.java b/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/PbTest.java
index 78863e3..3c5b493 100644
--- a/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/PbTest.java
+++ b/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/PbTest.java
@@ -1,4 +1,88 @@
package org.apache.dubbo.sample.tri;
+import org.apache.dubbo.common.constants.CommonConstants;
+import org.apache.dubbo.common.stream.StreamObserver;
+import org.apache.dubbo.config.ApplicationConfig;
+import org.apache.dubbo.config.ReferenceConfig;
+import org.apache.dubbo.config.RegistryConfig;
+import org.apache.dubbo.config.bootstrap.DubboBootstrap;
+import org.apache.dubbo.hello.HelloReply;
+import org.apache.dubbo.hello.HelloRequest;
+
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+
public class PbTest {
+ private static PbGreeter delegate;
+
+ @BeforeClass
+ public static void init() {
+ ReferenceConfig<PbGreeter> ref = new ReferenceConfig<>();
+ ref.setInterface(PbGreeter.class);
+ ref.setCheck(false);
+ ref.setInterface(PbGreeter.class);
+ ref.setCheck(false);
+ ref.setProtocol(CommonConstants.TRIPLE);
+ ref.setLazy(true);
+ ref.setTimeout(10000);
+
+ DubboBootstrap bootstrap = DubboBootstrap.getInstance();
+ bootstrap.application(new ApplicationConfig("demo-consumer"))
+ .registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
+ .reference(ref)
+ .start();
+
+ delegate = ref.get();
+ }
+
+ @Test
+ public void serverStream() throws InterruptedException {
+ int n = 10;
+ CountDownLatch latch = new CountDownLatch(n);
+ final HelloRequest request = HelloRequest.newBuilder()
+ .setName("request")
+ .build();
+ delegate.sayHelloServerStream(request, new StdoutStreamObserver<HelloReply>("sayHelloServerStream") {
+ @Override
+ public void onNext(HelloReply data) {
+ super.onNext(data);
+ latch.countDown();
+ }
+ });
+ Assert.assertTrue(latch.await(3, TimeUnit.SECONDS));
+ }
+
+ @Test
+ public void stream() throws InterruptedException {
+ int n = 10;
+ CountDownLatch latch = new CountDownLatch(n);
+ final HelloRequest request = HelloRequest.newBuilder()
+ .setName("stream request")
+ .build();
+ final StreamObserver<HelloRequest> requestObserver = delegate.sayHelloStream(new StdoutStreamObserver<HelloReply>("sayHelloStream") {
+ @Override
+ public void onNext(HelloReply data) {
+ super.onNext(data);
+ latch.countDown();
+ }
+ });
+ for (int i = 0; i < n; i++) {
+ requestObserver.onNext(request);
+ }
+ requestObserver.onCompleted();
+ Assert.assertTrue(latch.await(3, TimeUnit.SECONDS));
+ }
+
+ @Test
+ public void unaryHello() {
+ final HelloReply reply = delegate.sayHello(HelloRequest.newBuilder()
+ .setName("name")
+ .build());
+ Assert.assertNotNull(reply);
+ }
+
}
diff --git a/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/TestProvider.java b/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/TestProvider.java
index ba351bb..9fcd594 100644
--- a/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/TestProvider.java
+++ b/dubbo-samples-triple/src/test/java/org/apache/dubbo/sample/tri/TestProvider.java
@@ -10,9 +10,9 @@
public class TestProvider {
public static void main(String[] args) {
-// ServiceConfig<PbGreeter> pbService = new ServiceConfig<>();
-// pbService.setInterface(IGreeter.class);
-// pbService.setRef(new IGreeter1Impl());
+ ServiceConfig<PbGreeter> pbService = new ServiceConfig<>();
+ pbService.setInterface(PbGreeter.class);
+ pbService.setRef(new PbGreeterImpl());
ServiceConfig<WrapGreeter> wrapService = new ServiceConfig<>();
wrapService.setInterface(WrapGreeter.class);
@@ -23,7 +23,7 @@
bootstrap.application(new ApplicationConfig("demo-provider"))
.registry(new RegistryConfig("zookeeper://127.0.0.1:2181"))
.protocol(new ProtocolConfig(CommonConstants.TRIPLE, 50051))
-// .service(pbService)
+ .service(pbService)
.service(wrapService)
.start()
.await();