use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class DiscoveryTest method testAddServiceListenerIServiceTypeIDIServiceListener.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#addServiceListener(org.eclipse.ecf.discovery.identity.IServiceTypeID, org.eclipse.ecf.discovery.IServiceListener)}.
* @throws ContainerConnectException
*/
public void testAddServiceListenerIServiceTypeIDIServiceListener() 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());
discoveryLocator.addServiceListener(serviceInfo.getServiceID().getServiceTypeID(), tsl);
addListenerRegisterAndWait(tsl, serviceInfo);
discoveryLocator.removeServiceListener(serviceInfo.getServiceID().getServiceTypeID(), tsl);
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 testAddServiceListenerIServiceListener.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#addServiceListener(org.eclipse.ecf.discovery.IServiceListener)}.
* @throws ContainerConnectException
*/
public void testAddServiceListenerIServiceListener() 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());
addServiceListener(tsl);
}
use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class DiscoveryTest method testGetServicesIServiceTypeID.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#getServices(org.eclipse.ecf.discovery.identity.IServiceTypeID)}.
* @throws ContainerConnectException
*/
public void testGetServicesIServiceTypeID() throws ContainerConnectException {
registerService();
final IServiceInfo[] serviceInfos = discoveryLocator.getServices(serviceInfo.getServiceID().getServiceTypeID());
assertTrue("IServiceInfo[] is empty", serviceInfos.length >= 1);
for (int i = 0; i < serviceInfos.length; i++) {
IServiceInfo iServiceInfo = serviceInfos[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 testAddServiceTypeListener.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#addServiceTypeListener(org.eclipse.ecf.discovery.IServiceTypeListener)}.
* @throws ContainerConnectException
*/
public void testAddServiceTypeListener() 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 TestServiceTypeListener testTypeListener = new TestServiceTypeListener(eventsToExpect);
discoveryLocator.addServiceTypeListener(testTypeListener);
synchronized (testTypeListener) {
// register a service which we expect the test listener to get notified of
registerService();
try {
testTypeListener.wait(waitTimeForProvider);
} catch (final InterruptedException e) {
Thread.currentThread().interrupt();
fail("Some discovery unrelated threading issues?");
}
}
discoveryLocator.removeServiceTypeListener(testTypeListener);
IContainerEvent[] event = testTypeListener.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);
}
use of org.eclipse.ecf.discovery.IServiceInfo in project ecf by eclipse.
the class DiscoveryTest method testUnregisterService.
/**
* Test method for
* {@link org.eclipse.ecf.discovery.IDiscoveryContainerAdapter#unregisterService(org.eclipse.ecf.discovery.IServiceInfo)}.
* @throws ContainerConnectException
*/
public void testUnregisterService() throws ContainerConnectException {
testRegisterService();
unregisterService();
final IServiceInfo[] services = discoveryLocator.getServices();
for (int i = 0; i < services.length; i++) {
final IServiceInfo service = services[i];
if (comparator.compare(service, serviceInfo) == 0) {
fail("Expected service to be not registered anymore");
}
}
}
Aggregations