Skip to content

Commit 6a71afb

Browse files
author
Matthias Radestock
committed
merge bug20152 into default
2 parents 6cc18e8 + 70c7c02 commit 6a71afb

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed

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

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.io.IOException;
3838
import java.util.List;
3939
import java.util.ArrayList;
40+
import java.util.Hashtable;
4041

4142
public class Routing extends BrokerTestCase
4243
{
@@ -164,6 +165,58 @@ public void testTopicRouting() throws Exception {
164165
}
165166
}
166167

168+
public void testHeadersRouting() throws Exception {
169+
Hashtable<String, Object> spec = new Hashtable<String, Object>();
170+
spec.put("h1", "12345");
171+
spec.put("h2", "bar");
172+
// See bug 20154: no current way to add a "Void"-typed spec pattern.
173+
spec.put("x-match", "all");
174+
channel.queueBind(Q1, "amq.match", "", spec);
175+
spec.put("x-match", "any");
176+
channel.queueBind(Q2, "amq.match", "", spec);
177+
178+
AMQP.BasicProperties props = new AMQP.BasicProperties();
179+
180+
channel.basicPublish("amq.match", "", null, "0".getBytes());
181+
channel.basicPublish("amq.match", "", props, "0b".getBytes());
182+
183+
props.headers = new Hashtable<String, Object>();
184+
props.headers.put("h1", "12345");
185+
channel.basicPublish("amq.match", "", props, "1".getBytes());
186+
187+
props.headers = new Hashtable<String, Object>();
188+
props.headers.put("h1", 12345);
189+
channel.basicPublish("amq.match", "", props, "1b".getBytes());
190+
191+
props.headers = new Hashtable<String, Object>();
192+
props.headers.put("h2", "bar");
193+
channel.basicPublish("amq.match", "", props, "2".getBytes());
194+
195+
props.headers = new Hashtable<String, Object>();
196+
props.headers.put("h1", "12345");
197+
props.headers.put("h2", "bar");
198+
channel.basicPublish("amq.match", "", props, "3".getBytes());
199+
200+
props.headers = new Hashtable<String, Object>();
201+
props.headers.put("h1", "12345");
202+
props.headers.put("h2", "quux");
203+
channel.basicPublish("amq.match", "", props, "4".getBytes());
204+
205+
props.headers = new Hashtable<String, Object>();
206+
props.headers.put("h1", "zot");
207+
props.headers.put("h2", "quux");
208+
channel.basicPublish("amq.match", "", props, "5".getBytes());
209+
210+
checkGet(Q1, true); // 3
211+
checkGet(Q1, false);
212+
213+
checkGet(Q2, true); // 1
214+
checkGet(Q2, true); // 2
215+
checkGet(Q2, true); // 3
216+
checkGet(Q2, true); // 4
217+
checkGet(Q2, false);
218+
}
219+
167220
public void testUnbind() throws Exception {
168221
AMQP.Queue.DeclareOk ok = channel.queueDeclare();
169222
String queue = ok.getQueue();

0 commit comments

Comments
 (0)