store.start();
Set<ServiceBindingMetadata> updatedSet =
new HashSet<ServiceBindingMetadata>(store.getStandardBindings());
assertEquals(3, updatedSet.size());
ServiceBindingMetadata updated = new ServiceBindingMetadata(AA);
updated.setPort(9999);
updated.setDescription("updated");
updatedSet.remove(AA);
updatedSet.add(updated);
updatedSet.add(BA);
assertEquals(4, updatedSet.size());
store.setStandardBindings(updatedSet);
Set<ServiceBindingMetadata> result = store.getStandardBindings();
assertNotNull(result);
assertTrue("has updated", result.contains(updated));
assertTrue("has AB", result.contains(AB));
assertTrue("has Anull", result.contains(Anull));
assertTrue("has BA", result.contains(BA));
for (ServiceBindingSet bindingSet : sbs)
{
String setName = bindingSet.getName();
Set<ServiceBinding> bindings = store.getServiceBindings(setName);
assertNotNull(bindings);
assertEquals(4, bindings.size());
Map<String, ServiceBinding> byFQN = new HashMap<String, ServiceBinding>();
for (ServiceBinding binding : bindings)
{
byFQN.put(binding.getFullyQualifiedName(), binding);
}
ServiceBinding aa = byFQN.get(updated.getFullyQualifiedName());
assertNotNull(aa);
assertEquals(setName + "/updated/serviceName", updated.getServiceName(), aa.getServiceName());
assertEquals(setName + "/updated/bindingName", updated.getBindingName(), aa.getBindingName());
assertEquals(setName + "/updated/description", updated.getDescription(), aa.getDescription());
assertEquals(setName + "/updated/hostName", bindingSet.getDefaultHostName(), aa.getHostName());
assertEquals(setName + "/updated/port", updated.getPort() + bindingSet.getPortOffset(), aa.getPort());
ServiceBinding ab = byFQN.get(AB.getFullyQualifiedName());
assertNotNull(aa);
assertEquals(setName + "/AB/serviceName", AB.getServiceName(), ab.getServiceName());
assertEquals(setName + "/AB/bindingName", AB.getBindingName(), ab.getBindingName());