Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Mô hình thực hiện của giao diện HttpServletRequest. Có thể được sử dụng để kiểm tra các servlet và các bộ điều khiển. Mô hình thực hiện của giao diện HttpServletResponse. Có thể được sử dụng để kiểm tra các servlet và các bộ điều khiển. Mô hình thực hiện của giao diện HttpSession. | CHAPTER 10 TESTING 301 Table 10-3. Web Mock Classes Provided by Spring Class Description MockHttpServletRequest Mock implementation of the HttpServletRequest interface. Can be used to test servlets and controllers. MockHttpServletResponse Mock implementation of the HttpServletResponse interface. Can be used to test servlets and controllers. MockHttpSession Mock implementation of the HttpSession interface. Can be used to test code that requires a session in order to function. MockFilterConfig Mock implementation of the FilterConfig interface. Can be used to test filter implementations. MockServletConfig Mock implementation of the ServletConfig interface. Can be used to test servlets. MockServletContext Mock implementation of the ServletContext interface. Can be used to test servlets. MockRequestDispatcher Mock implementation of the RequestDispatcher interface. Can be used to test servlets and controllers. MockPageContext Mock implementation of the PageContext abstract class. Can be used to test JSP tag implementations. MockExpressionEvaluator Mock implementation of the ExpressionEvaluator abstract class. Can be used to test JSP tag implementations. Along with these web-specific mock objects Spring also provides mock objects for a number of other hard-to-mock J2EE interfaces and classes. Currently it provides mock objects mainly for working with JNDI such as the SimpleNamingContext which provides a mock object for the Context interface. Summary This chapter started with an overview of testing including unit testing integration testing and TDD. We then introduced JUnit as a framework for writing tests and EasyMock to mock the dependencies your classes may have. Finally you saw how Spring provides a number of convenient base test classes and mock objects to perform integration testing and test your web application code. APPENDIX Installing the Eclipse Web Tools Platform N o longer is it acceptable to run through a long and cumbersome series of steps just to see if a .