Package org.apache.camel.component.mock

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


    @Test
    public void testExceptionSchemaValidation() throws Exception {
        String detachedPayload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + //
                "<ns:root xmlns:ns=\"http://test\"><a ID=\"myID\"><error>bValue</error></a></ns:root>";
        MockEndpoint mock = setupExceptionMock();
        mock.expectedMessageCount(1);
        sendBody("direct:detached", detachedPayload);
        assertMockEndpointsSatisfied();
        checkThrownException(mock, SchemaValidationException.class, null);
    }
View Full Code Here


        String detachedPayload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + //
                "<ns:root xmlns:ns=\"http://test\"><a ID=\"myID\"><b>bValue</b></a></ns:root>";
        XmlSignerEndpoint endpoint = getDetachedSignerEndpoint();
        endpoint.setSchemaResourceUri(null);
        MockEndpoint mock = setupExceptionMock();
        mock.expectedMessageCount(1);
        sendBody("direct:detached", detachedPayload);
        assertMockEndpointsSatisfied();
        checkThrownException(mock, XmlSignatureException.class,
                "The configruation of the XML Signature component is wrong: No XML schema specified in the detached case", null);
    }
View Full Code Here

        return testXpath(xPath, detachedPayload);
    }

    private MockEndpoint testXpath(String xPath, String detachedPayload) throws InterruptedException {
        MockEndpoint mock = setupExceptionMock();
        mock.expectedMessageCount(1);
        List<XPathFilterParameterSpec> list = Collections.singletonList(XmlSignatureHelper.getXpathFilter(xPath, null));
        sendBody("direct:detached", detachedPayload,
                Collections.singletonMap(XmlSignatureConstants.HEADER_XPATHS_TO_ID_ATTRIBUTES, (Object) list));
        assertMockEndpointsSatisfied();
        return mock;
View Full Code Here

    public void testMarshalAndUnmarshalMap() throws Exception {
        Map<String, Object> in = new HashMap<String, Object>();
        in.put("name", "Camel");

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

        Object marshalled = template.requestBody("direct:in", in);
        String marshalledAsString = context.getTypeConverter().convertTo(String.class, marshalled);
View Full Code Here

    public void testMarshalAndUnmarshalMapWithPrettyPrint() throws Exception {
        Map<String, Object> in = new HashMap<String, Object>();
        in.put("name", "Camel");

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

        Object marshalled = template.requestBody("direct:pretty", in);
        String marshalledAsString = context.getTypeConverter().convertTo(String.class, marshalled);
View Full Code Here

    public void testMarshalAndUnmarshalPojo() throws Exception {
        TestPojo in = new TestPojo();
        in.setName("Camel");

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

        Object marshalled = template.requestBody("direct:inPojo", in);
        String marshalledAsString = context.getTypeConverter().convertTo(String.class, marshalled);
View Full Code Here

    @Test
    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);
View Full Code Here

    }

    @Test
    public void testScanFile() throws Exception {
        MockEndpoint mock = getMockEndpoint("mock:result");
        mock.expectedMessageCount(6);
        assertMockEndpointsSatisfied(1, TimeUnit.SECONDS);
    }

    protected RouteBuilder createRouteBuilder() {
        return new RouteBuilder() {
View Full Code Here

    public void testMarshalAndUnmarshal() throws Exception {
        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

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

        Object json = template.requestBody("direct:marshal", in);
        String jsonString = context.getTypeConverter().convertTo(String.class, json);
        JSONObject obj = (JSONObject) JSONSerializer.toJSON(jsonString);
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.