|
|
|
@ -37,6 +37,7 @@ import reactor.core.publisher.Mono |
|
|
|
* Kotlin tests for [RSocketServiceMethod]. |
|
|
|
* Kotlin tests for [RSocketServiceMethod]. |
|
|
|
* |
|
|
|
* |
|
|
|
* @author Dmitry Sulman |
|
|
|
* @author Dmitry Sulman |
|
|
|
|
|
|
|
* @author Sebastien Deleuze |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class RSocketServiceMethodKotlinTests { |
|
|
|
class RSocketServiceMethodKotlinTests { |
|
|
|
|
|
|
|
|
|
|
|
@ -95,6 +96,23 @@ class RSocketServiceMethodKotlinTests { |
|
|
|
assertThat(rsocket.savedPayload?.dataUtf8).isEqualTo(requestPayload) |
|
|
|
assertThat(rsocket.savedPayload?.dataUtf8).isEqualTo(requestPayload) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
|
|
|
|
fun nonSuspendingRequestStream(): Unit = runBlocking { |
|
|
|
|
|
|
|
val service = proxyFactory.createClient(NonSuspendingFunctionsService::class.java) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val requestPayload = "request" |
|
|
|
|
|
|
|
val responsePayload1 = "response1" |
|
|
|
|
|
|
|
val responsePayload2 = "response2" |
|
|
|
|
|
|
|
rsocket.setPayloadFluxToReturn( |
|
|
|
|
|
|
|
Flux.just(DefaultPayload.create(responsePayload1), DefaultPayload.create(responsePayload2))) |
|
|
|
|
|
|
|
val response = service.requestStream(requestPayload).toList() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assertThat(response).containsExactly(responsePayload1, responsePayload2) |
|
|
|
|
|
|
|
assertThat(rsocket.savedMethodName).isEqualTo("requestStream") |
|
|
|
|
|
|
|
assertThat(rsocket.savedPayload?.metadataUtf8).isEqualTo("rs") |
|
|
|
|
|
|
|
assertThat(rsocket.savedPayload?.dataUtf8).isEqualTo(requestPayload) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Test |
|
|
|
@Test |
|
|
|
fun requestChannel(): Unit = runBlocking { |
|
|
|
fun requestChannel(): Unit = runBlocking { |
|
|
|
val service = proxyFactory.createClient(SuspendingFunctionsService::class.java) |
|
|
|
val service = proxyFactory.createClient(SuspendingFunctionsService::class.java) |
|
|
|
@ -131,4 +149,11 @@ class RSocketServiceMethodKotlinTests { |
|
|
|
@RSocketExchange("rc") |
|
|
|
@RSocketExchange("rc") |
|
|
|
suspend fun requestChannel(input: Flow<String>): Flow<String> |
|
|
|
suspend fun requestChannel(input: Flow<String>): Flow<String> |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private interface NonSuspendingFunctionsService { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@RSocketExchange("rs") |
|
|
|
|
|
|
|
fun requestStream(input: String): Flow<String> |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |