Map<String, Object> bindArgs = Collections.<String, Object>singletonMap(JMS_SELECTOR.toString(), "arg > 5");
createBinding(UUID.randomUUID(), bindingKey, queue, _exchange, bindArgs);
ServerMessage matchMsg1 = mock(ServerMessage.class);
AMQMessageHeader msgHeader1 = createMessageHeader(Collections.<String, Object>singletonMap("arg", 6));
when(matchMsg1.getMessageHeader()).thenReturn(msgHeader1);
routeMessage(matchMsg1, bindingKey, 1);
Assert.assertEquals("First message should be routed to queue", 1, queue.getQueueDepthMessages());
ServerMessage nonmatchMsg2 = mock(ServerMessage.class);
AMQMessageHeader msgHeader2 = createMessageHeader(Collections.<String, Object>singletonMap("arg", 5));
when(nonmatchMsg2.getMessageHeader()).thenReturn(msgHeader2);
routeMessage(nonmatchMsg2, bindingKey, 2);
Assert.assertEquals("Second message should not be routed to queue", 1, queue.getQueueDepthMessages());
ServerMessage nonmatchMsg3 = mock(ServerMessage.class);
AMQMessageHeader msgHeader3 = createMessageHeader(Collections.<String, Object>emptyMap());
when(nonmatchMsg3.getMessageHeader()).thenReturn(msgHeader3);
routeMessage(nonmatchMsg3, bindingKey, 3);
Assert.assertEquals("Third message should not be routed to queue", 1, queue.getQueueDepthMessages());
ServerMessage matchMsg4 = mock(ServerMessage.class);
AMQMessageHeader msgHeader4 = createMessageHeader(Collections.<String, Object>singletonMap("arg", 7));
when(matchMsg4.getMessageHeader()).thenReturn(msgHeader4);
routeMessage(matchMsg4, bindingKey, 4);
Assert.assertEquals("First message should be routed to queue", 2, queue.getQueueDepthMessages());
}