Search in sources :

Example 86 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class SignatureDigestMethodTest method setupMock.

private MockEndpoint setupMock(String payload) {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedBodiesReceived(payload);
    return mock;
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 87 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class SignatureDigestMethodTest method doSignatureRouteTest.

public Exchange doSignatureRouteTest(RouteBuilder builder, Exchange e, Map<String, Object> headers) throws Exception {
    CamelContext context = new DefaultCamelContext();
    try {
        context.addRoutes(builder);
        context.start();
        MockEndpoint mock = context.getEndpoint("mock:result", MockEndpoint.class);
        mock.setExpectedMessageCount(1);
        ProducerTemplate template = context.createProducerTemplate();
        if (e != null) {
            template.send("direct:in", e);
        } else {
            template.sendBodyAndHeaders("direct:in", payload, headers);
        }
        assertMockEndpointsSatisfied();
        return mock.getReceivedExchanges().get(0);
    } finally {
        context.stop();
    }
}
Also used : DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext) CamelContext(org.apache.camel.CamelContext) ProducerTemplate(org.apache.camel.ProducerTemplate) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) DefaultCamelContext(org.apache.camel.impl.DefaultCamelContext)

Example 88 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class SpringXmlSignatureTest method xades.

@Test
public void xades() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    sendBody("direct:xades", payload);
    assertMockEndpointsSatisfied();
    Message message = getMessage(mock);
    byte[] body = message.getBody(byte[].class);
    Document doc = XmlSignatureHelper.newDocumentBuilder(true).parse(new ByteArrayInputStream(body));
    Map<String, String> prefix2Ns = XAdESSignaturePropertiesTest.getPrefix2NamespaceMap();
    prefix2Ns.put("t", "http://test.com/");
    XAdESSignaturePropertiesTest.checkXpath(doc, "/ds:Signature/ds:Object/etsi:QualifyingProperties/etsi:SignedProperties/etsi:SignedSignatureProperties/etsi:SignerRole/etsi:ClaimedRoles/etsi:ClaimedRole/t:test", prefix2Ns, "test");
}
Also used : Message(org.apache.camel.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ByteArrayInputStream(java.io.ByteArrayInputStream) Document(org.w3c.dom.Document) Test(org.junit.Test)

Example 89 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class XmlRpcComponentTest method invokeService.

private void invokeService(String uri) throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.reset();
    mock.expectedBodiesReceived("GreetMe!");
    template.requestBodyAndHeader(uri, new Object[] { "me" }, XmlRpcConstants.METHOD_NAME, "hello");
    assertMockEndpointsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 90 with MockEndpoint

use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.

the class XmlBeansDslTest method testSendXmlAndUnmarshal.

@Test
public void testSendXmlAndUnmarshal() throws Exception {
    MockEndpoint unmarshal = getMockEndpoint("mock:unmarshal");
    unmarshal.expectedMessageCount(1);
    MockEndpoint marshal = getMockEndpoint("mock:marshal");
    marshal.expectedMessageCount(1);
    template.sendBody("direct:start", createBuyStocksDocument());
    assertMockEndpointsSatisfied();
    Object marshaledBody = marshal.getReceivedExchanges().get(0).getIn().getBody();
    assertIsInstanceOf(byte[].class, marshaledBody);
    Object unmarshaledBody = unmarshal.getReceivedExchanges().get(0).getIn().getBody();
    assertIsInstanceOf(BuyStocksDocument.class, unmarshaledBody);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Aggregations

MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3401 Test (org.junit.Test)2024 Exchange (org.apache.camel.Exchange)511 RouteBuilder (org.apache.camel.builder.RouteBuilder)302 Processor (org.apache.camel.Processor)148 File (java.io.File)144 HashMap (java.util.HashMap)130 ObjectName (javax.management.ObjectName)90 MBeanServer (javax.management.MBeanServer)85 Message (org.apache.camel.Message)85 InputStream (java.io.InputStream)73 ArrayList (java.util.ArrayList)63 CamelExecutionException (org.apache.camel.CamelExecutionException)63 List (java.util.List)57 CamelContext (org.apache.camel.CamelContext)57 ProducerTemplate (org.apache.camel.ProducerTemplate)51 Tx (org.nhindirect.common.tx.model.Tx)49 ByteArrayInputStream (java.io.ByteArrayInputStream)47 Map (java.util.Map)43 RuntimeCamelException (org.apache.camel.RuntimeCamelException)38