Search in sources :

Example 21 with IFuture

use of org.eclipse.equinox.concurrent.future.IFuture in project ecf by eclipse.

the class DiscoveryTest method testGetAsyncServiceTypes.

/**
 * Test method for
 * {@link org.eclipse.ecf.discovery.IDiscoveryLocator#getAsyncServiceTypes()}.
 * @throws ContainerConnectException
 * @throws InterruptedException
 * @throws OperationCanceledException
 */
public void testGetAsyncServiceTypes() throws ContainerConnectException, OperationCanceledException, InterruptedException {
    registerService();
    final IFuture aFuture = discoveryLocator.getAsyncServiceTypes();
    final Object object = aFuture.get();
    assertTrue(object instanceof IServiceTypeID[]);
    final IServiceTypeID[] services = (IServiceTypeID[]) object;
    // just expect one event as the implementation filters dupes
    assertTrue("Found: " + services.length + Arrays.asList(services), services.length == 1);
    for (int i = 0; i < services.length; i++) {
        IServiceTypeID iServiceTypeId = services[i];
        if (serviceInfo.getServiceID().getServiceTypeID().equals(iServiceTypeId)) {
            return;
        }
    }
    fail("Self registered service not found");
}
Also used : IServiceTypeID(org.eclipse.ecf.discovery.identity.IServiceTypeID) IFuture(org.eclipse.equinox.concurrent.future.IFuture)

Aggregations

IFuture (org.eclipse.equinox.concurrent.future.IFuture)21 IRemoteService (org.eclipse.ecf.remoteservice.IRemoteService)10 IRemoteServiceContainerAdapter (org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter)6 IRemoteServiceListener (org.eclipse.ecf.remoteservice.IRemoteServiceListener)6 IRemoteServiceReference (org.eclipse.ecf.remoteservice.IRemoteServiceReference)6 IRemoteServiceEvent (org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent)6 IRemoteServiceRegisteredEvent (org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent)6 IConcatService (org.eclipse.ecf.tests.remoteservice.IConcatService)6 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)4 IServiceInfo (org.eclipse.ecf.discovery.IServiceInfo)3 ExecutionException (java.util.concurrent.ExecutionException)2 IHelloAsync (org.eclipse.ecf.examples.remoteservices.hello.IHelloAsync)2 IAsyncCallback (org.eclipse.ecf.remoteservice.IAsyncCallback)2 ServiceReference (org.osgi.framework.ServiceReference)2 IServiceTypeID (org.eclipse.ecf.discovery.identity.IServiceTypeID)1 HelloMessage (org.eclipse.ecf.examples.remoteservices.hello.HelloMessage)1 IHello (org.eclipse.ecf.examples.remoteservices.hello.IHello)1 IRemoteServiceProxy (org.eclipse.ecf.remoteservice.IRemoteServiceProxy)1 JSONObject (org.json.JSONObject)1 InvalidSyntaxException (org.osgi.framework.InvalidSyntaxException)1