Package org.apache.camel.component.mock

Examples of org.apache.camel.component.mock.MockEndpoint.message()


    public void testMarshalAndUnmarshalAgeView() throws Exception {
        TestPojoView in = new TestPojoView();

        MockEndpoint mock = getMockEndpoint("mock:reverseAgeView");
        mock.expectedMessageCount(1);
        mock.message(0).body().isInstanceOf(TestPojoView.class);
        mock.message(0).body().equals(in);

        Object marshalled = template.requestBody("direct:inAgeView", in);
        String marshalledAsString = context.getTypeConverter().convertTo(String.class, marshalled);
        assertEquals("{\"age\":30,\"height\":190}", marshalledAsString);
View Full Code Here


        TestPojoView in = new TestPojoView();

        MockEndpoint mock = getMockEndpoint("mock:reverseAgeView");
        mock.expectedMessageCount(1);
        mock.message(0).body().isInstanceOf(TestPojoView.class);
        mock.message(0).body().equals(in);

        Object marshalled = template.requestBody("direct:inAgeView", in);
        String marshalledAsString = context.getTypeConverter().convertTo(String.class, marshalled);
        assertEquals("{\"age\":30,\"height\":190}", marshalledAsString);
View Full Code Here

        InputStream inStream = getClass().getResourceAsStream("testMessage1.xml");
        String in = context.getTypeConverter().convertTo(String.class, inStream);

        MockEndpoint mockJSON = getMockEndpoint("mock:json");
        mockJSON.expectedMessageCount(1);
        mockJSON.message(0).body().isInstanceOf(byte[].class);

        MockEndpoint mockXML = getMockEndpoint("mock:xml");
        mockXML.expectedMessageCount(1);
        mockXML.message(0).body().isInstanceOf(String.class);
View Full Code Here

        mockJSON.expectedMessageCount(1);
        mockJSON.message(0).body().isInstanceOf(byte[].class);

        MockEndpoint mockXML = getMockEndpoint("mock:xml");
        mockXML.expectedMessageCount(1);
        mockXML.message(0).body().isInstanceOf(String.class);

        Object json = template.requestBody("direct:marshal", in);
        String jsonString = context.getTypeConverter().convertTo(String.class, json);
        JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString);
        assertEquals("JSONObject doesn't contain 7 keys", 7, obj.entrySet().size());
View Full Code Here

        InputStream inStream = getClass().getResourceAsStream("testMessage1.json");
        String in = context.getTypeConverter().convertTo(String.class, inStream);

        MockEndpoint mockXML = getMockEndpoint("mock:xmlWithOptions");
        mockXML.expectedMessageCount(1);
        mockXML.message(0).body().isInstanceOf(String.class);

        Object marshalled = template.requestBody("direct:unmarshalWithOptions", in);
        Document document = context.getTypeConverter().convertTo(Document.class, marshalled);
        assertEquals("The XML document doesn't carry newRoot as the root name", "newRoot", document.getDocumentElement().getLocalName());
        // with expandable properties, array elements are converted to XML as a
View Full Code Here

        InputStream inStream = getClass().getClassLoader().getResourceAsStream("org/apache/camel/dataformat/xmljson/testMessage1.xml");
        String in = context.getTypeConverter().convertTo(String.class, inStream);

        MockEndpoint mockJSON = getMockEndpoint("mock:json");
        mockJSON.expectedMessageCount(1);
        mockJSON.message(0).body().isInstanceOf(byte[].class);

        Object json = template.requestBody("direct:marshal", in);
        String jsonString = context.getTypeConverter().convertTo(String.class, json);
        JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString);
        assertEquals("JSON must contain 1 top-level element", 1, obj.entrySet().size());
View Full Code Here

        InputStream inStream = getClass().getClassLoader().getResourceAsStream("org/apache/camel/dataformat/xmljson/testMessage4.xml");
        String in = context.getTypeConverter().convertTo(String.class, inStream);

        MockEndpoint mockJSON = getMockEndpoint("mock:json");
        mockJSON.expectedMessageCount(1);
        mockJSON.message(0).body().isInstanceOf(byte[].class);

        Object json = template.requestBody("direct:marshal", in);
        String jsonString = context.getTypeConverter().convertTo(String.class, json);
        JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString);
        assertEquals("JSON must contain 1 top-level element", 1, obj.entrySet().size());
View Full Code Here

        InputStream inStream = getClass().getClassLoader().getResourceAsStream("org/apache/camel/dataformat/xmljson/testMessage1.json");
        String in = context.getTypeConverter().convertTo(String.class, inStream);

        MockEndpoint mockXML = getMockEndpoint("mock:xml");
        mockXML.expectedMessageCount(1);
        mockXML.message(0).body().isInstanceOf(String.class);

        Object marshalled = template.requestBody("direct:unmarshal", in);
        Document document = context.getTypeConverter().convertTo(Document.class, marshalled);
        assertEquals("The XML document doesn't carry newRoot as the root name", "newRoot", document.getDocumentElement().getLocalName());
        // with expandable properties, array elements are converted to XML as a
View Full Code Here

        InputStream inStream = getClass().getClassLoader().getResourceAsStream("org/apache/camel/dataformat/xmljson/testMessage2-namespaces.xml");
        String in = context.getTypeConverter().convertTo(String.class, inStream);

        MockEndpoint mockJSON = getMockEndpoint("mock:json");
        mockJSON.expectedMessageCount(1);
        mockJSON.message(0).body().isInstanceOf(byte[].class);

        Object json = template.requestBody("direct:marshal", in);
        String jsonString = context.getTypeConverter().convertTo(String.class, json);
        JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString);
        assertEquals("JSON must contain 1 top-level element", 1, obj.entrySet().size());
View Full Code Here

        InputStream inStream = getClass().getClassLoader().getResourceAsStream("org/apache/camel/dataformat/xmljson/testMessage2-namespaces.json");
        String in = context.getTypeConverter().convertTo(String.class, inStream);

        MockEndpoint mockXML = getMockEndpoint("mock:xmlNS");
        mockXML.expectedMessageCount(1);
        mockXML.message(0).body().isInstanceOf(String.class);

        Object marshalled = template.requestBody("direct:unmarshalNS", in);
        Document document = context.getTypeConverter().convertTo(Document.class, marshalled);
        assertEquals("Element surname must be qualified in the default namespace", "http://camel.apache.org/default", document.getDocumentElement().getElementsByTagName("surname").item(0)
                .getNamespaceURI());
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. 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.