Search in sources :

Example 1 with IRemoteServiceClientContainerAdapter

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

the class RestContainerTest method testGetRemoteServiceNamespace.

public void testGetRemoteServiceNamespace() throws Exception {
    IContainer container = createRestContainer(RestConstants.TEST_DE_TARGET);
    IRemoteServiceClientContainerAdapter adapter = getRemoteServiceClientContainerAdapter(container);
    assertNotNull(adapter);
    Namespace namespace = adapter.getRemoteServiceNamespace();
    assertNotNull(namespace);
}
Also used : IRemoteServiceClientContainerAdapter(org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter) IContainer(org.eclipse.ecf.core.IContainer) Namespace(org.eclipse.ecf.core.identity.Namespace)

Example 2 with IRemoteServiceClientContainerAdapter

use of org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter 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 3 with IRemoteServiceClientContainerAdapter

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

the class RestRemoteServiceAdapterTest method testRemoteServiceRegisteredEvent.

public void testRemoteServiceRegisteredEvent() {
    IRemoteServiceClientContainerAdapter adapter = getRemoteServiceClientContainerAdapter();
    adapter.addRemoteServiceListener(new IRemoteServiceListener() {

        public void handleServiceEvent(IRemoteServiceEvent event) {
            assertTrue(event instanceof IRemoteServiceRegisteredEvent);
        }
    });
    createRestRegistration("resourcePath");
}
Also used : IRemoteServiceClientContainerAdapter(org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter) IRemoteServiceListener(org.eclipse.ecf.remoteservice.IRemoteServiceListener) IRemoteServiceEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent) IRemoteServiceRegisteredEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent)

Example 4 with IRemoteServiceClientContainerAdapter

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

the class RpcRemoteServiceAdapterTest method testRemoteServiceRegisteredEvent.

public void testRemoteServiceRegisteredEvent() {
    IRemoteServiceClientContainerAdapter adapter = getRemoteServiceClientContainerAdapter();
    adapter.addRemoteServiceListener(new IRemoteServiceListener() {

        public void handleServiceEvent(IRemoteServiceEvent event) {
            assertTrue(event instanceof IRemoteServiceRegisteredEvent);
        }
    });
    createRpcRegistration(RpcConstants.TEST_ECHO_METHOD);
}
Also used : IRemoteServiceClientContainerAdapter(org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter) IRemoteServiceListener(org.eclipse.ecf.remoteservice.IRemoteServiceListener) IRemoteServiceEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent) IRemoteServiceRegisteredEvent(org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent)

Example 5 with IRemoteServiceClientContainerAdapter

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

the class TwitterRemoteServiceTest method setUp.

protected void setUp() throws Exception {
    // Create container
    container = createRestContainer(RestConstants.TEST_TWITTER_TARGET);
    // Get adapter
    IRemoteServiceClientContainerAdapter adapter = (IRemoteServiceClientContainerAdapter) getRemoteServiceClientContainerAdapter(container);
    // Setup authentication info
    adapter.setConnectContextForAuthentication(ConnectContextFactory.createUsernamePasswordConnectContext(username, password));
    // Setup resource handler
    adapter.setResponseDeserializer(createRestResource());
    // Create and register callable to register service
    IRemoteCallParameter[] parameters1 = RemoteCallParameterFactory.createParameters("count", null);
    // Setup callable
    IRemoteCallable callable1 = RestCallableFactory.createCallable("getUserStatuses", "/statuses/user_timeline.json", parameters1);
    IRemoteCallParameter[] parameters2 = RemoteCallParameterFactory.createParameters("body", null);
    HttpPostRequestType requestType2 = new HttpPostRequestType(HttpPostRequestType.STRING_REQUEST_ENTITY);
    IRemoteCallable callable2 = RestCallableFactory.createCallable("postMethodString", "/statuses/user_timeline.json", parameters2, requestType2);
    IRemoteCallParameter[] parameters3 = RemoteCallParameterFactory.createParameters("body", null);
    HttpPostRequestType requestType3 = new HttpPostRequestType(HttpPostRequestType.INPUT_STREAM_REQUEST_ENTITY);
    IRemoteCallable callable3 = RestCallableFactory.createCallable("postMethodInputStream", "/statuses/user_timeline.json", parameters3, requestType3);
    IRemoteCallParameter[] parameters4 = RemoteCallParameterFactory.createParameters("body", null);
    HttpPostRequestType requestType4 = new HttpPostRequestType(HttpPostRequestType.BYTEARRAY_REQUEST_ENTITY);
    IRemoteCallable callable4 = RestCallableFactory.createCallable("postMethodByteArray", "/statuses/user_timeline.json", parameters4, requestType4);
    registration = adapter.registerCallables(new String[] { IUserTimeline.class.getName() }, new IRemoteCallable[][] { { callable1, callable2, callable3, callable4 } }, null);
}
Also used : IRemoteCallable(org.eclipse.ecf.remoteservice.client.IRemoteCallable) IRemoteCallParameter(org.eclipse.ecf.remoteservice.client.IRemoteCallParameter) IRemoteServiceClientContainerAdapter(org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter) HttpPostRequestType(org.eclipse.ecf.remoteservice.rest.client.HttpPostRequestType)

Aggregations

IRemoteServiceClientContainerAdapter (org.eclipse.ecf.remoteservice.client.IRemoteServiceClientContainerAdapter)5 IRemoteServiceListener (org.eclipse.ecf.remoteservice.IRemoteServiceListener)2 IRemoteCallParameter (org.eclipse.ecf.remoteservice.client.IRemoteCallParameter)2 IRemoteCallable (org.eclipse.ecf.remoteservice.client.IRemoteCallable)2 IRemoteServiceEvent (org.eclipse.ecf.remoteservice.events.IRemoteServiceEvent)2 IRemoteServiceRegisteredEvent (org.eclipse.ecf.remoteservice.events.IRemoteServiceRegisteredEvent)2 NotSerializableException (java.io.NotSerializableException)1 Map (java.util.Map)1 IContainer (org.eclipse.ecf.core.IContainer)1 Namespace (org.eclipse.ecf.core.identity.Namespace)1 IRemoteCall (org.eclipse.ecf.remoteservice.IRemoteCall)1 IRemoteResponseDeserializer (org.eclipse.ecf.remoteservice.client.IRemoteResponseDeserializer)1 RemoteCallParameter (org.eclipse.ecf.remoteservice.client.RemoteCallParameter)1 HttpPostRequestType (org.eclipse.ecf.remoteservice.rest.client.HttpPostRequestType)1 HttpPutRequestType (org.eclipse.ecf.remoteservice.rest.client.HttpPutRequestType)1