Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ public class HeadersExchangeValidation extends BrokerTestCase {

arguments.put("x-match", "any");
succeedBind(queue, arguments);

arguments.put("x-match", "all-with-x");
succeedBind(queue, arguments);

arguments.put("x-match", "any-with-x");
succeedBind(queue, arguments);
}

private void failBind(String queue, HashMap<String, Object> arguments) {
Expand Down
45 changes: 45 additions & 0 deletions src/test/java/com/rabbitmq/client/test/functional/Routing.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ private void checkGet(String queue, boolean messageExpected)
spec.put("h1", "12345");
spec.put("h2", "bar");
spec.put("h3", null);
spec.put("x-key-1", "bindings starting with x- get filtered out");
spec.put("x-match", "all");
channel.queueBind(Q1, "amq.match", "", spec);
spec.put("x-match", "any");
Expand Down Expand Up @@ -226,6 +227,10 @@ private void checkGet(String queue, boolean messageExpected)
map.put("h2", "quux");
channel.basicPublish("amq.match", "", props.build(), "8".getBytes());

map.clear();
map.put("x-key-1", "bindings starting with x- get filtered out");
channel.basicPublish("amq.match", "", props.build(), "9".getBytes());

checkGet(Q1, true); // 4
checkGet(Q1, false);

Expand All @@ -240,6 +245,46 @@ private void checkGet(String queue, boolean messageExpected)
checkGet(Q2, false);
}

@Test public void headersWithXRouting() throws Exception {
Map<String, Object> spec = new HashMap<String, Object>();
spec.put("x-key-1", "value-1");
spec.put("x-key-2", "value-2");
spec.put("x-match", "all-with-x");
channel.queueBind(Q1, "amq.match", "", spec);
spec.put("x-match", "any-with-x");
channel.queueBind(Q2, "amq.match", "", spec);

AMQP.BasicProperties.Builder props = new AMQP.BasicProperties.Builder();
channel.basicPublish("amq.match", "", props.build(), "0".getBytes());

Map<String, Object> map = new HashMap<String, Object>();
props.headers(map);

map.clear();
map.put("x-key-1", "value-1");
channel.basicPublish("amq.match", "", props.build(), "1".getBytes());

map.clear();
map.put("x-key-1", "value-1");
map.put("x-key-2", "value-2");
channel.basicPublish("amq.match", "", props.build(), "2".getBytes());

map.clear();
map.put("x-key-1", "value-1");
map.put("x-key-2", "value-2");
map.put("x-key-3", "value-3");
channel.basicPublish("amq.match", "", props.build(), "3".getBytes());

checkGet(Q1, true); // 2
checkGet(Q1, true); // 3
checkGet(Q1, false);

checkGet(Q2, true); // 1
checkGet(Q2, true); // 2
checkGet(Q2, true); // 3
checkGet(Q2, false);
}

@Test public void basicReturn() throws IOException {
channel.addReturnListener(makeReturnListener());
returnCell = new BlockingCell<Integer>();
Expand Down