1 3 5 7 9 10 11 package com.mockobjects.atg; 12 import javax.servlet.http.HttpServletResponse ; 13 import atg.servlet.*; 14 import com.mockobjects.*; 15 import java.io.IOException ;public class MockDynamoHttpServletResponse extends DynamoHttpServletResponse implements Verifiable 16 { 17 private ExpectationList myLocalRedirect = new ExpectationList("Local redirect"); 18 private boolean myShouldThrowExceptionOnRedirect = false; 19 20 21 22 public MockDynamoHttpServletResponse() { 23 } 24 25 public MockDynamoHttpServletResponse(HttpServletResponse arg1) { 26 super(arg1); 27 } 28 29 30 31 public void sendLocalRedirect(String url, DynamoHttpServletRequest request) throws IOException { 32 myLocalRedirect.addActual(url); 33 myLocalRedirect.addActual(request); 34 if (myShouldThrowExceptionOnRedirect) { 35 throw new IOException ("Mock exception"); 36 } 37 } 38 39 40 41 public void setExpectedLocalRedirect(String url, DynamoHttpServletRequest request) { 42 myLocalRedirect.addExpected(url); 43 myLocalRedirect.addExpected(request); 44 } 45 46 47 48 public void setupThrowExceptionOnRedirect() { 49 myShouldThrowExceptionOnRedirect = true; 50 } 51 52 53 54 public String toString() { 55 return "MockDynamoServletResponse"; 56 } 57 58 59 60 public void verify() { 61 myLocalRedirect.verify(); 62 } 63 } | Popular Tags |