Package org.openengsb.core.api.remote

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


        }
        return text;
    }

    private void sendResult(MethodCallMessage request, MethodResult result) throws JMSException {
        MethodResultMessage methodResultMessage = new MethodResultMessage(result, request.getCallId());
        String resultText = handler.marshal(methodResultMessage);
        jmsConfig.sendMessage(request.getCallId(), resultText);
    }
View Full Code Here


        return convertStringToResult(resultString);
    }

    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

        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,
            ClassProvider.class);
View Full Code Here

        final String encryptedString = new ObjectMapper().writeValueAsString(encryptedMessage);

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

        FilterAction mock = mock(FilterAction.class);
        when(mock.filter(any(MethodCallMessage.class), any(Map.class))).thenReturn(RESULT_MESSAGE);
        when(mock.getSupportedInputType()).thenAnswer(new Returns(String.class));
        when(mock.getSupportedOutputType()).thenAnswer(new Returns(String.class));
        jsonOutgoingMethodCallMarshalFilter.setNext(mock);
        MethodResultMessage result =
            (MethodResultMessage) jsonOutgoingMethodCallMarshalFilter.filter(new MethodCallMessage(),
                new HashMap<String, Object>());
        Object arg = result.getResult().getArg();
        assertThat(arg, is(TestModel.class));
        TestModel resultModel = (TestModel) arg;
        assertThat(resultModel.getId(), is(42));
        assertThat(resultModel.getName(), is("foo"));
    }
View Full Code Here

        JsonMethodCallMarshalFilter jsonMethodCallMarshalFilter = new JsonMethodCallMarshalFilter();
        FilterAction mock = mock(FilterAction.class);
        TestModel testResult = new TestModel();
        testResult.setId(42);
        testResult.setName("bar");
        MethodResultMessage testResultMessage =
            new MethodResultMessage(new MethodResult(testResult), "foo");
        when(mock.filter(any(MethodCallMessage.class), any(Map.class))).thenReturn(testResultMessage);
        when(mock.getSupportedInputType()).thenAnswer(new Returns(MethodCallMessage.class));
        when(mock.getSupportedOutputType()).thenAnswer(new Returns(MethodResultMessage.class));
        jsonMethodCallMarshalFilter.setNext(mock);
        jsonMethodCallMarshalFilter.filter(CALL_MESSAGE, new HashMap<String, Object>());
View Full Code Here

        ObjectMapper objectMapper = new ObjectMapper();
        MethodCall methodCall = new MethodCall("test", new Object[]{ "foo" });
        MethodCallMessage request = new MethodCallMessage(methodCall, "bar");
        String input = objectMapper.writeValueAsString(request);
        String result = (String) filterChain.filter(input, new HashMap<String, Object>());
        MethodResultMessage returnValue = objectMapper.readValue(result, MethodResultMessage.class);
        assertThat((String) returnValue.getResult().getArg(), is("foo"));
        assertThat(returnValue.getCallId(), is("bar"));
    }
View Full Code Here

            MethodCallMessage.class, request), domResult);
        String input = XmlDecoderFilter.writeDocument(domResult.getNode());
        String result = (String) filterChain.filter(input, new HashMap<String, Object>());

        Document parseDocument = XmlDecoderFilter.parseDocument(result);
        MethodResultMessage value = unmarshaller.unmarshal(parseDocument, MethodResultMessage.class).getValue();
        String value2 = unmarshaller.unmarshal((Node) value.getResult().getArg(), String.class).getValue();
        value.getResult().setArg(value2);
        assertThat((String) value.getResult().getArg(), is("foo"));
        assertThat(value.getCallId(), is("bar"));
    }
View Full Code Here

        return MAPPER.writeValueAsBytes(methodCallRequest);
    }

    private static MethodResult convertStringToResult(String resultString, SecretKey sessionKey) throws IOException,
            ClassNotFoundException, DecryptionException {
        MethodResultMessage resultMessage = decryptResponse(resultString, sessionKey);
        return convertResult(resultMessage);
    }
View Full Code Here

TOP

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

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.