use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class ConsulEventWatchTest method testWatchEvent.
@Test
public void testWatchEvent() throws Exception {
List<String> values = generateRandomListOfStrings(3);
MockEndpoint mock = getMockEndpoint("mock:event-watch");
mock.expectedMessageCount(values.size());
mock.expectedBodiesReceived(values);
mock.expectedHeaderReceived(ConsulConstants.CONSUL_RESULT, true);
values.forEach(v -> client.fireEvent(key, v));
mock.assertIsSatisfied();
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class ConsulKeyValueWatchTest method testWatchKey.
@Test
public void testWatchKey() throws Exception {
List<String> values = generateRandomListOfStrings(3);
MockEndpoint mock = getMockEndpoint("mock:kv-watch");
mock.expectedMessageCount(values.size());
mock.expectedBodiesReceived(values);
mock.expectedHeaderReceived(ConsulConstants.CONSUL_RESULT, true);
for (String val : values) {
client.putValue(key, val);
Thread.sleep(250 + random.nextInt(250));
}
mock.assertIsSatisfied();
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class CoAPComponentTest method testCoAP.
@Test
public void testCoAP() throws Exception {
NetworkConfig.createStandardWithoutFile();
CoapClient client = new CoapClient("coap://localhost:" + PORT + "/TestResource");
CoapResponse rsp = client.get();
assertEquals("Hello ", rsp.getResponseText());
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMinimumMessageCount(1);
mock.expectedBodiesReceived("Hello");
sender.sendBody("Hello");
assertMockEndpointsSatisfied();
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class ECDSASignatureTest 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 SignatureTests method testVerifyHeadersNotCleared.
@Test
public void testVerifyHeadersNotCleared() throws Exception {
setupMock();
template.requestBody("direct:headers", payload);
assertMockEndpointsSatisfied();
assertMockEndpointsSatisfied();
MockEndpoint mock = getMockEndpoint("mock:result");
Exchange e = mock.getExchanges().get(0);
Message result = e == null ? null : e.hasOut() ? e.getOut() : e.getIn();
assertNotNull(result.getHeader(DigitalSignatureConstants.SIGNATURE));
}
Aggregations