Package org.apache.camel.component.mock

Examples of org.apache.camel.component.mock.MockEndpoint


        String value = "not id";
        String detachedPayload = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + //
                "<ns:root xmlns:ns=\"http://test\"><a ID=\"myID\" stringAttr=\"" + value + "\"><b>bValue</b></a></ns:root>";
        String xPath = "a/@stringAttr";

        MockEndpoint mock = testXpath(xPath, detachedPayload);
        checkThrownException(mock, XmlSignatureException.class,
                "Wrong configured xpath expression for ID attributes: The evaluation of the xpath expression " + xPath
                        + " resulted in an attribute which is not of type ID. The attribute value is " + value + ".", null);
    }
View Full Code Here


    }

    @Test
    public void testExceptionDetachedXpathNoAttribute() throws Exception {
        String xPath = "a"; // Element a
        MockEndpoint mock = testXpath(xPath);
        checkThrownException(mock, XmlSignatureException.class,
                "Wrong configured xpath expression for ID attributes: The evaluation of the xpath expression " + xPath
                        + " returned a node which was not of type Attribute.", null);
    }
View Full Code Here

    }

    @Test
    public void testExceptionDetachedXPathNoResult() throws Exception {
        String xPath = "a/@stringAttr"; // for this xpath there is no result
        MockEndpoint mock = testXpath(xPath);
        checkThrownException(
                mock,
                XmlSignatureException.class,
                "No element to sign found in the detached case. No node found for the configured xpath expressions "
                        + xPath
View Full Code Here

                "<ns:root xmlns:ns=\"http://test\"><a ID=\"myID\"><b>bValue</b></a></ns:root>";
        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

                "<ns:root ID=\"rootId\" xmlns:ns=\"http://test\"><a ID=\"myID\"><b>bValue</b></a></ns:root>";
        String xPath = "//@ID";
        String localName = "root";
        String namespaceURI = "http://test";
        String referenceUri = "#rootId";
        MockEndpoint mock = testXpath(xPath, detachedPayload);
        checkThrownException(mock, XmlSignatureException.class,
                "Either the configuration of the XML Signature component is wrong or the incoming document has an invalid structure: The element "
                        + localName + "{" + namespaceURI + "} which is referenced by the reference URI " + referenceUri
                        + " has no parent element. The element must have a parent element in the configured detached case.", null);
    }
View Full Code Here

    @Test
    public void testExceptionParentLocalNameAndXPathSet() throws Exception {

        XmlSignerEndpoint endpoint = getSignatureEncpointForSignException();
        MockEndpoint mock = setupExceptionMock();
        try {
            endpoint.setParentXpath(getNodeSerachXPath());
            endpoint.setParentLocalName("root");
            sendBody("direct:signexceptions", payload);
            assertMockEndpointsSatisfied();
View Full Code Here

    @Test
    public void testExceptionXpathsToIdAttributesNameAndXPathSet() throws Exception {

        XmlSignerEndpoint endpoint = getSignatureEncpointForSignException();
        MockEndpoint mock = setupExceptionMock();
        try {
            endpoint.setParentXpath(getNodeSerachXPath());
            List<XPathFilterParameterSpec> xpaths = Collections.singletonList(XmlSignatureHelper.getXpathFilter("/ns:root/a/@ID", null));
            endpoint.setXpathsToIdAttributes(xpaths);
            sendBody("direct:signexceptions", payload);
View Full Code Here

    @Test
    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);
        assertEquals("{\"name\":\"Camel\"}", marshalledAsString);

        template.sendBody("direct:back", marshalled);

        mock.assertIsSatisfied();
    }
View Full Code Here

    @Test
    public void testExceptionInvalidParentXpath() throws Exception {

        XmlSignerEndpoint endpoint = getSignatureEncpointForSignException();
        MockEndpoint mock = setupExceptionMock();
        try {
            endpoint.setParentXpath(XmlSignatureHelper.getXpathFilter("//pre:root", null)); // invalid xpath: namespace-prefix mapping is missing
            sendBody("direct:signexceptions", payload);
            assertMockEndpointsSatisfied();
            checkThrownException(mock, XmlSignatureException.class,
View Full Code Here

    @Test
    public void testExceptionParentXpathWithNoResult() throws Exception {

        XmlSignerEndpoint endpoint = getSignatureEncpointForSignException();
        MockEndpoint mock = setupExceptionMock();
        try {
            endpoint.setParentXpath(XmlSignatureHelper.getXpathFilter("//root", null)); // xpath with no result
            sendBody("direct:signexceptions", payload);
            assertMockEndpointsSatisfied();
            checkThrownException(mock, XmlSignatureException.class,
View Full Code Here

TOP

Related Classes of org.apache.camel.component.mock.MockEndpoint

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.