Skip to content

Commit

Permalink
Merged bug 21055 into default.
Browse files Browse the repository at this point in the history
  • Loading branch information
Marek Majkowski committed Sep 21, 2009
2 parents 030511b + 80b9733 commit 22d265f
Showing 1 changed file with 70 additions and 50 deletions.
120 changes: 70 additions & 50 deletions test/src/com/rabbitmq/client/test/functional/Routing.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@
import java.io.IOException;
import java.util.List;
import java.util.ArrayList;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Map;

public class Routing extends BrokerTestCase
{
Expand Down Expand Up @@ -166,55 +167,74 @@ public void testTopicRouting() throws Exception {
}

public void testHeadersRouting() throws Exception {
Hashtable<String, Object> spec = new Hashtable<String, Object>();
spec.put("h1", "12345");
spec.put("h2", "bar");
// See bug 20154: no current way to add a "Void"-typed spec pattern.
spec.put("x-match", "all");
channel.queueBind(Q1, "amq.match", "", spec);
spec.put("x-match", "any");
channel.queueBind(Q2, "amq.match", "", spec);

AMQP.BasicProperties props = new AMQP.BasicProperties();

channel.basicPublish("amq.match", "", null, "0".getBytes());
channel.basicPublish("amq.match", "", props, "0b".getBytes());

props.setHeaders(new Hashtable<String, Object>());
props.getHeaders().put("h1", "12345");
channel.basicPublish("amq.match", "", props, "1".getBytes());

props.setHeaders(new Hashtable<String, Object>());
props.getHeaders().put("h1", 12345);
channel.basicPublish("amq.match", "", props, "1b".getBytes());

props.setHeaders(new Hashtable<String, Object>());
props.getHeaders().put("h2", "bar");
channel.basicPublish("amq.match", "", props, "2".getBytes());

props.setHeaders(new Hashtable<String, Object>());
props.getHeaders().put("h1", "12345");
props.getHeaders().put("h2", "bar");
channel.basicPublish("amq.match", "", props, "3".getBytes());

props.setHeaders(new Hashtable<String, Object>());
props.getHeaders().put("h1", "12345");
props.getHeaders().put("h2", "quux");
channel.basicPublish("amq.match", "", props, "4".getBytes());

props.setHeaders(new Hashtable<String, Object>());
props.getHeaders().put("h1", "zot");
props.getHeaders().put("h2", "quux");
channel.basicPublish("amq.match", "", props, "5".getBytes());

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

checkGet(Q2, true); // 1
checkGet(Q2, true); // 2
checkGet(Q2, true); // 3
checkGet(Q2, true); // 4
checkGet(Q2, false);
Map<String, Object> spec = new HashMap<String, Object>();
spec.put("h1", "12345");
spec.put("h2", "bar");
spec.put("h3", null);
spec.put("x-match", "all");
channel.queueBind(Q1, "amq.match", "", spec);
spec.put("x-match", "any");
channel.queueBind(Q2, "amq.match", "", spec);

AMQP.BasicProperties props = new AMQP.BasicProperties();

channel.basicPublish("amq.match", "", null, "0".getBytes());
channel.basicPublish("amq.match", "", props, "0b".getBytes());

props.setHeaders(new HashMap<String, Object>());
props.getHeaders().put("h1", "12345");
channel.basicPublish("amq.match", "", props, "1".getBytes());

props.setHeaders(new HashMap<String, Object>());
props.getHeaders().put("h1", 12345);
channel.basicPublish("amq.match", "", props, "1b".getBytes());

props.setHeaders(new HashMap<String, Object>());
props.getHeaders().put("h2", "bar");
channel.basicPublish("amq.match", "", props, "2".getBytes());

props.setHeaders(new HashMap<String, Object>());
props.getHeaders().put("h1", "12345");
props.getHeaders().put("h2", "bar");
channel.basicPublish("amq.match", "", props, "3".getBytes());

props.setHeaders(new HashMap<String, Object>());
props.getHeaders().put("h1", "12345");
props.getHeaders().put("h2", "bar");
props.getHeaders().put("h3", null);
channel.basicPublish("amq.match", "", props, "4".getBytes());

props.setHeaders(new HashMap<String, Object>());
props.getHeaders().put("h1", "12345");
props.getHeaders().put("h2", "quux");
channel.basicPublish("amq.match", "", props, "5".getBytes());

props.setHeaders(new HashMap<String, Object>());
props.getHeaders().put("h1", "zot");
props.getHeaders().put("h2", "quux");
props.getHeaders().put("h3", null);
channel.basicPublish("amq.match", "", props, "6".getBytes());

props.setHeaders(new HashMap<String, Object>());
props.getHeaders().put("h3", null);
channel.basicPublish("amq.match", "", props, "7".getBytes());

props.setHeaders(new HashMap<String, Object>());
props.getHeaders().put("h1", "zot");
props.getHeaders().put("h2", "quux");
channel.basicPublish("amq.match", "", props, "8".getBytes());

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

checkGet(Q2, true); // 1
checkGet(Q2, true); // 2
checkGet(Q2, true); // 3
checkGet(Q2, true); // 4
checkGet(Q2, true); // 5
checkGet(Q2, true); // 6
checkGet(Q2, true); // 7
checkGet(Q2, false);
}

}
Expand Down

0 comments on commit 22d265f

Please sign in to comment.