1 7 package com.inversoft.junit.internal.http; 8 9 10 import java.io.IOException ; 11 import java.io.Reader ; 12 import java.io.StringReader ; 13 import java.io.Writer ; 14 15 import javax.servlet.jsp.JspWriter ; 16 import javax.servlet.jsp.tagext.BodyContent ; 17 18 19 28 public class MockBodyContent extends BodyContent { 29 30 private String bodyContent; 31 32 33 38 public MockBodyContent(String bodyContent, JspWriter writer) { 39 super(writer); 40 this.bodyContent = bodyContent; 41 } 42 43 44 47 public Reader getReader() { 48 if (bodyContent == null) { 49 return new StringReader (""); 50 } 51 52 return new StringReader (bodyContent); 53 } 54 55 58 public String getString() { 59 return bodyContent; 60 } 61 62 65 public void writeOut(Writer writer) throws IOException { 66 if (bodyContent != null) { 67 writer.write(bodyContent); 68 } 69 } 70 71 74 public void newLine() throws IOException { 75 getEnclosingWriter().write("\n"); 76 } 77 78 81 public void print(boolean b) throws IOException { 82 getEnclosingWriter().write("" + b); 83 } 84 85 88 public void print(char c) throws IOException { 89 getEnclosingWriter().write("" + c); 90 } 91 92 95 public void print(int i) throws IOException { 96 getEnclosingWriter().write("" + i); 97 } 98 99 102 public void print(long l) throws IOException { 103 getEnclosingWriter().write("" + l); 104 } 105 106 109 public void print(float f) throws IOException { 110 getEnclosingWriter().write("" + f); 111 } 112 113 116 public void print(double d) throws IOException { 117 getEnclosingWriter().write("" + d); 118 } 119 120 123 public void print(char[] str) throws IOException { 124 getEnclosingWriter().write(str); 125 } 126 127 130 public void print(String str) throws IOException { 131 getEnclosingWriter().write(str); 132 } 133 134 137 public void print(Object obj) throws IOException { 138 getEnclosingWriter().write(obj.toString()); 139 } 140 141 144 public void println() throws IOException { 145 getEnclosingWriter().write("\n"); 146 } 147 148 151 public void println(boolean b) throws IOException { 152 getEnclosingWriter().write("" + b); 153 getEnclosingWriter().write("\n"); 154 } 155 156 159 public void println(char c) throws IOException { 160 getEnclosingWriter().write("" + c); 161 getEnclosingWriter().write("\n"); 162 } 163 164 167 public void println(int i) throws IOException { 168 getEnclosingWriter().write("" + i); 169 getEnclosingWriter().write("\n"); 170 } 171 172 175 public void println(long l) throws IOException { 176 getEnclosingWriter().write("" + l); 177 getEnclosingWriter().write("\n"); 178 } 179 180 183 public void println(float f) throws IOException { 184 getEnclosingWriter().write("" + f); 185 getEnclosingWriter().write("\n"); 186 } 187 188 191 public void println(double d) throws IOException { 192 getEnclosingWriter().write("" + d); 193 getEnclosingWriter().write("\n"); 194 } 195 196 199 public void println(char[] str) throws IOException { 200 getEnclosingWriter().write(str); 201 getEnclosingWriter().write("\n"); 202 } 203 204 207 public void println(String str) throws IOException { 208 getEnclosingWriter().write(str); 209 getEnclosingWriter().write("\n"); 210 } 211 212 215 public void println(Object obj) throws IOException { 216 getEnclosingWriter().write(obj.toString()); 217 getEnclosingWriter().write("\n"); 218 } 219 220 223 public void clear() throws IOException { 224 } 225 226 229 public void clearBuffer() throws IOException { 230 } 231 232 235 public void close() throws IOException { 236 } 237 238 241 public int getRemaining() { 242 return 0; 243 } 244 245 248 public void write(char[] cbuf, int off, int len) throws IOException { 249 getEnclosingWriter().write(cbuf, off, len); 250 } 251 } | Popular Tags |