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();
}
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();
}
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();
}
}
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);
}
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;
}
Aggregations