use of org.eclipse.ecf.remoteservice.IRemoteService in project ecf by eclipse.
the class RestRemoteServiceAdapterTest method testGetRemoteService.
public void testGetRemoteService() {
IRemoteServiceRegistration registration = createRestRegistration("resourcePath");
IRemoteServiceReference reference = registration.getReference();
assertNotNull(reference);
IRemoteService remoteService = getRemoteServiceClientContainerAdapter().getRemoteService(reference);
assertNotNull(remoteService);
}
use of org.eclipse.ecf.remoteservice.IRemoteService in project ecf by eclipse.
the class RemoteServiceProxyTest method testRemoteServiceProxy.
public void testRemoteServiceProxy() throws Exception {
final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
// client [0]/adapter[0] is the service 'server'
// client [1]/adapter[1] is the service target (client)
final Dictionary props = new Hashtable();
// Register
adapters[0].registerRemoteService(new String[] { IConcatService.class.getName() }, createService(), props);
// Give some time for propagation
sleep(3000);
final RemoteServiceTracker st = new RemoteServiceTracker(adapters[1], null, IConcatService.class.getName(), null);
assertNotNull(st);
st.open();
IRemoteService rs = st.getRemoteService();
final IConcatService concatService = (IConcatService) rs.getProxy();
assertNotNull(concatService);
// test for proxy implementing IRemoteServiceProxy
if (concatService instanceof IRemoteServiceProxy) {
IRemoteService remoteService = ((IRemoteServiceProxy) concatService).getRemoteService();
assertNotNull(remoteService);
IRemoteServiceReference remoteServiceReference = ((IRemoteServiceProxy) concatService).getRemoteServiceReference();
assertNotNull(remoteServiceReference);
System.out.println("remote service reference found from proxy=" + remoteServiceReference);
System.out.println("remoteserviceproxy call start");
Object result = RemoteServiceHelper.syncExec(remoteService, "concat", new Object[] { "IRemoteServiceProxy ", "is very cool" }, 20000);
System.out.println("remoteserviceproxy call end. result=" + result);
} else {
System.out.println("proxy call start");
final String result = concatService.concat("OSGi ", "is cool");
System.out.println("proxy call end. result=" + result);
}
sleep(3000);
st.close();
sleep(3000);
}
use of org.eclipse.ecf.remoteservice.IRemoteService in project ecf by eclipse.
the class RemoteServiceTrackerTest method testRemoteServiceTracker.
public void testRemoteServiceTracker() throws Exception {
final IRemoteServiceContainerAdapter[] adapters = getRemoteServiceAdapters();
// client [0]/adapter[0] is the service 'server'
// client [1]/adapter[1] is the service target (client)
final Dictionary props = new Hashtable();
// Register
adapters[0].registerRemoteService(new String[] { IConcatService.class.getName() }, createService(), props);
// Give some time for propagation
sleep(3000);
final RemoteServiceTracker st = new RemoteServiceTracker(adapters[1], null, IConcatService.class.getName(), null);
assertNotNull(st);
st.open();
IRemoteService rs = st.getRemoteService();
final IConcatService concatService = (IConcatService) rs.getProxy();
assertNotNull(concatService);
System.out.println("proxy call start");
final String result = concatService.concat("OSGi ", "is cool");
System.out.println("proxy call end. result=" + result);
sleep(3000);
st.close();
sleep(3000);
}
use of org.eclipse.ecf.remoteservice.IRemoteService in project ecf by eclipse.
the class SimpleTest method testSimpleClientAndServerWithCallSync.
public void testSimpleClientAndServerWithCallSync() throws Exception {
IRemoteService remoteService = client.getRemoteService();
assertNotNull(remoteService);
// Use callSync
String result = (String) remoteService.callSync(getRemoteConcatCall(TEST_STRING_2, TEST_STRING_1));
assertTrue(result != null && result.equals(TEST_STRING_2 + TEST_STRING_1));
}
use of org.eclipse.ecf.remoteservice.IRemoteService in project ecf by eclipse.
the class SimpleTest method testSimpleClientAndServerWithProxy.
public void testSimpleClientAndServerWithProxy() throws Exception {
IRemoteService remoteService = client.getRemoteService();
assertNotNull(remoteService);
// Use proxy
String result = ((IConcatService) remoteService.getProxy()).concat(TEST_STRING_1, TEST_STRING_2);
assertTrue(result != null && result.equals(TEST_STRING_1 + TEST_STRING_2));
}
Aggregations