@Test
public void testFilterRequired() throws Exception {

    // Mock up the service references
    ServiceReference[] serviceReferences = {};
    // Mock up the bundle context
    BundleContext bundleContext = EasyMock.createNiceMock(BundleContext.class);
    EasyMock.expect(bundleContext.getServiceReferences(Filter.class.getName(),
                                                       "(org.apache.cxf.httpservice.filter=true)"))
        .andReturn(serviceReferences);
    EasyMock.replay(bundleContext);
    // Set up the secure http context
    httpContext = new SecurityDelegatingHttpContext(bundleContext, defaultHttpContext);
    httpContext.requireFilter = true;
    // Ensure that the httpContext doesn't allow the request to be processed, since there are no registered servlet
    // filters
    HttpServletRequest request = EasyMock.createNiceMock(HttpServletRequest.class);
    EasyMock.replay(request);
    HttpServletResponse response = EasyMock.createNiceMock(HttpServletResponse.class);
    EasyMock.replay(response);
    boolean requestAllowed = httpContext.handleSecurity(request, response);
    assertFalse(requestAllowed);
    // Ensure that the httpContext returns true if there is no requirement for registered servlet filters
    httpContext.requireFilter = false;
    requestAllowed = httpContext.handleSecurity(request, response);
    assertTrue(requestAllowed);
}