use of io.undertow.servlet.core.ApplicationListeners in project wildfly by wildfly.
the class UndertowContextTestCase method addSessionListener.
@Test
public void addSessionListener() throws ServletException {
HttpSessionListener listener = mock(HttpSessionListener.class);
ServletContext context = mock(ServletContext.class);
HttpSession session = mock(HttpSession.class);
ApplicationListeners listeners = new ApplicationListeners(Collections.<ManagedListener>emptyList(), context);
ArgumentCaptor<HttpSessionEvent> event = ArgumentCaptor.forClass(HttpSessionEvent.class);
when(this.deployment.getApplicationListeners()).thenReturn(listeners);
this.context.addSessionListener(listener);
listeners.start();
listeners.sessionCreated(session);
verify(listener).sessionCreated(event.capture());
assertSame(session, event.getValue().getSession());
event = ArgumentCaptor.forClass(HttpSessionEvent.class);
listeners.sessionDestroyed(session);
verify(listener).sessionDestroyed(event.capture());
assertSame(session, event.getValue().getSession());
}
use of io.undertow.servlet.core.ApplicationListeners in project wildfly by wildfly.
the class UndertowContextTestCase method addRequestListener.
@Test
public void addRequestListener() throws ServletException {
ServletRequestListener listener = mock(ServletRequestListener.class);
ServletContext context = mock(ServletContext.class);
ServletRequest request = mock(ServletRequest.class);
ApplicationListeners listeners = new ApplicationListeners(Collections.<ManagedListener>emptyList(), context);
ArgumentCaptor<ServletRequestEvent> event = ArgumentCaptor.forClass(ServletRequestEvent.class);
when(this.deployment.getApplicationListeners()).thenReturn(listeners);
this.context.addRequestListener(listener);
listeners.start();
listeners.requestInitialized(request);
verify(listener).requestInitialized(event.capture());
assertSame(request, event.getValue().getServletRequest());
assertSame(context, event.getValue().getServletContext());
event = ArgumentCaptor.forClass(ServletRequestEvent.class);
listeners.requestDestroyed(request);
verify(listener).requestDestroyed(event.capture());
assertSame(request, event.getValue().getServletRequest());
assertSame(context, event.getValue().getServletContext());
}
use of io.undertow.servlet.core.ApplicationListeners in project wildfly by wildfly.
the class UndertowContextTestCase method isStarted.
@Test
public void isStarted() throws ServletException {
ServletContext context = mock(ServletContext.class);
ApplicationListeners listeners = new ApplicationListeners(Collections.<ManagedListener>emptyList(), context);
when(this.deployment.getApplicationListeners()).thenReturn(listeners);
assertFalse(this.context.isStarted());
listeners.start();
assertTrue(this.context.isStarted());
listeners.stop();
assertFalse(this.context.isStarted());
}
Aggregations