KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > mockobjects > servlet > MockJspWriter


1 package com.mockobjects.servlet;
2
3 import com.mockobjects.ExpectationValue;
4 import com.mockobjects.util.AssertMo;
5
6 import javax.servlet.jsp.JspWriter JavaDoc;
7 import java.io.PrintWriter JavaDoc;
8 import java.io.StringWriter JavaDoc;
9
10 public class MockJspWriter extends JspWriter JavaDoc {
11     private final ExpectationValue expectedData = new ExpectationValue("data");
12     private StringWriter JavaDoc stringWriter = new StringWriter JavaDoc();
13     private PrintWriter JavaDoc printWriter = new PrintWriter JavaDoc(stringWriter);
14
15     public MockJspWriter() {
16         super(0, true);
17     }
18
19     public void setExpectedData(String JavaDoc data) {
20         expectedData.setExpected(data);
21     }
22
23     private final void notImplemented(){
24         AssertMo.notImplemented(this.getClass().getName());
25     }
26
27     public void newLine() {
28         notImplemented();
29     }
30
31     public void flush() {
32         notImplemented();
33     }
34
35     public void print(double d) {
36         printWriter.print(String.valueOf(d));
37     }
38
39     public void println() {
40         notImplemented();
41     }
42
43     public void close() {
44         notImplemented();
45     }
46
47     public void print(int anInt) {
48         printWriter.print(String.valueOf(anInt));
49     }
50
51     public void print(long aLong) {
52         printWriter.print(String.valueOf(aLong));
53     }
54
55     public void print(float f) {
56         notImplemented();
57     }
58
59     public void println(char c) {
60         notImplemented();
61     }
62
63     public void clear() {
64         notImplemented();
65     }
66
67     public void print(boolean b) {
68         notImplemented();
69     }
70
71     public void print(String JavaDoc aString) {
72         printWriter.print(aString);
73     }
74
75     public void println(String JavaDoc aString) {
76         printWriter.print(aString);
77     }
78
79     public void print(char c) {
80         notImplemented();
81     }
82
83     public void write(char[] buf, int off, int len) {
84         printWriter.write(buf, off, len);
85     }
86
87     public void println(char[] c) {
88         notImplemented();
89     }
90
91     public void println(boolean b) {
92         notImplemented();
93     }
94
95     public void clearBuffer() {
96         notImplemented();
97     }
98
99     public void print(Object JavaDoc anObject) {
100         printWriter.print(anObject);
101     }
102
103     public void println(long l) {
104         notImplemented();
105     }
106
107     public void println(int i) {
108         notImplemented();
109     }
110
111     public void print(char[] c) {
112         notImplemented();
113     }
114
115     public void println(float f) {
116         notImplemented();
117     }
118
119     public void println(double d) {
120         notImplemented();
121     }
122
123     public int getRemaining() {
124         notImplemented();
125         return -1;
126     }
127
128     public void println(Object JavaDoc anObject) {
129         printWriter.print(anObject);
130     }
131
132     public void verify() {
133         printWriter.flush();
134         expectedData.setActual(stringWriter.toString());
135         expectedData.verify();
136         expectedData.setExpected("");
137         stringWriter = new StringWriter JavaDoc();
138         printWriter = new PrintWriter JavaDoc(stringWriter);
139     }
140 }
141
142
Popular Tags