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


Java SalesOrder类代码示例

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


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

示例1: test

import com.alibaba.cobar.manager.jdbcmock.domain.SalesOrder; //导入依赖的package包/类
public void test() {
    IMocksControl control = EasyMock.createControl();

    DBUtility mockDBUtility = control.createMock(DBUtility.class);
    Connection mockConnection = control.createMock(Connection.class);
    Statement mockStatement = control.createMock(Statement.class);
    ResultSet mockResultSet = control.createMock(ResultSet.class);

    try {
        mockDBUtility.getConnection();
        EasyMock.expectLastCall().andStubReturn(mockConnection);

        mockConnection.createStatement();
        EasyMock.expectLastCall().andStubReturn(mockStatement);

        mockStatement.executeQuery(SQLEquals.sqlEquals("SELECT * FROM sales_order_table"));
        EasyMock.expectLastCall().andStubReturn(mockResultSet);

        mockResultSet.next();
        EasyMock.expectLastCall().andReturn(true).times(3);
        EasyMock.expectLastCall().andReturn(false).times(1);

        mockResultSet.getString(1);
        EasyMock.expectLastCall().andReturn("DEMO_ORDER_001").times(1);
        EasyMock.expectLastCall().andReturn("DEMO_ORDER_002").times(1);
        EasyMock.expectLastCall().andReturn("DEMO_ORDER_003").times(1);

        mockResultSet.getString(2);
        EasyMock.expectLastCall().andReturn("Asia Pacific").times(1);
        EasyMock.expectLastCall().andReturn("Europe").times(1);
        EasyMock.expectLastCall().andReturn("America").times(1);

        mockResultSet.getDouble(3);
        EasyMock.expectLastCall().andReturn(350.0).times(1);
        EasyMock.expectLastCall().andReturn(1350.0).times(1);
        EasyMock.expectLastCall().andReturn(5350.0).times(1);

        control.replay();

        Connection conn = mockDBUtility.getConnection();
        Statement stat = conn.createStatement();
        ResultSet rs = stat.executeQuery("select * from sales_order_table");

        int i = 0;
        String[] priceLevels = { "Level_A", "Level_C", "Level_E" };
        while (rs.next()) {
            SalesOrder order = new SalesOrderImpl();
            order.loadDataFromDB(rs);
            assertEquals(order.getPriceLevel(), priceLevels[i]);
            i++;
        }

        control.verify();

    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:loye168,项目名称:tddl5,代码行数:59,代码来源:JdbcTest.java


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