Search in sources :

Example 1 with RemoteCallParameter

use of org.eclipse.ecf.remoteservice.client.RemoteCallParameter in project ecf by eclipse.

the class RestPutServiceTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    // Create container for service URI
    container = createRestContainer(uri);
    // Get adapter and set authentication info
    IRemoteServiceClientContainerAdapter adapter = (IRemoteServiceClientContainerAdapter) getRemoteServiceClientContainerAdapter(container);
    // Setup authentication
    adapter.setConnectContextForAuthentication(ConnectContextFactory.createUsernamePasswordConnectContext(username, password));
    // Setup response deserializer to do absolutely nothing (return null).  Note this is specific to this service.
    adapter.setResponseDeserializer(new IRemoteResponseDeserializer() {

        public Object deserializeResponse(String endpoint, IRemoteCall call, IRemoteCallable callable, Map responseHeaders, byte[] responseBody) throws NotSerializableException {
            return null;
        }
    });
    // Create callable and register
    IRemoteCallable callable = RestCallableFactory.createCallable(method, resourcePath, new IRemoteCallParameter[] { new RemoteCallParameter("body") }, new HttpPutRequestType(HttpPutRequestType.STRING_REQUEST_ENTITY, "application/xml", -1, "UTF-8"));
    // register callable
    registration = adapter.registerCallables(new IRemoteCallable[] { callable }, null);
}
Also used : IRemoteCallable(org.eclipse.ecf.remoteservice.client.IRemoteCallable) NotSerializableException(java.io.NotSerializableException) IRemoteServiceClientContainerAdapter(org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter) RemoteCallParameter(org.eclipse.ecf.remoteservice.client.RemoteCallParameter) IRemoteCallParameter(org.eclipse.ecf.remoteservice.client.IRemoteCallParameter) IRemoteResponseDeserializer(org.eclipse.ecf.remoteservice.client.IRemoteResponseDeserializer) Map(java.util.Map) IRemoteCall(org.eclipse.ecf.remoteservice.IRemoteCall) HttpPutRequestType(org.eclipse.ecf.remoteservice.rest.client.HttpPutRequestType)

Example 2 with RemoteCallParameter

use of org.eclipse.ecf.remoteservice.client.RemoteCallParameter in project ecf by eclipse.

the class RpcRemoteServiceTest method setUp.

protected void setUp() throws Exception {
    container = createRpcContainer(RpcConstants.TEST_ECHO_TARGET);
    IRemoteCallable callableEcho = RemoteCallableFactory.createCallable(RpcConstants.TEST_ECHO_METHOD_NAME, RpcConstants.TEST_ECHO_METHOD, new IRemoteCallParameter[] { new RemoteCallParameter(RpcConstants.TEST_ECHO_METHOD_PARAM) });
    registrationEcho = registerCallable(container, callableEcho, null);
    IRemoteCallable callableEchoProxy = RemoteCallableFactory.createCallable(IEcho.class.getName());
    registrationEchoProxy = registerCallable(container, callableEchoProxy, null);
    IRemoteCallable callableCalc = RemoteCallableFactory.createCallable(RpcConstants.TEST_CALC_PLUS_METHOD_NAME, RpcConstants.TEST_CALC_PLUS_METHOD, new IRemoteCallParameter[] { new RemoteCallParameter(RpcConstants.TEST_CALC_PLUS_METHOD_PARAM1), new RemoteCallParameter(RpcConstants.TEST_CALC_PLUS_METHOD_PARAM2) });
    registrationCalc = registerCallable(container, callableCalc, null);
}
Also used : IRemoteCallable(org.eclipse.ecf.remoteservice.client.IRemoteCallable) RemoteCallParameter(org.eclipse.ecf.remoteservice.client.RemoteCallParameter) IRemoteCallParameter(org.eclipse.ecf.remoteservice.client.IRemoteCallParameter) IEcho(org.eclipse.ecf.tests.remoteservice.rpc.common.IEcho)

Example 3 with RemoteCallParameter

use of org.eclipse.ecf.remoteservice.client.RemoteCallParameter in project ecf by eclipse.

the class TwitterRemoteServiceTest method testSyncCallWithCountParameter.

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

Aggregations

IRemoteCallParameter (org.eclipse.ecf.remoteservice.client.IRemoteCallParameter)3 RemoteCallParameter (org.eclipse.ecf.remoteservice.client.RemoteCallParameter)3 IRemoteCallable (org.eclipse.ecf.remoteservice.client.IRemoteCallable)2 NotSerializableException (java.io.NotSerializableException)1 Map (java.util.Map)1 ECFException (org.eclipse.ecf.core.util.ECFException)1 IRemoteCall (org.eclipse.ecf.remoteservice.IRemoteCall)1 IRemoteService (org.eclipse.ecf.remoteservice.IRemoteService)1 IRemoteResponseDeserializer (org.eclipse.ecf.remoteservice.client.IRemoteResponseDeserializer)1 IRemoteServiceClientContainerAdapter (org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter)1 HttpPutRequestType (org.eclipse.ecf.remoteservice.rest.client.HttpPutRequestType)1 IEcho (org.eclipse.ecf.tests.remoteservice.rpc.common.IEcho)1 JSONObject (org.json.JSONObject)1