SecurityProviderRegistration { @Deactivate public void deactivate() { ServiceRegistration registration; synchronized (this) { registration = this.registration; this.registration = null; this.registering = false; this.context = null; this.preconditions.clearPreconditions(); } if (registration != null) { registration.unregister(); } closeQuietly(closer); }  @Activate void activate(BundleContext context, Configuration configuration); @Modified void modified(Configuration configuration); @Deactivate void deactivate(); @Reference(name = "authenticationConfiguration") void bindAuthenticationConfiguration(AuthenticationConfiguration authenticationConfiguration); void unbindAuthenticationConfiguration(AuthenticationConfiguration authenticationConfiguration); @Reference(name = "privilegeConfiguration") void bindPrivilegeConfiguration(PrivilegeConfiguration privilegeConfiguration); void unbindPrivilegeConfiguration(PrivilegeConfiguration privilegeConfiguration); @Reference(name = "userConfiguration") void bindUserConfiguration(UserConfiguration userConfiguration); void unbindUserConfiguration(UserConfiguration userConfiguration); @Reference(name = "rootProvider") void bindRootProvider(RootProvider rootProvider); void unbindRootProvider(RootProvider rootProvider); @Reference(name = "treeProvider") void bindTreeProvider(TreeProvider treeProvider); void unbindTreeProvider(TreeProvider treeProvider); @Reference( name = "authorizationConfiguration", service = AuthorizationConfiguration.class, cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC ) void bindAuthorizationConfiguration(AuthorizationConfiguration configuration, Map<String, Object> properties); void unbindAuthorizationConfiguration(AuthorizationConfiguration configuration, Map<String, Object> properties); @Reference( name = "principalConfiguration", service = PrincipalConfiguration.class, cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC ) void bindPrincipalConfiguration(PrincipalConfiguration configuration, Map<String, Object> properties); void unbindPrincipalConfiguration(PrincipalConfiguration configuration, Map<String, Object> properties); @Reference( name = "tokenConfiguration", service = TokenConfiguration.class, cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC ) void bindTokenConfiguration(TokenConfiguration configuration, Map<String, Object> properties); void unbindTokenConfiguration(TokenConfiguration configuration, Map<String, Object> properties); @Reference( name = "authorizableNodeName", service = AuthorizableNodeName.class, cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC ) void bindAuthorizableNodeName(@NotNull ServiceReference serviceReference, @NotNull AuthorizableNodeName authorizableNodeName); void unbindAuthorizableNodeName(@NotNull ServiceReference serviceReference, @NotNull AuthorizableNodeName authorizableNodeName); @Reference( name = "authorizableActionProvider", service = AuthorizableActionProvider.class, cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC ) void bindAuthorizableActionProvider(@NotNull ServiceReference serviceReference, @NotNull AuthorizableActionProvider authorizableActionProvider); void unbindAuthorizableActionProvider(@NotNull ServiceReference serviceReference, @NotNull AuthorizableActionProvider authorizableActionProvider); @Reference( name = "restrictionProvider", service = RestrictionProvider.class, cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC ) void bindRestrictionProvider(@NotNull ServiceReference serviceReference, @NotNull RestrictionProvider restrictionProvider); void unbindRestrictionProvider(@NotNull ServiceReference serviceReference, @NotNull RestrictionProvider restrictionProvider); @Reference( name = "userAuthenticationFactory", service = UserAuthenticationFactory.class, cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC ) void bindUserAuthenticationFactory(@NotNull ServiceReference serviceReference, @NotNull UserAuthenticationFactory userAuthenticationFactory); void unbindUserAuthenticationFactory(@NotNull ServiceReference serviceReference, @NotNull UserAuthenticationFactory userAuthenticationFactory); @Reference( name = "aggregationFilters", service = AggregationFilter.class, cardinality = ReferenceCardinality.MULTIPLE, policy = ReferencePolicy.DYNAMIC) void bindAggregationFilter(@NotNull ServiceReference serviceReference, @NotNull AggregationFilter aggregationFilter); void unbindAggregationFilter(@NotNull ServiceReference serviceReference, @NotNull AggregationFilter aggregationFilter);  }
@Test public void testDeactivate() throws Exception { registration.activate(context.bundleContext(), configWithRequiredServiceIds("nodeName")); AuthorizableNodeName mock = mock(AuthorizableNodeName.class); ServiceReference sr = when(mock(ServiceReference.class).getProperty(SERVICE_PID)).thenReturn("nodeName").getMock(); registration.bindAuthorizableNodeName(sr, mock); SecurityProvider service = context.getService(SecurityProvider.class); assertNotNull(service); registration.deactivate(); assertNull(context.getService(SecurityProvider.class)); }