From ba9d8324ee45a186d61110ac75f201a2fd3fe819 Mon Sep 17 00:00:00 2001 From: Grzegorz Piwowarek Date: Tue, 12 Sep 2017 20:30:01 +0200 Subject: [PATCH] Refactor RxJava (#2612) --- rxjava/pom.xml | 6 ++++++ .../com/baeldung/rxjava/ConnectableObservableTest.java | 7 ++++--- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/rxjava/pom.xml b/rxjava/pom.xml index 7b78d09eb6..bf5f073d8d 100644 --- a/rxjava/pom.xml +++ b/rxjava/pom.xml @@ -25,6 +25,12 @@ rxjava 2.1.3 + + + com.jayway.awaitility + awaitility + 1.7.0 + diff --git a/rxjava/src/test/java/com/baeldung/rxjava/ConnectableObservableTest.java b/rxjava/src/test/java/com/baeldung/rxjava/ConnectableObservableTest.java index 981875510d..031ff0c5bb 100644 --- a/rxjava/src/test/java/com/baeldung/rxjava/ConnectableObservableTest.java +++ b/rxjava/src/test/java/com/baeldung/rxjava/ConnectableObservableTest.java @@ -6,6 +6,7 @@ import rx.observables.ConnectableObservable; import java.util.concurrent.TimeUnit; +import static com.jayway.awaitility.Awaitility.await; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertTrue; @@ -15,12 +16,12 @@ public class ConnectableObservableTest { public void givenConnectableObservable_whenConnect_thenGetMessage() throws InterruptedException { String[] result = {""}; ConnectableObservable connectable - = Observable.interval(200, TimeUnit.MILLISECONDS).publish(); + = Observable.interval(500, TimeUnit.MILLISECONDS).publish(); connectable.subscribe(i -> result[0] += i); assertFalse(result[0].equals("01")); connectable.connect(); - Thread.sleep(500); - assertTrue(result[0].equals("01")); + await() + .until(() -> assertTrue(result[0].equals("01"))); } }