@@ -48,6 +48,40 @@ public class PriorityQueues extends BrokerTestCase {
48
48
channel .queueDelete (q );
49
49
}
50
50
51
+ @ Test public void negativeMaxPriority () throws IOException , TimeoutException , InterruptedException {
52
+ String q = "with-minus-10-priorities" ;
53
+ int n = -10 ;
54
+ try {
55
+ channel .queueDeclare (q , true , false , false , argsWithPriorities (n ));
56
+ } catch (IOException ioe ) {
57
+ checkShutdownSignal (AMQP .PRECONDITION_FAILED , ioe );
58
+ }
59
+ }
60
+
61
+ @ Test public void excessiveMaxPriority () throws IOException , TimeoutException , InterruptedException {
62
+ String q = "with-260-priorities" ;
63
+ int n = 260 ;
64
+ try {
65
+ channel .queueDeclare (q , true , false , false , argsWithPriorities (n ));
66
+ } catch (IOException ioe ) {
67
+ checkShutdownSignal (AMQP .PRECONDITION_FAILED , ioe );
68
+ }
69
+ }
70
+
71
+ @ Test public void maxAllowedPriority () throws IOException , TimeoutException , InterruptedException {
72
+ String q = "with-255-priorities" ;
73
+ int n = 255 ;
74
+ channel .queueDeclare (q , true , false , false , argsWithPriorities (n ));
75
+ publishWithPriorities (q , n );
76
+
77
+ List <Integer > xs = prioritiesOfEnqueuedMessages (q , n );
78
+ assertEquals (Integer .valueOf (255 ), xs .get (0 ));
79
+ assertEquals (Integer .valueOf (254 ), xs .get (1 ));
80
+ assertEquals (Integer .valueOf (253 ), xs .get (2 ));
81
+
82
+ channel .queueDelete (q );
83
+ }
84
+
51
85
private List <Integer > prioritiesOfEnqueuedMessages (String q , int n ) throws InterruptedException , IOException {
52
86
final List <Integer > xs = new ArrayList <Integer >();
53
87
final CountDownLatch latch = new CountDownLatch (n );
0 commit comments