KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > junit > internal > http > MockServletOutputStream


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.junit.internal.http;
8
9
10 import javax.servlet.ServletOutputStream JavaDoc;
11
12
13 /**
14  * This is a Mock servlet output stream
15  *
16  * @author Brian Pontarelli
17  * @since 2.0
18  * @version 2.0
19  */

20 public class MockServletOutputStream extends ServletOutputStream JavaDoc {
21
22     private StringBuffer JavaDoc buf;
23
24     /**
25      * Constructs a new Mock servlet output stream
26      */

27     public MockServletOutputStream() {
28         buf = new StringBuffer JavaDoc();
29     }
30
31     public void print(String JavaDoc a) {
32         buf.append(a);
33     }
34
35     public void print(boolean a) {
36         buf.append(a);
37     }
38
39     public void print(float a) {
40         buf.append(a);
41     }
42
43     public void print(char a) {
44         buf.append(a);
45     }
46
47     public void print(int a) {
48         buf.append(a);
49     }
50
51     public void println(String JavaDoc a) {
52         buf.append(a + "\n");
53     }
54
55     public void print(double a) {
56         buf.append(a + "\n");
57     }
58
59     public void println() {
60         buf.append("\n");
61     }
62
63     public void println(boolean a) {
64         buf.append(a + "\n");
65     }
66
67     public void println(char a) {
68         buf.append(a + "\n");
69     }
70
71     public void println(int a) {
72         buf.append(a + "\n");
73     }
74
75     public void println(float a) {
76         buf.append(a + "\n");
77     }
78
79     public void println(double a) {
80         buf.append(a + "\n");
81     }
82
83     public void write(int a) {
84         buf.append(a + "\n");
85     }
86
87     public void write(byte[] a) {
88         buf.append(new String JavaDoc(a));
89     }
90
91     public void write(byte[] a, int b, int c) {
92         buf.append(new String JavaDoc(a, b, c));
93     }
94
95     public void flush() {
96         // NO OP
97
}
98
99     public void close() {
100         // NO OP
101
}
102
103     public String JavaDoc getText() {
104         return buf.toString();
105     }
106 }
107
Popular Tags