Search in sources :

Example 11 with FailedDTOHolder

use of org.apache.felix.http.base.internal.runtime.dto.FailedDTOHolder in project felix by apache.

the class HandlerRegistryTest method testInitialSetup.

@Test
public void testInitialSetup() {
    final FailedDTOHolder holder = new FailedDTOHolder();
    final ServletContextDTO dto = new ServletContextDTO();
    dto.serviceId = HttpServiceFactory.HTTP_SERVICE_CONTEXT_SERVICE_ID;
    assertFalse(registry.getRuntimeInfo(dto, holder));
    registry.init();
    assertTrue(registry.getRuntimeInfo(dto, holder));
    registry.shutdown();
    assertFalse(registry.getRuntimeInfo(dto, holder));
}
Also used : FailedDTOHolder(org.apache.felix.http.base.internal.runtime.dto.FailedDTOHolder) ServletContextDTO(org.osgi.service.http.runtime.dto.ServletContextDTO) Test(org.junit.Test)

Example 12 with FailedDTOHolder

use of org.apache.felix.http.base.internal.runtime.dto.FailedDTOHolder in project felix by apache.

the class FailureStateHandlerTest method testAddRemoveNoContext.

@Test
public void testAddRemoveNoContext() {
    final ServletInfo info = new ServletInfo("test", "/test", Collections.<String, String>emptyMap());
    final FailureStateHandler handler = new FailureStateHandler();
    handler.addFailure(info, DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
    final FailedDTOHolder holder = new FailedDTOHolder();
    handler.getRuntimeInfo(holder);
    assertEquals(1, holder.failedServletDTOs.size());
    assertEquals(DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE, holder.failedServletDTOs.get(0).failureReason);
    holder.failedServletDTOs.clear();
    handler.remove(info);
    handler.getRuntimeInfo(holder);
    assertEquals(0, holder.failedServletDTOs.size());
}
Also used : ServletInfo(org.apache.felix.http.base.internal.runtime.ServletInfo) FailedDTOHolder(org.apache.felix.http.base.internal.runtime.dto.FailedDTOHolder) Test(org.junit.Test)

Example 13 with FailedDTOHolder

use of org.apache.felix.http.base.internal.runtime.dto.FailedDTOHolder in project felix by apache.

the class FailureStateHandlerTest method testAddRemoveContext.

@Test
public void testAddRemoveContext() {
    final ServletInfo info1 = new ServletInfo("test", "/test", Collections.<String, String>emptyMap());
    final ServletInfo info2 = new ServletInfo("test", "/test", Collections.<String, String>emptyMap());
    final FailureStateHandler handler = new FailureStateHandler();
    handler.addFailure(info1, 1L, DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
    handler.addFailure(info2, 2L, DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE);
    final FailedDTOHolder holder = new FailedDTOHolder();
    handler.getRuntimeInfo(holder);
    assertEquals(2, holder.failedServletDTOs.size());
    assertEquals(DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE, holder.failedServletDTOs.get(0).failureReason);
    assertEquals(DTOConstants.FAILURE_REASON_SHADOWED_BY_OTHER_SERVICE, holder.failedServletDTOs.get(1).failureReason);
    assertContainsExactly(holder.failedServletDTOs, new long[] { 1L, 2L });
    handler.remove(info1, 1L);
    handler.remove(info2, 2L);
    holder.failedServletDTOs.clear();
    handler.getRuntimeInfo(holder);
    assertEquals(0, holder.failedServletDTOs.size());
}
Also used : ServletInfo(org.apache.felix.http.base.internal.runtime.ServletInfo) FailedDTOHolder(org.apache.felix.http.base.internal.runtime.dto.FailedDTOHolder) Test(org.junit.Test)

Aggregations

FailedDTOHolder (org.apache.felix.http.base.internal.runtime.dto.FailedDTOHolder)13 Test (org.junit.Test)12 ServletContextDTO (org.osgi.service.http.runtime.dto.ServletContextDTO)11 HttpServiceServletHandler (org.apache.felix.http.base.internal.handler.HttpServiceServletHandler)7 ServletHandler (org.apache.felix.http.base.internal.handler.ServletHandler)7 Servlet (javax.servlet.Servlet)5 ServletConfig (javax.servlet.ServletConfig)5 ServletInfo (org.apache.felix.http.base.internal.runtime.ServletInfo)3 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 ArrayList (java.util.ArrayList)1 Filter (javax.servlet.Filter)1 FilterConfig (javax.servlet.FilterConfig)1 ServletContextListener (javax.servlet.ServletContextListener)1 FilterHandler (org.apache.felix.http.base.internal.handler.FilterHandler)1 HttpServiceFilterHandler (org.apache.felix.http.base.internal.handler.HttpServiceFilterHandler)1 ListenerHandler (org.apache.felix.http.base.internal.handler.ListenerHandler)1 PreprocessorHandler (org.apache.felix.http.base.internal.handler.PreprocessorHandler)1 WhiteboardListenerHandler (org.apache.felix.http.base.internal.handler.WhiteboardListenerHandler)1