|
16 | 16 |
|
17 | 17 | package io.rsocket; |
18 | 18 |
|
19 | | -import static org.hamcrest.Matchers.empty; |
20 | | -import static org.hamcrest.Matchers.is; |
21 | | -import static org.mockito.ArgumentMatchers.any; |
22 | | -import static org.mockito.Mockito.verify; |
23 | | - |
24 | 19 | import io.rsocket.exceptions.ApplicationException; |
25 | 20 | import io.rsocket.test.util.LocalDuplexConnection; |
26 | 21 | import io.rsocket.test.util.TestSubscriber; |
27 | 22 | import io.rsocket.util.DefaultPayload; |
28 | 23 | import io.rsocket.util.EmptyPayload; |
29 | | -import java.util.ArrayList; |
30 | | -import java.util.concurrent.CountDownLatch; |
31 | 24 | import org.hamcrest.MatcherAssert; |
32 | 25 | import org.junit.Assert; |
33 | 26 | import org.junit.Rule; |
|
41 | 34 | import reactor.core.publisher.Flux; |
42 | 35 | import reactor.core.publisher.Mono; |
43 | 36 |
|
| 37 | +import java.nio.channels.ClosedChannelException; |
| 38 | +import java.util.ArrayList; |
| 39 | +import java.util.concurrent.CountDownLatch; |
| 40 | + |
| 41 | +import static org.hamcrest.Matchers.empty; |
| 42 | +import static org.hamcrest.Matchers.is; |
| 43 | +import static org.mockito.ArgumentMatchers.any; |
| 44 | +import static org.mockito.Mockito.verify; |
| 45 | + |
44 | 46 | public class RSocketTest { |
45 | 47 |
|
46 | 48 | @Rule public final SocketRule rule = new SocketRule(); |
@@ -85,6 +87,22 @@ public void testChannel() throws Exception { |
85 | 87 |
|
86 | 88 | latch.await(); |
87 | 89 | } |
| 90 | + |
| 91 | + @Test(timeout = 2_000L) |
| 92 | + public void testCleanup() throws Exception { |
| 93 | + CountDownLatch latch = new CountDownLatch(1); |
| 94 | + rule.crs |
| 95 | + .requestStream(DefaultPayload.create("hi")) |
| 96 | + .doOnError(t -> { |
| 97 | + Assert.assertTrue(t instanceof ClosedChannelException); |
| 98 | + latch.countDown(); |
| 99 | + }) |
| 100 | + .subscribe(); |
| 101 | + |
| 102 | + rule.crs.cleanup(); |
| 103 | + |
| 104 | + latch.await(); |
| 105 | + } |
88 | 106 |
|
89 | 107 | public static class SocketRule extends ExternalResource { |
90 | 108 |
|
@@ -124,6 +142,11 @@ protected void init() { |
124 | 142 | public Mono<Payload> requestResponse(Payload payload) { |
125 | 143 | return Mono.just(payload); |
126 | 144 | } |
| 145 | + |
| 146 | + @Override |
| 147 | + public Flux<Payload> requestStream(Payload payload) { |
| 148 | + return Flux.never(); |
| 149 | + } |
127 | 150 |
|
128 | 151 | @Override |
129 | 152 | public Flux<Payload> requestChannel(Publisher<Payload> payloads) { |
|
0 commit comments