{
IndexedArray result = new IndexedArray();
// First confirm the expected binding set is there
ManagedProperty prop = properties.get("bindingSets");
assertNotNull("Missing property bindingSets", prop);
MetaValue val = prop.getValue();
assertNotNull("property bindingSets has no value", val);
assertTrue("property bindingSets value is CollectionValue", val instanceof CollectionValue);
MetaValue[] elements = ((CollectionValue) val).getElements();
assertNotNull(elements);
assertEquals(numSets, elements.length);
result.array = elements;
boolean sawAdded = false;
for (int i = 0; i < elements.length; i++)
{
MetaValue mv = elements[i];
if ("ports-test".equals(getSimpleValue(mv, "name")))
{
sawAdded = true;
assertEquals("added binding set has correct defaultHostName",
"localhost", getSimpleValue(mv, "defaultHostName"));
assertEquals("added binding set has correct portOffset",
portOffset, getSimpleValue(mv, "portOffset", Integer.class).intValue());
MetaValue overVal = ((CompositeValue) mv).get("overrideBindings");
assertTrue(overVal instanceof CollectionValue);
MetaValue[] overrides = ((CollectionValue) overVal).getElements();
assertNotNull("added binding set has overrides", overrides);
assertEquals("added binding set has correct # of overrides", 1, overrides.length);
mv = overrides[0];
assertEquals("added binding set has AddedOverrideBinding",
"AddedOverrideBinding", getSimpleValue(mv, "serviceName"));
assertNull("AddedOverrideBinding has null bindingName",
getSimpleValue(mv, "bindingName"));
assertEquals("AddedOverrideBinding has correct description",
"description", getSimpleValue(mv, "description"));
assertNull("AddedOverrideBinding has null hostName",
getSimpleValue(mv, "hostName"));
assertEquals("AddedOverrideBinding has correct port",
overrideBindingPort, getSimpleValue(mv, "port", Integer.class).intValue());
assertFalse("AddedOverrideBinding has correct fixedHostName",
getSimpleValue(mv, "fixedHostName", Boolean.class).booleanValue());
assertFalse("AddedOverrideBinding has correct fixedPort",
getSimpleValue(mv, "fixedPort", Boolean.class).booleanValue());
result.index = i;
break;
}
}
assertTrue(sawAdded);
// Next validate the expected actual bindings are there
prop = properties.get("serviceBindings");
assertNotNull("Missing property serviceBindings", prop);
val = prop.getValue();
assertNotNull("property serviceBindings has no value", val);
assertTrue("property serviceBindings value is Composite", val instanceof CompositeValue);
val = ((CompositeValue) val).get("ports-test");
assertNotNull(val);
assertTrue("property serviceBindings value is CollectionValue", val instanceof CollectionValue);