ServiceAuthenticationHttpContext extends DefaultHttpContext { public void close() { if (authenticatorServiceTracker != null) { authenticatorServiceTracker.close(); authenticatorServiceTracker = null; } } ServiceAuthenticationHttpContext(final BundleContext bundleContext, final String authMode); @Override boolean handleSecurity(final HttpServletRequest request, final HttpServletResponse response); void close(); static boolean shouldBeUsed(String authMode);  }
@Test public void checkClose() throws Exception { BundleContext bundleContext = createBundleContext(); expect(bundleContext.getServiceReferences(eq(Authenticator.class.getName()), (String) isNull())).andReturn(null); bundleContext.removeServiceListener((ServiceListener) anyObject()); replay(bundleContext); ServiceAuthenticationHttpContext ctx = createContext(bundleContext, "service-any"); ctx.close(); }