// =====================================================================
// Set Expectations
// =====================================================================
Dictionary dictionary = new CaseInsensitiveDictionary();
dictionary.put("a", "b");
InternalConfiguration internalConfiguration =
new ConfigurationImpl("pid", null, null,
AUTHORIZED_BUNDLE_LOCATION, null);
storeMock.expects.createConfiguration(
"pid", AUTHORIZED_BUNDLE_LOCATION)
.returns(internalConfiguration);
storeMock.expects.update(internalConfiguration);
dispatcherMock.expects
.managedServiceConfigurationUpdated(EMPTY_REFERENCES,
new ConfigurationSnapshot("pid", dictionary));
storeMock.expects.remove(internalConfiguration);
// =====================================================================
// Test Expectations
// =====================================================================
Configuration configuration = authorizedAdmin.getConfiguration("pid");
// Make sure that the configuration can be retrieved before deletion.
configuration.update(dictionary);
Configuration[] configurations;
configurations = authorizedAdmin.listConfigurations(null);
assertCorrectConfigurations(new Configuration[]{
configuration
}, configurations);
// Delete the configuration.
configuration.delete();
// Make sure that the configuration cannot be retrieved after
// deletion.
configurations = authorizedAdmin.listConfigurations(null);
assertCorrectConfigurations(null, configurations);
try {
configuration.delete();
fail("Failed to check delete state");
} catch (IllegalStateException expected) {
assertEquals("Configuration 'pid' has been deleted",
expected.getMessage());
}
try {
configuration.getBundleLocation();
fail("Failed to check delete state");
} catch (IllegalStateException expected) {
assertEquals("Configuration 'pid' has been deleted",
expected.getMessage());
}
try {
configuration.getFactoryPid();
fail("Failed to check delete state");
} catch (IllegalStateException expected) {
assertEquals("Configuration 'pid' has been deleted",
expected.getMessage());
}
try {
configuration.getPid();
fail("Failed to check delete state");
} catch (IllegalStateException expected) {
assertEquals("Configuration 'pid' has been deleted",
expected.getMessage());
}
try {
configuration.getProperties();
fail("Failed to check delete state");
} catch (IllegalStateException expected) {
assertEquals("Configuration 'pid' has been deleted",
expected.getMessage());
}
try {
configuration.setBundleLocation("blah");
fail("Failed to check delete state");
} catch (IllegalStateException expected) {
assertEquals("Configuration 'pid' has been deleted",
expected.getMessage());
}
try {
configuration.update();
fail("Failed to check delete state");
} catch (IllegalStateException expected) {
assertEquals("Configuration 'pid' has been deleted",
expected.getMessage());
}
try {
configuration.update(new CaseInsensitiveDictionary());
fail("Failed to check delete state");
} catch (IllegalStateException expected) {
assertEquals("Configuration 'pid' has been deleted",
expected.getMessage());
}