|
25 | 25 | import org.mockito.Mockito; |
26 | 26 |
|
27 | 27 | import java.io.IOException; |
28 | | -import java.util.concurrent.*; |
29 | | -import java.util.concurrent.atomic.AtomicReference;import java.util.stream.Stream; |
| 28 | +import java.util.concurrent.atomic.AtomicReference; |
| 29 | +import java.util.stream.Stream; |
30 | 30 |
|
31 | 31 | import static org.assertj.core.api.Assertions.assertThat; |
| 32 | +import java.util.concurrent.ExecutorService; |
| 33 | +import java.util.concurrent.Executors; |
32 | 34 | import static org.assertj.core.api.Assertions.assertThatThrownBy; |
33 | 35 | import static org.junit.jupiter.api.Assertions.assertNotNull; |
34 | 36 |
|
@@ -116,17 +118,16 @@ public void confirmSelectOnlySendsRPCCallOnce() throws Exception { |
116 | 118 |
|
117 | 119 | ChannelN channel = new ChannelN(connection, 1, consumerWorkService); |
118 | 120 |
|
119 | | - Future<AMQImpl.Confirm.SelectOk> future = executorService.submit(() -> { |
| 121 | + new Thread(() -> { |
120 | 122 | try { |
121 | | - return channel.confirmSelect(); |
122 | | - } catch (IOException e) { |
| 123 | + Thread.sleep(15); |
| 124 | + channel.handleCompleteInboundCommand(new AMQCommand(new AMQImpl.Confirm.SelectOk())); |
| 125 | + } catch (Exception e) { |
123 | 126 | throw new RuntimeException(e); |
124 | 127 | } |
125 | | - }); |
| 128 | + }).start(); |
126 | 129 |
|
127 | | - channel.handleCompleteInboundCommand(new AMQCommand(new AMQImpl.Confirm.SelectOk())); |
128 | | - |
129 | | - assertNotNull(future.get(1, TimeUnit.SECONDS)); |
| 130 | + assertNotNull(channel.confirmSelect()); |
130 | 131 | assertNotNull(channel.confirmSelect()); |
131 | 132 | Mockito.verify(trafficListener, Mockito.times(1)).write(Mockito.any(Command.class)); |
132 | 133 | } |
|
0 commit comments