Search in sources :

Example 56 with MockEndpoint

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

the class MixedStreamCachingInterceptorTest method testNoStreamCaching.

public void testNoStreamCaching() throws Exception {
    MockEndpoint b = getMockEndpoint("mock:b");
    b.expectedMessageCount(1);
    StreamSource message = new StreamSource(new StringReader("<hello>world!</hello>"));
    template.sendBody("direct:b", message);
    assertMockEndpointsSatisfied();
    Exchange exchange = b.getExchanges().get(0);
    StreamSource stream = assertIsInstanceOf(StreamSource.class, exchange.getIn().getBody());
    assertNotNull(stream);
}
Also used : Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader)

Example 57 with MockEndpoint

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

the class NoStreamCachingInterceptorTest method testNoStreamCachingInterceptorEnabled.

public void testNoStreamCachingInterceptorEnabled() throws Exception {
    MockEndpoint a = getMockEndpoint("mock:a");
    a.expectedMessageCount(1);
    StreamSource message = new StreamSource(new StringReader("<hello>world!</hello>"));
    template.sendBody("direct:a", message);
    assertMockEndpointsSatisfied();
    Exchange exchange = a.getExchanges().get(0);
    StreamSource stream = assertIsInstanceOf(StreamSource.class, exchange.getIn().getBody());
    assertNotNull(stream);
}
Also used : Exchange(org.apache.camel.Exchange) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) StreamSource(javax.xml.transform.stream.StreamSource) StringReader(java.io.StringReader)

Example 58 with MockEndpoint

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

the class SpringPackageTest method testFoundRoute.

public void testFoundRoute() throws Exception {
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    template.sendBody("direct:start", "Hello World");
    mock.assertIsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 59 with MockEndpoint

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

the class SpringPropertyPlaceholderFileEndpointIssueTest method testSpring.

public void testSpring() throws Exception {
    deleteDirectory("target/issue");
    MockEndpoint mock = getMockEndpoint("mock:result");
    mock.expectedMessageCount(1);
    mock.expectedFileExists("target/issue/foo.txt");
    template.sendBodyAndHeader("direct:start", "Hello World", "foo", "foo.txt");
    assertMockEndpointsSatisfied();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Example 60 with MockEndpoint

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

the class StringDataFormatTest method testMarshalString.

public void testMarshalString() throws Exception {
    // include a UTF-8 char in the text จ is a Thai elephant
    String body = "Hello Thai Elephant จ";
    MockEndpoint mock = getMockEndpoint("mock:marshal");
    mock.expectedMessageCount(1);
    byte[] out = (byte[]) template.requestBody("direct:marshal", body);
    assertMockEndpointsSatisfied();
    String result = new String(out, "UTF-8");
    assertEquals(body, result);
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint)

Aggregations

MockEndpoint (org.apache.camel.component.mock.MockEndpoint)3401 Test (org.junit.Test)2024 Exchange (org.apache.camel.Exchange)511 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