|
25 | 25 | import static org.junit.jupiter.api.Assertions.assertTimeout;
|
26 | 26 | import static org.junit.jupiter.api.Assertions.assertTimeoutPreemptively;
|
27 | 27 | import static org.junit.jupiter.api.Assertions.assertTrue;
|
28 |
| -import static org.junit.jupiter.api.Assertions.fail; |
29 | 28 | import static org.mockito.Mockito.mock;
|
30 | 29 | import static org.mockito.Mockito.reset;
|
31 | 30 | import static org.mockito.Mockito.when;
|
|
37 | 36 | import org.junit.jupiter.api.BeforeEach;
|
38 | 37 | import org.junit.jupiter.api.Test;
|
39 | 38 | import org.junit.jupiter.api.function.Executable;
|
40 |
| -import org.opentest4j.AssertionFailedError; |
41 | 39 |
|
42 | 40 | import io.grpc.Server;
|
43 | 41 |
|
@@ -128,36 +126,6 @@ void testAwaitShutdown() {
|
128 | 126 |
|
129 | 127 | }
|
130 | 128 |
|
131 |
| - @Test |
132 |
| - void testInterruptShutdown() { |
133 |
| - |
134 |
| - // The server takes 60s seconds to shutdown |
135 |
| - final TestServer server = new TestServer(60000); |
136 |
| - when(this.factory.createServer()).thenReturn(server); |
137 |
| - |
138 |
| - // And we give it infinite time to shutdown |
139 |
| - final GrpcServerLifecycle lifecycle = new GrpcServerLifecycle(this.factory, ofSeconds(-1)); |
140 |
| - |
141 |
| - lifecycle.start(); |
142 |
| - |
143 |
| - assertFalse(server.isShutdown()); |
144 |
| - assertFalse(server.isTerminated()); |
145 |
| - |
146 |
| - try { |
147 |
| - // But we are in a hurry, so we interrupt it after 2s |
148 |
| - assertTimeoutPreemptively(ofMillis(2000), (Executable) lifecycle::stop); |
149 |
| - fail("Did not wait for shutdown to complete"); |
150 |
| - } catch (final AssertionFailedError e) { |
151 |
| - // We failed due to the timeout/interrupt |
152 |
| - assertThat(e).getCause().matches(t -> "ExecutionTimeoutException".equals(t.getClass().getSimpleName())); |
153 |
| - } |
154 |
| - |
155 |
| - // But the server is still properly terminated |
156 |
| - assertTrue(server.isShutdown()); |
157 |
| - assertTrue(server.isTerminated()); |
158 |
| - |
159 |
| - } |
160 |
| - |
161 | 129 | public class TestServer extends Server {
|
162 | 130 |
|
163 | 131 | private final long shutdownDelayMillis;
|
|
0 commit comments