Search in sources :

Example 31 with BrokerService

use of org.apache.activemq.broker.BrokerService in project camel by apache.

the class AMQPRouteTest method beforeClass.

@BeforeClass
public static void beforeClass() throws Exception {
    broker = new BrokerService();
    broker.setPersistent(false);
    broker.addConnector("amqp://0.0.0.0:" + amqpPort);
    broker.start();
    System.setProperty(AMQP_PORT, amqpPort + "");
}
Also used : BrokerService(org.apache.activemq.broker.BrokerService) BeforeClass(org.junit.BeforeClass)

Example 32 with BrokerService

use of org.apache.activemq.broker.BrokerService in project spring-framework by spring-projects.

the class ReactorNettyTcpStompClientTests method setUp.

@Before
public void setUp() throws Exception {
    logger.debug("Setting up before '" + this.testName.getMethodName() + "'");
    int port = SocketUtils.findAvailableTcpPort(61613);
    this.activeMQBroker = new BrokerService();
    this.activeMQBroker.addConnector("stomp://127.0.0.1:" + port);
    this.activeMQBroker.setStartAsync(false);
    this.activeMQBroker.setPersistent(false);
    this.activeMQBroker.setUseJmx(false);
    this.activeMQBroker.getSystemUsage().getMemoryUsage().setLimit(1024 * 1024 * 5);
    this.activeMQBroker.getSystemUsage().getTempUsage().setLimit(1024 * 1024 * 5);
    this.activeMQBroker.start();
    ThreadPoolTaskScheduler taskScheduler = new ThreadPoolTaskScheduler();
    taskScheduler.afterPropertiesSet();
    this.client = new ReactorNettyTcpStompClient("127.0.0.1", port);
    this.client.setMessageConverter(new StringMessageConverter());
    this.client.setTaskScheduler(taskScheduler);
}
Also used : StringMessageConverter(org.springframework.messaging.converter.StringMessageConverter) BrokerService(org.apache.activemq.broker.BrokerService) ThreadPoolTaskScheduler(org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler) Before(org.junit.Before)

Example 33 with BrokerService

use of org.apache.activemq.broker.BrokerService in project hevelian-activemq by Hevelian.

the class WebBrokerInitializerTest method contextDestroyed_excDuringWaitUntilStopped_ExcThrown.

@Test(expected = BrokerLifecycleException.class)
public void contextDestroyed_excDuringWaitUntilStopped_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).waitUntilStopped();
    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 34 with BrokerService

use of org.apache.activemq.broker.BrokerService in project hevelian-activemq by Hevelian.

the class WebBrokerInitializerTest method contextInitialized.

@Test
public void contextInitialized() throws Exception {
    ServletContext sc = mock(ServletContext.class);
    BrokerService broker = mock(BrokerService.class);
    doReturn(true).when(broker).waitUntilStarted();
    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 35 with BrokerService

use of org.apache.activemq.broker.BrokerService in project hevelian-activemq by Hevelian.

the class WebBrokerInitializerTest method contextDestroyed_brokerNotStarted_doNothing.

@Test
public void contextDestroyed_brokerNotStarted_doNothing() throws Exception {
    ServletContext sc = mock(ServletContext.class);
    BrokerService broker = mock(BrokerService.class);
    doReturn(false).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));
    verify(broker, never()).stop();
}
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