ServiceBindingMetadata new1 = new ServiceBindingMetadata(B, A, "192.168.0.22", 1, false, true);
store.addServiceBinding(new1);
InetAddress address = InetAddress.getByName("192.168.0.22");
ServiceBinding got = store.getServiceBinding(A, B, A);
assertEquals(getServiceBinding(new1, newSetA), got);
assertEquals(11, got.getPort());
assertEquals("192.168.0.22", got.getHostName());
assertEquals(address, got.getBindAddress());
got = store.getServiceBinding(B, B, A);
assertEquals(getServiceBinding(new1, newSetB), got);
assertEquals(21, got.getPort());
assertEquals("192.168.0.22", got.getHostName());
assertEquals(address, got.getBindAddress());
got = store.getServiceBinding(C, B, A);
assertEquals(getServiceBinding(new1, newSetC), got);
assertEquals(31, got.getPort());
assertEquals("192.168.0.22", got.getHostName());
assertEquals(address, got.getBindAddress());
ServiceBindingMetadata new2 = new ServiceBindingMetadata(B, A, "localhost", 2, false, false);
try
{
store.addServiceBinding(new2);
fail("duplicate add succeeded");
}
catch (DuplicateServiceException good) {}
ServiceBindingMetadata new3 = new ServiceBindingMetadata(C, C, null, 3, false, false);
store.addServiceBinding(new3);
got = store.getServiceBinding(A, C, C);
assertEquals(getServiceBinding(new3, newSetA), got);
assertEquals(13, got.getPort());
assertNull(got.getHostName());
assertEquals(InetAddress.getByName(null), got.getBindAddress());
got = store.getServiceBinding(B, C, C);
assertEquals(getServiceBinding(new3, newSetB), got);
assertEquals(23, got.getPort());
assertEquals("localhost", got.getHostName());
assertEquals(InetAddress.getByName("localhost"), got.getBindAddress());
got = store.getServiceBinding(C, C, C);
assertEquals(getServiceBinding(new3, newSetC), got);
assertEquals(33, got.getPort());
assertEquals("192.168.0.10", got.getHostName());
assertEquals(InetAddress.getByName("192.168.0.10"), got.getBindAddress());
}