Skip to content

Commit

Permalink
Add test for Channel#basicCancel with unknown consumer tag
Browse files Browse the repository at this point in the history
References #525, #528

(cherry picked from commit 261ffff)
  • Loading branch information
acogoluegnes committed Mar 22, 2019
1 parent 6081628 commit 365dd22
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions src/test/java/com/rabbitmq/client/test/ChannelNTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import org.junit.Test;
import org.mockito.Mockito;

import java.io.IOException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

Expand All @@ -30,22 +31,31 @@ public class ChannelNTest {
ConsumerWorkService consumerWorkService;
ExecutorService executorService;

@Before public void init() {
@Before
public void init() {
executorService = Executors.newSingleThreadExecutor();
consumerWorkService = new ConsumerWorkService(executorService, null, 1000, 1000);
}

@After public void tearDown() {
@After
public void tearDown() {
consumerWorkService.shutdown();
executorService.shutdownNow();
}

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

@Test(expected = IOException.class)
public void callingBasicCancelForUnknownConsumerThrowsException() throws Exception {
AMQConnection connection = Mockito.mock(AMQConnection.class);
ChannelN channel = new ChannelN(connection, 1, consumerWorkService);
channel.basicCancel("does-not-exist");
}

}

0 comments on commit 365dd22

Please sign in to comment.