Skip to content

Commit 365dd22

Browse files
committed
Add test for Channel#basicCancel with unknown consumer tag
References #525, #528 (cherry picked from commit 261ffff)
1 parent 6081628 commit 365dd22

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

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

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import org.junit.Test;
2323
import org.mockito.Mockito;
2424

25+
import java.io.IOException;
2526
import java.util.concurrent.ExecutorService;
2627
import java.util.concurrent.Executors;
2728

@@ -30,22 +31,31 @@ public class ChannelNTest {
3031
ConsumerWorkService consumerWorkService;
3132
ExecutorService executorService;
3233

33-
@Before public void init() {
34+
@Before
35+
public void init() {
3436
executorService = Executors.newSingleThreadExecutor();
3537
consumerWorkService = new ConsumerWorkService(executorService, null, 1000, 1000);
3638
}
3739

38-
@After public void tearDown() {
40+
@After
41+
public void tearDown() {
3942
consumerWorkService.shutdown();
4043
executorService.shutdownNow();
4144
}
4245

4346
@Test
44-
public void cancelUnknownConsumerDoesNotThrowException() throws Exception {
47+
public void serverBasicCancelForUnknownConsumerDoesNotThrowException() throws Exception {
4548
AMQConnection connection = Mockito.mock(AMQConnection.class);
4649
ChannelN channel = new ChannelN(connection, 1, consumerWorkService);
4750
Method method = new AMQImpl.Basic.Cancel.Builder().consumerTag("does-not-exist").build();
4851
channel.processAsync(new AMQCommand(method));
4952
}
5053

54+
@Test(expected = IOException.class)
55+
public void callingBasicCancelForUnknownConsumerThrowsException() throws Exception {
56+
AMQConnection connection = Mockito.mock(AMQConnection.class);
57+
ChannelN channel = new ChannelN(connection, 1, consumerWorkService);
58+
channel.basicCancel("does-not-exist");
59+
}
60+
5161
}

0 commit comments

Comments
 (0)