Skip to content

Commit 17cb52e

Browse files
authored
Add TCK validation to Single and Completable converter, update versions (#157)
1 parent daf3ecc commit 17cb52e

File tree

7 files changed

+226
-8
lines changed

7 files changed

+226
-8
lines changed

Diff for: rxjava-reactive-streams/build.gradle

+18-3
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,26 @@ description = "Adapter between RxJava and ReactiveStreams"
33
apply plugin: 'java'
44

55
dependencies {
6-
compile 'io.reactivex:rxjava:1.1.8'
6+
compile 'io.reactivex:rxjava:1.2.1'
77
compile 'org.reactivestreams:reactive-streams:1.0.0'
88
testCompile 'org.reactivestreams:reactive-streams-tck:1.0.0'
9+
testCompile group: 'org.testng', name: 'testng', version: '6.9.10'
910
}
1011

1112
test {
12-
useTestNG()
13-
}
13+
useTestNG()
14+
testLogging {
15+
events=['passed', 'skipped', 'failed']
16+
exceptionFormat="full"
17+
18+
debug.events = ['passed', 'skipped', 'failed']
19+
debug.exceptionFormat="full"
20+
21+
info.events = ['passed', 'skipped', 'failed']
22+
info.exceptionFormat="full"
23+
24+
warn.events = ['passed', 'skipped', 'failed']
25+
warn.exceptionFormat="full"
26+
}
27+
}
28+

Diff for: rxjava-reactive-streams/src/main/java/rx/internal/reactivestreams/CompletableAsPublisher.java

+8-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,11 @@
1616

1717
package rx.internal.reactivestreams;
1818

19-
import org.reactivestreams.*;
19+
import org.reactivestreams.Publisher;
20+
import org.reactivestreams.Subscriber;
21+
import org.reactivestreams.Subscription;
2022

21-
import rx.Completable;
23+
import rx.*;
2224

2325
/**
2426
* Wraps a Completable and exposes it as a Publisher.
@@ -35,11 +37,14 @@ public CompletableAsPublisher(Completable completable) {
3537

3638
@Override
3739
public void subscribe(Subscriber<? super T> s) {
40+
if (s == null) {
41+
throw new NullPointerException();
42+
}
3843
completable.subscribe(new CompletableAsPublisherSubscriber<T>(s));
3944
}
4045

4146
static final class CompletableAsPublisherSubscriber<T>
42-
implements Completable.CompletableSubscriber, Subscription {
47+
implements CompletableSubscriber, Subscription {
4348

4449
final Subscriber<? super T> actual;
4550

Diff for: rxjava-reactive-streams/src/main/java/rx/internal/reactivestreams/PublisherAsCompletable.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818

1919
import org.reactivestreams.*;
2020

21-
import rx.Completable.CompletableSubscriber;
21+
import rx.CompletableSubscriber;
2222

2323
/**
2424
* Wraps an arbitrary Publisher and exposes it as a Completable, ignoring any onNext events.
2525
*/
26-
public final class PublisherAsCompletable implements rx.Completable.CompletableOnSubscribe {
26+
public final class PublisherAsCompletable implements rx.Completable.OnSubscribe {
2727

2828
final Publisher<?> publisher;
2929

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Copyright 2014 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package rx.reactivestreams;
18+
19+
import java.io.IOException;
20+
21+
import org.reactivestreams.Publisher;
22+
import org.reactivestreams.tck.*;
23+
import org.testng.annotations.Test;
24+
25+
import rx.*;
26+
import rx.schedulers.Schedulers;
27+
28+
@Test
29+
public class TckCompletableAsyncConversionTest extends PublisherVerification<Long> {
30+
31+
public TckCompletableAsyncConversionTest() {
32+
super(new TestEnvironment(300L));
33+
}
34+
35+
@Override
36+
public Publisher<Long> createPublisher(long elements) {
37+
return RxReactiveStreams.toPublisher(Completable.complete().observeOn(Schedulers.computation()));
38+
}
39+
40+
@Override
41+
public long maxElementsFromPublisher() {
42+
return 0L;
43+
}
44+
45+
@Override
46+
public Publisher<Long> createFailedPublisher() {
47+
return RxReactiveStreams.toPublisher(Completable.error(new IOException()).observeOn(Schedulers.computation()));
48+
}
49+
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright 2014 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package rx.reactivestreams;
18+
19+
import java.io.IOException;
20+
21+
import org.reactivestreams.Publisher;
22+
import org.reactivestreams.tck.*;
23+
import org.testng.annotations.Test;
24+
25+
import rx.*;
26+
27+
@Test
28+
public class TckCompletableConversionTest extends PublisherVerification<Long> {
29+
30+
public TckCompletableConversionTest() {
31+
super(new TestEnvironment(300L));
32+
}
33+
34+
@Override
35+
public Publisher<Long> createPublisher(long elements) {
36+
return RxReactiveStreams.toPublisher(Completable.complete());
37+
}
38+
39+
@Override
40+
public long maxElementsFromPublisher() {
41+
return 0L;
42+
}
43+
44+
@Override
45+
public Publisher<Long> createFailedPublisher() {
46+
return RxReactiveStreams.toPublisher(Completable.error(new IOException()));
47+
}
48+
49+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
/**
2+
* Copyright 2014 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package rx.reactivestreams;
18+
19+
import java.io.IOException;
20+
21+
import org.reactivestreams.Publisher;
22+
import org.reactivestreams.tck.*;
23+
import org.testng.annotations.Test;
24+
25+
import rx.*;
26+
import rx.schedulers.Schedulers;
27+
28+
@Test
29+
public class TckSingleAsyncConversionTest extends PublisherVerification<Long> {
30+
31+
public TckSingleAsyncConversionTest() {
32+
super(new TestEnvironment(300L));
33+
}
34+
35+
@Override
36+
public Publisher<Long> createPublisher(long elements) {
37+
return RxReactiveStreams.toPublisher(Single.just(1L).observeOn(Schedulers.computation()));
38+
}
39+
40+
@Override
41+
public long maxElementsFromPublisher() {
42+
return 1L;
43+
}
44+
45+
@Override
46+
public Publisher<Long> createFailedPublisher() {
47+
return RxReactiveStreams.toPublisher(Single.<Long>error(new IOException()).observeOn(Schedulers.computation()));
48+
}
49+
50+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/**
2+
* Copyright 2014 Netflix, Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package rx.reactivestreams;
18+
19+
import java.io.IOException;
20+
21+
import org.reactivestreams.Publisher;
22+
import org.reactivestreams.tck.*;
23+
import org.testng.annotations.Test;
24+
25+
import rx.*;
26+
27+
@Test
28+
public class TckSingleConversionTest extends PublisherVerification<Long> {
29+
30+
public TckSingleConversionTest() {
31+
super(new TestEnvironment(300L));
32+
}
33+
34+
@Override
35+
public Publisher<Long> createPublisher(long elements) {
36+
return RxReactiveStreams.toPublisher(Single.just(1L));
37+
}
38+
39+
@Override
40+
public long maxElementsFromPublisher() {
41+
return 1L;
42+
}
43+
44+
@Override
45+
public Publisher<Long> createFailedPublisher() {
46+
return RxReactiveStreams.toPublisher(Single.<Long>error(new IOException()));
47+
}
48+
49+
}

0 commit comments

Comments
 (0)