Skip to content

Commit 5965bad

Browse files
ansdacogoluegnes
authored andcommitted
Add tests for any-with-x and all-with-x
for x-match binding argument in headers exchange (cherry picked from commit 7e92c2d)
1 parent 8e0123f commit 5965bad

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ public class HeadersExchangeValidation extends BrokerTestCase {
4747

4848
arguments.put("x-match", "any");
4949
succeedBind(queue, arguments);
50+
51+
arguments.put("x-match", "all-with-x");
52+
succeedBind(queue, arguments);
53+
54+
arguments.put("x-match", "any-with-x");
55+
succeedBind(queue, arguments);
5056
}
5157

5258
private void failBind(String queue, HashMap<String, Object> arguments) {

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

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ private void checkGet(String queue, boolean messageExpected)
170170
spec.put("h1", "12345");
171171
spec.put("h2", "bar");
172172
spec.put("h3", null);
173+
spec.put("x-key-1", "bindings starting with x- get filtered out");
173174
spec.put("x-match", "all");
174175
channel.queueBind(Q1, "amq.match", "", spec);
175176
spec.put("x-match", "any");
@@ -226,6 +227,10 @@ private void checkGet(String queue, boolean messageExpected)
226227
map.put("h2", "quux");
227228
channel.basicPublish("amq.match", "", props.build(), "8".getBytes());
228229

230+
map.clear();
231+
map.put("x-key-1", "bindings starting with x- get filtered out");
232+
channel.basicPublish("amq.match", "", props.build(), "9".getBytes());
233+
229234
checkGet(Q1, true); // 4
230235
checkGet(Q1, false);
231236

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

248+
@Test public void headersWithXRouting() throws Exception {
249+
Map<String, Object> spec = new HashMap<String, Object>();
250+
spec.put("x-key-1", "value-1");
251+
spec.put("x-key-2", "value-2");
252+
spec.put("x-match", "all-with-x");
253+
channel.queueBind(Q1, "amq.match", "", spec);
254+
spec.put("x-match", "any-with-x");
255+
channel.queueBind(Q2, "amq.match", "", spec);
256+
257+
AMQP.BasicProperties.Builder props = new AMQP.BasicProperties.Builder();
258+
channel.basicPublish("amq.match", "", props.build(), "0".getBytes());
259+
260+
Map<String, Object> map = new HashMap<String, Object>();
261+
props.headers(map);
262+
263+
map.clear();
264+
map.put("x-key-1", "value-1");
265+
channel.basicPublish("amq.match", "", props.build(), "1".getBytes());
266+
267+
map.clear();
268+
map.put("x-key-1", "value-1");
269+
map.put("x-key-2", "value-2");
270+
channel.basicPublish("amq.match", "", props.build(), "2".getBytes());
271+
272+
map.clear();
273+
map.put("x-key-1", "value-1");
274+
map.put("x-key-2", "value-2");
275+
map.put("x-key-3", "value-3");
276+
channel.basicPublish("amq.match", "", props.build(), "3".getBytes());
277+
278+
checkGet(Q1, true); // 2
279+
checkGet(Q1, true); // 3
280+
checkGet(Q1, false);
281+
282+
checkGet(Q2, true); // 1
283+
checkGet(Q2, true); // 2
284+
checkGet(Q2, true); // 3
285+
checkGet(Q2, false);
286+
}
287+
243288
@Test public void basicReturn() throws IOException {
244289
channel.addReturnListener(makeReturnListener());
245290
returnCell = new BlockingCell<Integer>();

0 commit comments

Comments
 (0)