Search in sources :

Example 1 with GregorianCalendar

use of java.util.GregorianCalendar in project camel by apache.

the class BindyFixedLengthDynamicFieldTest method testMarshallMessage.

@Test
public void testMarshallMessage() throws Exception {
    BindyFixedLengthDynamicFieldTest.Order order = new Order();
    order.setOrderNr(10);
    order.setOrderType("BUY");
    order.setClientNr("A9");
    order.setFirstName("Pauline");
    order.setLastName("M");
    order.setAmount(new BigDecimal("2500.45"));
    order.setInstrumentCode("ISIN");
    order.setInstrumentNumberLen(10);
    order.setInstrumentNumber("XD12345678");
    order.setInstrumentType("Share");
    order.setCurrency("USD");
    Calendar calendar = new GregorianCalendar();
    calendar.set(2009, 7, 1);
    order.setOrderDate(calendar.getTime());
    marshallResult.expectedMessageCount(1);
    marshallResult.expectedBodiesReceived(Arrays.asList(new String[] { TEST_RECORD }));
    template.sendBody(URI_DIRECT_MARSHALL, order);
    marshallResult.assertIsSatisfied();
}
Also used : GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 2 with GregorianCalendar

use of java.util.GregorianCalendar in project camel by apache.

the class BindySimpleFixedLengthHeaderFooterTest method testMarshallMessageWithIndirectHeaderAndFooterInput.

/**
     * Verifies that header & footer provided via message headers are marshalled successfully
     */
@Test
public void testMarshallMessageWithIndirectHeaderAndFooterInput() throws Exception {
    Order order = new Order();
    order.setOrderNr(10);
    order.setOrderType("BUY");
    order.setClientNr("A9");
    order.setFirstName("Pauline");
    order.setLastName("M");
    order.setAmount(new BigDecimal("2500.45"));
    order.setInstrumentCode("ISIN");
    order.setInstrumentNumber("XD12345678");
    order.setInstrumentType("Share");
    order.setCurrency("USD");
    Calendar calendar = new GregorianCalendar();
    calendar.set(2009, 7, 1, 0, 0, 0);
    order.setOrderDate(calendar.getTime());
    List<Map<String, Object>> input = new ArrayList<Map<String, Object>>();
    Map<String, Object> bodyRow = new HashMap<String, Object>();
    bodyRow.put(Order.class.getName(), order);
    input.add(bodyRow);
    Map<String, Object> headers = new HashMap<String, Object>();
    headers.put(BindyFixedLengthDataFormat.CAMEL_BINDY_FIXED_LENGTH_HEADER, createHeaderRow());
    headers.put(BindyFixedLengthDataFormat.CAMEL_BINDY_FIXED_LENGTH_FOOTER, createFooterRow());
    marshallResult.reset();
    marshallResult.expectedMessageCount(1);
    StringBuffer buff = new StringBuffer();
    buff.append(TEST_HEADER).append(TEST_RECORD).append(TEST_FOOTER);
    marshallResult.expectedBodiesReceived(Arrays.asList(new String[] { buff.toString() }));
    template.sendBodyAndHeaders(URI_DIRECT_MARSHALL, input, headers);
    marshallResult.assertIsSatisfied();
}
Also used : HashMap(java.util.HashMap) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) ArrayList(java.util.ArrayList) HashMap(java.util.HashMap) Map(java.util.Map) BigDecimal(java.math.BigDecimal) Test(org.junit.Test)

Example 3 with GregorianCalendar

use of java.util.GregorianCalendar in project camel by apache.

the class BindyPojoSimpleCsvMarshallTest method generateModel.

public Object generateModel() {
    // just use the order POJO directly
    Order order = new Order();
    order.setOrderNr(1);
    order.setOrderType("BUY");
    order.setClientNr("B2");
    order.setFirstName("Keira");
    order.setLastName("Knightley");
    order.setAmount(new BigDecimal("400.25"));
    order.setInstrumentCode("ISIN");
    order.setInstrumentNumber("XX23456789");
    order.setInstrumentType("Share");
    order.setCurrency("EUR");
    Calendar calendar = new GregorianCalendar();
    calendar.set(2009, 0, 14);
    order.setOrderDate(calendar.getTime());
    calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    // 4 hour shift
    // 16-02-2010 23:21:59 by GMT+4
    calendar.set(2010, 1, 17, 19, 27, 59);
    calendar.set(Calendar.MILLISECOND, 0);
    order.setOrderDateTime(calendar.getTime());
    return order;
}
Also used : Order(org.apache.camel.dataformat.bindy.model.simple.oneclass.Order) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) BigDecimal(java.math.BigDecimal)

