use of java.text.SimpleDateFormat in project camel by apache.
the class TimerWithTimeOptionTest method testFiredInFutureWithTPattern.
public void testFiredInFutureWithTPattern() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
Date future = new Date(new Date().getTime() + 1000);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
String time = sdf.format(future);
fromF("timer://foo?time=%s", time).to("mock:result");
}
});
context.start();
MockEndpoint mock = getMockEndpoint("mock:result");
// period is default 1000 so we can get more messages
mock.expectedMinimumMessageCount(1);
assertMockEndpointsSatisfied();
}
use of java.text.SimpleDateFormat in project camel by apache.
the class TimerWithTimeOptionTest method testFiredInFutureWithTPatternFixedRate.
public void testFiredInFutureWithTPatternFixedRate() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
Date future = new Date(new Date().getTime() + 1000);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
String time = sdf.format(future);
fromF("timer://foo?fixedRate=true&time=%s", time).to("mock:result");
}
});
context.start();
MockEndpoint mock = getMockEndpoint("mock:result");
// period is default 1000 so we can get more messages
mock.expectedMinimumMessageCount(1);
assertMockEndpointsSatisfied();
}
use of java.text.SimpleDateFormat in project camel by apache.
the class TimerWithTimeOptionTest method testFiredInFutureWithTPatternNoPeriod.
public void testFiredInFutureWithTPatternNoPeriod() throws Exception {
context.addRoutes(new RouteBuilder() {
@Override
public void configure() throws Exception {
Date future = new Date(new Date().getTime() + 1000);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
String time = sdf.format(future);
fromF("timer://foo?period=0&time=%s", time).to("mock:result");
}
});
context.start();
MockEndpoint mock = getMockEndpoint("mock:result");
mock.expectedMessageCount(1);
assertMockEndpointsSatisfied();
}
use of java.text.SimpleDateFormat in project camel by apache.
the class TimerReferenceConfigurationTest method testReferenceConfiguration.
/**
* Test that the reference configuration params are correct
*
* @throws Exception
*/
public void testReferenceConfiguration() throws Exception {
Endpoint e = context.getEndpoint(refTimerUri);
TimerEndpoint timer = (TimerEndpoint) e;
final Date expectedTimeObject = new SimpleDateFormat(refExpectedPattern).parse(refExpectedTimeString);
final Date time = timer.getTime();
final long period = timer.getPeriod();
final long delay = timer.getDelay();
final boolean fixedRate = timer.isFixedRate();
final boolean daemon = timer.isDaemon();
final long repeatCount = timer.getRepeatCount();
assertEquals(refExpectedDelay, delay);
assertEquals(refExpectedPeriod, period);
assertEquals(expectedTimeObject, time);
assertEquals(refExpectedFixedRate, fixedRate);
assertEquals(refExpectedDaemon, daemon);
assertEquals(refExpectedRepeatCount, repeatCount);
}
use of java.text.SimpleDateFormat in project camel by apache.
the class WireTapNewExchangeTest method testFireAndForgetUsingExpressions.
public void testFireAndForgetUsingExpressions() throws Exception {
MockEndpoint result = getMockEndpoint("mock:result");
result.expectedBodiesReceived("Hello World");
MockEndpoint tap = getMockEndpoint("mock:tap");
tap.expectedBodiesReceived("Bye World");
tap.expectedHeaderReceived("id", 123);
String today = new SimpleDateFormat("yyyyMMdd").format(new Date());
tap.expectedHeaderReceived("date", today);
template.sendBody("direct:start", "Hello World");
assertMockEndpointsSatisfied();
}
Aggregations