use of org.apache.camel.ProducerTemplate in project camel by apache.
the class CamelGreeterFileDomTest method testCamelGreeter.
@Test
public void testCamelGreeter() throws Exception {
TestSupport.deleteDirectory("target/greeter/response");
assertNotNull(camelContext);
ProducerTemplate template = camelContext.createProducerTemplate();
Object result = template.requestBody("direct:start", REQUEST);
template.stop();
assertEquals("The result is wrong.", "Hello Willem", result);
File file = new File("target/greeter/response/response.txt");
assertTrue("File " + file + " should be there.", file.exists());
}
use of org.apache.camel.ProducerTemplate in project camel by apache.
the class CamelGreeterTest method testMocksAreValid.
@Test
public void testMocksAreValid() throws Exception {
assertNotNull(camelContext);
assertNotNull(resultEndpoint);
ProducerTemplate template = camelContext.createProducerTemplate();
template.sendBodyAndHeader("jms:requestQueue", "Willem", CxfConstants.OPERATION_NAME, "greetMe");
// Sleep a while and wait for the message whole processing
Thread.sleep(4000);
template.stop();
MockEndpoint.assertIsSatisfied(camelContext);
List<Exchange> list = resultEndpoint.getReceivedExchanges();
assertEquals("Should get one message", list.size(), 1);
for (Exchange exchange : list) {
String result = (String) exchange.getIn().getBody();
assertEquals("Get the wrong result ", result, "Hello Willem");
}
}
use of org.apache.camel.ProducerTemplate in project camel by apache.
the class JettyJmsTest method testMocksAreValid.
@Test
public void testMocksAreValid() throws Exception {
assertNotNull(resultEndpoint);
resultEndpoint.reset();
ProducerTemplate template = camelContext.createProducerTemplate();
template.sendBodyAndHeader(URL, "Hello form Willem", "Operation", "greetMe");
// Sleep a while and wait for the message whole processing
Thread.sleep(4000);
template.stop();
MockEndpoint.assertIsSatisfied(camelContext);
List<Exchange> list = resultEndpoint.getReceivedExchanges();
assertEquals("Should get one message", list.size(), 1);
for (Exchange exchange : list) {
Object result = exchange.getIn().getBody();
assertEquals("Should get the request", "Hello form Willem", result);
assertEquals("Should get the header", "greetMe", exchange.getIn().getHeader("Operation"));
}
}
use of org.apache.camel.ProducerTemplate in project java-design-patterns by iluwatar.
the class App method main.
/**
* Program entry point
*/
public static void main(String[] args) throws Exception {
CamelContext context = new DefaultCamelContext();
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
from("direct:origin").multicast().to("mock:foo", "mock:bar", "stream:out");
}
});
ProducerTemplate template = context.createProducerTemplate();
context.start();
context.getRoutes().stream().forEach(r -> LOGGER.info(r.toString()));
template.sendBody("direct:origin", "Hello from origin");
context.stop();
}
use of org.apache.camel.ProducerTemplate in project quickstarts by jboss-switchyard.
the class HL7Client method testSendA19.
public void testSendA19() throws Exception {
SimpleRegistry registry = new SimpleRegistry();
HL7MLLPCodec codec = new HL7MLLPCodec();
codec.setCharset("iso-8859-1");
codec.setConvertLFtoCR(true);
registry.put("hl7codec", codec);
CamelContext camelContext = new DefaultCamelContext(registry);
camelContext.start();
ProducerTemplate template = camelContext.createProducerTemplate();
String line1 = "MSH|^~\\&|MYSENDER|MYRECEIVER|MYAPPLICATION||200612211200||QRY^A19|1234|P|2.4";
String line2 = "QRD|200612211200|R|I|GetPatient|||1^RD|0101701234|DEM||";
StringBuilder in = new StringBuilder();
in.append(line1);
in.append("\r");
in.append(line2);
template.requestBody("mina2:tcp://127.0.0.1:" + MINA2_PORT + "?sync=true&codec=#hl7codec", in.toString());
template.stop();
camelContext.stop();
}
Aggregations