use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class DiscoveryServiceTest method testAddServiceListenerIServiceTypeIDIServiceListenerOSGiWildcards.
public void testAddServiceListenerIServiceTypeIDIServiceListenerOSGiWildcards() throws ContainerConnectException {
IServiceInfo[] services = discoveryLocator.getServices();
assertTrue("No Services must be registerd at this point " + (services.length == 0 ? "" : services[0].toString()), services.length == 0);
final TestServiceListener tsl = new TestServiceListener(eventsToExpect, discoveryLocator, getName(), getTestId());
Properties props = new Properties();
props.put("org.eclipse.ecf.discovery.services", "*");
props.put("org.eclipse.ecf.discovery.scopes", "*");
props.put("org.eclipse.ecf.discovery.protocols", "*");
props.put("org.eclipse.ecf.discovery.namingauthority", "*");
props.put(IDiscoveryLocator.CONTAINER_NAME, containerUnderTest);
BundleContext ctxt = Activator.getDefault().getContext();
ServiceRegistration registration = ctxt.registerService(IServiceListener.class.getName(), tsl, props);
addListenerRegisterAndWait(tsl, serviceInfo);
registration.unregister();
IContainerEvent[] event = tsl.getEvent();
assertNotNull("Test listener didn't receive discovery", event);
assertEquals("Test listener received unexpected amount of discovery events: \n\t" + Arrays.asList(event), eventsToExpect, event.length);
IServiceInfo serviceInfo2 = ((IServiceEvent) event[eventsToExpect - 1]).getServiceInfo();
assertTrue("IServiceInfo should match, expected:\n\t" + serviceInfo + " but:\n\t" + serviceInfo2, comparator.compare(serviceInfo2, serviceInfo) == 0);
}
use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class DiscoveryTest method testGetAsyncServicesIServiceTypeID.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServices(org.eclipse.ecf.discovery.identity.IServiceTypeID)}.
* @throws ContainerConnectException
* @throws InterruptedException
* @throws OperationCanceledException
*/
public void testGetAsyncServicesIServiceTypeID() throws ContainerConnectException, OperationCanceledException, InterruptedException {
registerService();
final IFuture aFuture = discoveryLocator.getAsyncServices(serviceInfo.getServiceID().getServiceTypeID());
final Object object = aFuture.get();
assertTrue(object instanceof IServiceInfo[]);
final IServiceInfo[] services = (IServiceInfo[]) object;
assertTrue("Found: " + services.length + Arrays.asList(services), services.length == eventsToExpect);
for (int i = 0; i < services.length; i++) {
IServiceInfo iServiceInfo = services[i];
if (comparator.compare(iServiceInfo, serviceInfo) == 0) {
return;
}
}
fail("Self registered service not found");
}
use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class DiscoveryTest method addServiceListener.
protected void addServiceListener(TestServiceListener serviceListener) {
discoveryLocator.addServiceListener(serviceListener);
addListenerRegisterAndWait(serviceListener, serviceInfo);
discoveryLocator.removeServiceListener(serviceListener);
IContainerEvent[] event = serviceListener.getEvent();
assertNotNull("Test listener didn't receive any discovery event", event);
assertEquals("Test listener received unexpected amount of discovery events: \n\t" + Arrays.asList(event), eventsToExpect, event.length);
IServiceInfo serviceInfo2 = ((IServiceEvent) event[eventsToExpect - 1]).getServiceInfo();
assertTrue("IServiceInfo should match, expected:\n\t" + serviceInfo + " but was \n\t" + serviceInfo2, comparator.compare(serviceInfo2, serviceInfo) == 0);
}
use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class DiscoveryTest method testGetAsyncServiceInfo.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServiceInfo(org.eclipse.ecf.discovery.identity.IServiceID)}.
* @throws InterruptedException
* @throws OperationCanceledException
* @throws ContainerConnectException
*/
public void testGetAsyncServiceInfo() throws OperationCanceledException, InterruptedException, ContainerConnectException {
registerService();
final IFuture aFuture = discoveryLocator.getAsyncServiceInfo(serviceInfo.getServiceID());
final Object object = aFuture.get();
assertTrue(object instanceof IServiceInfo);
final IServiceInfo info = (IServiceInfo) object;
assertTrue("IServiceInfo should match, expected:\n\t" + serviceInfo + " but:\n\t" + info, comparator.compare(info, serviceInfo) == 0);
}
use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class DiscoveryTest method testRegisterService.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#registerService(org.eclipse.ecf.discovery.IServiceInfo)}.
* @throws ContainerConnectException
*/
public void testRegisterService() throws ContainerConnectException {
registerService();
final IServiceInfo[] services = discoveryLocator.getServices();
assertTrue("IServiceInfo[] is empty", services.length >= 1);
for (int i = 0; i < services.length; i++) {
final IServiceInfo service = services[i];
if (comparator.compare(service, serviceInfo) == 0) {
return;
}
}
fail("Self registered service not found");
}
Aggregations