protected ActiveMQServer getJmsServer() throws Exception { return ActiveMQServerTestCase.servers.get(0).getActiveMQServer(); }
protected static void assertActiveConnectionsOnTheServer(final int expectedSize) throws Exception { ProxyAssertSupport.assertEquals(expectedSize, ActiveMQServerTestCase.servers.get(0).getActiveMQServer().getActiveMQServerControl().getConnectionCount()); }
protected boolean assertRemainingMessages(final int expected) throws Exception { String queueName = "Queue1"; Binding binding = servers.get(0).getActiveMQServer().getPostOffice().getBinding(SimpleString.toSimpleString(queueName)); if (binding != null && binding instanceof LocalQueueBinding) { ((LocalQueueBinding) binding).getQueue().flushExecutor(); } Long messageCount = null; for (int i = 0; i < 10; i++) { messageCount = servers.get(0).getMessageCountForQueue(queueName); if (messageCount.longValue() == expected) { break; } else { Thread.sleep(100); } } ProxyAssertSupport.assertEquals(expected, messageCount.intValue()); return expected == messageCount.intValue(); }
@Test public void testSendToQueueOnlyWhenTopicWithSameAddress() throws Exception { SimpleString addr = SimpleString.toSimpleString("testAddr"); EnumSet<RoutingType> supportedRoutingTypes = EnumSet.of(RoutingType.ANYCAST, RoutingType.MULTICAST); servers.get(0).getActiveMQServer().addAddressInfo(new AddressInfo(addr, supportedRoutingTypes)); servers.get(0).getActiveMQServer().createQueue(addr, RoutingType.ANYCAST, addr, null, false, false); Connection pconn = createConnection(); pconn.start(); Session ps = pconn.createSession(false, Session.AUTO_ACKNOWLEDGE); Queue queue = ps.createQueue(addr.toString()); Topic topic = ps.createTopic(addr.toString()); MessageConsumer queueConsumer = ps.createConsumer(queue); MessageConsumer topicConsumer = ps.createConsumer(topic); MessageProducer queueProducer = ps.createProducer(queue); queueProducer.send(ps.createMessage()); assertNotNull(queueConsumer.receive(1000)); assertNull(topicConsumer.receive(1000)); MessageProducer topicProducer = ps.createProducer(topic); topicProducer.send(ps.createMessage()); assertNull(queueConsumer.receive(1000)); assertNotNull(topicConsumer.receive(1000)); }