Skip to content

Commit f05f233

Browse files
author
Steve Powell
committed
Added test -- which fails at the moment :-(
1 parent 3211181 commit f05f233

File tree

2 files changed

+34
-9
lines changed

2 files changed

+34
-9
lines changed

src/com/rabbitmq/client/impl/Frame.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,9 @@ else if(value instanceof byte[]) {
297297
else if(value instanceof List) {
298298
acc += 4 + arraySize((List<?>)value);
299299
}
300+
else if(value instanceof Object[]) {
301+
acc += 4 + arraySize((Object[])value);
302+
}
300303
else if(value == null) {
301304
}
302305
else {
@@ -305,7 +308,7 @@ else if(value == null) {
305308
return acc;
306309
}
307310

308-
/** Computes the AMQP wire-protocol length of an encoded field-array */
311+
/** Computes the AMQP wire-protocol length of an encoded field-array of type List<?> */
309312
public static long arraySize(List<?> values)
310313
throws UnsupportedEncodingException
311314
{
@@ -315,7 +318,16 @@ public static long arraySize(List<?> values)
315318
}
316319
return acc;
317320
}
318-
321+
322+
/** Computes the AMQP wire-protocol length of an encoded field-array of type Object[] */
323+
public static long arraySize(Object[] values) throws UnsupportedEncodingException {
324+
long acc = 0;
325+
for (Object value : values) {
326+
acc += fieldValueSize(value);
327+
}
328+
return acc;
329+
}
330+
319331
/** Computes the AMQP wire-protocol length of a protocol-encoded long string. */
320332
private static int longStrSize(String str)
321333
throws UnsupportedEncodingException

test/src/com/rabbitmq/client/test/functional/QueueLifecycle.java

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,17 @@
1818
package com.rabbitmq.client.test.functional;
1919

2020
import java.io.IOException;
21+
import java.util.Arrays;
2122
import java.util.HashMap;
2223
import java.util.Map;
2324

2425
import com.rabbitmq.client.AMQP;
2526
import com.rabbitmq.client.QueueingConsumer;
2627
import com.rabbitmq.client.test.BrokerTestCase;
2728

28-
// Test queue auto-delete and exclusive semantics.
29+
/**
30+
* Test queue auto-delete and exclusive semantics.
31+
*/
2932
public class QueueLifecycle extends BrokerTestCase {
3033

3134
void verifyQueueExists(String name) throws IOException {
@@ -77,12 +80,13 @@ void verifyNotEquivalent(boolean durable, boolean exclusive,
7780
fail("Queue.declare should have been rejected as not equivalent");
7881
}
7982

80-
// From amqp-0-9-1.xml, for "passive" property, "equivalent" rule:
81-
// "If not set and the queue exists, the server MUST check that the
82-
// existing queue has the same values for durable, exclusive,
83-
// auto-delete, and arguments fields. The server MUST respond with
84-
// Declare-Ok if the requested queue matches these fields, and MUST
85-
// raise a channel exception if not."
83+
/** From amqp-0-9-1.xml, for "passive" property, "equivalent" rule:
84+
* "If not set and the queue exists, the server MUST check that the
85+
* existing queue has the same values for durable, exclusive,
86+
* auto-delete, and arguments fields. The server MUST respond with
87+
* Declare-Ok if the requested queue matches these fields, and MUST
88+
* raise a channel exception if not."
89+
*/
8690
public void testQueueEquivalence() throws IOException {
8791
String q = "queue";
8892
channel.queueDeclare(q, false, false, false, null);
@@ -154,4 +158,13 @@ public void testExclusiveGoesWithConnection() throws IOException {
154158
verifyQueueMissing(name);
155159
}
156160

161+
public void testArgumentArrays() throws Exception {
162+
Map<String, Object> args = new HashMap<String, Object>();
163+
args.put("my-key", new String[]{"foo", "bar", "baz"});
164+
String queueName = "argumentArraysQueue";
165+
channel.queueDeclare(queueName, true, true, false, args).getQueue();
166+
args = new HashMap<String, Object>();
167+
args.put("my-key", Arrays.asList(new String[]{"foo", "bar", "baz"}));
168+
verifyQueueExists(queueName);
169+
}
157170
}

0 commit comments

Comments
 (0)