Skip to content

Commit 5d513f2

Browse files
committed
warnings cleanup in test source
1 parent 3a7dca9 commit 5d513f2

13 files changed

+47
-41
lines changed

src/test/java/rx/CovarianceTest.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public String call(Movie m) {
106106
assertEquals(6, ts.getOnNextEvents().size());
107107
}
108108

109+
@SuppressWarnings("unused")
109110
@Test
110111
public void testCovarianceOfCompose() {
111112
Observable<HorrorMovie> movie = Observable.just(new HorrorMovie());
@@ -119,6 +120,7 @@ public Observable<Movie> call(Observable<Movie> t1) {
119120
});
120121
}
121122

123+
@SuppressWarnings("unused")
122124
@Test
123125
public void testCovarianceOfCompose2() {
124126
Observable<Movie> movie = Observable.<Movie> just(new HorrorMovie());
@@ -130,6 +132,7 @@ public Observable<HorrorMovie> call(Observable<Movie> t1) {
130132
});
131133
}
132134

135+
@SuppressWarnings("unused")
133136
@Test
134137
public void testCovarianceOfCompose3() {
135138
Observable<Movie> movie = Observable.<Movie>just(new HorrorMovie());
@@ -147,6 +150,7 @@ public HorrorMovie call(HorrorMovie horrorMovie) {
147150
});
148151
}
149152

