當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。