Search in sources :

Example 11 with MockEndpoint

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();
}
Also used : CoapResponse(org.eclipse.californium.core.CoapResponse) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) CoapClient(org.eclipse.californium.core.CoapClient) Test(org.junit.Test)

Example 12 with MockEndpoint

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();
}
Also used : CoapResponse(org.eclipse.californium.core.CoapResponse) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) CoapClient(org.eclipse.californium.core.CoapClient) Test(org.junit.Test)

Example 13 with MockEndpoint

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));
    }
}
Also used : Exchange(org.apache.camel.Exchange) ServerMessage(org.cometd.bayeux.server.ServerMessage) Message(org.apache.camel.Message) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 14 with MockEndpoint

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());
    }
}
Also used : Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Test(org.junit.Test)

Example 15 with MockEndpoint

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());
}
Also used : EventResponse(com.orbitz.consul.model.EventResponse) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) Event(com.orbitz.consul.model.event.Event) 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