Search in sources :

Example 6 with SimpleDateFormat

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();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SimpleDateFormat(java.text.SimpleDateFormat) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ParseException(java.text.ParseException) Date(java.util.Date)

Example 7 with SimpleDateFormat

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();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SimpleDateFormat(java.text.SimpleDateFormat) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ParseException(java.text.ParseException) Date(java.util.Date)

Example 8 with SimpleDateFormat

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();
}
Also used : RouteBuilder(org.apache.camel.builder.RouteBuilder) MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SimpleDateFormat(java.text.SimpleDateFormat) FailedToCreateRouteException(org.apache.camel.FailedToCreateRouteException) ParseException(java.text.ParseException) Date(java.util.Date)

Example 9 with SimpleDateFormat

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);
}
Also used : Endpoint(org.apache.camel.Endpoint) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Example 10 with SimpleDateFormat

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();
}
Also used : MockEndpoint(org.apache.camel.component.mock.MockEndpoint) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date)

Aggregations

SimpleDateFormat (java.text.SimpleDateFormat)2847 Date (java.util.Date)1590 ParseException (java.text.ParseException)463 DateFormat (java.text.DateFormat)425 Calendar (java.util.Calendar)307 Test (org.junit.Test)305 ArrayList (java.util.ArrayList)232 File (java.io.File)230 IOException (java.io.IOException)185 GregorianCalendar (java.util.GregorianCalendar)139 HashMap (java.util.HashMap)121 Locale (java.util.Locale)70 DateField (edu.uci.ics.textdb.api.field.DateField)64 DoubleField (edu.uci.ics.textdb.api.field.DoubleField)64 IField (edu.uci.ics.textdb.api.field.IField)64 IntegerField (edu.uci.ics.textdb.api.field.IntegerField)64 StringField (edu.uci.ics.textdb.api.field.StringField)63 TextField (edu.uci.ics.textdb.api.field.TextField)63 Map (java.util.Map)63 Tuple (edu.uci.ics.textdb.api.tuple.Tuple)61