Package org.openengsb.core.api.remote

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


    public void onMessage(Message message) {
        SecureSampleConnector.LOGGER.info("recieved JMS-message");
        TextMessage content = (TextMessage) message;
        String text = getTextFromMessage(content);
        MethodCallMessage request = handler.unmarshal(text);
        MethodResult result = requestHander.process(request.getMethodCall());
        try {
            sendResult(request, result);
        } catch (JMSException e) {
            throw Throwables.propagate(e);
        }
View Full Code Here


        }
        try {
            LOGGER.info("invoking method {}", method);
            Object result = method.invoke(connector, request.getArgs());
            if (method.getReturnType().equals(void.class)) {
                MethodResult methodResult = new MethodResult();
                methodResult.setClassName(Object.class.getName());
                methodResult.setType(ReturnType.Void);
                return methodResult;
            }
            LOGGER.debug("invocation successful");
            return new MethodResult(result);
        } catch (InvocationTargetException e) {
            return makeExceptionResult((Exception) e.getTargetException());
        } catch (IllegalArgumentException e) {
            return makeExceptionResult(e);
        } catch (IllegalAccessException e) {
View Full Code Here

        }
    }

    private MethodResult makeExceptionResult(Exception e) {
        LOGGER.error("Exception occured, making Exception result");
        return new MethodResult(Throwables.getStackTraceAsString(e), ReturnType.Exception);
    }
View Full Code Here

    }

    private static MethodResult convertStringToResult(String resultString) throws IOException,
        ClassNotFoundException {
        MethodResultMessage resultMessage = MAPPER.readValue(resultString, MethodResultMessage.class);
        MethodResult result = resultMessage.getResult();
        Class<?> clazz = Class.forName(result.getClassName());
        Object resultValue = MAPPER.convertValue(result.getArg(), clazz);
        result.setArg(resultValue);
        return result;
    }
View Full Code Here

        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);

        stop();
    }
View Full Code Here

        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);
        methodReturn = new MethodResultMessage(result, "123");
        Dictionary<String, Object> props = new Hashtable<String, Object>();
        props.put(Constants.PROVIDED_CLASSES_KEY, Password.class.getName());
        props.put(Constants.DELEGATION_CONTEXT_KEY, org.openengsb.core.api.Constants.DELEGATION_CONTEXT_CREDENTIALS);
        registerService(new ClassProviderImpl(bundle, Sets.newHashSet(Password.class.getName())), props,
View Full Code Here

        String resultString = sendWithTempQueue(encryptedString);

        byte[] result = CipherUtils.decrypt(Base64.decodeBase64(resultString), sessionKey);
        MethodResultMessage result2 = OBJECT_MAPPER.readValue(result, MethodResultMessage.class);
        MethodResult methodResult = result2.getResult();
        Object realResultArg =
            OBJECT_MAPPER.convertValue(methodResult.getArg(), Class.forName(methodResult.getClassName()));
        assertThat(realResultArg, equalTo((Object) new TestClass("test")));
    }
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

        assertThat((Integer) result.getArg(), is(42));
    }

    @Test
    public void testReceiveMethodCallWithVoidMethod_shouldSendResponseWithVoidType() throws Exception {
        MethodResult result = requestHandler.handleCall(methodCall);

        verify(serviceMock).test();
        assertThat(result.getType(), equalTo(ReturnType.Void));
        assertNull(result.getArg());
    }
View Full Code Here

    }

    @Test
    public void testSendSyncMethodCall_shouldReturnResult() throws Exception {
        when(serviceMock.getAnswer()).thenReturn(42);
        MethodResult expectedResult = new MethodResult();
        MethodResultMessage value = mock(MethodResultMessage.class);
        when(value.getResult()).thenReturn(expectedResult);
        when(outgoingPortMock.sendSync(any(MethodCallMessage.class))).thenReturn(value);
        MethodResult result = callrouter.sendMethodCallWithResult("jms+json-out", "jms://localhost", methodCall);
        assertThat(result, is(expectedResult));
    }
View Full Code Here

TOP

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

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.