AdaptiveImageServletMappingConfigurationConsumer { protected void unbindAdaptiveImageServletConfigurationFactory(AdaptiveImageServletMappingConfigurationFactory configurationFactory, Map<String, ?> properties) { String servicePid = (String)properties.get(Constants.SERVICE_PID); configs.remove(servicePid); updateServletRegistrations(); }  @Activate void activate(ComponentContext componentContext, BundleContext bundleContext, Map<String, Object> config); @Deactivate void deactivate();  }
@Test public void testUnbindAdaptiveImageServletConfigurationFactory() throws Exception { AdaptiveImageServletMappingConfigurationConsumer configurationConsumer = new AdaptiveImageServletMappingConfigurationConsumer(); context.registerInjectActivateService(configurationConsumer); AdaptiveImageServletMappingConfigurationFactory configurationFactory = context.registerInjectActivateService(new AdaptiveImageServletMappingConfigurationFactory(), new Hashtable<String, Object>() {{ put(Constants.SERVICE_PID, "pid1"); put("resource.types", new String[]{"a/b/c"}); put("selectors", new String[]{"a"}); put("extensions", new String[]{"jpeg"}); put("defaultResizeWidth", AdaptiveImageServlet.DEFAULT_RESIZE_WIDTH); }}); Collection<ServiceReference<Servlet>> servletServiceReferences = context.bundleContext().getServiceReferences(Servlet.class, "(sling.servlet.resourceTypes=a/b/c)"); assertEquals(1, servletServiceReferences.size()); String pid = (String) Objects.requireNonNull(context.bundleContext().getServiceReference(AdaptiveImageServletMappingConfigurationFactory.class)) .getProperty(Constants.SERVICE_PID); configurationConsumer.unbindAdaptiveImageServletConfigurationFactory(configurationFactory, Collections.singletonMap(Constants.SERVICE_PID, pid)); servletServiceReferences = context.bundleContext().getServiceReferences(Servlet.class, "(sling.servlet.resourceTypes=a/b/c)"); assertEquals(0, servletServiceReferences.size()); }