22
22
import org .junit .Test ;
23
23
import org .mockito .Mockito ;
24
24
25
+ import java .io .IOException ;
25
26
import java .util .concurrent .ExecutorService ;
26
27
import java .util .concurrent .Executors ;
27
28
@@ -30,22 +31,31 @@ public class ChannelNTest {
30
31
ConsumerWorkService consumerWorkService ;
31
32
ExecutorService executorService ;
32
33
33
- @ Before public void init () {
34
+ @ Before
35
+ public void init () {
34
36
executorService = Executors .newSingleThreadExecutor ();
35
37
consumerWorkService = new ConsumerWorkService (executorService , null , 1000 , 1000 );
36
38
}
37
39
38
- @ After public void tearDown () {
40
+ @ After
41
+ public void tearDown () {
39
42
consumerWorkService .shutdown ();
40
43
executorService .shutdownNow ();
41
44
}
42
45
43
46
@ Test
44
- public void cancelUnknownConsumerDoesNotThrowException () throws Exception {
47
+ public void serverBasicCancelForUnknownConsumerDoesNotThrowException () throws Exception {
45
48
AMQConnection connection = Mockito .mock (AMQConnection .class );
46
49
ChannelN channel = new ChannelN (connection , 1 , consumerWorkService );
47
50
Method method = new AMQImpl .Basic .Cancel .Builder ().consumerTag ("does-not-exist" ).build ();
48
51
channel .processAsync (new AMQCommand (method ));
49
52
}
50
53
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
+
51
61
}
0 commit comments