Skip to content

Commit

Permalink
The test has to wait on each action independently.
Browse files Browse the repository at this point in the history
Reduced the size of the iterable because I think it was blowing through the stack.
  • Loading branch information
abersnaze authored and benjchristensen committed Jan 7, 2014
1 parent 22b6b3d commit 2e53b67
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 5 deletions.
6 changes: 3 additions & 3 deletions rxjava-core/src/test/java/rx/ObserveOnTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void testObserveOnWithNewThreadScheduler() {
final AtomicInteger count = new AtomicInteger();
final int _multiple = 99;

Observable.range(1, 100000).map(new Func1<Integer, Integer>() {
Observable.range(1, 1000).map(new Func1<Integer, Integer>() {

@Override
public Integer call(Integer t1) {
Expand All @@ -62,7 +62,7 @@ public void testObserveOnWithThreadPoolScheduler() {
final AtomicInteger count = new AtomicInteger();
final int _multiple = 99;

Observable.range(1, 100000).map(new Func1<Integer, Integer>() {
Observable.range(1, 1000).map(new Func1<Integer, Integer>() {

@Override
public Integer call(Integer t1) {
Expand Down Expand Up @@ -95,7 +95,7 @@ public void testObserveOnOrderingConcurrency() {
final AtomicInteger count = new AtomicInteger();
final int _multiple = 99;

Observable.range(1, 10000).map(new Func1<Integer, Integer>() {
Observable.range(1, 1000).map(new Func1<Integer, Integer>() {

@Override
public Integer call(Integer t1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,16 +205,31 @@ public String call(String s) {
assertTrue(strings.contains("names=>b-2"));
}

/**
* The order of execution is nondeterministic.
* @throws InterruptedException
*/
@SuppressWarnings("rawtypes")
@Test
public final void testSequenceOfActions() throws InterruptedException {
final Scheduler scheduler = getScheduler();

final CountDownLatch latch = new CountDownLatch(1);
final CountDownLatch latch = new CountDownLatch(2);
final Action0 first = mock(Action0.class);
final Action0 second = mock(Action0.class);

// make it wait until after the second is called
// make it wait until both the first and second are called
doAnswer(new Answer() {

@Override
public Object answer(InvocationOnMock invocation) throws Throwable {
try {
return invocation.getMock();
} finally {
latch.countDown();
}
}
}).when(first).call();
doAnswer(new Answer() {

@Override
Expand Down

0 comments on commit 2e53b67

Please sign in to comment.