@@ -115,31 +115,11 @@ public void testDeadLetterExchangeDeleteTwice()
115115 }
116116
117117 public void testDeadLetterOnReject () throws Exception {
118- deadLetterTest (new Callable <Void >() {
119- public Void call () throws Exception {
120- for (int x = 0 ; x < MSG_COUNT ; x ++) {
121- GetResponse getResponse =
122- channel .basicGet (TEST_QUEUE_NAME , false );
123- long tag = getResponse .getEnvelope ().getDeliveryTag ();
124- channel .basicReject (tag , false );
125- }
126- return null ;
127- }
128- }, null , PropertiesFactory .NULL , "rejected" );
118+ rejectionTest (false );
129119 }
130120
131121 public void testDeadLetterOnNack () throws Exception {
132- deadLetterTest (new Callable <Void >() {
133- public Void call () throws Exception {
134- for (int x = 0 ; x < MSG_COUNT ; x ++) {
135- GetResponse getResponse =
136- channel .basicGet (TEST_QUEUE_NAME , false );
137- long tag = getResponse .getEnvelope ().getDeliveryTag ();
138- channel .basicNack (tag , false , false );
139- }
140- return null ;
141- }
142- }, null , PropertiesFactory .NULL , "rejected" );
122+ rejectionTest (true );
143123 }
144124
145125 public void testDeadLetterNoDeadLetterQueue () throws IOException {
@@ -261,6 +241,24 @@ public void process(GetResponse getResponse) {
261241 });
262242 }
263243
244+ public void rejectionTest (final boolean useNack ) throws Exception {
245+ deadLetterTest (new Callable <Void >() {
246+ public Void call () throws Exception {
247+ for (int x = 0 ; x < MSG_COUNT ; x ++) {
248+ GetResponse getResponse =
249+ channel .basicGet (TEST_QUEUE_NAME , false );
250+ long tag = getResponse .getEnvelope ().getDeliveryTag ();
251+ if (useNack ) {
252+ channel .basicNack (tag , false , false );
253+ } else {
254+ channel .basicReject (tag , false );
255+ }
256+ }
257+ return null ;
258+ }
259+ }, null , PropertiesFactory .NULL , "rejected" );
260+ }
261+
264262 private void deadLetterTest (final Runnable deathTrigger ,
265263 Map <String , Object > queueDeclareArgs ,
266264 PropertiesFactory propsFactory ,
0 commit comments