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