use of org.apache.activemq.broker.BrokerService in project beam by apache.
the class MqttIOTest method startBroker.
@Before
public void startBroker() throws Exception {
LOG.info("Finding free network port");
ServerSocket socket = new ServerSocket(0);
port = socket.getLocalPort();
socket.close();
LOG.info("Starting ActiveMQ brokerService on {}", port);
brokerService = new BrokerService();
brokerService.setDeleteAllMessagesOnStartup(true);
// use memory persistence for the test: it's faster and don't pollute test folder with KahaDB
brokerService.setPersistent(false);
brokerService.addConnector("mqtt://localhost:" + port);
brokerService.start();
brokerService.waitUntilStarted();
}
use of org.apache.activemq.broker.BrokerService in project ignite by apache.
the class IgniteJmsStreamerTest method beforeTest.
/**
* @throws Exception If failed.
*/
@Before
@SuppressWarnings("unchecked")
public void beforeTest() throws Exception {
grid().<Integer, String>getOrCreateCache(defaultCacheConfiguration());
broker = new BrokerService();
broker.setDeleteAllMessagesOnStartup(true);
broker.setPersistent(false);
broker.setPersistenceAdapter(null);
broker.setPersistenceFactory(null);
PolicyMap plcMap = new PolicyMap();
PolicyEntry plc = new PolicyEntry();
plc.setQueuePrefetch(1);
broker.setDestinationPolicy(plcMap);
broker.getDestinationPolicy().setDefaultEntry(plc);
broker.setSchedulerSupport(false);
broker.start(true);
connFactory = new ActiveMQConnectionFactory(BrokerRegistry.getInstance().findFirst().getVmConnectorURI());
}
use of org.apache.activemq.broker.BrokerService in project hevelian-activemq by Hevelian.
the class WebBrokerInitializerTest method contextInitialized_excDuringStart_ExcThrown.
@Test(expected = BrokerLifecycleException.class)
public void contextInitialized_excDuringStart_ExcThrown() throws Exception {
ServletContext sc = mock(ServletContext.class);
BrokerService broker = mock(BrokerService.class);
doThrow(new BrokerLifecycleException()).when(broker).start();
WebBrokerInitializer i = spy(WebBrokerInitializer.class);
doReturn(broker).when(i).createBroker(sc);
i.contextInitialized(new ServletContextEvent(sc));
}
use of org.apache.activemq.broker.BrokerService in project hevelian-activemq by Hevelian.
the class WebBrokerInitializerTest method contextDestroyed.
@Test
public void contextDestroyed() throws Exception {
ServletContext sc = mock(ServletContext.class);
BrokerService broker = mock(BrokerService.class);
doReturn(true).when(broker).isStarted();
doReturn(true).when(broker).waitUntilStarted();
WebBrokerInitializer i = spy(WebBrokerInitializer.class);
doReturn(broker).when(i).createBroker(sc);
i.contextInitialized(new ServletContextEvent(sc));
i.contextDestroyed(new ServletContextEvent(sc));
}
use of org.apache.activemq.broker.BrokerService in project hevelian-activemq by Hevelian.
the class WebBrokerInitializerTest method contextDestroyed_excDuringStop_ExcThrown.
@Test(expected = BrokerLifecycleException.class)
public void contextDestroyed_excDuringStop_ExcThrown() throws Exception {
ServletContext sc = mock(ServletContext.class);
BrokerService broker = mock(BrokerService.class);
doReturn(true).when(broker).isStarted();
doReturn(true).when(broker).waitUntilStarted();
doThrow(new BrokerLifecycleException()).when(broker).stop();
WebBrokerInitializer i = spy(WebBrokerInitializer.class);
doReturn(broker).when(i).createBroker(sc);
i.contextInitialized(new ServletContextEvent(sc));
i.contextDestroyed(new ServletContextEvent(sc));
}
Aggregations