Đang chuẩn bị liên kết để tải về tài liệu:
Java Extreme Programming Cookbook phần 6

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

Điều này có vẻ ngớ ngẩn, nhưng suy nghĩ lại về các dự án cuối cùng bạn làm việc trên rất nhiều các sơ đồ được tạo ra. Khi bạn gặp phải một lỗi trong ứng dụng, bạn thường chuyển sang sơ đồ đầu tiên, | return true public int getRow throws SQLException return 1 MockResultSet mockRs new MyMockResultSet mockRs.setExpectedCloseCalls 1 mockRs.setExpectedNextCalls 1 MockPreparedStatement mockPs new MockPreparedStatement mockPs.addExpectedSetParameter 1 0001 mockPs.setExpectedCloseCalls 1 mockPs.addResultSet mockRs MockConnection mockConnection new MockConnection mockConnection.setupAddPreparedStatement mockPs mockConnection.setExpectedCloseCalls 0 AccountFactory acctFact new AccountFactory call the method that we are actually testing Account acct acctFact.getAccount 0001 mockConnection mockRs.verify mockPs.verify mockConnection.verify MyMockResultSet is the key to this test. It extends MockResultSetJdk14 described shortly . MyMockResultSet overrides a handful of abstract methods in order to simulate data that would normally be returned from a true database call. Our goal is to support our unit tests without relying on a real database and we only need to stub out the actual methods that our test calls. The remainder of the unit test should look familiar if you read through the recipes presented earlier in this chapter. Specifically we tell the mock result set how many calls to expect. We then create and set up the mock prepared statement and connection using them to exercise the code in AccountFactory. When finished we ask each of the mock objects to verify themselves. It turns out that the version of Mock Objects used in this chapter does not fully support J2SE 1.4. Specifically many new JDBC methods are not defined in the MockResultSet class. For this reason we created MockResultSetJdk14 as shown in Example 6-10. This class merely provides dummy implementations of the new JDBC methods so our examples compile under J2SE 1.4. Example 6-10. Making MockResultSet work with J2SE 1.4 package com.oreilly.mock import com.mockobjects.sql.MockResultSet import java.net.URL import java.sql. public abstract class MockResultSetJdk14 extends MockResultSet public URL getURL int .

Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.