public void execute(Runnable command) {
command.run();
}
};
ServiceScope localScope = new LocalScope(
executor,
Generators.randomBasedGenerator());
ServiceURL url1 = new ServiceURL("service:http://foo.bar/one");
ServiceURL url2 = new ServiceURL("service:http://foo.bar/two");
UUID reference1 = localScope.register(url1,
new HashMap<String, String>());
String serviceType = "service:http";
assertEquals(url1, localScope.getServiceReference(serviceType).getUrl());
localScope.register(url2, new HashMap<String, String>());
List<ServiceReference> references = localScope.getServiceReferences(serviceType,
"");
assertNotNull(references);
assertEquals(2, references.size());
Set<ServiceURL> urls = new HashSet<ServiceURL>();
urls.add(references.get(0).getUrl());
urls.add(references.get(1).getUrl());
assertTrue(urls.contains(url1));
assertTrue(urls.contains(url2));
localScope.unregister(reference1);
references = localScope.getServiceReferences(serviceType, "");
assertEquals(1, references.size());
assertEquals(url2, references.get(0).getUrl());
}