Skip to content

Commit 1a36873

Browse files
committed
Test with full compatibility with 0.17.0
1 parent 6a858c4 commit 1a36873

File tree

2 files changed

+17
-23
lines changed

2 files changed

+17
-23
lines changed

language-adaptors/rxjava-kotlin/src/test/kotlin/rx/lang/kotlin/BasicKotlinTests.kt

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -329,24 +329,23 @@ public class BasicKotlinTests : KotlinTests() {
329329

330330
}
331331

332-
class AsyncObservable : OnSubscribeFunc<Int> {
333-
override fun onSubscribe(op: Observer<in Int>?): Subscription? {
332+
class AsyncObservable : OnSubscribe<Int> {
333+
override fun call(op: Subscriber<in Int>?) {
334334
thread {
335335
Thread.sleep(50)
336336
op!!.onNext(1)
337337
op.onNext(2)
338338
op.onNext(3)
339339
op.onCompleted()
340340
}
341-
return Subscriptions.empty()
341+
342342
}
343343
}
344344

345-
class TestOnSubscribe(val count: Int) : OnSubscribeFunc<String> {
346-
override fun onSubscribe(op: Observer<in String>?): Subscription? {
345+
class TestOnSubscribe(val count: Int) : OnSubscribe<String> {
346+
override fun call(op: Subscriber<in String>?) {
347347
op!!.onNext("hello_$count")
348348
op.onCompleted()
349-
return Subscriptions.empty()!!
350349
}
351350

352351
}

language-adaptors/rxjava-kotlin/src/test/kotlin/rx/lang/kotlin/ExtensionTests.kt

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,10 @@ package rx.lang.kotlin
1818

1919
import rx.Observable
2020
import org.junit.Test
21-
import rx.subscriptions.Subscriptions
2221
import org.mockito.Mockito.*
2322
import org.mockito.Matchers.*
24-
import rx.Observer
2523
import org.junit.Assert.*
2624
import rx.Notification
27-
import rx.Subscription
2825
import kotlin.concurrent.thread
2926
import rx.Subscriber
3027

@@ -213,15 +210,15 @@ public class ExtensionTests : KotlinTests() {
213210

214211
[Test]
215212
public fun testForEach() {
216-
asyncObservable.asObservableFunc().toBlockingObservable()!!.forEach(received())
213+
asyncObservable.asObservable().toBlockingObservable()!!.forEach(received())
217214
verify(a, times(1))!!.received(1)
218215
verify(a, times(1))!!.received(2)
219216
verify(a, times(1))!!.received(3)
220217
}
221218

222219
[Test(expected = javaClass<RuntimeException>())]
223220
public fun testForEachWithError() {
224-
asyncObservable.asObservableFunc().toBlockingObservable()!!.forEach { throw RuntimeException("err") }
221+
asyncObservable.asObservable().toBlockingObservable()!!.forEach { throw RuntimeException("err") }
225222
fail("we expect an exception to be thrown")
226223
}
227224

@@ -256,21 +253,19 @@ public class ExtensionTests : KotlinTests() {
256253
assertEquals(listOf(3, 6, 9), values[2])
257254
}
258255

259-
val funOnSubscribe: (Int, Observer<in String>) -> Subscription = { counter, observer ->
260-
observer.onNext("hello_$counter")
261-
observer.onCompleted()
262-
Subscriptions.empty()!!
256+
val funOnSubscribe: (Int, Subscriber<in String>) -> Unit = { counter, subscriber ->
257+
subscriber.onNext("hello_$counter")
258+
subscriber.onCompleted()
263259
}
264260

265-
val asyncObservable: (Observer<in Int>) -> Subscription = { observer ->
261+
val asyncObservable: (Subscriber<in Int>) -> Unit = { subscriber ->
266262
thread {
267263
Thread.sleep(50)
268-
observer.onNext(1)
269-
observer.onNext(2)
270-
observer.onNext(3)
271-
observer.onCompleted()
264+
subscriber.onNext(1)
265+
subscriber.onNext(2)
266+
subscriber.onNext(3)
267+
subscriber.onCompleted()
272268
}
273-
Subscriptions.empty()!!
274269
}
275270

276271
/**
@@ -288,14 +283,14 @@ public class ExtensionTests : KotlinTests() {
288283
return listOf(1, 3, 2, 5, 4).asObservable()
289284
}
290285

291-
val onSubscribe: (Observer<in String>) -> Subscription
286+
val onSubscribe: (Subscriber<in String>) -> Unit
292287
get(){
293288
return funOnSubscribe.partially1(counter++)
294289
}
295290

296291
val observable: Observable<String>
297292
get(){
298-
return onSubscribe.asObservableFunc()
293+
return onSubscribe.asObservable()
299294
}
300295

301296
}

0 commit comments

Comments
 (0)