Search in sources :

Example 1 with EventListenerRegistry

use of org.apache.felix.http.base.internal.registry.EventListenerRegistry in project felix by apache.

the class ServletContextImplTest method setUp.

@Before
public void setUp() {
    this.bundle = Mockito.mock(Bundle.class);
    ServletContext globalContext = new MockServletContext();
    this.httpContext = Mockito.mock(HttpContext.class);
    this.listener = new AttributeListener();
    final HandlerRegistry reg = new HandlerRegistry();
    reg.init();
    contextRegistry = reg.getRegistry(HttpServiceFactory.HTTP_SERVICE_CONTEXT_SERVICE_ID);
    final EventListenerRegistry eventReg = contextRegistry.getEventListenerRegistry();
    final ListenerInfo info = Mockito.mock(ListenerInfo.class);
    when(info.getListenerTypes()).thenReturn(new String[] { ServletContextAttributeListener.class.getName() });
    when(info.isListenerType(ServletContextAttributeListener.class.getName())).thenReturn(true);
    final ListenerHandler handler = Mockito.mock(ListenerHandler.class);
    when(handler.getListenerInfo()).thenReturn(info);
    when(handler.getContextServiceId()).thenReturn(HttpServiceFactory.HTTP_SERVICE_CONTEXT_SERVICE_ID);
    when(handler.getListener()).thenReturn(listener);
    when(handler.init()).thenReturn(-1);
    eventReg.addListeners(handler);
    this.context = new ServletContextImpl(this.bundle, globalContext, this.httpContext, false, contextRegistry);
}
Also used : ServletContextAttributeListener(javax.servlet.ServletContextAttributeListener) HandlerRegistry(org.apache.felix.http.base.internal.registry.HandlerRegistry) PerContextHandlerRegistry(org.apache.felix.http.base.internal.registry.PerContextHandlerRegistry) ListenerInfo(org.apache.felix.http.base.internal.runtime.ListenerInfo) Bundle(org.osgi.framework.Bundle) ServletContextImpl(org.apache.felix.http.base.internal.service.ServletContextImpl) HttpContext(org.osgi.service.http.HttpContext) ServletContext(javax.servlet.ServletContext) ServletContextAttributeListener(javax.servlet.ServletContextAttributeListener) ListenerHandler(org.apache.felix.http.base.internal.handler.ListenerHandler) EventListenerRegistry(org.apache.felix.http.base.internal.registry.EventListenerRegistry) Before(org.junit.Before)

Aggregations

ServletContext (javax.servlet.ServletContext)1 ServletContextAttributeListener (javax.servlet.ServletContextAttributeListener)1 ListenerHandler (org.apache.felix.http.base.internal.handler.ListenerHandler)1 EventListenerRegistry (org.apache.felix.http.base.internal.registry.EventListenerRegistry)1 HandlerRegistry (org.apache.felix.http.base.internal.registry.HandlerRegistry)1 PerContextHandlerRegistry (org.apache.felix.http.base.internal.registry.PerContextHandlerRegistry)1 ListenerInfo (org.apache.felix.http.base.internal.runtime.ListenerInfo)1 ServletContextImpl (org.apache.felix.http.base.internal.service.ServletContextImpl)1 Before (org.junit.Before)1 Bundle (org.osgi.framework.Bundle)1 HttpContext (org.osgi.service.http.HttpContext)1