|
19 | 19 |
|
20 | 20 | import java.util.List;
|
21 | 21 | import java.util.Vector;
|
| 22 | +import java.util.concurrent.ExecutionException; |
22 | 23 |
|
23 | 24 | import org.junit.Test;
|
24 | 25 |
|
@@ -139,25 +140,13 @@ public void testMaterialize2() {
|
139 | 140 | }
|
140 | 141 |
|
141 | 142 | @Test
|
142 |
| - public void testMultipleSubscribes() { |
143 |
| - final TestAsyncErrorObservable o1 = new TestAsyncErrorObservable("one", "two", null, "three"); |
144 |
| - |
145 |
| - Observable<Notification<String>> m = Observable.create(materialize(o1)); |
146 |
| - |
147 |
| - TestObserver Observer1 = new TestObserver(); |
148 |
| - m.subscribe(Observer1); |
149 |
| - |
150 |
| - TestObserver Observer2 = new TestObserver(); |
151 |
| - m.subscribe(Observer2); |
| 143 | + public void testMultipleSubscribes() throws InterruptedException, ExecutionException { |
| 144 | + final TestAsyncErrorObservable o = new TestAsyncErrorObservable("one", "two", null, "three"); |
152 | 145 |
|
153 |
| - try { |
154 |
| - o1.t.join(); |
155 |
| - } catch (InterruptedException e) { |
156 |
| - throw new RuntimeException(e); |
157 |
| - } |
| 146 | + Observable<Notification<String>> m = Observable.create(materialize(o)); |
158 | 147 |
|
159 |
| - assertEquals(3, Observer1.notifications.size()); |
160 |
| - assertEquals(3, Observer2.notifications.size()); |
| 148 | + assertEquals(3, m.toList().toBlockingObservable().toFuture().get().size()); |
| 149 | + assertEquals(3, m.toList().toBlockingObservable().toFuture().get().size()); |
161 | 150 | }
|
162 | 151 |
|
163 | 152 | }
|
@@ -193,7 +182,7 @@ private static class TestAsyncErrorObservable extends Observable<String> {
|
193 | 182 | valuesToReturn = values;
|
194 | 183 | }
|
195 | 184 |
|
196 |
| - Thread t; |
| 185 | + volatile Thread t; |
197 | 186 |
|
198 | 187 | @Override
|
199 | 188 | public Subscription subscribe(final Observer<String> observer) {
|
|
0 commit comments