Last active
February 19, 2016 09:01
-
-
Save mootoh/47fd79c088ffc191b562 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class ApplicationTest extends ApplicationTestCase<Application> { | |
private static final String TAG = "Test"; | |
public ApplicationTest() { | |
super(Application.class); | |
} | |
public void testRxSample() throws InterruptedException { | |
final CountDownLatch signal = new CountDownLatch(1); | |
final String[] last = new String[1]; | |
Observable.just("one", "two", "three", "four", "five") | |
.subscribeOn(Schedulers.newThread()) | |
.observeOn(AndroidSchedulers.mainThread()) | |
.subscribe(new Subscriber<String>() { | |
@Override | |
public void onCompleted() { | |
Log.d(TAG, "completed"); | |
signal.countDown(); | |
} | |
@Override | |
public void onError(Throwable e) { | |
} | |
@Override | |
public void onNext(String s) { | |
Log.d(TAG, "onNext: " + s); | |
last[0] = s; | |
} | |
}) | |
; | |
signal.await(5, TimeUnit.SECONDS); | |
assertEquals("five", last[0]); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment