Search in sources :

Example 26 with MockEndpoint

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

the class PGPDataFormatTest method testEmptyBody.

@Test
public void testEmptyBody() throws Exception {
    String payload = "";
    MockEndpoint mockSubkey = getMockEndpoint("mock:unencrypted");
    mockSubkey.expectedBodiesReceived(payload);
    template.sendBody("direct:subkey", payload);
    assertMockEndpointsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 27 with MockEndpoint

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

the class PGPDataFormatTest method testSignatureVerificationOptionIgnore.

@Test
public void testSignatureVerificationOptionIgnore() throws Exception {
    // encryptor is sending a PGP message with signature! Decryptor is ignoreing the signature
    decryptor.setSignatureVerificationOption(PGPKeyAccessDataFormat.SIGNATURE_VERIFICATION_OPTION_IGNORE);
    decryptor.setSignatureKeyUserids(null);
    // no public keyring! --> no signature validation possible
    decryptor.setSignatureKeyFileName(null);
    String payload = "Test Message";
    MockEndpoint mock = getMockEndpoint("mock:unencrypted");
    mock.expectedBodiesReceived(payload);
    template.sendBody("direct:subkey", payload);
    assertMockEndpointsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 28 with MockEndpoint

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

the class SignatureTests 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 29 with MockEndpoint

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

the class AbstractPGPDataFormatTest method doRoundTripEncryptionTests.

protected void doRoundTripEncryptionTests(String endpoint) throws Exception {
    MockEndpoint encrypted = setupExpectations(context, 3, "mock:encrypted");
    MockEndpoint unencrypted = setupExpectations(context, 3, "mock:unencrypted");
    String payload = "Hi Alice, Be careful Eve is listening, signed Bob";
    Map<String, Object> headers = getHeaders();
    template.sendBodyAndHeaders(endpoint, payload, headers);
    template.sendBodyAndHeaders(endpoint, payload.getBytes(), headers);
    template.sendBodyAndHeaders(endpoint, new ByteArrayInputStream(payload.getBytes()), headers);
    assertMocksSatisfied(encrypted, unencrypted, payload);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ByteArrayInputStream(java.io.ByteArrayInputStream)

Example 30 with MockEndpoint

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

the class AbstractPGPDataFormatTest method setupExpectations.

public MockEndpoint setupExpectations(CamelContext context, int expected, String mock) {
    MockEndpoint mockEp = context.getEndpoint(mock, MockEndpoint.class);
    mockEp.expectedMessageCount(expected);
    return mockEp;
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Aggregations

MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3393 Test (org.junit.Test)2016 Exchange (org.apache.camel.Exchange)506 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