1 package com.mockobjects.servlet; 2 3 import com.mockobjects.ExpectationValue; 4 import com.mockobjects.MockObject; 5 6 import javax.servlet.RequestDispatcher ; 7 import javax.servlet.ServletException ; 8 import javax.servlet.ServletRequest ; 9 import javax.servlet.ServletResponse ; 10 import java.io.IOException ; 11 12 public class MockRequestDispatcher extends MockObject implements RequestDispatcher { 13 private final ExpectationValue myRequest = new ExpectationValue("request"); 14 private final ExpectationValue myResponse = new ExpectationValue("response"); 15 16 public void setExpectedRequest(ServletRequest aRequest) { 17 myRequest.setExpected(aRequest); 18 } 19 20 public void setExpectedResponse(ServletResponse aResponse) { 21 myResponse.setExpected(aResponse); 22 } 23 24 public void forward(ServletRequest aRequest, ServletResponse aResponse) 25 throws ServletException , IOException { 26 27 myRequest.setActual(aRequest); 28 myResponse.setActual(aResponse); 29 } 30 31 public void include(ServletRequest aRequest, ServletResponse aResponse) 32 throws ServletException , IOException { 33 34 myRequest.setActual(aRequest); 35 myResponse.setActual(aResponse); 36 } 37 } 38 | Popular Tags |