You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@dubbo.apache.org by ho...@apache.org on 2021/08/11 09:13:29 UTC
[dubbo] branch 3.0 updated: suit ut. (#8471)
This is an automated email from the ASF dual-hosted git repository.
horizonzy pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 961ce5f suit ut. (#8471)
961ce5f is described below
commit 961ce5f101bbf0f8ddbf2394a8518bc9b58bb561
Author: 赵延 <ho...@apache.org>
AuthorDate: Wed Aug 11 17:13:18 2021 +0800
suit ut. (#8471)
---
.../org/apache/dubbo/config/ServiceConfigTest.java | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java
index dbde04f..a9cd67f 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ServiceConfigTest.java
@@ -18,6 +18,7 @@
package org.apache.dubbo.config;
import com.google.common.collect.Lists;
+
import org.apache.dubbo.common.URL;
import org.apache.dubbo.common.extension.ExtensionLoader;
import org.apache.dubbo.config.api.DemoService;
@@ -43,7 +44,7 @@ import org.mockito.Mockito;
import java.util.Collections;
import java.util.Map;
-import java.util.concurrent.TimeUnit;
+import java.util.concurrent.CountDownLatch;
import static org.apache.dubbo.common.constants.CommonConstants.ANYHOST_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.APPLICATION_KEY;
@@ -204,11 +205,22 @@ public class ServiceConfigTest {
@Test
public void testDelayExport() throws Exception {
+ CountDownLatch latch = new CountDownLatch(1);
+ delayService.addServiceListener(new ServiceListener() {
+ @Override
+ public void exported(ServiceConfig sc) {
+ assertThat(delayService.getExportedUrls(), hasSize(1));
+ latch.countDown();
+ }
+
+ @Override
+ public void unexported(ServiceConfig sc) {
+
+ }
+ });
delayService.export();
assertTrue(delayService.getExportedUrls().isEmpty());
- //add 300ms to ensure that the delayService has been exported
- TimeUnit.MILLISECONDS.sleep(delayService.getDelay() + 300);
- assertThat(delayService.getExportedUrls(), hasSize(1));
+ latch.await();
}
@Test