153+
@SuppressWarnings("unused")
150154
@Test
151155
public void testCovarianceOfCompose4() {
152156
Observable<HorrorMovie> movie = Observable.just(new HorrorMovie());
@@ -201,7 +205,7 @@ public Observable<Movie> call(List<List<Movie>> listOfLists) {
201205
oldList.removeAll(newList);
202206

203207
// for all left in the oldList we'll create DROP events
204-
for (Movie old : oldList) {
208+
for (@SuppressWarnings("unused") Movie old : oldList) {
205209
delta.add(new Movie());
206210
}
207211

src/test/java/rx/ObservableTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1054,9 +1054,9 @@ public Observable<String> call(String s) {
10541054

10551055
@Test
10561056
public void testTakeWhileToList() {
1057-
int[] nums = {1, 2, 3};
1057+
final int expectedCount = 3;
10581058
final AtomicInteger count = new AtomicInteger();
1059-
for(final int n: nums) {
1059+
for (int i = 0;i < expectedCount; i++) {
10601060
Observable
10611061
.just(Boolean.TRUE, Boolean.FALSE)
10621062
.takeWhile(new Func1<Boolean, Boolean>() {
@@ -1074,7 +1074,7 @@ public void call(List<Boolean> booleans) {
10741074
})
10751075
.subscribe();
10761076
}
1077-
assertEquals(nums.length, count.get());
1077+
assertEquals(expectedCount, count.get());
10781078
}
10791079

10801080
@Test

src/test/java/rx/internal/operators/OnSubscribeToObservableFutureTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void testCancelledBeforeSubscribe() throws Exception {
8888

8989
TestSubscriber<Object> testSubscriber = new TestSubscriber<Object>(o);
9090
testSubscriber.unsubscribe();
91-
Subscription sub = Observable.from(future).subscribe(testSubscriber);
91+
Observable.from(future).subscribe(testSubscriber);
9292
assertEquals(0, testSubscriber.getOnErrorEvents().size());
9393
assertEquals(0, testSubscriber.getOnCompletedEvents().size());
9494
}

src/test/java/rx/internal/operators/OperatorConcatTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,11 +485,11 @@ public boolean isUnsubscribed() {
485485
private final T seed;
486486
private final int size;
487487

488-
public TestObservable(T... values) {
488+
public TestObservable(@SuppressWarnings("unchecked") T... values) {
489489
this(null, null, values);
490490
}
491491

492-
public TestObservable(CountDownLatch once, CountDownLatch okToContinue, T... values) {
492+
public TestObservable(CountDownLatch once, CountDownLatch okToContinue, @SuppressWarnings("unchecked") T... values) {
493493
this.values = Arrays.asList(values);
494494
this.size = this.values.size();
495495
this.once = once;

src/test/java/rx/internal/operators/OperatorDoOnEachTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,9 @@ public void call(String s) {
123123
@Test
124124
public void testIssue1451Case1() {
125125
// https://github.com/Netflix/RxJava/issues/1451
126-
int[] nums = { 1, 2, 3 };
126+
final int expectedCount = 3;
127127
final AtomicInteger count = new AtomicInteger();
128-
for (final int n : nums) {
128+
for (int i=0; i < expectedCount; i++) {
129129
Observable
130130
.just(Boolean.TRUE, Boolean.FALSE)
131131
.takeWhile(new Func1<Boolean, Boolean>() {
@@ -143,15 +143,15 @@ public void call(List<Boolean> booleans) {
143143
})
144144
.subscribe();
145145
}
146-
assertEquals(nums.length, count.get());
146+
assertEquals(expectedCount, count.get());
147147
}
148148

149149
@Test
150150
public void testIssue1451Case2() {
151151
// https://github.com/Netflix/RxJava/issues/1451
152-
int[] nums = { 1, 2, 3 };
152+
final int expectedCount = 3;
153153
final AtomicInteger count = new AtomicInteger();
154-
for (final int n : nums) {
154+
for (int i=0; i < expectedCount; i++) {
155155
Observable
156156
.just(Boolean.TRUE, Boolean.FALSE, Boolean.FALSE)
157157
.takeWhile(new Func1<Boolean, Boolean>() {
@@ -169,7 +169,7 @@ public void call(List<Boolean> booleans) {
169169
})
170170
.subscribe();
171171
}
172-
assertEquals(nums.length, count.get());
172+
assertEquals(expectedCount, count.get());
173173
}
174174

175175
@Test

src/test/java/rx/internal/operators/OperatorMulticastTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import static org.mockito.Mockito.times;
2222
import static org.mockito.Mockito.verify;
2323

24-
import org.junit.Assert;
2524
import org.junit.Test;
2625

2726
import rx.Observer;

src/test/java/rx/internal/operators/OperatorOnErrorResumeNextViaObservableTest.java

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@
2121
import static org.mockito.Mockito.times;
2222
import static org.mockito.Mockito.verify;
2323

24-
import java.util.concurrent.TimeUnit;
25-
2624
import org.junit.Test;
2725
import org.mockito.Mockito;
2826

@@ -109,7 +107,6 @@ public String call(String s) {
109107

110108
@Test
111109
public void testResumeNextWithFailedOnSubscribe() {
112-
Subscription s = mock(Subscription.class);
113110
Observable<String> testObservable = Observable.create(new OnSubscribe<String>() {
114111

115112
@Override
@@ -132,7 +129,6 @@ public void call(Subscriber<? super String> t1) {
132129

133130
@Test
134131
public void testResumeNextWithFailedOnSubscribeAsync() {
135-
Subscription s = mock(Subscription.class);
136132
Observable<String> testObservable = Observable.create(new OnSubscribe<String>() {
137133

138134
@Override

src/test/java/rx/internal/operators/OperatorPublishTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ public void testConnectWithNoSubscriber() {
251251
co.connect();
252252
// Emit 0
253253
scheduler.advanceTimeBy(15, TimeUnit.MILLISECONDS);
254-
TestSubscriber subscriber = new TestSubscriber<Long>();
254+
TestSubscriber<Long> subscriber = new TestSubscriber<Long>();
255255
co.subscribe(subscriber);
256256
// Emit 1 and 2
257257
scheduler.advanceTimeBy(50, TimeUnit.MILLISECONDS);

src/test/java/rx/internal/operators/OperatorReplayTest.java

Lines changed: 27 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,24 @@
1515
*/
1616
package rx.internal.operators;
1717

18+
import static org.junit.Assert.assertEquals;
1819
import static org.mockito.Matchers.any;
20+
import static org.mockito.Matchers.notNull;
21+
import static org.mockito.Mockito.inOrder;
22+
import static org.mockito.Mockito.mock;
23+
import static org.mockito.Mockito.never;
24+
import static org.mockito.Mockito.spy;
25+
import static org.mockito.Mockito.times;
26+
import static org.mockito.Mockito.verify;
27+
import static org.mockito.Mockito.verifyNoMoreInteractions;
28+
import static org.mockito.Mockito.when;
1929

2030
import java.util.concurrent.TimeUnit;
2131
import java.util.concurrent.atomic.AtomicInteger;
22-
import static org.junit.Assert.assertEquals;
23-
import static org.mockito.Matchers.notNull;
24-
import static org.mockito.Mockito.*;
2532

2633
import org.junit.Test;
2734
import org.mockito.InOrder;
2835

29-
3036
import rx.Observable;
3137
import rx.Observer;
3238
import rx.Scheduler;
@@ -523,14 +529,15 @@ public void call() {
523529
/**
524530
* test the basic expectation of OperatorMulticast via replay
525531
*/
532+
@SuppressWarnings("unchecked")
526533
@Test
527534
public void testIssue2191_UnsubscribeSource() {
528535
// setup mocks
529-
Action1 sourceNext = mock(Action1.class);
536+
Action1<Integer> sourceNext = mock(Action1.class);
530537
Action0 sourceCompleted = mock(Action0.class);
531538
Action0 sourceUnsubscribed = mock(Action0.class);
532-
Observer spiedSubscriberBeforeConnect = mock(Observer.class);
533-
Observer spiedSubscriberAfterConnect = mock(Observer.class);
539+
Observer<Integer> spiedSubscriberBeforeConnect = mock(Observer.class);
540+
Observer<Integer> spiedSubscriberAfterConnect = mock(Observer.class);
534541

535542
// Observable under test
536543
Observable<Integer> source = Observable.just(1,2);
@@ -570,17 +577,18 @@ public void testIssue2191_UnsubscribeSource() {
570577
*
571578
* @throws Exception
572579
*/
580+
@SuppressWarnings("unchecked")
573581
@Test
574582
public void testIssue2191_SchedulerUnsubscribe() throws Exception {
575583
// setup mocks
576-
Action1 sourceNext = mock(Action1.class);
584+
Action1<Integer> sourceNext = mock(Action1.class);
577585
Action0 sourceCompleted = mock(Action0.class);
578586
Action0 sourceUnsubscribed = mock(Action0.class);
579587
final Scheduler mockScheduler = mock(Scheduler.class);
580588
final Subscription mockSubscription = mock(Subscription.class);
581589
Worker spiedWorker = workerSpy(mockSubscription);
582-
Observer mockObserverBeforeConnect = mock(Observer.class);
583-
Observer mockObserverAfterConnect = mock(Observer.class);
590+
Observer<Integer> mockObserverBeforeConnect = mock(Observer.class);
591+
Observer<Integer> mockObserverAfterConnect = mock(Observer.class);
584592

585593
when(mockScheduler.createWorker()).thenReturn(spiedWorker);
586594

@@ -626,18 +634,19 @@ public void testIssue2191_SchedulerUnsubscribe() throws Exception {
626634
*
627635
* @throws Exception
628636
*/
637+
@SuppressWarnings("unchecked")
629638
@Test
630639
public void testIssue2191_SchedulerUnsubscribeOnError() throws Exception {
631640
// setup mocks
632-
Action1 sourceNext = mock(Action1.class);
641+
Action1<Integer> sourceNext = mock(Action1.class);
633642
Action0 sourceCompleted = mock(Action0.class);
634-
Action1 sourceError = mock(Action1.class);
643+
Action1<Throwable> sourceError = mock(Action1.class);
635644
Action0 sourceUnsubscribed = mock(Action0.class);
636645
final Scheduler mockScheduler = mock(Scheduler.class);
637646
final Subscription mockSubscription = mock(Subscription.class);
638647
Worker spiedWorker = workerSpy(mockSubscription);
639-
Observer mockObserverBeforeConnect = mock(Observer.class);
640-
Observer mockObserverAfterConnect = mock(Observer.class);
648+
Observer<Integer> mockObserverBeforeConnect = mock(Observer.class);
649+
Observer<Integer> mockObserverAfterConnect = mock(Observer.class);
641650

642651
when(mockScheduler.createWorker()).thenReturn(spiedWorker);
643652

@@ -682,14 +691,14 @@ public void testIssue2191_SchedulerUnsubscribeOnError() throws Exception {
682691
verifyNoMoreInteractions(mockObserverAfterConnect);
683692
}
684693

685-
private static void verifyObserverMock(Observer mock, int numSubscriptions, int numItemsExpected) {
686-
verify(mock, times(numItemsExpected)).onNext(notNull());
694+
private static void verifyObserverMock(Observer<Integer> mock, int numSubscriptions, int numItemsExpected) {
695+
verify(mock, times(numItemsExpected)).onNext((Integer) notNull());
687696
verify(mock, times(numSubscriptions)).onCompleted();
688697
verifyNoMoreInteractions(mock);
689698
}
690699

691-
private static void verifyObserver(Observer mock, int numSubscriptions, int numItemsExpected, Throwable error) {
692-
verify(mock, times(numItemsExpected)).onNext(notNull());
700+
private static void verifyObserver(Observer<Integer> mock, int numSubscriptions, int numItemsExpected, Throwable error) {
701+
verify(mock, times(numItemsExpected)).onNext((Integer) notNull());
693702
verify(mock, times(numSubscriptions)).onError(error);
694703
verifyNoMoreInteractions(mock);
695704
}

src/test/java/rx/internal/operators/OperatorSampleTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import rx.functions.Action0;
3434
import rx.schedulers.TestScheduler;
3535
import rx.subjects.PublishSubject;
36-
import rx.subscriptions.Subscriptions;
3736

3837
public class OperatorSampleTest {
3938
private TestScheduler scheduler;

src/test/java/rx/internal/operators/OperatorScanTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,7 +318,7 @@ public void testScanShouldNotRequestZero() {
318318
final AtomicReference<Producer> producer = new AtomicReference<Producer>();
319319
Observable<Integer> o = Observable.create(new Observable.OnSubscribe<Integer>() {
320320
@Override
321-
public void call(final Subscriber subscriber) {
321+
public void call(final Subscriber<? super Integer> subscriber) {
322322
Producer p = spy(new Producer() {
323323

324324
private AtomicBoolean requested = new AtomicBoolean(false);

src/test/java/rx/internal/operators/OperatorSkipWhileTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import rx.Observable;
3030
import rx.Observer;
3131
import rx.functions.Func1;
32-
import rx.functions.Func2;
3332

3433
public class OperatorSkipWhileTest {
3534

src/test/java/rx/internal/util/IndexedRingBufferTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ public void longRunningAddRemoveAddDoesntLeakMemory() {
242242
list.forEach(newCounterAction(c));
243243
assertEquals(0, c.get());
244244
// System.out.println("Index is: " + list.index.get() + " when it should be no bigger than " + list.SIZE);
245-
assertTrue(list.index.get() < list.SIZE);
245+
assertTrue(list.index.get() < IndexedRingBuffer.SIZE);
246246
// it should actually be 1 since we only did add/remove sequentially
247247
assertEquals(1, list.index.get());
248248
}

0 commit comments

Comments
 (0)