Package org.openengsb.core.api.remote

Examples of org.openengsb.core.api.remote.MethodCall


     */
    public static void main(String[] args) throws Exception {
        LOGGER.info("initializing");
        init();
        LOGGER.info("initialized");
        MethodCall methodCall =
            new MethodCall("doSomething", new Object[]{ "Hello World!" }, ImmutableMap.of("serviceId",
                "example+example+testlog", "contextId", "foo"));
        LOGGER.info("calling method");
        MethodResult methodResult = call(methodCall);
        System.out.println(methodResult);

View Full Code Here


        TestInterface mock2 = mock(TestInterface.class);
        registerServiceViaId(mock2, "test", TestInterface.class);
        when(mock2.method(anyString(), anyInt(), any(TestClass.class))).thenReturn(new TestClass("test"));

        Map<String, String> metaData = Maps.newHashMap(ImmutableMap.of("serviceId", "test"));
        MethodCall methodCall = new MethodCall("method", new Object[]{ "123", 5, new TestClass("test"), }, metaData);
        call = new MethodCallMessage(methodCall, "123");
        call.setDestination("host?receive");

        MethodResult result = new MethodResult(new TestClass("test"));
        result.setMetaData(metaData);
View Full Code Here

        registerServiceViaId(mock2, "test", TestInterface.class);
        when(mock2.method(Mockito.anyString(), Mockito.anyInt(), Mockito.any(TestClass.class))).thenReturn(
            new TestClass("test"));
        metaData = new HashMap<String, String>();
        metaData.put("serviceId", "test");
        MethodCall methodCall = new MethodCall("method", new Object[]{ "123", 5, new TestClass("test"), }, metaData);
        call = new MethodCallMessage(methodCall, "123");
        call.setDestination("host?receive");

        JMSOutgoingPort jmsOutgoingPort = new JMSOutgoingPort();
        jmsOutgoingPort.setFactory(jmsTemplateFactory);
View Full Code Here

        sendRemoteEvent(portId, destination, e, new HashMap<String, String>());
    }

    public static void sendRemoteEvent(String portId, String destination, RemoteEvent e, Map<String, String> metaData)
        throws PortNotAvailableException {
        MethodCall methodCall = new MethodCall("processRemoteEvent", new Object[]{ e }, metaData);
        OutgoingPortUtilService portUtilService = utilsService.getOsgiServiceProxy(OutgoingPortUtilService.class);
        portUtilService.sendMethodCall(portId, destination, methodCall);
    }
View Full Code Here

        callrouter = new DefaultOutgoingPortUtilService(new DefaultOsgiUtilsService(bundleContext));
        requestHandler = new RequestHandlerImpl();
        requestHandler.setUtilsService(new DefaultOsgiUtilsService(bundleContext));

        Map<String, String> metaData = getMetadata("foo");
        methodCall = new MethodCall("test", new Object[0], metaData);
    }
View Full Code Here

        return metaData;
    }

    @Test
    public void testReceiveMethodCallWithArgument_shouldCallMethod() throws Exception {
        MethodCall call2 = new MethodCall("test", new Object[]{ 42 }, getMetadata("foo"));
        requestHandler.handleCall(call2);
        verify(serviceMock, never()).test();
        verify(serviceMock, times(1)).test(eq(42));
    }
View Full Code Here

    }

    @Test
    public void testRecieveMethodCall_shouldSendResponse() throws Exception {
        when(serviceMock.getAnswer()).thenReturn(42);
        MethodCall call2 = new MethodCall("getAnswer", new Object[0], getMetadata("foo"));
        MethodResult result = requestHandler.handleCall(call2);

        verify(serviceMock).getAnswer();
        assertThat((Integer) result.getArg(), is(42));
    }
View Full Code Here

        assertNull(result.getArg());
    }

    @Test
    public void testSendMethodCall_shouldCallPort() throws Exception {
        callrouter.sendMethodCall("jms+json-out", testURI, new MethodCall());
        Thread.sleep(300);
        verify(outgoingPortMock, times(1)).send(any(MethodCallMessage.class));
    }
View Full Code Here

                }
                return 42L;
            }
        };
        when(serviceMock.getOtherAnswer()).thenAnswer(answer);
        MethodCall blockingCall = new MethodCall("getOtherAnswer", new Object[0], getMetadata("foo"));
        MethodCall normalCall = new MethodCall("getAnswer", new Object[0], getMetadata("foo"));

        ExecutorService threadPool = Executors.newCachedThreadPool();
        Future<MethodResult> blockingFuture = threadPool.submit(new MethodCallable(blockingCall));
        Future<MethodResult> normalFuture = threadPool.submit(new MethodCallable(normalCall));
View Full Code Here

    public void setUp() {
        RequestHandler requestHandlerMock = mock(RequestHandler.class);
        when(requestHandlerMock.handleCall(any(MethodCall.class))).thenAnswer(new Answer<MethodResult>() {
            @Override
            public MethodResult answer(InvocationOnMock invocation) throws Throwable {
                MethodCall input = (MethodCall) invocation.getArguments()[0];
                return new MethodResult(input.getArgs()[0]);
            }
        });
        requestMapperFilter = new RequestMapperFilter(requestHandlerMock);
    }
View Full Code Here

TOP

Related Classes of org.openengsb.core.api.remote.MethodCall

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.