You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by al...@apache.org on 2022/11/30 07:33:21 UTC

[dubbo-samples] branch master updated: block test case if assert failed (#572)

This is an automated email from the ASF dual-hosted git repository.

albumenj 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 d1be1653 block test case if assert failed (#572)
d1be1653 is described below

commit d1be165330d8a2fee81395b0deac1f0caa620948
Author: Jianran <ta...@163.com>
AuthorDate: Wed Nov 30 15:33:15 2022 +0800

    block test case if assert failed (#572)
---
 .../java/org/apache/dubbo/samples/async/AsyncServiceIT.java    | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/dubbo-samples-async/dubbo-samples-async-simple/src/test/java/org/apache/dubbo/samples/async/AsyncServiceIT.java b/dubbo-samples-async/dubbo-samples-async-simple/src/test/java/org/apache/dubbo/samples/async/AsyncServiceIT.java
index 113544b4..163bd67d 100644
--- a/dubbo-samples-async/dubbo-samples-async-simple/src/test/java/org/apache/dubbo/samples/async/AsyncServiceIT.java
+++ b/dubbo-samples-async/dubbo-samples-async-simple/src/test/java/org/apache/dubbo/samples/async/AsyncServiceIT.java
@@ -29,6 +29,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
 
 import java.util.concurrent.CompletableFuture;
 import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.atomic.AtomicReference;
 
 @RunWith(SpringJUnit4ClassRunner.class)
 @ContextConfiguration(locations = {"classpath:/spring/async-consumer.xml"})
@@ -41,13 +42,16 @@ public class AsyncServiceIT {
         asyncService.sayHello("completable future");
         CompletableFuture<String> helloFuture = RpcContext.getContext().getCompletableFuture();
         CountDownLatch latch = new CountDownLatch(1);
+        AtomicReference<Throwable> exceptionRef = new AtomicReference<>();
+        AtomicReference<String> retValueRef = new AtomicReference<>();
         helloFuture.whenComplete((retValue, exception) -> {
-            Assert.assertNull(exception);
-            Assert.assertEquals("hello, completable future", retValue);
+            exceptionRef.set(exception);
+            retValueRef.set(retValue);
             latch.countDown();
         });
-
         latch.await();
+        Assert.assertNull(exceptionRef.get());
+        Assert.assertEquals("hello, completable future", retValueRef.get());
     }
 
     @Test


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