Resource resource2 = newResource2;
try {
Subject overlord = LookupUtil.getSubjectManager().getOverlord();
Configuration configuration1 = new Configuration();
configuration1.put(new PropertySimple("foo", "1"));
configuration1.put(new PropertySimple("fail", "false"));
Configuration configuration2 = new Configuration();
configuration2.put(new PropertySimple("foo", "2"));
configuration2.put(new PropertySimple("fail", "false"));
/* begin simple checks */
PluginConfigurationUpdate update1 = configurationManager.updatePluginConfiguration(overlord,
resource1.getId(), configuration1);
assert update1.getErrorMessage() == null : "We weren't expecting a failure here";
PluginConfigurationUpdate update2 = configurationManager.updatePluginConfiguration(overlord,
resource2.getId(), configuration2);
assert update2.getErrorMessage() == null : "We weren't expecting a failure here";
Configuration updatedConfiguration1 = configurationManager.getPluginConfiguration(overlord,
resource1.getId());
Configuration updatedConfiguration2 = configurationManager.getPluginConfiguration(overlord,
resource2.getId());
assert updatedConfiguration1.equals(configuration1) : "configuration1 was: " + updatedConfiguration1 + ", "
+ "expected was: " + configuration1;
assert updatedConfiguration2.equals(configuration2) : "configuration2 was: " + updatedConfiguration2 + ", "
+ "expected was: " + configuration2;
/* end simple checks */
/* begin group configuration creation checks */
Configuration expectedGroupConfiguration = new Configuration();
expectedGroupConfiguration
.put(new PropertySimple("foo", GroupPluginConfigurationUpdate.MIXED_VALUES_MARKER));
expectedGroupConfiguration.put(new PropertySimple("fail", "false"));
List<Configuration> updatedConfigurations = Arrays.asList(new Configuration[] { updatedConfiguration1,
updatedConfiguration2 });
Configuration groupConfiguration = null;
/*
Configuration groupConfiguration = GroupPluginConfigurationUpdate
.getGroupConfiguration(updatedConfigurations);
*/
assert groupConfiguration.equals(expectedGroupConfiguration) : "group configuration was: "
+ groupConfiguration + ", " + "expected was: " + expectedGroupConfiguration;
/* end group configuration creation checks */
/* begin group modification */
Configuration groupConfigurationOverride = new Configuration();
PropertySimple propertySimple1 = new PropertySimple("foo", "3");
PropertySimple propertySimple2 = new PropertySimple("fail", "true");
groupConfigurationOverride.put(propertySimple1);
groupConfigurationOverride.put(propertySimple2);
// regardless of failures, semantics dictate that the new configuration should be persisted to the resource
Configuration expectedGroupConfigurationResults = new Configuration();
expectedGroupConfigurationResults.put(new PropertySimple("foo", "3")); // from groupConfigurationOverride
propertySimple1.setOverride(Boolean.TRUE);
if (failOnChildUpdates) {
expectedGroupConfigurationResults.put(new PropertySimple("fail", "true")); // from groupConfigurationOverride
propertySimple2.setOverride(Boolean.TRUE); // will make TestServices fail
} else {
expectedGroupConfigurationResults.put(new PropertySimple("fail", "false")); // from both resource's current configuration
propertySimple2.setOverride(Boolean.FALSE); // false is default, but setting explicitly for test clarity
}
Map<Integer, Configuration> memberConfigs = new HashMap<Integer, Configuration>();
memberConfigs.put(resource1.getId(), configuration1);
memberConfigs.put(resource2.getId(), configuration2);
int groupUpdateId = configurationManager.scheduleGroupPluginConfigurationUpdate(overlord,
compatibleGroup.getId(), memberConfigs);
// instead of sleeping, let's directly execute what would normally be scheduled
//configurationManager.completeGroupPluginConfigurationUpdate(groupUpdateId);
GroupPluginConfigurationUpdate update = configurationManager.getGroupPluginConfigurationById(groupUpdateId);
assert update != null : "Group plugin configuration update should not have been null";
int i = 0;
for (PluginConfigurationUpdate childUpdate : update.getConfigurationUpdates()) {
Configuration childUpdateConfiguration = childUpdate.getConfiguration();
assert childUpdateConfiguration.equals(expectedGroupConfigurationResults) : "new updateChildConfig["
+ i + "] was: " + childUpdateConfiguration + ", " + "expected was: "
+ expectedGroupConfigurationResults;
i++;
}
Configuration configurationAfterGroupUpdate1 = configurationManager.getPluginConfiguration(overlord,
resource1.getId());
Configuration configurationAfterGroupUpdate2 = configurationManager.getPluginConfiguration(overlord,
resource2.getId());
ConfigurationUpdateStatus expectedResultStatus = null;
if (failOnChildUpdates) {
expectedResultStatus = ConfigurationUpdateStatus.FAILURE;
} else {
expectedResultStatus = ConfigurationUpdateStatus.SUCCESS;
}
assert configurationAfterGroupUpdate1.equals(expectedGroupConfigurationResults) : "new config1 was: "
+ configurationAfterGroupUpdate1 + ", " + "expected was: " + expectedGroupConfigurationResults;
assert configurationAfterGroupUpdate2.equals(expectedGroupConfigurationResults) : "new config2 was: "
+ configurationAfterGroupUpdate2 + ", " + "expected was: " + expectedGroupConfigurationResults;
assert update.getStatus() == expectedResultStatus : "Group plugin configuration update "
+ "should have been marked as " + expectedResultStatus + ": " + update;