ProtocolData origTransport = origConfig[0];
assertNotNull(origTransport);
ProtocolParameter[] origParams = origTransport.getParametersAsArray();
ProtocolParameter[] newParams = origParams.clone();
ProtocolData newTransport = new ProtocolData(origTransport.getProtocolName(), origTransport.getClassName(), newParams);
ProtocolParameter overrideParam = new ProtocolParameter("max_bundle_size", "50000");
newTransport.override(new ProtocolParameter[]{overrideParam});
ProtocolData[] newConfig = origConfig.clone();
newConfig[0] = newTransport;
ProtocolStackConfigInfo updated = new ProtocolStackConfigInfo(unshared1.getName(), unshared1.getDescription(), newConfig);
Map<String, ProtocolStackConfigInfo> newMap = new HashMap<String, ProtocolStackConfigInfo>(origMap);
newMap.put("unshared1", updated);
ProtocolData[] addedConfig = origConfig.clone();
ProtocolStackConfigInfo added = new ProtocolStackConfigInfo("added", "added", addedConfig);
newMap.put("added", added);
assertTrue(newMap.containsKey("shared2"));
newMap.remove("shared2");
factory.setProtocolStackConfigurations(newMap);
if (startBeforeOverride == false)
{
factory.create();
factory.start();
}
Map<String, ProtocolStackConfigInfo> reread = factory.getProtocolStackConfigurations();
origKeys.remove("shared2");
origKeys.add("added");
assertEquals(origKeys, reread.keySet());
ProtocolStackConfigInfo addedInfo = reread.get("added");
assertEquals("added", addedInfo.getName());
assertEquals("added", addedInfo.getDescription());
ProtocolData[] readAdded = addedInfo.getConfiguration();
assertEquals(addedConfig.length, readAdded.length);
for (int i = 0; i < readAdded.length; i++)
{
assertEquals(addedConfig[i], readAdded[i]);
ProtocolParameter[] inputParams = addedConfig[i].getParametersAsArray();
ProtocolParameter[] outputParams = readAdded[i].getParametersAsArray();
assertEquals(inputParams.length, outputParams.length);
@SuppressWarnings("unchecked")
Map<String, ProtocolParameter> paramMap = readAdded[i].getParameters();
for (int j = 0; j < inputParams.length; j++)
{
ProtocolParameter param = paramMap.get(inputParams[j].getName());
assertNotNull(param);
assertEquals(inputParams[j].getValue(), param.getValue());
}
}
ProtocolStackConfigInfo updatedInfo = reread.get("unshared1");
assertEquals("unshared1", updatedInfo.getName());
ProtocolData[] readUpdated = updatedInfo.getConfiguration();
assertEquals(origConfig.length, readUpdated.length);
for (int i = 0; i < readUpdated.length; i++)
{
assertEquals(origConfig[i], readUpdated[i]);
ProtocolParameter[] inputParams = origConfig[i].getParametersAsArray();
ProtocolParameter[] outputParams = readUpdated[i].getParametersAsArray();
assertEquals(inputParams.length, outputParams.length);
@SuppressWarnings("unchecked")
Map<String, ProtocolParameter> paramMap = readUpdated[i].getParameters();
for (int j = 0; j < inputParams.length; j++)
{
String name = inputParams[j].getName();
ProtocolParameter param = paramMap.get(name);
assertNotNull(param);
if ("max_bundle_size".equals(name))
{
assertEquals("50000", param.getValue());
}
else
{
assertEquals(inputParams[j].getValue(), param.getValue());
}
}
}
// Validate that the overrides actuall affect created channels