Package org.openengsb.core.api.remote

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


        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, "admin", "password");
        System.out.println(methodResult);

        stop();
    }
View Full Code Here


        setupSecurityManager();
        when(requestHandler.handleCall(any(MethodCall.class))).thenAnswer(new Answer<MethodResult>() {
            @Override
            public MethodResult answer(InvocationOnMock invocation) throws Throwable {
                MethodCall call = (MethodCall) invocation.getArguments()[0];
                return new MethodResult(call.getArgs()[0], call.getMetaData());
            }
        });

        FilterChainFactory<MethodCallMessage, MethodResultMessage> factory =
            new FilterChainFactory<MethodCallMessage, MethodResultMessage>(MethodCallMessage.class,
View Full Code Here

                return AliveState.OFFLINE;
            }
            throw new IllegalArgumentException("not registered");
        }

        MethodResult callResult =
                portUtil.sendMethodCallWithResult(registration.getPortId(), registration.getDestination(), methodCall);
        switch (callResult.getType()) {
            case Object:
                Object result = callResult.getArg();
                return transformationHandler.transformResult(result);
            case Void:
                return null;
            case Exception:
                throw new RuntimeException(callResult.getArg().toString());
            default:
                throw new IllegalStateException("Return Type has to be either Void, Object or Exception");
        }
    }
View Full Code Here

            LOGGER.error(result);
        }

        if (!result.contains("The answer to life the universe and everything")) {
            MethodResultMessage readValue = new ObjectMapper().readValue(result, MethodResultMessage.class);
            MethodResult result2 = readValue.getResult();
            if (result2.getType().equals(MethodResult.ReturnType.Exception)) {
                LOGGER.error(result2.getArg().toString());
            }
            assertThat(result, containsString("The answer to life the universe and everything"));
        }
    }
View Full Code Here

        try {
            request = MAPPER.readValue(text, MethodCallMessage.class);
        } catch (IOException e1) {
            throw Throwables.propagate(e1);
        }
        MethodResult result = requestHandler.process(request.getMethodCall());
        try {
            sendResult(request, result);
        } catch (JMSException e) {
            throw Throwables.propagate(e);
        }
View Full Code Here

            LOGGER.info("invoking method {}", method);
            JsonUtils.convertAllArgs(request);
            LOGGER.info("argument: ", request.getArgs()[0].getClass());
            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");
            MethodResult methodResult = new MethodResult(result);
            invocationHistory.put(request, methodResult);
            return methodResult;
        } catch (InvocationTargetException e) {
            return makeExceptionResult((Exception) e.getTargetException());
        } catch (IllegalArgumentException 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

            }
            resultMessage = objectMapper.readValue(resultString, MethodResultMessage.class);
        } catch (IOException e) {
            throw new FilterException(e);
        }
        MethodResult result = resultMessage.getResult();

        if (result.getType().equals(ReturnType.Void)) {
            result.setArg(null);
        } else {
            Class<?> resultType;
            try {
                resultType = Class.forName(result.getClassName());
            } catch (ClassNotFoundException e) {
                throw new FilterException(e);
            }
            Object convertedValue = objectMapper.convertValue(result.getArg(), resultType);
            result.setArg(convertedValue);
        }
        return resultMessage;
    }
View Full Code Here

    }

    @Test
    public void testCallInvoke_shouldCreateMethodCallAndReturnResult() throws Exception {
        ArgumentCaptor<MethodCall> captor = ArgumentCaptor.forClass(MethodCall.class);
        MethodResult result2 = new MethodResult("id");
        when(router.sendMethodCallWithResult(Mockito.eq("jms-json"), Mockito.eq("tcp://localhost"), captor.capture()))
            .thenReturn(result2);

        Object[] args = new Object[]{ "id", "test" };
        Interface newProxyInstance =
View Full Code Here

    }

    @Test
    public void callInvokeWithException_ShouldThrowException() throws Exception {
        String message = "Message";
        MethodResult result = new MethodResult(message, ReturnType.Exception);
        when(router.sendMethodCallWithResult(any(String.class), any(String.class), any(MethodCall.class)))
            .thenReturn(result);
        Interface newProxyInstance =
            (Interface) Proxy.newProxyInstance(Interface.class.getClassLoader(), new Class[]{ Interface.class }, proxy);
        try {
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.