Skip to content

Commit f5c26a7

Browse files
committed
Fix flaky test
1 parent 7253c94 commit f5c26a7

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/test/java/com/rabbitmq/client/test/ChannelNTest.java

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@
2424
import org.junit.jupiter.api.Test;
2525
import org.mockito.Mockito;
2626

27-
import java.io.IOException;
28-
import java.util.concurrent.*;
27+
import java.util.concurrent.ExecutorService;
28+
import java.util.concurrent.Executors;
2929
import java.util.stream.Stream;
3030
import static org.assertj.core.api.Assertions.assertThatThrownBy;
3131
import static org.junit.jupiter.api.Assertions.assertNotNull;
@@ -93,17 +93,16 @@ public void confirmSelectOnlySendsRPCCallOnce() throws Exception {
9393

9494
ChannelN channel = new ChannelN(connection, 1, consumerWorkService);
9595

96-
Future<AMQImpl.Confirm.SelectOk> future = executorService.submit(() -> {
96+
new Thread(() -> {
9797
try {
98-
return channel.confirmSelect();
99-
} catch (IOException e) {
98+
Thread.sleep(15);
99+
channel.handleCompleteInboundCommand(new AMQCommand(new AMQImpl.Confirm.SelectOk()));
100+
} catch (Exception e) {
100101
throw new RuntimeException(e);
101102
}
102-
});
103+
}).start();
103104

104-
channel.handleCompleteInboundCommand(new AMQCommand(new AMQImpl.Confirm.SelectOk()));
105-
106-
assertNotNull(future.get(1, TimeUnit.SECONDS));
105+
assertNotNull(channel.confirmSelect());
107106
assertNotNull(channel.confirmSelect());
108107
Mockito.verify(trafficListener, Mockito.times(1)).write(Mockito.any(Command.class));
109108
}

0 commit comments

Comments
 (0)