001: /*
002: * Copyright (c) 2002-2003 by OpenSymphony
003: * All rights reserved.
004: */
005: package com.opensymphony.webwork.views.jsp;
006:
007: import com.mockobjects.servlet.MockJspWriter;
008:
009: import javax.servlet.jsp.JspWriter;
010: import java.io.IOException;
011: import java.io.StringWriter;
012:
013: /**
014: * Unforunately, the MockJspWriter throws a NotImplementedException when any of the Writer methods are invoked and
015: * as you might guess, Velocity uses the Writer methods. I'velocityEngine subclassed the MockJspWriter for the time being so
016: * that we can do testing on the results until MockJspWriter gets fully implemented.
017: * <p/>
018: * todo replace this once MockJspWriter implements Writer correctly (i.e. doesn't throw NotImplementException)
019: */
020: public class WebWorkMockJspWriter extends JspWriter {
021: StringWriter writer;
022:
023: public WebWorkMockJspWriter(StringWriter writer) {
024: super (1024, true);
025: this .writer = writer;
026: }
027:
028: public void newLine() throws IOException {
029: writer.write("\n");
030: }
031:
032: public void print(boolean b) throws IOException {
033: writer.write(String.valueOf(b));
034: }
035:
036: public void print(char c) throws IOException {
037: writer.write(String.valueOf(c));
038: }
039:
040: public void print(int i) throws IOException {
041: writer.write(i);
042: }
043:
044: public void print(long l) throws IOException {
045: writer.write(String.valueOf(l));
046: }
047:
048: public void print(float v) throws IOException {
049: writer.write(String.valueOf(v));
050: }
051:
052: public void print(double v) throws IOException {
053: writer.write(String.valueOf(v));
054: }
055:
056: public void print(char[] chars) throws IOException {
057: writer.write(chars);
058: }
059:
060: public void print(String s) throws IOException {
061: writer.write(s);
062: }
063:
064: public void print(Object o) throws IOException {
065: writer.write(o.toString());
066: }
067:
068: public void println() throws IOException {
069: writer.write("\n");
070: }
071:
072: public void println(boolean b) throws IOException {
073: print(b);
074: println();
075: }
076:
077: public void println(char c) throws IOException {
078: print(c);
079: println();
080: }
081:
082: public void println(int i) throws IOException {
083: print(i);
084: println();
085: }
086:
087: public void println(long l) throws IOException {
088: print(l);
089: println();
090: }
091:
092: public void println(float v) throws IOException {
093: print(v);
094: println();
095: }
096:
097: public void println(double v) throws IOException {
098: print(v);
099: println();
100: }
101:
102: public void println(char[] chars) throws IOException {
103: print(chars);
104: println();
105: }
106:
107: public void println(String s) throws IOException {
108: print(s);
109: println();
110: }
111:
112: public void println(Object o) throws IOException {
113: print(o);
114: println();
115: }
116:
117: public void clear() throws IOException {
118: }
119:
120: public void clearBuffer() throws IOException {
121: }
122:
123: public void close() throws IOException {
124: writer.close();
125: }
126:
127: public int getRemaining() {
128: return 0;
129: }
130:
131: public void write(char cbuf[], int off, int len) throws IOException {
132: writer.write(cbuf, off, len);
133: }
134:
135: public void write(String str) throws IOException {
136: writer.write(str);
137: }
138:
139: public void write(int c) throws IOException {
140: writer.write(c);
141: }
142:
143: public void write(char[] cbuf) throws IOException {
144: writer.write(cbuf);
145: }
146:
147: public void write(String str, int off, int len) throws IOException {
148: writer.write(str, off, len);
149: }
150:
151: public void flush() {
152: writer.flush();
153: }
154: }
|