Skip to content

Commit d37ce86

Browse files
Down to 7 of 893 unit tests failing
1 parent a70afdf commit d37ce86

11 files changed

+315
-302
lines changed

rxjava-core/src/test/java/rx/ObservableTests.java

Lines changed: 87 additions & 86 deletions
Large diffs are not rendered by default.

rxjava-core/src/test/java/rx/RefCountTests.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import org.junit.Test;
2828
import org.mockito.MockitoAnnotations;
2929

30+
import rx.observers.TestObserver;
3031
import rx.schedulers.TestScheduler;
3132
import rx.subscriptions.Subscriptions;
3233
import rx.util.functions.Action0;
@@ -57,9 +58,9 @@ public void call() {
5758
});
5859
Observable<Integer> refCounted = observable.publish().refCount();
5960
Observer<Integer> observer = mock(Observer.class);
60-
Subscription first = refCounted.subscribe(observer);
61+
Subscription first = refCounted.subscribe(new TestObserver<Integer>(observer));
6162
assertEquals(1, subscriptionCount.get());
62-
Subscription second = refCounted.subscribe(observer);
63+
Subscription second = refCounted.subscribe(new TestObserver<Integer>(observer));
6364
assertEquals(1, subscriptionCount.get());
6465
first.unsubscribe();
6566
assertEquals(0, unsubscriptionCount.get());

rxjava-core/src/test/java/rx/ThrottleFirstTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.Test;
2323
import org.mockito.InOrder;
2424

25+
import rx.observers.TestObserver;
2526
import rx.schedulers.TestScheduler;
2627
import rx.subjects.PublishSubject;
2728

