use of javax.servlet.ServletContextEvent 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));
}
use of javax.servlet.ServletContextEvent 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));
}
use of javax.servlet.ServletContextEvent in project hevelian-activemq by Hevelian.
the class WebBrokerInitializerTest method contextInitialized_excDuringBrokerCreate_ExcThrown.
@Test(expected = BrokerLifecycleException.class)
public void contextInitialized_excDuringBrokerCreate_ExcThrown() throws Exception {
ServletContext sc = mock(ServletContext.class);
WebBrokerInitializer i = spy(WebBrokerInitializer.class);
doThrow(new BrokerLifecycleException()).when(i).createBroker(sc);
i.contextInitialized(new ServletContextEvent(sc));
}
use of javax.servlet.ServletContextEvent 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();
}
use of javax.servlet.ServletContextEvent in project hevelian-activemq by Hevelian.
the class ServletContextHolderInitializerTest method contextInitialized.
@Test
public void contextInitialized() {
ServletContextHolderInitializer i = new ServletContextHolderInitializer();
ServletContext sc = Mockito.mock(ServletContext.class);
i.contextInitialized(new ServletContextEvent(sc));
assertEquals(sc, ServletContextHolder.getServletContext());
}
Aggregations