Search in sources :

Example 21 with MockEndpoint

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

the class SignatureTests method setupMock.

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

Example 22 with MockEndpoint

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

the class PGPDataFormatTest method testExceptionDecryptorIncorrectInputFormatPGPSignedData.

@Test
public void testExceptionDecryptorIncorrectInputFormatPGPSignedData() throws Exception {
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    createSignature(bos);
    MockEndpoint mock = getMockEndpoint("mock:exception");
    mock.expectedMessageCount(1);
    template.sendBody("direct:subkeyUnmarshal", bos.toByteArray());
    assertMockEndpointsSatisfied();
    checkThrownException(mock, IllegalArgumentException.class, null, "The input message body has an invalid format.");
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Test(org.junit.Test)

Example 23 with MockEndpoint

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

the class PGPDataFormatTest method testExceptionDecryptorIncorrectInputFormatNoPGPMessage.

@Test
public void testExceptionDecryptorIncorrectInputFormatNoPGPMessage() throws Exception {
    String payload = "Not Correct Format";
    MockEndpoint mock = getMockEndpoint("mock:exception");
    mock.expectedMessageCount(1);
    template.sendBody("direct:subkeyUnmarshal", payload);
    assertMockEndpointsSatisfied();
    checkThrownException(mock, IllegalArgumentException.class, null, "The input message body has an invalid format.");
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 24 with MockEndpoint

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

the class PGPDataFormatTest method testVerifyExceptionNoPassphraseSpecifiedForSignatureKeyUserId.

@Test
public void testVerifyExceptionNoPassphraseSpecifiedForSignatureKeyUserId() throws Exception {
    MockEndpoint exception = setupExpectations(context, 1, "mock:exception");
    String payload = "Hi Alice, Be careful Eve is listening, signed Bob";
    Map<String, Object> headers = new HashMap<String, Object>();
    // add signature user id which does not have a passphrase
    headers.put(PGPKeyAccessDataFormat.SIGNATURE_KEY_USERID, "userIDWithNoPassphrase");
    // the following entry is necessary for the dynamic test
    headers.put(PGPKeyAccessDataFormat.KEY_USERID, "second");
    template.sendBodyAndHeaders("direct:several-signer-keys", payload, headers);
    assertMockEndpointsSatisfied();
    checkThrownException(exception, IllegalArgumentException.class, null, "No passphrase specified for signature key user ID");
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 25 with MockEndpoint

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

the class PGPDataFormatTest method testExceptionForSignatureVerificationOptionNoSignatureAllowed.

@Test
public void testExceptionForSignatureVerificationOptionNoSignatureAllowed() throws Exception {
    decryptor.setSignatureVerificationOption(PGPKeyAccessDataFormat.SIGNATURE_VERIFICATION_OPTION_NO_SIGNATURE_ALLOWED);
    MockEndpoint mock = getMockEndpoint("mock:exception");
    mock.expectedMessageCount(1);
    template.sendBody("direct:subkey", "Test Message");
    assertMockEndpointsSatisfied();
    checkThrownException(mock, PGPException.class, null, "PGP message contains a signature although a signature is not expected");
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

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