Search in sources :

Example 16 with IRemoteService

use of org.eclipse.ecf.remoteservice.IRemoteService in project ecf by eclipse.

the class TwitterRemoteServiceTest method testProxyCall.

public void testProxyCall() {
    IRemoteService restClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registration.getReference());
    try {
        IUserTimeline userTimeline = (IUserTimeline) restClientService.getProxy();
        IUserStatus[] statuses = userTimeline.getUserStatuses();
        assertNotNull(statuses);
    } catch (ECFException e) {
        fail("Could not contact the service");
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService)

Example 17 with IRemoteService

use of org.eclipse.ecf.remoteservice.IRemoteService in project ecf by eclipse.

the class TwitterRemoteServiceTest method testSyncCallWithCountParameter1.

public void testSyncCallWithCountParameter1() {
    IRemoteService restClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registration.getReference());
    try {
        Object result = restClientService.callSync(RestCallFactory.createRestCall(IUserTimeline.class.getName() + ".getUserStatuses", new String[] { "1" }));
        assertNotNull(result);
    } catch (ECFException e) {
        fail("Could not contact the service");
    }
}
Also used : ECFException(org.eclipse.ecf.core.util.ECFException) JSONObject(org.json.JSONObject) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService)

Example 18 with IRemoteService

use of org.eclipse.ecf.remoteservice.IRemoteService in project ecf by eclipse.

the class TwitterRemoteServiceTest method testAsyncCallWithListener.

public void testAsyncCallWithListener() throws Exception {
    IRemoteService restClientService = getRemoteServiceClientContainerAdapter(container).getRemoteService(registration.getReference());
    restClientService.callAsync(RestCallFactory.createRestCall(IUserTimeline.class.getName() + ".getUserStatuses"), new IRemoteCallListener() {

        public void handleEvent(IRemoteCallEvent event) {
            if (event instanceof IRemoteCallCompleteEvent) {
                IRemoteCallCompleteEvent cce = (IRemoteCallCompleteEvent) event;
                Object response = cce.getResponse();
                assertTrue(response instanceof IUserStatus[]);
                syncNotify();
            }
        }
    });
    syncWaitForNotify(10000);
}
Also used : JSONObject(org.json.JSONObject) IRemoteCallEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallEvent) IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) IRemoteCallListener(org.eclipse.ecf.remoteservice.IRemoteCallListener) IRemoteCallCompleteEvent(org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)

Example 19 with IRemoteService

use of org.eclipse.ecf.remoteservice.IRemoteService in project ecf by eclipse.

the class AbstractRemoteServiceTest method testAsyncResult.

public void testAsyncResult() throws Exception {
    final IRemoteService service = registerAndGetRemoteService();
    if (service == null)
        return;
    traceCallStart("callAsynchResult");
    final IFuture result = service.callAsync(createRemoteConcat("ECF AsynchResults ", "are cool"));
    traceCallEnd("callAsynchResult", result);
    assertNotNull(result);
    Thread.sleep(SLEEPTIME);
}
Also used : IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) IFuture(org.eclipse.equinox.concurrent.future.IFuture)

Example 20 with IRemoteService

use of org.eclipse.ecf.remoteservice.IRemoteService in project ecf by eclipse.

the class AbstractRemoteServiceAccessTest method testFireAsync.

public void testFireAsync() throws Exception {
    createServiceTrackerAndRegister();
    // Client - Get service references from service tracker
    final ServiceReference[] remoteReferences = st.getServiceReferences();
    assertReferencesValid(remoteReferences);
    final Object o = remoteReferences[0].getProperty(RemoteConstants.SERVICE_IMPORTED);
    assertNotNull(o);
    assertTrue(o instanceof IRemoteService);
    final IRemoteService rs = (IRemoteService) o;
    // Call asynchronously
    rs.fireAsync(createRemoteCall());
    Thread.sleep(REGISTER_WAIT);
}
Also used : IRemoteService(org.eclipse.ecf.remoteservice.IRemoteService) ServiceReference(org.osgi.framework.ServiceReference)

Aggregations

IRemoteService (org.eclipse.ecf.remoteservice.IRemoteService)64 ServiceReference (org.osgi.framework.ServiceReference)11 IFuture (org.eclipse.equinox.concurrent.future.IFuture)10 ECFException (org.eclipse.ecf.core.util.ECFException)9 IRemoteServiceContainerAdapter (org.eclipse.ecf.remoteservice.IRemoteServiceContainerAdapter)9 IRemoteServiceReference (org.eclipse.ecf.remoteservice.IRemoteServiceReference)8 IRemoteCallListener (org.eclipse.ecf.remoteservice.IRemoteCallListener)6 IRemoteCallCompleteEvent (org.eclipse.ecf.remoteservice.events.IRemoteCallCompleteEvent)6 IRemoteCallEvent (org.eclipse.ecf.remoteservice.events.IRemoteCallEvent)6 IConcatService (org.eclipse.ecf.tests.remoteservice.IConcatService)6 Dictionary (java.util.Dictionary)5 IRemoteServiceProxy (org.eclipse.ecf.remoteservice.IRemoteServiceProxy)5 JSONObject (org.json.JSONObject)5 Hashtable (java.util.Hashtable)4 OperationCanceledException (org.eclipse.core.runtime.OperationCanceledException)4 RemoteServiceTracker (org.eclipse.ecf.remoteservice.util.tracker.RemoteServiceTracker)4 IRemoteServiceRegistration (org.eclipse.ecf.remoteservice.IRemoteServiceRegistration)3 ExecutionException (java.util.concurrent.ExecutionException)2 ExecutionException (org.eclipse.core.commands.ExecutionException)2 IContainerManager (org.eclipse.ecf.core.IContainerManager)2