Search in sources :

Example 11 with BrokerService

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();
}
Also used : ServerSocket(java.net.ServerSocket) BrokerService(org.apache.activemq.broker.BrokerService) Before(org.junit.Before)

Example 12 with BrokerService

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());
}
Also used : ActiveMQConnectionFactory(org.apache.activemq.ActiveMQConnectionFactory) PolicyMap(org.apache.activemq.broker.region.policy.PolicyMap) BrokerService(org.apache.activemq.broker.BrokerService) PolicyEntry(org.apache.activemq.broker.region.policy.PolicyEntry) Before(org.junit.Before)

Example 13 with BrokerService

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));
}
Also used : ServletContext(javax.servlet.ServletContext) BrokerService(org.apache.activemq.broker.BrokerService) ServletContextEvent(javax.servlet.ServletContextEvent) Test(org.junit.Test)

Example 14 with BrokerService

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));
}
Also used : ServletContext(javax.servlet.ServletContext) BrokerService(org.apache.activemq.broker.BrokerService) ServletContextEvent(javax.servlet.ServletContextEvent) Test(org.junit.Test)

Example 15 with BrokerService

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));
}
Also used : ServletContext(javax.servlet.ServletContext) BrokerService(org.apache.activemq.broker.BrokerService) ServletContextEvent(javax.servlet.ServletContextEvent) Test(org.junit.Test)

Aggregations

BrokerService (org.apache.activemq.broker.BrokerService)40 Test (org.junit.Test)13 URI (java.net.URI)10 ServletContext (javax.servlet.ServletContext)7 ServletContextEvent (javax.servlet.ServletContextEvent)7 MemoryPersistenceAdapter (org.apache.activemq.store.memory.MemoryPersistenceAdapter)5 Before (org.junit.Before)5 PersistenceAdapter (org.apache.activemq.store.PersistenceAdapter)4 JDBCPersistenceAdapter (org.apache.activemq.store.jdbc.JDBCPersistenceAdapter)4 Properties (java.util.Properties)3 ActiveMQConnectionFactory (org.apache.activemq.ActiveMQConnectionFactory)3 ServerSocket (java.net.ServerSocket)2 HashMap (java.util.HashMap)2 BrokerPlugin (org.apache.activemq.broker.BrokerPlugin)2 PolicyEntry (org.apache.activemq.broker.region.policy.PolicyEntry)2 PolicyMap (org.apache.activemq.broker.region.policy.PolicyMap)2 SystemUsage (org.apache.activemq.usage.SystemUsage)2 URISupport (org.apache.activemq.util.URISupport)2 MockEndpoint (org.apache.camel.component.mock.MockEndpoint)2 JDBCDataSource (org.hsqldb.jdbc.JDBCDataSource)2