@@ -97,15 +97,15 @@ public void testDeadLetterQueueTTLExpiredMessages() throws Exception {
9797 public void run () {
9898 sleep (2000 );
9999 }
100- }, args , PropertiesFactory . NULL , "expired" );
100+ }, args , "expired" );
101101 }
102102
103103 public void testDeadLetterExchangeDeleteTwice ()
104104 throws IOException
105105 {
106106 declareQueue (TEST_QUEUE_NAME , DLX , null , null , 1 );
107107
108- publishN (MSG_COUNT_MANY , PropertiesFactory . NULL );
108+ publishN (MSG_COUNT_MANY );
109109 channel .queueDelete (TEST_QUEUE_NAME );
110110 try {
111111 channel .queueDelete (TEST_QUEUE_NAME );
@@ -126,7 +126,7 @@ public void testDeadLetterNoDeadLetterQueue() throws IOException {
126126 channel .queueDelete (DLQ );
127127 declareQueue (TEST_QUEUE_NAME , DLX , null , null , 1 );
128128 channel .queueBind (TEST_QUEUE_NAME , "amq.direct" , "test" );
129- publishN (MSG_COUNT , PropertiesFactory . NULL );
129+ publishN (MSG_COUNT );
130130 }
131131
132132 public void testDeadLetterMultipleDeadLetterQueues ()
@@ -140,7 +140,7 @@ public void testDeadLetterMultipleDeadLetterQueues()
140140 channel .queueBind (DLQ , DLX , "test" );
141141 channel .queueBind (DLQ2 , DLX , "test" );
142142
143- publishN (MSG_COUNT , PropertiesFactory . NULL );
143+ publishN (MSG_COUNT );
144144 }
145145
146146 public void testDeadLetterTwice () throws Exception {
@@ -155,7 +155,7 @@ public void testDeadLetterTwice() throws Exception {
155155 channel .queueBind (DLQ , DLX , "test" );
156156 channel .queueBind (DLQ2 , DLX , "test" );
157157
158- publishN (MSG_COUNT , PropertiesFactory . NULL );
158+ publishN (MSG_COUNT );
159159
160160 sleep (100 );
161161
@@ -184,7 +184,7 @@ public void testDeadLetterSelf() throws Exception {
184184 declareQueue (TEST_QUEUE_NAME , "amq.direct" , "test" , null , 1 );
185185 channel .queueBind (TEST_QUEUE_NAME , "amq.direct" , "test" );
186186
187- publishN (MSG_COUNT , PropertiesFactory . NULL );
187+ publishN (MSG_COUNT );
188188 // This test hangs if the queue doesn't process ALL the
189189 // messages before being deleted, so make sure the next
190190 // sleep is long enough.
@@ -206,16 +206,13 @@ public void testDeadLetterNewRK() throws Exception {
206206 channel .queueBind (DLQ , DLX , "test" );
207207 channel .queueBind (DLQ2 , DLX , "test-other" );
208208
209- publishN (MSG_COUNT , new PropertiesFactory () {
210- public AMQP .BasicProperties create (int msgNum ) {
211- Map <String , Object > headers = new HashMap <String , Object >();
212- headers .put ("CC" , Arrays .asList (new String []{"foo" }));
213- headers .put ("BCC" , Arrays .asList (new String []{"bar" }));
214- return (new AMQP .BasicProperties .Builder ())
215- .headers (headers )
216- .build ();
217- }
218- });
209+ Map <String , Object > headers = new HashMap <String , Object >();
210+ headers .put ("CC" , Arrays .asList (new String []{"foo" }));
211+ headers .put ("BCC" , Arrays .asList (new String []{"bar" }));
212+
213+ publishN (MSG_COUNT , (new AMQP .BasicProperties .Builder ())
214+ .headers (headers )
215+ .build ());
219216
220217 sleep (100 );
221218
@@ -256,12 +253,11 @@ public Void call() throws Exception {
256253 }
257254 return null ;
258255 }
259- }, null , PropertiesFactory . NULL , "rejected" );
256+ }, null , "rejected" );
260257 }
261258
262259 private void deadLetterTest (final Runnable deathTrigger ,
263260 Map <String , Object > queueDeclareArgs ,
264- PropertiesFactory propsFactory ,
265261 String reason )
266262 throws Exception
267263 {
@@ -270,12 +266,11 @@ public Object call() throws Exception {
270266 deathTrigger .run ();
271267 return null ;
272268 }
273- }, queueDeclareArgs , propsFactory , reason );
269+ }, queueDeclareArgs , reason );
274270 }
275271
276272 private void deadLetterTest (Callable <?> deathTrigger ,
277273 Map <String , Object > queueDeclareArgs ,
278- PropertiesFactory propsFactory ,
279274 final String reason )
280275 throws Exception
281276 {
@@ -284,7 +279,7 @@ private void deadLetterTest(Callable<?> deathTrigger,
284279 channel .queueBind (TEST_QUEUE_NAME , "amq.direct" , "test" );
285280 channel .queueBind (DLQ , DLX , "test" );
286281
287- publishN (MSG_COUNT , propsFactory );
282+ publishN (MSG_COUNT );
288283
289284 deathTrigger .call ();
290285
@@ -341,12 +336,15 @@ private void declareQueue(String queue, Object deadLetterExchange,
341336 channel .queueDeclare (queue , false , true , false , args );
342337 }
343338
344- private void publishN (int n , PropertiesFactory propsFactory )
339+ private void publishN (int n ) throws IOException {
340+ publishN (n , null );
341+ }
342+
343+ private void publishN (int n , AMQP .BasicProperties props )
345344 throws IOException
346345 {
347346 for (int x = 0 ; x < n ; x ++) {
348- channel .basicPublish ("amq.direct" , "test" ,
349- propsFactory .create (x ),
347+ channel .basicPublish ("amq.direct" , "test" , props ,
350348 "test message" .getBytes ());
351349 }
352350 }
@@ -394,16 +392,6 @@ private void assertDeathReason(List<Object> death, int num,
394392 assertEquals (reason , deathHeader .get ("reason" ).toString ());
395393 }
396394
397- private static interface PropertiesFactory {
398- static final PropertiesFactory NULL = new PropertiesFactory (){
399- public AMQP .BasicProperties create (int msgNum ) {
400- return null ;
401- }
402- };
403-
404- AMQP .BasicProperties create (int msgNum );
405- }
406-
407395 private static interface WithResponse {
408396 public void process (GetResponse response );
409397 }
0 commit comments