Skip to content

Commit 26f66f1

Browse files
committed
Test headers exchange routing
1 parent 6cc18e8 commit 26f66f1

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

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

Lines changed: 46 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,51 @@ 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", "foo");
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+
props.headers = new Hashtable<String, Object>();
181+
props.headers.put("h1", "foo");
182+
channel.basicPublish("amq.match", "", props, "1".getBytes());
183+
184+
props.headers = new Hashtable<String, Object>();
185+
props.headers.put("h2", "bar");
186+
channel.basicPublish("amq.match", "", props, "2".getBytes());
187+
188+
props.headers = new Hashtable<String, Object>();
189+
props.headers.put("h1", "foo");
190+
props.headers.put("h2", "bar");
191+
channel.basicPublish("amq.match", "", props, "3".getBytes());
192+
193+
props.headers = new Hashtable<String, Object>();
194+
props.headers.put("h1", "foo");
195+
props.headers.put("h2", "quux");
196+
channel.basicPublish("amq.match", "", props, "4".getBytes());
197+
198+
props.headers = new Hashtable<String, Object>();
199+
props.headers.put("h1", "zot");
200+
props.headers.put("h2", "quux");
201+
channel.basicPublish("amq.match", "", props, "5".getBytes());
202+
203+
checkGet(Q1, true); // 3
204+
checkGet(Q1, false);
205+
206+
checkGet(Q2, true); // 1
207+
checkGet(Q2, true); // 2
208+
checkGet(Q2, true); // 3
209+
checkGet(Q2, true); // 4
210+
checkGet(Q2, false);
211+
}
212+
167213
public void testUnbind() throws Exception {
168214
AMQP.Queue.DeclareOk ok = channel.queueDeclare();
169215
String queue = ok.getQueue();

0 commit comments

Comments
 (0)