Skip to content

Commit 74a784c

Browse files
committed
Switch to RxJava 3.x
1 parent 5a12201 commit 74a784c

5 files changed

Lines changed: 54 additions & 38 deletions

File tree

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# RxJavaInterop
22

33

4-
<a href='https://travis-ci.org/akarnokd/RxJavaInterop/builds'><img src='https://travis-ci.org/akarnokd/RxJavaInterop.svg?branch=master'></a>
5-
[![codecov.io](http://codecov.io/github/akarnokd/RxJavaInterop/coverage.svg?branch=master)](http://codecov.io/github/akarnokd/RxJavaInterop?branch=master)
6-
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.akarnokd/rxjava2-interop/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.akarnokd/rxjava2-interop)
4+
<a href='https://travis-ci.org/akarnokd/RxJavaInterop/builds'><img src='https://travis-ci.org/akarnokd/RxJavaInterop.svg?branch=3.x'></a>
5+
[![codecov.io](http://codecov.io/github/akarnokd/RxJavaInterop/coverage.svg?branch=3.x)](http://codecov.io/github/akarnokd/RxJavaInterop?branch=3.x)
6+
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.akarnokd/rxjava3-interop/badge.svg)](https://maven-badges.herokuapp.com/maven-central/com.github.akarnokd/rxjava3-interop)
77

88
RxJava 1.x: [![RxJava 1.x](https://maven-badges.herokuapp.com/maven-central/io.reactivex/rxjava/badge.svg)](https://maven-badges.herokuapp.com/maven-central/maven-central/io.reactivex/rxjava)
9-
RxJava 2.x: [![RxJava 2.x](https://maven-badges.herokuapp.com/maven-central/io.reactivex.rxjava2/rxjava/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.reactivex.rxjava2/rxjava)
9+
RxJava 2.x: [![RxJava 3.x](https://maven-badges.herokuapp.com/maven-central/io.reactivex.rxjava3/rxjava/badge.svg)](https://maven-badges.herokuapp.com/maven-central/io.reactivex.rxjava3/rxjava)
1010

11-
Library to convert between RxJava 1.x and 2.x reactive types.
11+
Library to convert between RxJava 1.x and 3.x reactive types.
1212

1313
# Releases
1414

@@ -17,7 +17,7 @@ Library to convert between RxJava 1.x and 2.x reactive types.
1717

1818
```
1919
dependencies {
20-
compile "com.github.akarnokd:rxjava2-interop:0.13.7"
20+
compile "com.github.akarnokd:rxjava3-interop:3.0.0-RC0"
2121
}
2222
```
2323

build.gradle

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ sourceCompatibility = '1.6'
2525
targetCompatibility = '1.6'
2626

2727
group = "com.github.akarnokd"
28-
ext.githubProjectName = 'rxjava2-interop'
28+
ext.githubProjectName = 'rxjava3-interop'
2929

3030
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
3131

@@ -50,7 +50,7 @@ dependencies {
5050

5151
compile "org.reactivestreams:reactive-streams:1.0.2"
5252
compile "io.reactivex:rxjava:1.3.8"
53-
compile "io.reactivex.rxjava2:rxjava:2.2.10"
53+
compile "io.reactivex.rxjava3:rxjava:3.0.0-RC0"
5454

5555
testCompile group: 'junit', name: 'junit', version: '4.12'
5656
testCompile 'org.mockito:mockito-core:2.28.2'
@@ -86,7 +86,7 @@ artifacts {
8686

8787
jar {
8888
manifest {
89-
name = 'rxjava2-interop'
89+
name = 'rxjava3-interop'
9090
instruction 'Bundle-Vendor', 'akarnokd'
9191
instruction 'Bundle-DocURL', 'https://github.com/akarnokd/RxJavaInterop'
9292
instruction 'Import-Package', '!org.junit,!junit.framework,!org.mockito.*,*'
@@ -124,9 +124,11 @@ plugins.withType(EclipsePlugin) {
124124
javadoc {
125125
failOnError = false
126126

127-
options.links("http://docs.oracle.com/javase/7/docs/api/")
128-
options.links("http://reactivex.io/RxJava/1.x/javadoc")
129-
options.links("http://reactivex.io/RxJava/2.x/javadoc")
127+
options.links(
128+
"http://docs.oracle.com/javase/7/docs/api/",
129+
"http://reactivex.io/RxJava/1.x/javadoc",
130+
"http://reactivex.io/RxJava/3.x/javadoc"
131+
)
130132
}
131133

132134
test {

gradle.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version=0.13.7
1+
version=3.0.0-RC0

settings.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
rootProject.name = 'rxjava2-interop'
1+
rootProject.name = 'rxjava3-interop'

src/test/java/hu/akarnokd/rxjava/interop/RxJavaInteropTest.java

Lines changed: 38 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,7 @@
1818

1919
import static hu.akarnokd.rxjava.interop.RxJavaInterop.*;
2020
import static org.junit.Assert.*;
21-
import static org.mockito.Mockito.mock;
22-
import static org.mockito.Mockito.verify;
23-
import static org.mockito.Mockito.verifyZeroInteractions;
21+
import static org.mockito.Mockito.*;
2422

2523
import java.io.IOException;
2624
import java.lang.reflect.*;
@@ -30,9 +28,13 @@
3028
import org.reactivestreams.Subscription;
3129

3230
import io.reactivex.*;
31+
import io.reactivex.Completable;
32+
import io.reactivex.Single;
3333
import io.reactivex.disposables.*;
3434
import io.reactivex.functions.Function;
35+
import io.reactivex.functions.Predicate;
3536
import io.reactivex.internal.subscriptions.BooleanSubscription;
37+
import io.reactivex.observers.BaseTestConsumer;
3638
import rx.Observable;
3739
import rx.Observable.*;
3840
import rx.Subscriber;
@@ -159,11 +161,23 @@ public void o1f2Empty() {
159161
.assertResult();
160162
}
161163

164+
@SuppressWarnings("unchecked")
165+
static void assertFailureAndMessage(BaseTestConsumer<?, ?> testConsumer, Class<? extends Throwable> errorClass, final String message) {
166+
testConsumer
167+
.assertFailure(errorClass)
168+
.assertError(new Predicate<Throwable>() {
169+
@Override
170+
public boolean test(Throwable error) throws Throwable {
171+
return error.getMessage().equals(message);
172+
}
173+
});
174+
}
175+
162176
@Test
163177
public void o1f2Error() {
164-
toV2Flowable(rx.Observable.error(new RuntimeException("Forced failure")))
165-
.test()
166-
.assertFailureAndMessage(RuntimeException.class, "Forced failure");
178+
assertFailureAndMessage(toV2Flowable(rx.Observable.error(new RuntimeException("Forced failure")))
179+
.test(),
180+
RuntimeException.class, "Forced failure");
167181
}
168182

169183
@Test
@@ -216,9 +230,9 @@ public void o1o2Empty() {
216230

217231
@Test
218232
public void o1o2Error() {
219-
toV2Observable(rx.Observable.error(new RuntimeException("Forced failure")))
220-
.test()
221-
.assertFailureAndMessage(RuntimeException.class, "Forced failure");
233+
assertFailureAndMessage(toV2Observable(rx.Observable.error(new RuntimeException("Forced failure")))
234+
.test(),
235+
RuntimeException.class, "Forced failure");
222236
}
223237

224238
@Test
@@ -283,20 +297,20 @@ public void s1s2Normal() {
283297
@Test
284298
public void s1s2Cancel() {
285299
rx.subjects.PublishSubject<Integer> ps = rx.subjects.PublishSubject.create();
286-
io.reactivex.observers.TestObserver<Integer> ts = toV2Single(ps.toSingle()).test();
300+
io.reactivex.observers.TestObserver<Integer> to = toV2Single(ps.toSingle()).test();
287301

288302
assertTrue("1.x PublishSubject has no observers!", ps.hasObservers());
289303

290-
ts.cancel();
304+
to.dispose();
291305

292306
assertFalse("1.x PublishSubject has observers!", ps.hasObservers());
293307

294308
}
295309

296310
@Test
297311
public void s1s2Error() {
298-
toV2Single(rx.Single.error(new RuntimeException("Forced failure"))).test()
299-
.assertFailureAndMessage(RuntimeException.class, "Forced failure");
312+
assertFailureAndMessage(toV2Single(rx.Single.error(new RuntimeException("Forced failure"))).test()
313+
, RuntimeException.class, "Forced failure");
300314
}
301315

302316
@Test
@@ -340,20 +354,20 @@ public void s1m2Normal() {
340354
@Test
341355
public void s1m2Cancel() {
342356
rx.subjects.PublishSubject<Integer> ps = rx.subjects.PublishSubject.create();
343-
io.reactivex.observers.TestObserver<Integer> ts = toV2Maybe(ps.toSingle()).test();
357+
io.reactivex.observers.TestObserver<Integer> to = toV2Maybe(ps.toSingle()).test();
344358

345359
assertTrue("1.x PublishSubject has no observers!", ps.hasObservers());
346360

347-
ts.cancel();
361+
to.dispose();
348362

349363
assertFalse("1.x PublishSubject has observers!", ps.hasObservers());
350364

351365
}
352366

353367
@Test
354368
public void s1m2Error() {
355-
toV2Maybe(rx.Single.error(new RuntimeException("Forced failure"))).test()
356-
.assertFailureAndMessage(RuntimeException.class, "Forced failure");
369+
assertFailureAndMessage(toV2Maybe(rx.Single.error(new RuntimeException("Forced failure"))).test()
370+
, RuntimeException.class, "Forced failure");
357371
}
358372

359373
@Test
@@ -401,19 +415,19 @@ public void c1c2Normal() {
401415
@Test
402416
public void c1c2Cancel() {
403417
rx.subjects.PublishSubject<Integer> ps = rx.subjects.PublishSubject.create();
404-
io.reactivex.observers.TestObserver<Void> ts = toV2Completable(ps.toCompletable()).test();
418+
io.reactivex.observers.TestObserver<Void> to = toV2Completable(ps.toCompletable()).test();
405419

406420
assertTrue("1.x PublishSubject has no observers!", ps.hasObservers());
407421

408-
ts.cancel();
422+
to.dispose();
409423

410424
assertFalse("1.x PublishSubject has observers!", ps.hasObservers());
411425
}
412426

413427
@Test
414428
public void c1c2Error() {
415-
toV2Completable(rx.Completable.error(new RuntimeException("Forced failure"))).test()
416-
.assertFailureAndMessage(RuntimeException.class, "Forced failure");
429+
assertFailureAndMessage(toV2Completable(rx.Completable.error(new RuntimeException("Forced failure"))).test()
430+
, RuntimeException.class, "Forced failure");
417431
}
418432

419433
@Test
@@ -454,15 +468,15 @@ public void c1m2Cancel() {
454468

455469
assertTrue("1.x PublishSubject has no observers!", ps.hasObservers());
456470

457-
ts.cancel();
471+
ts.dispose();
458472

459473
assertFalse("1.x PublishSubject has observers!", ps.hasObservers());
460474
}
461475

462476
@Test
463477
public void c1m2Error() {
464-
toV2Maybe(rx.Completable.error(new RuntimeException("Forced failure"))).test()
465-
.assertFailureAndMessage(RuntimeException.class, "Forced failure");
478+
assertFailureAndMessage(toV2Maybe(rx.Completable.error(new RuntimeException("Forced failure"))).test()
479+
, RuntimeException.class, "Forced failure");
466480
}
467481

468482

0 commit comments

Comments
 (0)