1 16 package org.apache.cocoon.environment.mock; 17 18 import java.util.Locale ; 19 import java.util.HashMap ; 20 import java.util.HashSet ; 21 import java.util.Map ; 22 import java.util.Set ; 23 24 import junit.framework.AssertionFailedError; 25 26 import org.apache.cocoon.environment.Cookie; 27 import org.apache.cocoon.environment.Response; 28 29 public class MockResponse implements Response { 30 31 private String encoding; 32 private Locale locale; 33 private HashSet cookies = new HashSet (); 34 private HashMap header = new HashMap (); 35 36 public void setCharacterEncoding(String encoding) { 37 this.encoding = encoding; 38 } 39 40 public String getCharacterEncoding() { 41 return encoding; 42 } 43 44 public void setLocale(Locale locale) { 45 this.locale = locale; 46 } 47 48 public Locale getLocale() { 49 return locale; 50 } 51 52 public Cookie createCookie(String name, String value) { 53 MockCookie cookie = new MockCookie(); 54 cookie.setName(name); 55 cookie.setValue(value); 56 return cookie; 57 } 58 59 public void addCookie(Cookie cookie) { 60 cookies.add(cookie); 61 } 62 63 public Set getCookies() { 64 return cookies; 65 } 66 67 public boolean containsHeader(String name) { 68 return header.containsKey(name); 69 } 70 71 public String encodeURL(String url) { 72 throw new AssertionFailedError("Not implemented"); 73 } 74 75 public void setDateHeader(String name, long date) { 76 header.put(name, new Long (date)); 77 } 78 79 public void addDateHeader(String name, long date) { 80 header.put(name, new Long (date)); 81 } 82 83 public void setHeader(String name, String value) { 84 header.put(name, value); 85 } 86 87 public void addHeader(String name, String value) { 88 header.put(name, value); 89 } 90 91 public void setIntHeader(String name, int value) { 92 header.put(name, new Integer (value)); 93 } 94 95 public void addIntHeader(String name, int value) { 96 header.put(name, new Integer (value)); 97 } 98 99 public Map getHeader() { 100 return header; 101 } 102 103 public void reset() { 104 encoding = null; 105 locale = null; 106 cookies.clear(); 107 header.clear(); 108 } 109 } 110 | Popular Tags |