Example 4 with GregorianCalendar

use of java.util.GregorianCalendar in project camel by apache.

the class BindySimpleCsvMarshallDslTest method generateModel.

public List<Map<String, Object>> generateModel() {
    Map<String, Object> modelObjects = new HashMap<String, Object>();
    Order order = new Order();
    order.setOrderNr(1);
    order.setOrderType("BUY");
    order.setClientNr("B2");
    order.setFirstName("Keira");
    order.setLastName("Knightley");
    order.setAmount(new BigDecimal("450.45").setScale(2));
    order.setInstrumentCode("ISIN");
    order.setInstrumentNumber("XX23456789");
    order.setInstrumentType("Share");
    order.setCurrency("EUR");
    Calendar calendar = new GregorianCalendar();
    calendar.set(2009, 0, 14);
    order.setOrderDate(calendar.getTime());
    calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    // 4 hour shift
    // 17-05-2010 23:21:59 by GMT+4
    calendar.set(2010, 4, 17, 19, 21, 59);
    order.setOrderDateTime(calendar.getTime());
    modelObjects.put(order.getClass().getName(), order);
    models.add(modelObjects);
    return models;
}
Also used : Order(org.apache.camel.dataformat.bindy.model.simple.oneclass.Order) HashMap(java.util.HashMap) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) BigDecimal(java.math.BigDecimal)

Example 5 with GregorianCalendar

use of java.util.GregorianCalendar in project camel by apache.

the class BindySimpleCsvMarshallTest method generateModel.

public List<Map<String, Object>> generateModel() {
    Map<String, Object> modelObjects = new HashMap<String, Object>();
    Order order = new Order();
    order.setOrderNr(1);
    order.setOrderType("BUY");
    order.setClientNr("B2");
    order.setFirstName("Keira");
    order.setLastName("Knightley");
    order.setAmount(new BigDecimal("400.25"));
    order.setInstrumentCode("ISIN");
    order.setInstrumentNumber("XX23456789");
    order.setInstrumentType("Share");
    order.setCurrency("EUR");
    Calendar calendar = new GregorianCalendar();
    calendar.set(2009, 0, 14);
    order.setOrderDate(calendar.getTime());
    calendar = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
    // 4 hour shift
    // 17-02-2011 23:21:59 by GMT+4
    calendar.set(2011, 1, 17, 19, 21, 59);
    order.setOrderDateTime(calendar.getTime());
    modelObjects.put(order.getClass().getName(), order);
    models.add(modelObjects);
    return models;
}
Also used : Order(org.apache.camel.dataformat.bindy.model.simple.oneclass.Order) HashMap(java.util.HashMap) GregorianCalendar(java.util.GregorianCalendar) Calendar(java.util.Calendar) GregorianCalendar(java.util.GregorianCalendar) BigDecimal(java.math.BigDecimal)

Aggregations

GregorianCalendar (java.util.GregorianCalendar)1212 Calendar (java.util.Calendar)574 Date (java.util.Date)358 Test (org.junit.Test)233 SimpleDateFormat (java.text.SimpleDateFormat)100 Timestamp (java.sql.Timestamp)54 ScheduleExpression (javax.ejb.ScheduleExpression)51 ArrayList (java.util.ArrayList)47 EJBCronTrigger (org.apache.openejb.core.timer.EJBCronTrigger)42 HashMap (java.util.HashMap)41 ParseException (java.text.ParseException)38 TimeZone (java.util.TimeZone)38 SimpleTimeZone (java.util.SimpleTimeZone)35 BigDecimal (java.math.BigDecimal)32 Date (java.sql.Date)30 XMLGregorianCalendar (javax.xml.datatype.XMLGregorianCalendar)21 DateFormat (java.text.DateFormat)18 SQLException (java.sql.SQLException)17 Map (java.util.Map)16 Meeting (net.johnpwood.android.standuptimer.model.Meeting)16