From 3239222d8f245c7d197d3a0d10a812a5aadbdf3b Mon Sep 17 00:00:00 2001 From: Ben Christensen Date: Tue, 17 Dec 2013 11:42:41 -0800 Subject: [PATCH] Fix non-deterministic unit test - there is no guarantee for how many threads Interval will use so useless to assert anything on it --- .../operators/OperationParallelMergeTest.java | 30 +++++-------------- 1 file changed, 7 insertions(+), 23 deletions(-) diff --git a/rxjava-core/src/test/java/rx/operators/OperationParallelMergeTest.java b/rxjava-core/src/test/java/rx/operators/OperationParallelMergeTest.java index 907993ef104..7872ae59d5f 100644 --- a/rxjava-core/src/test/java/rx/operators/OperationParallelMergeTest.java +++ b/rxjava-core/src/test/java/rx/operators/OperationParallelMergeTest.java @@ -58,24 +58,8 @@ public void testParallelMerge() { @Test public void testNumberOfThreads() { - final ConcurrentHashMap threads = new ConcurrentHashMap(); - Observable.merge(getStreams()) - .toBlockingObservable().forEach(new Action1() { - - @Override - public void call(String o) { - System.out.println("o: " + o + " Thread: " + Thread.currentThread()); - threads.put(Thread.currentThread().getName(), Thread.currentThread().getName()); - } - }); - - // without injecting anything, the getStream() method uses Interval which runs on a default scheduler - assertEquals(Runtime.getRuntime().availableProcessors(), threads.keySet().size()); - - // clear - threads.clear(); - - // now we parallelMerge into 3 streams and observeOn for each + final ConcurrentHashMap threads = new ConcurrentHashMap(); + // parallelMerge into 3 streams and observeOn for each // we expect 3 threads in the output OperationParallelMerge.parallelMerge(getStreams(), 3) .flatMap(new Func1, Observable>() { @@ -90,8 +74,8 @@ public Observable call(Observable o) { @Override public void call(String o) { - System.out.println("o: " + o + " Thread: " + Thread.currentThread()); - threads.put(Thread.currentThread().getName(), Thread.currentThread().getName()); + System.out.println("o: " + o + " Thread: " + Thread.currentThread().getId()); + threads.put(Thread.currentThread().getId(), Thread.currentThread().getId()); } }); @@ -100,7 +84,7 @@ public void call(String o) { @Test public void testNumberOfThreadsOnScheduledMerge() { - final ConcurrentHashMap threads = new ConcurrentHashMap(); + final ConcurrentHashMap threads = new ConcurrentHashMap(); // now we parallelMerge into 3 streams and observeOn for each // we expect 3 threads in the output @@ -109,8 +93,8 @@ public void testNumberOfThreadsOnScheduledMerge() { @Override public void call(String o) { - System.out.println("o: " + o + " Thread: " + Thread.currentThread()); - threads.put(Thread.currentThread().getName(), Thread.currentThread().getName()); + System.out.println("o: " + o + " Thread: " + Thread.currentThread().getId()); + threads.put(Thread.currentThread().getId(), Thread.currentThread().getId()); } });