当前位置: 首页>>代码示例>>Java>>正文


Java InputOrder类代码示例

本文整理汇总了Java中camelinaction.order.InputOrder的典型用法代码示例。如果您正苦于以下问题:Java InputOrder类的具体用法?Java InputOrder怎么用?Java InputOrder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


InputOrder类属于camelinaction.order包,在下文中一共展示了InputOrder类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processOrder

import camelinaction.order.InputOrder; //导入依赖的package包/类
public void processOrder(Exchange exchange, InputOrder order,
                         @Header(Exchange.REDELIVERED) Boolean redelivered) throws Exception {

    // simulate CPU processing of the order by sleeping a bit
    Thread.sleep(1000);

    // simulate fatal error if we refer to a special no
    if (order.getRefNo().equals("FATAL")) {
        throw new IllegalArgumentException("Simulated fatal error");
    }

    // simulate fail once if we have not yet redelivered, which means its the first
    // time processOrder method is called
    if (order.getRefNo().equals("FAIL-ONCE") && redelivered == null) {
        throw new IOException("Simulated failing once");
    }

    // processing is okay
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:20,代码来源:OrderService.java

示例2: testOrderOk

import camelinaction.order.InputOrder; //导入依赖的package包/类
@Test
public void testOrderOk() throws Exception {
    // there should be 0 row in the database when we start
    int rows = jdbc.queryForObject("select count(*) from riders_order", Integer.class);
    assertEquals(0, rows);

    InputOrder input = new InputOrder();
    input.setCustomerId("4444");
    input.setRefNo("57123");
    input.setPartId("333");
    input.setAmount("50");

    // give CXF time to wake up
    Thread.sleep(2000);

    OutputOrder reply = template.requestBody("cxf:bean:orderEndpoint", input, OutputOrder.class);
    assertEquals("OK", reply.getCode());

    // there should be 1 row in the database with the inserted order
    rows = jdbc.queryForObject("select count(*) from riders_order", Integer.class);
    assertEquals(1, rows);
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:23,代码来源:OrderTest.java

示例3: testOrderFailOnce

import camelinaction.order.InputOrder; //导入依赖的package包/类
@Test
public void testOrderFailOnce() throws Exception {
    // there should be 0 row in the database when we start
    int rows = jdbc.queryForObject("select count(*) from riders_order", Integer.class);
    assertEquals(0, rows);

    InputOrder input = new InputOrder();
    input.setCustomerId("4444");
    // by using FAIL-ONCE as ref no we simulate failure in first processing
    input.setRefNo("FAIL-ONCE");
    input.setPartId("333");
    input.setAmount("50");

    // give CXF time to wake up
    Thread.sleep(2000);

    OutputOrder reply = template.requestBody("cxf:bean:orderEndpoint", input, OutputOrder.class);
    assertEquals("OK", reply.getCode());

    // there should be 1 row in the database with the inserted order
    rows = jdbc.queryForObject("select count(*) from riders_order", Integer.class);
    assertEquals(1, rows);
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:24,代码来源:OrderTest.java

示例4: testOrderFailAll

import camelinaction.order.InputOrder; //导入依赖的package包/类
@Test
public void testOrderFailAll() throws Exception {
    // there should be 0 row in the database when we start
    int rows = jdbc.queryForObject("select count(*) from riders_order", Integer.class);
    assertEquals(0, rows);

    InputOrder input = new InputOrder();
    input.setCustomerId("4444");
    // by using FATAL as ref no we simulate failure in all processing
    input.setRefNo("FATAL");
    input.setPartId("333");
    input.setAmount("50");

    // give CXF time to wake up
    Thread.sleep(2000);

    OutputOrder reply = template.requestBody("cxf:bean:orderEndpoint", input, OutputOrder.class);
    assertEquals("ERROR: Simulated fatal error", reply.getCode());

    // there should still be 0 row in the database as the entire route was rolled back
    rows = jdbc.queryForObject("select count(*) from riders_order", Integer.class);
    assertEquals(0, rows);
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:24,代码来源:OrderTest.java

示例5: testOrderOk

import camelinaction.order.InputOrder; //导入依赖的package包/类
@Test
public void testOrderOk() throws Exception {
    // there should be 0 row in the database when we start
    assertEquals(0, jdbc.queryForInt("select count(*) from riders_order"));

    InputOrder input = new InputOrder();
    input.setCustomerId("4444");
    input.setRefNo("57123");
    input.setPartId("333");
    input.setAmount("50");

    // give CXF time to wake up
    Thread.sleep(2000);

    OutputOrder reply = template.requestBody("cxf:bean:orderEndpoint", input, OutputOrder.class);
    assertEquals("OK", reply.getCode());

    // there should be 1 row in the database with the inserted order
    assertEquals(1, jdbc.queryForInt("select count(*) from riders_order"));
}
 
开发者ID:camelinaction,项目名称:camelinaction,代码行数:21,代码来源:OrderTest.java

示例6: testOrderFailOnce

import camelinaction.order.InputOrder; //导入依赖的package包/类
@Test
public void testOrderFailOnce() throws Exception {
    // there should be 0 row in the database when we start
    assertEquals(0, jdbc.queryForInt("select count(*) from riders_order"));

    InputOrder input = new InputOrder();
    input.setCustomerId("4444");
    // by using FAIL-ONCE as ref no we simulate failure in first processing
    input.setRefNo("FAIL-ONCE");
    input.setPartId("333");
    input.setAmount("50");

    // give CXF time to wake up
    Thread.sleep(2000);

    OutputOrder reply = template.requestBody("cxf:bean:orderEndpoint", input, OutputOrder.class);
    assertEquals("OK", reply.getCode());

    // there should be 1 row in the database with the inserted order
    assertEquals(1, jdbc.queryForInt("select count(*) from riders_order"));
}
 
开发者ID:camelinaction,项目名称:camelinaction,代码行数:22,代码来源:OrderTest.java

示例7: testOrderFailAll

import camelinaction.order.InputOrder; //导入依赖的package包/类
@Test
public void testOrderFailAll() throws Exception {
    // there should be 0 row in the database when we start
    assertEquals(0, jdbc.queryForInt("select count(*) from riders_order"));

    InputOrder input = new InputOrder();
    input.setCustomerId("4444");
    // by using FATAL as ref no we simulate failure in all processing
    input.setRefNo("FATAL");
    input.setPartId("333");
    input.setAmount("50");

    // give CXF time to wake up
    Thread.sleep(2000);

    OutputOrder reply = template.requestBody("cxf:bean:orderEndpoint", input, OutputOrder.class);
    assertEquals("ERROR: Simulated fatal error", reply.getCode());

    // there should still be 0 row in the database as the entire route was rolled back
    assertEquals(0, jdbc.queryForInt("select count(*) from riders_order"));
}
 
开发者ID:camelinaction,项目名称:camelinaction,代码行数:22,代码来源:OrderTest.java

示例8: insertOrder

import camelinaction.order.InputOrder; //导入依赖的package包/类
public void insertOrder(InputOrder order, Registry registry) {
    DataSource ds = registry.lookupByNameAndType("myDataSource", DataSource.class);
    JdbcTemplate jdbc = new JdbcTemplate(ds);

    Object[] args = new Object[] { order.getCustomerId(), order.getRefNo(), order.getPartId(), order.getAmount()};
    jdbc.update("insert into riders_order (customer_id, ref_no, part_id, amount) values (?, ?, ?, ?)", args);
}
 
开发者ID:camelinaction,项目名称:camelinaction2,代码行数:8,代码来源:OrderDAO.java

示例9: insertOrder

import camelinaction.order.InputOrder; //导入依赖的package包/类
public void insertOrder(InputOrder order, Registry registry) {
    DataSource ds = registry.lookup("myDataSource", DataSource.class);
    JdbcTemplate jdbc = new JdbcTemplate(ds);

    Object[] args = new Object[] { order.getCustomerId(), order.getRefNo(), order.getPartId(), order.getAmount()};
    jdbc.update("insert into riders_order (customer_id, ref_no, part_id, amount) values (?, ?, ?, ?)", args);
}
 
开发者ID:xuzhikethinker,项目名称:t4f-data,代码行数:8,代码来源:OrderDAO.java


注:本文中的camelinaction.order.InputOrder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。