Package org.openengsb.core.api.remote

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


    @Test
    public void testMethodCallMarashalFilter_shouldMarshalOutgoingMessage() throws Exception {
        JsonOutgoingMethodCallMarshalFilter jsonOutgoingMethodCallMarshalFilter =
            new JsonOutgoingMethodCallMarshalFilter();
        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();
View Full Code Here


    }

    @Test
    public void testIncomingMethodCallMarashalFilter_shouldMarshalIngoingMessage() throws Exception {
        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

            new FilterChainFactory<String, String>(String.class, String.class);

        List<Object> filters = Arrays.asList(new Object[]{ JsonMethodCallMarshalFilter.class, requestMapperFilter });
        filterChainFactory.setFilters(filters);

        FilterAction filterChain = filterChainFactory.create();

        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

        List<Object> filters =
            Arrays
                .asList(new Object[]{ XmlDecoderFilter.class, XmlMethodCallMarshalFilter.class, requestMapperFilter, });
        filterChainFactory.setFilters(filters);

        FilterAction filterChain = filterChainFactory.create();

        MethodCall methodCall = new MethodCall("test", new Object[]{ "foo" }, Arrays.asList(String.class.getName()));
        MethodCallMessage request = new MethodCallMessage(methodCall, "bar");

        JAXBContext jaxbContext = JAXBContext.newInstance(MethodCallMessage.class, MethodResultMessage.class);
        final Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
        final Marshaller marshaller = jaxbContext.createMarshaller();

        DOMResult domResult = new DOMResult();
        marshaller.marshal(new JAXBElement<MethodCallMessage>(new QName(MethodCallMessage.class.getSimpleName()),
            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);
View Full Code Here

            new FilterChainFactory<String, String>(String.class, String.class);

        List<Object> filters = Arrays.asList(new Object[]{ JsonMethodCallMarshalFilter.class, requestMapperFilter, });
        filterChainFactory.setFilters(filters);

        FilterAction filterChain = filterChainFactory.create();

        ObjectMapper objectMapper = new ObjectMapper();
        MethodCall methodCall = new MethodCall("test", new Object[]{ "foo" });
        MethodCallMessage request = new MethodCallMessage(methodCall, "bar");
        String input = objectMapper.writeValueAsString(request);
        HashMap<String, Object> metaData = new HashMap<String, Object>();
        filterChain.filter(input, metaData);
        assertThat((String) metaData.get("callId"), is("bar"));
    }
View Full Code Here

TOP

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

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.