use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class CoAPRestVerbTest method testDelete.
@Test
public void testDelete() throws Exception {
NetworkConfig.createStandardWithoutFile();
MockEndpoint mock = getMockEndpoint("mock:delete");
mock.expectedHeaderReceived("id", "1");
CoapClient client = new CoapClient("coap://localhost:" + coapport + "/users/1");
client.setTimeout(1000000);
CoapResponse rsp = client.delete();
assertMockEndpointsSatisfied();
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class CoAPRestVerbTest method testPut.
@Test
public void testPut() throws Exception {
NetworkConfig.createStandardWithoutFile();
final String body = "{ \"id\":\"1\", \"name\":\"Scott\" }";
MockEndpoint mock = getMockEndpoint("mock:update");
mock.expectedBodiesReceived(body);
mock.expectedHeaderReceived("id", "1");
CoapClient client = new CoapClient("coap://localhost:" + coapport + "/users/1");
client.setTimeout(1000000);
CoapResponse rsp = client.put(body, MediaTypeRegistry.APPLICATION_JSON);
assertMockEndpointsSatisfied();
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class CometdProducerConsumerTest method testSessionInformationTransferred.
@Test
public void testSessionInformationTransferred() throws Exception {
// act
template.sendBody("direct:input", "message");
// assert
MockEndpoint ep = context.getEndpoint("mock:test", MockEndpoint.class);
List<Exchange> exchanges = ep.getReceivedExchanges();
assertTrue(exchanges.size() > 0);
for (Exchange exchange : exchanges) {
Message message = exchange.getIn();
assertTrue((Boolean) message.getHeader(SHOOKHANDS_SESSION_HEADER));
}
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class SslContextParametersInUriCometdProducerConsumerTest method testProducer.
@Test
public void testProducer() throws Exception {
Person person = new Person("David", "Greco");
template.requestBody("direct:input", person);
MockEndpoint ep = context.getEndpoint("mock:test", MockEndpoint.class);
List<Exchange> exchanges = ep.getReceivedExchanges();
for (Exchange exchange : exchanges) {
Person person1 = (Person) exchange.getIn().getBody();
assertEquals("David", person1.getName());
assertEquals("Greco", person1.getSurname());
}
}
use of org.apache.camel.component.mock.MockEndpoint in project camel by apache.
the class ConsulEventTest method testFireEvent.
@Test
public void testFireEvent() throws Exception {
String key = generateRandomString();
String val = generateRandomString();
MockEndpoint mock = getMockEndpoint("mock:event");
mock.expectedMinimumMessageCount(1);
mock.expectedHeaderReceived(ConsulConstants.CONSUL_RESULT, true);
fluentTemplate().withHeader(ConsulConstants.CONSUL_ACTION, ConsulEventActions.FIRE).withHeader(ConsulConstants.CONSUL_KEY, key).withBody(val).to("direct:event").send();
mock.assertIsSatisfied();
EventResponse response = getConsul().eventClient().listEvents(key);
List<Event> events = response.getEvents();
assertFalse(events.isEmpty());
assertTrue(events.get(0).getPayload().isPresent());
assertEquals(val, events.get(0).getPayload().get());
}
Aggregations