@@ -33,7 +34,7 @@ public void testThrottle() {
3334
Observer<Integer> observer = mock(Observer.class);
3435
TestScheduler s = new TestScheduler();
3536
PublishSubject<Integer> o = PublishSubject.create();
36-
o.toObservable().throttleFirst(500, TimeUnit.MILLISECONDS, s).subscribe(observer);
37+
o.toObservable().throttleFirst(500, TimeUnit.MILLISECONDS, s).subscribe(new TestObserver<Integer>(observer));
3738

3839
// send events with simulated time increments
3940
s.advanceTimeTo(0, TimeUnit.MILLISECONDS);

rxjava-core/src/test/java/rx/ThrottleLastTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.Test;
2323
import org.mockito.InOrder;
2424

25+
import rx.observers.TestObserver;
2526
import rx.schedulers.TestScheduler;
2627
import rx.subjects.PublishSubject;
2728

@@ -33,7 +34,7 @@ public void testThrottle() {
3334
Observer<Integer> observer = mock(Observer.class);
3435
TestScheduler s = new TestScheduler();
3536
PublishSubject<Integer> o = PublishSubject.create();
36-
o.toObservable().throttleLast(500, TimeUnit.MILLISECONDS, s).subscribe(observer);
37+
o.toObservable().throttleLast(500, TimeUnit.MILLISECONDS, s).subscribe(new TestObserver<Integer>(observer));
3738

3839
// send events with simulated time increments
3940
s.advanceTimeTo(0, TimeUnit.MILLISECONDS);

rxjava-core/src/test/java/rx/ThrottleWithTimeoutTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.Test;
2323
import org.mockito.InOrder;
2424

25+
import rx.observers.TestObserver;
2526
import rx.schedulers.TestScheduler;
2627
import rx.subjects.PublishSubject;
2728

@@ -33,7 +34,7 @@ public void testThrottle() {
3334
Observer<Integer> observer = mock(Observer.class);
3435
TestScheduler s = new TestScheduler();
3536
PublishSubject<Integer> o = PublishSubject.create();
36-
o.toObservable().throttleWithTimeout(500, TimeUnit.MILLISECONDS, s).subscribe(observer);
37+
o.toObservable().throttleWithTimeout(500, TimeUnit.MILLISECONDS, s).subscribe(new TestObserver<Integer>(observer));
3738

3839
// send events with simulated time increments
3940
s.advanceTimeTo(0, TimeUnit.MILLISECONDS);

rxjava-core/src/test/java/rx/TimeoutTests.java

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
import org.mockito.InOrder;
2727
import org.mockito.MockitoAnnotations;
2828

29+
import rx.observers.TestObserver;
2930
import rx.schedulers.TestScheduler;
3031
import rx.subjects.PublishSubject;
3132

@@ -49,7 +50,7 @@ public void setUp() {
4950
public void shouldNotTimeoutIfOnNextWithinTimeout() {
5051
@SuppressWarnings("unchecked")
5152
Observer<String> observer = mock(Observer.class);
52-
Subscription subscription = withTimeout.subscribe(observer);
53+
Subscription subscription = withTimeout.subscribe(new TestObserver<String>(observer));
5354
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
5455
underlyingSubject.onNext("One");
5556
verify(observer).onNext("One");
@@ -62,7 +63,7 @@ public void shouldNotTimeoutIfOnNextWithinTimeout() {
6263
public void shouldNotTimeoutIfSecondOnNextWithinTimeout() {
6364
@SuppressWarnings("unchecked")
6465
Observer<String> observer = mock(Observer.class);
65-
Subscription subscription = withTimeout.subscribe(observer);
66+
Subscription subscription = withTimeout.subscribe(new TestObserver<String>(observer));
6667
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
6768
underlyingSubject.onNext("One");
6869
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
@@ -77,7 +78,7 @@ public void shouldNotTimeoutIfSecondOnNextWithinTimeout() {
7778
public void shouldTimeoutIfOnNextNotWithinTimeout() {
7879
@SuppressWarnings("unchecked")
7980
Observer<String> observer = mock(Observer.class);
80-
Subscription subscription = withTimeout.subscribe(observer);
81+
Subscription subscription = withTimeout.subscribe(new TestObserver<String>(observer));
8182
testScheduler.advanceTimeBy(TIMEOUT + 1, TimeUnit.SECONDS);
8283
verify(observer).onError(any(TimeoutException.class));
8384
subscription.unsubscribe();
@@ -87,7 +88,7 @@ public void shouldTimeoutIfOnNextNotWithinTimeout() {
8788
public void shouldTimeoutIfSecondOnNextNotWithinTimeout() {
8889
@SuppressWarnings("unchecked")
8990
Observer<String> observer = mock(Observer.class);
90-
Subscription subscription = withTimeout.subscribe(observer);
91+
Subscription subscription = withTimeout.subscribe(new TestObserver<String>(observer));
9192
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
9293
underlyingSubject.onNext("One");
9394
verify(observer).onNext("One");
@@ -100,7 +101,7 @@ public void shouldTimeoutIfSecondOnNextNotWithinTimeout() {
100101
public void shouldCompleteIfUnderlyingComletes() {
101102
@SuppressWarnings("unchecked")
102103
Observer<String> observer = mock(Observer.class);
103-
Subscription subscription = withTimeout.subscribe(observer);
104+
Subscription subscription = withTimeout.subscribe(new TestObserver<String>(observer));
104105
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
105106
underlyingSubject.onCompleted();
106107
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
@@ -113,7 +114,7 @@ public void shouldCompleteIfUnderlyingComletes() {
113114
public void shouldErrorIfUnderlyingErrors() {
114115
@SuppressWarnings("unchecked")
115116
Observer<String> observer = mock(Observer.class);
116-
Subscription subscription = withTimeout.subscribe(observer);
117+
Subscription subscription = withTimeout.subscribe(new TestObserver<String>(observer));
117118
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
118119
underlyingSubject.onError(new UnsupportedOperationException());
119120
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
@@ -128,7 +129,7 @@ public void shouldSwitchToOtherIfOnNextNotWithinTimeout() {
128129

129130
@SuppressWarnings("unchecked")
130131
Observer<String> observer = mock(Observer.class);
131-
Subscription subscription = source.subscribe(observer);
132+
Subscription subscription = source.subscribe(new TestObserver<String>(observer));
132133

133134
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
134135
underlyingSubject.onNext("One");
@@ -151,7 +152,7 @@ public void shouldSwitchToOtherIfOnErrorNotWithinTimeout() {
151152

152153
@SuppressWarnings("unchecked")
153154
Observer<String> observer = mock(Observer.class);
154-
Subscription subscription = source.subscribe(observer);
155+
Subscription subscription = source.subscribe(new TestObserver<String>(observer));
155156

156157
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
157158
underlyingSubject.onNext("One");
@@ -174,7 +175,7 @@ public void shouldSwitchToOtherIfOnCompletedNotWithinTimeout() {
174175

175176
@SuppressWarnings("unchecked")
176177
Observer<String> observer = mock(Observer.class);
177-
Subscription subscription = source.subscribe(observer);
178+
Subscription subscription = source.subscribe(new TestObserver<String>(observer));
178179

179180
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
180181
underlyingSubject.onNext("One");
@@ -197,7 +198,7 @@ public void shouldSwitchToOtherAndCanBeUnsubscribedIfOnNextNotWithinTimeout() {
197198

198199
@SuppressWarnings("unchecked")
199200
Observer<String> observer = mock(Observer.class);
200-
Subscription subscription = source.subscribe(observer);
201+
Subscription subscription = source.subscribe(new TestObserver<String>(observer));
201202

202203
testScheduler.advanceTimeBy(2, TimeUnit.SECONDS);
203204
underlyingSubject.onNext("One");

rxjava-core/src/test/java/rx/operators/OperationJoinsTest.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,8 @@ public void whenComplicated() {
370370
xs.toObservable().and(zs.toObservable()).then(mul2),
371371
ys.toObservable().and(zs.toObservable()).then(sub2)
372372
);
373-
m.subscribe(new TestObserver<Object>(observer));
373+
TestObserver<Object> to = new TestObserver<Object>(observer);
374+
m.subscribe(to);
374375

375376
xs.onNext(1); // t == 210
376377

@@ -392,6 +393,8 @@ public void whenComplicated() {
392393

393394
zs.onCompleted(); // t == 300
394395

396+
System.out.println("Events: " + to.getOnNextEvents());
397+
395398
InOrder inOrder = inOrder(observer);
396399
inOrder.verify(observer, times(1)).onNext(1 * 7);
397400
inOrder.verify(observer, times(1)).onNext(2 * 8);

rxjava-core/src/test/java/rx/subjects/AsyncSubjectTest.java

Lines changed: 45 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828

2929
import rx.Observer;
3030
import rx.Subscription;
31+
import rx.observers.TestObserver;
3132
import rx.util.functions.Action1;
3233

3334
public class AsyncSubjectTest {
@@ -39,77 +40,77 @@ public void testNeverCompleted() {
3940
AsyncSubject<String> subject = AsyncSubject.create();
4041

4142
@SuppressWarnings("unchecked")
42-
Observer<String> aObserver = mock(Observer.class);
43-
subject.toObservable().subscribe(aObserver);
43+
Observer<String> observer = mock(Observer.class);
44+
subject.toObservable().subscribe(new TestObserver<String>(observer));
4445

4546
subject.onNext("one");
4647
subject.onNext("two");
4748
subject.onNext("three");
4849

49-
verify(aObserver, Mockito.never()).onNext(anyString());
50-
verify(aObserver, Mockito.never()).onError(testException);
51-
verify(aObserver, Mockito.never()).onCompleted();
50+
verify(observer, Mockito.never()).onNext(anyString());
51+
verify(observer, Mockito.never()).onError(testException);
52+
verify(observer, Mockito.never()).onCompleted();
5253
}
5354

5455
@Test
5556
public void testCompleted() {
5657
AsyncSubject<String> subject = AsyncSubject.create();
5758

5859
@SuppressWarnings("unchecked")
59-
Observer<String> aObserver = mock(Observer.class);
60-
subject.toObservable().subscribe(aObserver);
60+
Observer<String> observer = mock(Observer.class);
61+
subject.toObservable().subscribe(new TestObserver<String>(observer));
6162

6263
subject.onNext("one");
6364
subject.onNext("two");
6465
subject.onNext("three");
6566
subject.onCompleted();
6667

67-
verify(aObserver, times(1)).onNext("three");
68-
verify(aObserver, Mockito.never()).onError(any(Throwable.class));
69-
verify(aObserver, times(1)).onCompleted();
68+
verify(observer, times(1)).onNext("three");
69+
verify(observer, Mockito.never()).onError(any(Throwable.class));
70+
verify(observer, times(1)).onCompleted();
7071
}
7172

7273
@Test
7374
public void testNull() {
7475
AsyncSubject<String> subject = AsyncSubject.create();
7576

7677
@SuppressWarnings("unchecked")
77-
Observer<String> aObserver = mock(Observer.class);
78-
subject.toObservable().subscribe(aObserver);
78+
Observer<String> observer = mock(Observer.class);
79+
subject.toObservable().subscribe(new TestObserver<String>(observer));
7980

8081
subject.onNext(null);
8182
subject.onCompleted();
8283

83-
verify(aObserver, times(1)).onNext(null);
84-
verify(aObserver, Mockito.never()).onError(any(Throwable.class));
85-
verify(aObserver, times(1)).onCompleted();
84+
verify(observer, times(1)).onNext(null);
85+
verify(observer, Mockito.never()).onError(any(Throwable.class));
86+
verify(observer, times(1)).onCompleted();
8687
}
8788

8889
@Test
8990
public void testSubscribeAfterCompleted() {
9091
AsyncSubject<String> subject = AsyncSubject.create();
9192

9293
@SuppressWarnings("unchecked")
93-
Observer<String> aObserver = mock(Observer.class);
94+
Observer<String> observer = mock(Observer.class);
9495

9596
subject.onNext("one");
9697
subject.onNext("two");
9798
subject.onNext("three");
9899
subject.onCompleted();
99100

100-
subject.toObservable().subscribe(aObserver);
101+
subject.toObservable().subscribe(new TestObserver<String>(observer));
101102

102-
verify(aObserver, times(1)).onNext("three");
103-
verify(aObserver, Mockito.never()).onError(any(Throwable.class));
104-
verify(aObserver, times(1)).onCompleted();
103+
verify(observer, times(1)).onNext("three");
104+
verify(observer, Mockito.never()).onError(any(Throwable.class));
105+
verify(observer, times(1)).onCompleted();
105106
}
106107

107108
@Test
108109
public void testSubscribeAfterError() {
109110
AsyncSubject<String> subject = AsyncSubject.create();
110111

111112
@SuppressWarnings("unchecked")
112-
Observer<String> aObserver = mock(Observer.class);
113+
Observer<String> observer = mock(Observer.class);
113114

114115
subject.onNext("one");
115116
subject.onNext("two");
@@ -118,20 +119,20 @@ public void testSubscribeAfterError() {
118119
RuntimeException re = new RuntimeException("failed");
119120
subject.onError(re);
120121

121-
subject.toObservable().subscribe(aObserver);
122+
subject.toObservable().subscribe(new TestObserver<String>(observer));
122123

123-
verify(aObserver, times(1)).onError(re);
124-
verify(aObserver, Mockito.never()).onNext(any(String.class));
125-
verify(aObserver, Mockito.never()).onCompleted();
124+
verify(observer, times(1)).onError(re);
125+
verify(observer, Mockito.never()).onNext(any(String.class));
126+
verify(observer, Mockito.never()).onCompleted();
126127
}
127128

128129
@Test
129130
public void testError() {
130131
AsyncSubject<String> subject = AsyncSubject.create();
131132

132133
@SuppressWarnings("unchecked")
133-
Observer<String> aObserver = mock(Observer.class);
134-
subject.toObservable().subscribe(aObserver);
134+
Observer<String> observer = mock(Observer.class);
135+
subject.toObservable().subscribe(new TestObserver<String>(observer));
135136

136137
subject.onNext("one");
137138
subject.onNext("two");
@@ -141,50 +142,50 @@ public void testError() {
141142
subject.onError(new Throwable());
142143
subject.onCompleted();
143144

144-
verify(aObserver, Mockito.never()).onNext(anyString());
145-
verify(aObserver, times(1)).onError(testException);
146-
verify(aObserver, Mockito.never()).onCompleted();
145+
verify(observer, Mockito.never()).onNext(anyString());
146+
verify(observer, times(1)).onError(testException);
147+
verify(observer, Mockito.never()).onCompleted();
147148
}
148149

149150
@Test
150151
public void testUnsubscribeBeforeCompleted() {
151152
AsyncSubject<String> subject = AsyncSubject.create();
152153

153154
@SuppressWarnings("unchecked")
154-
Observer<String> aObserver = mock(Observer.class);
155-
Subscription subscription = subject.toObservable().subscribe(aObserver);
155+
Observer<String> observer = mock(Observer.class);
156+
Subscription subscription = subject.toObservable().subscribe(new TestObserver<String>(observer));
156157

157158
subject.onNext("one");
158159
subject.onNext("two");
159160

160161
subscription.unsubscribe();
161162

162-
verify(aObserver, Mockito.never()).onNext(anyString());
163-
verify(aObserver, Mockito.never()).onError(any(Throwable.class));
164-
verify(aObserver, Mockito.never()).onCompleted();
163+
verify(observer, Mockito.never()).onNext(anyString());
164+
verify(observer, Mockito.never()).onError(any(Throwable.class));
165+
verify(observer, Mockito.never()).onCompleted();
165166

166167
subject.onNext("three");
167168
subject.onCompleted();
168169

169-
verify(aObserver, Mockito.never()).onNext(anyString());
170-
verify(aObserver, Mockito.never()).onError(any(Throwable.class));
171-
verify(aObserver, Mockito.never()).onCompleted();
170+
verify(observer, Mockito.never()).onNext(anyString());
171+
verify(observer, Mockito.never()).onError(any(Throwable.class));
172+
verify(observer, Mockito.never()).onCompleted();
172173
}
173174

174175
@Test
175176
public void testEmptySubjectCompleted() {
176177
AsyncSubject<String> subject = AsyncSubject.create();
177178

178179
@SuppressWarnings("unchecked")
179-
Observer<String> aObserver = mock(Observer.class);
180-
subject.toObservable().subscribe(aObserver);
180+
Observer<String> observer = mock(Observer.class);
181+
subject.toObservable().subscribe(new TestObserver<String>(observer));
181182

182183
subject.onCompleted();
183184

184-
InOrder inOrder = inOrder(aObserver);
185-
inOrder.verify(aObserver, never()).onNext(null);
186-
inOrder.verify(aObserver, never()).onNext(any(String.class));
187-
inOrder.verify(aObserver, times(1)).onCompleted();
185+
InOrder inOrder = inOrder(observer);
186+
inOrder.verify(observer, never()).onNext(null);
187+
inOrder.verify(observer, never()).onNext(any(String.class));
188+
inOrder.verify(observer, times(1)).onCompleted();
188189
inOrder.verifyNoMoreInteractions();
189190
}
190191

0 commit comments

Comments
 (0)