use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class NettyHttpStreamCacheFileResponseTest method testStreamCacheToFileShouldBeDeletedInCaseOfResponse.
@Test
public void testStreamCacheToFileShouldBeDeletedInCaseOfResponse() throws Exception {
NotifyBuilder builder = new NotifyBuilder(context).whenDone(1).create();
String out = template.requestBody("http://localhost:{{port}}/myserver", body, String.class);
assertEquals(body2, out);
assertTrue(builder.matches(5, TimeUnit.SECONDS));
// the temporary files should have been deleted
File file = new File("target/cachedir");
String[] files = file.list();
assertEquals("There should be no files", 0, files.length);
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class NettyHttpStreamCacheFileResponseTest method testStreamCacheToFileShouldBeDeletedInCaseOfResponse.
@Test
public void testStreamCacheToFileShouldBeDeletedInCaseOfResponse() throws Exception {
NotifyBuilder builder = new NotifyBuilder(context).whenDone(1).create();
String out = template.requestBody("http://localhost:{{port}}/myserver", body, String.class);
assertEquals(body2, out);
assertTrue(builder.matches(5, TimeUnit.SECONDS));
// the temporary files should have been deleted
File file = new File("target/cachedir");
String[] files = file.list();
assertEquals("There should be no files", 0, files.length);
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class JmsErrorHandlerLogStackTraceTest method testErrorHandlerLogStackTrace.
@Test
public void testErrorHandlerLogStackTrace() throws Exception {
JmsComponent jms = context.getComponent("jms", JmsComponent.class);
assertFalse(jms.getConfiguration().isErrorHandlerLogStackTrace());
// should fail
NotifyBuilder notify = new NotifyBuilder(context).whenFailed(1).create();
template.sendBody("jms:queue:foo", "Hello World");
assertTrue(notify.matchesMockWaitTime());
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class JmsRequestReplyCorrelationTest method testRequestReplyCorrelationWithDuplicateId.
/**
* As the correlationID should be unique when receiving the reply message,
* now we just expect to get an exception here.
*/
@Test
public void testRequestReplyCorrelationWithDuplicateId() throws Exception {
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedMessageCount(1);
NotifyBuilder notify = new NotifyBuilder(context).whenReceived(1).create();
// just send out the request to fill the correlation id first
template.asyncSend("jms:queue:helloDelay", new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.setPattern(ExchangePattern.InOut);
Message in = exchange.getIn();
in.setBody("Hello World");
in.setHeader("JMSCorrelationID", "b");
}
});
// Added use the notify to make sure the message is processed, so we get the exception later
notify.matches(1, TimeUnit.SECONDS);
Exchange out = template.send("jms:queue:helloDelay", ExchangePattern.InOut, new Processor() {
public void process(Exchange exchange) throws Exception {
Message in = exchange.getIn();
in.setBody("Hello World");
in.setHeader("JMSCorrelationID", "b");
}
});
result.assertIsSatisfied();
assertNotNull("We are expecting the exception here!", out.getException());
assertTrue("Get a wrong exception", out.getException() instanceof IllegalArgumentException);
}
use of org.apache.camel.builder.NotifyBuilder in project camel by apache.
the class QueueToQueueTransactionWithoutDefineTransactionManagerTest method testNoTransactionRollbackUsingXmlQueueToQueue.
@Test
public void testNoTransactionRollbackUsingXmlQueueToQueue() throws Exception {
// configure routes and add to camel context
context.addRoutes(new SpringRouteBuilder() {
@Override
public void configure() throws Exception {
errorHandler(noErrorHandler());
from("activemq:queue:foo?transacted=false").process(new ConditionalExceptionProcessor()).to("activemq:queue:bar?transacted=false");
}
});
NotifyBuilder notify = new NotifyBuilder(context).whenDone(1).create();
template.sendBody("activemq:queue:foo", "blah");
notify.matchesMockWaitTime();
assertTrue("Expected only 1 calls to process() (1 failure) but encountered " + getConditionalExceptionProcessor().getCount() + ".", getConditionalExceptionProcessor().getCount() == 1);
}
Aggregations