ExternalPrincipalConfiguration extends ConfigurationBase implements PrincipalConfiguration { @NotNull @Override public String getName() { return NAME; } @SuppressWarnings("UnusedDeclaration")  ExternalPrincipalConfiguration();  ExternalPrincipalConfiguration(SecurityProvider securityProvider); @NotNull @Override PrincipalManager getPrincipalManager(Root root, NamePathMapper namePathMapper); @NotNull @Override PrincipalProvider getPrincipalProvider(Root root, NamePathMapper namePathMapper); @NotNull @Override String getName(); @NotNull @Override RepositoryInitializer getRepositoryInitializer(); @NotNull @Override List<? extends ValidatorProvider> getValidators(@NotNull String workspaceName, @NotNull Set<Principal> principals, @NotNull MoveTracker moveTracker); @NotNull @Override List<ProtectedItemImporter> getProtectedItemImporters(); @NotNull @Override List<ThreeWayConflictHandler> getConflictHandlers();  }
@Test public void testGetName() { assertEquals(PrincipalConfiguration.NAME, externalPrincipalConfiguration.getName()); enable(); assertEquals(PrincipalConfiguration.NAME, externalPrincipalConfiguration.getName()); }
@Ignore("TODO: mock doesn't reflect property-changes on the registration.") @Test public void testModifySyncHandler() { Dictionary<String, Object> enableProps = new Hashtable<>(ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, true)); Dictionary<String, Object> disableProps = new Hashtable<>(ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, false)); DefaultSyncHandler sh = new DefaultSyncHandler(); BundleContext bundleContext = context.bundleContext(); ServiceRegistration registration = bundleContext.registerService(DefaultSyncHandler.class.getName(), sh, disableProps); assertIsEnabled(externalPrincipalConfiguration, false); MockOsgi.modified(sh, bundleContext, enableProps); assertIsEnabled(externalPrincipalConfiguration, true); MockOsgi.modified(sh, bundleContext, disableProps); assertIsEnabled(externalPrincipalConfiguration, false); }
@Test public void testRemoveSyncHandler() { Dictionary<String, Object> enableProps = new Hashtable<>(ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, true)); Dictionary<String, Object> disableProps = new Hashtable<>(ImmutableMap.<String, Object>of(DefaultSyncConfigImpl.PARAM_USER_DYNAMIC_MEMBERSHIP, false)); DefaultSyncHandler sh = new DefaultSyncHandler(); BundleContext bundleContext = context.bundleContext(); ServiceRegistration registration1 = bundleContext.registerService(SyncHandler.class.getName(), sh, enableProps); ServiceRegistration registration2 = bundleContext.registerService(SyncHandler.class.getName(), sh, enableProps); ServiceRegistration registration3 = bundleContext.registerService(SyncHandler.class.getName(), sh, disableProps); assertIsEnabled(externalPrincipalConfiguration, true); registration2.unregister(); assertIsEnabled(externalPrincipalConfiguration, true); registration1.unregister(); assertIsEnabled(externalPrincipalConfiguration, false); registration3.unregister(); assertIsEnabled(externalPrincipalConfiguration, false); }