// =====================================================================
// Test Expectations
// =====================================================================
ServiceHandler factoryHandler =
new ManagedServiceFactoryHandler(manager);
// Register a ManagedServiceFactory before a suitable configuration
// has been created.
factoryHandler.serviceRegistered(unauthorizedFactoryReferenceMock);
// Attempt to register another factory for the same pid from a
// different bundle. This should fail and log a warning. Then make sure
// that the other service listener events do not fail.
factoryHandler.serviceRegistered(attackingFactoryReferenceMock);
factoryHandler.serviceModified(attackingFactoryReferenceMock);
factoryHandler.serviceUnregistering(attackingFactoryReferenceMock);
// Create a couple of factory configurations.
Configuration fc1_1 =
authorizedAdmin.createFactoryConfiguration(FACTORY_PID1, null);
fc1_1.update(new Hashtable());
checkLocationBinding(PREFIX + "a", UNAUTHORIZED_BUNDLE_LOCATION);
Configuration fc1_2 =
authorizedAdmin.createFactoryConfiguration(FACTORY_PID1, null);
fc1_2.update(new Hashtable());
checkLocationBinding(PREFIX + "b", UNAUTHORIZED_BUNDLE_LOCATION);
Configuration fc1_3 =
authorizedAdmin.createFactoryConfiguration(FACTORY_PID1,
UNAUTHORIZED_BUNDLE_LOCATION);
fc1_3.update(new Hashtable());
checkLocationBinding(PREFIX + "c", UNAUTHORIZED_BUNDLE_LOCATION);
// Check to see if the information has been correctly persisted.
checkPersistedConfigurations(
new InternalConfiguration[]{
new ConfigurationImpl(PREFIX + "a", FACTORY_PID1, null,
null, new CaseInsensitiveDictionary()),
new ConfigurationImpl(PREFIX + "b", FACTORY_PID1, null,
null, new CaseInsensitiveDictionary()),
new ConfigurationImpl(PREFIX + "c", FACTORY_PID1, null,
UNAUTHORIZED_BUNDLE_LOCATION,
new CaseInsensitiveDictionary()),
});
// Delete a factory configuration.
fc1_2.delete();
// The ManagedServiceFactory service has changed.
factoryHandler.serviceModified(unauthorizedFactoryReferenceMock);
// The ManagedServiceFactory service has unregistered.
factoryHandler.serviceUnregistering(unauthorizedFactoryReferenceMock);
// Make sure that the configurations that were created without any
// specific bundle location and have not since been deleted have
// reverted to null.
checkLocationBinding(PREFIX + "a", null);
// Reregister another ManagedServiceFactory with the same PID but from
// a different bundle.
factoryHandler.serviceRegistered(attackingFactoryReferenceMock);
// Check to see if the information has been correctly persisted.
checkPersistedConfigurations(
new InternalConfiguration[]{
new ConfigurationImpl(PREFIX + "a", FACTORY_PID1, null,