|
4 | 4 |
|
5 | 5 | package kotlinx.rpc.grpc.core.test |
6 | 6 |
|
7 | | -import StreamingTestService |
8 | | -import kotlinx.coroutines.flow.* |
9 | | -import kotlinx.rpc.RpcServer |
10 | | -import kotlinx.rpc.withService |
11 | | -import kotlin.test.Test |
12 | | -import kotlin.test.assertEquals |
13 | | - |
14 | | -class StreamingTestServiceImpl : StreamingTestService { |
15 | | - override fun Server(message: kotlinx.rpc.grpc.test.References): Flow<kotlinx.rpc.grpc.test.References> { |
16 | | - return flow { emit(message); emit(message); emit(message) } |
17 | | - } |
18 | | - |
19 | | - override suspend fun Client(message: Flow<kotlinx.rpc.grpc.test.References>): kotlinx.rpc.grpc.test.References { |
20 | | - return message.last() |
21 | | - } |
22 | | - |
23 | | - override fun Bidi(message: Flow<kotlinx.rpc.grpc.test.References>): Flow<kotlinx.rpc.grpc.test.References> { |
24 | | - return message |
25 | | - } |
26 | | -} |
27 | | - |
28 | | -class StreamingTest : GrpcServerTest() { |
29 | | - override fun RpcServer.registerServices() { |
30 | | - registerService<StreamingTestService> { StreamingTestServiceImpl() } |
31 | | - } |
32 | | - |
33 | | - @Test |
34 | | - fun testServerStreaming() = runGrpcTest { grpcClient -> |
35 | | - val service = grpcClient.withService<StreamingTestService>() |
36 | | - service.Server(kotlinx.rpc.grpc.test.References { |
37 | | - other = kotlinx.rpc.grpc.test.Other { |
38 | | - field = 42 |
39 | | - } |
40 | | - }).toList().run { |
41 | | - assertEquals(3, size) |
42 | | - |
43 | | - forEach { |
44 | | - assertEquals(42, it.other.field) |
45 | | - } |
46 | | - } |
47 | | - } |
48 | | - |
49 | | - @Test |
50 | | - fun testClientStreaming() = runGrpcTest { grpcClient -> |
51 | | - val service = grpcClient.withService<StreamingTestService>() |
52 | | - val result = service.Client(flow { |
53 | | - repeat(3) { |
54 | | - emit(kotlinx.rpc.grpc.test.References { |
55 | | - other = kotlinx.rpc.grpc.test.Other { |
56 | | - field = 42 + it |
57 | | - } |
58 | | - }) |
59 | | - } |
60 | | - }) |
61 | | - |
62 | | - assertEquals(44, result.other.field) |
63 | | - } |
64 | | - |
65 | | - @Test |
66 | | - fun testBidiStreaming() = runGrpcTest { grpcClient -> |
67 | | - val service = grpcClient.withService<StreamingTestService>() |
68 | | - service.Bidi(flow { |
69 | | - repeat(3) { |
70 | | - emit(kotlinx.rpc.grpc.test.References { |
71 | | - other = kotlinx.rpc.grpc.test.Other { |
72 | | - field = 42 + it |
73 | | - } |
74 | | - }) |
75 | | - } |
76 | | - }).collectIndexed { i, it -> |
77 | | - assertEquals(42 + i, it.other.field) |
78 | | - } |
79 | | - } |
80 | | -} |
| 7 | +//import StreamingTestService |
| 8 | +//import kotlinx.coroutines.flow.* |
| 9 | +//import kotlinx.rpc.RpcServer |
| 10 | +//import kotlinx.rpc.withService |
| 11 | +//import kotlin.test.Test |
| 12 | +//import kotlin.test.assertEquals |
| 13 | +// |
| 14 | +//class StreamingTestServiceImpl : StreamingTestService { |
| 15 | +// override fun Server(message: kotlinx.rpc.grpc.test.References): Flow<kotlinx.rpc.grpc.test.References> { |
| 16 | +// return flow { emit(message); emit(message); emit(message) } |
| 17 | +// } |
| 18 | +// |
| 19 | +// override suspend fun Client(message: Flow<kotlinx.rpc.grpc.test.References>): kotlinx.rpc.grpc.test.References { |
| 20 | +// return message.last() |
| 21 | +// } |
| 22 | +// |
| 23 | +// override fun Bidi(message: Flow<kotlinx.rpc.grpc.test.References>): Flow<kotlinx.rpc.grpc.test.References> { |
| 24 | +// return message |
| 25 | +// } |
| 26 | +//} |
| 27 | +// |
| 28 | +//class StreamingTest : GrpcServerTest() { |
| 29 | +// override fun RpcServer.registerServices() { |
| 30 | +// registerService<StreamingTestService> { StreamingTestServiceImpl() } |
| 31 | +// } |
| 32 | +// |
| 33 | +// @Test |
| 34 | +// fun testServerStreaming() = runGrpcTest { grpcClient -> |
| 35 | +// val service = grpcClient.withService<StreamingTestService>() |
| 36 | +// service.Server(kotlinx.rpc.grpc.test.References { |
| 37 | +// other = kotlinx.rpc.grpc.test.Other { |
| 38 | +// field = 42 |
| 39 | +// } |
| 40 | +// }).toList().run { |
| 41 | +// assertEquals(3, size) |
| 42 | +// |
| 43 | +// forEach { |
| 44 | +// assertEquals(42, it.other.field) |
| 45 | +// } |
| 46 | +// } |
| 47 | +// } |
| 48 | +// |
| 49 | +// @Test |
| 50 | +// fun testClientStreaming() = runGrpcTest { grpcClient -> |
| 51 | +// val service = grpcClient.withService<StreamingTestService>() |
| 52 | +// val result = service.Client(flow { |
| 53 | +// repeat(3) { |
| 54 | +// emit(kotlinx.rpc.grpc.test.References { |
| 55 | +// other = kotlinx.rpc.grpc.test.Other { |
| 56 | +// field = 42 + it |
| 57 | +// } |
| 58 | +// }) |
| 59 | +// } |
| 60 | +// }) |
| 61 | +// |
| 62 | +// assertEquals(44, result.other.field) |
| 63 | +// } |
| 64 | +// |
| 65 | +// @Test |
| 66 | +// fun testBidiStreaming() = runGrpcTest { grpcClient -> |
| 67 | +// val service = grpcClient.withService<StreamingTestService>() |
| 68 | +// service.Bidi(flow { |
| 69 | +// repeat(3) { |
| 70 | +// emit(kotlinx.rpc.grpc.test.References { |
| 71 | +// other = kotlinx.rpc.grpc.test.Other { |
| 72 | +// field = 42 + it |
| 73 | +// } |
| 74 | +// }) |
| 75 | +// } |
| 76 | +// }).collectIndexed { i, it -> |
| 77 | +// assertEquals(42 + i, it.other.field) |
| 78 | +// } |
| 79 | +// } |
| 80 | +//} |
0 commit comments