From: Jeff M. <cus...@us...> - 2002-06-19 15:26:55
|
Update of /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/servlet In directory usw-pr-cvs1:/tmp/cvs-serv12913/src/j2ee/common/com/mockobjects/servlet Modified Files: MockJspWriter.java MockServletContext.java Added Files: MockBodyContent.java Log Message: Lots of small changes to mocks --- NEW FILE: MockBodyContent.java --- package com.mockobjects.servlet; import com.mockobjects.util.AssertMo; import com.mockobjects.Verifiable; import com.mockobjects.ExpectationValue; import javax.servlet.jsp.JspWriter; import javax.servlet.jsp.tagext.BodyContent; import java.io.IOException; import java.io.Reader; import java.io.Writer; public class MockBodyContent extends BodyContent implements Verifiable{ private JspWriter myEnclosingWriter; private final ExpectationValue myWriter = new ExpectationValue("writer"); public int getBufferSize() { notImplemented(); return super.getBufferSize(); } public MockBodyContent() { super(null); } public void write(int c) throws IOException { notImplemented(); super.write(c); } public void flush() throws IOException { notImplemented(); super.flush(); } public boolean isAutoFlush() { notImplemented(); return super.isAutoFlush(); } public void write(char cbuf[]) throws IOException { notImplemented(); super.write(cbuf); } public boolean equals(Object obj) { notImplemented(); return super.equals(obj); } public void clearBody() { notImplemented(); super.clearBody(); } public void write(String str) throws IOException { notImplemented(); super.write(str); } public void setupGetEnclosingWriter(JspWriter aJspWriter){ myEnclosingWriter = aJspWriter; } public JspWriter getEnclosingWriter() { return myEnclosingWriter; } private void notImplemented() { AssertMo.notImplemented(MockBodyContent.class.getName()); } public Reader getReader() { notImplemented(); return null; } public void newLine() throws IOException { notImplemented(); } public void write(char cbuf[], int off, int len) throws IOException { notImplemented(); } public void print(boolean b) throws IOException { notImplemented(); } public void setExpectedWriteOut(Writer aWriter){ myWriter.setExpected(aWriter); } public void writeOut(Writer aWriter) throws IOException { myWriter.setActual(aWriter); } public void print(char c) throws IOException { notImplemented(); } public void print(int i) throws IOException { notImplemented(); } public void print(long l) throws IOException { notImplemented(); } public void print(float v) throws IOException { notImplemented(); } public void print(double v) throws IOException { notImplemented(); } public void print(char[] chars) throws IOException { notImplemented(); } public void print(String s) throws IOException { notImplemented(); } public void print(Object o) throws IOException { notImplemented(); } public void println() throws IOException { notImplemented(); } public void println(boolean b) throws IOException { notImplemented(); } public void println(char c) throws IOException { notImplemented(); } public void println(int i) throws IOException { notImplemented(); } public void println(long l) throws IOException { notImplemented(); } public void println(float v) throws IOException { notImplemented(); } public void println(double v) throws IOException { notImplemented(); } public void println(char[] chars) throws IOException { notImplemented(); } public void println(String s) throws IOException { notImplemented(); } public void println(Object o) throws IOException { notImplemented(); } public void clear() throws IOException { notImplemented(); } public void clearBuffer() throws IOException { notImplemented(); } public void close() throws IOException { notImplemented(); } public int getRemaining() { notImplemented(); return 0; } public void write(String str, int off, int len) throws IOException { notImplemented(); super.write(str, off, len); } public String getString() { notImplemented(); return null; } public void verify() { } } Index: MockJspWriter.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/servlet/MockJspWriter.java,v retrieving revision 1.1 retrieving revision 1.2 diff -u -r1.1 -r1.2 --- MockJspWriter.java 23 Feb 2002 18:50:35 -0000 1.1 +++ MockJspWriter.java 19 Jun 2002 15:26:22 -0000 1.2 @@ -1,86 +1,135 @@ package com.mockobjects.servlet; -import javax.servlet.*; -import javax.servlet.http.*; -import javax.servlet.jsp.*; -import junit.framework.*; -import junit.textui.*; -import java.util.*; -import java.io.*; -import java.net.*; -import com.mockobjects.*; +import com.mockobjects.ExpectationValue; +import com.mockobjects.util.AssertMo; -public class MockJspWriter extends JspWriter{ +import javax.servlet.jsp.JspWriter; +import java.io.PrintWriter; +import java.io.StringWriter; + +public class MockJspWriter extends JspWriter { private ExpectationValue expectedData = new ExpectationValue("data"); private StringWriter stringWriter = new StringWriter(); private PrintWriter printWriter = new PrintWriter(stringWriter); - public MockJspWriter(){ + public MockJspWriter() { super(0, true); } - public void setExpectedData(String data){ + public void setExpectedData(String data) { expectedData.setExpected(data); } - public void newLine(){ + private final void notImplemented(){ + AssertMo.notImplemented(this.getClass().getName()); + } + + public void newLine() { + notImplemented(); } public void flush() { + notImplemented(); } - public void print(double d){ + + public void print(double d) { + printWriter.print(String.valueOf(d)); } - public void println(){ + + public void println() { + notImplemented(); } - public void close(){ + + public void close() { + notImplemented(); } - public void print(int i){ + + public void print(int i) { + printWriter.print(String.valueOf(i)); } - public void print(long l){ + + public void print(long l) { + printWriter.print(String.valueOf(l)); } - public void print(float f){ + + public void print(float f) { + notImplemented(); } - public void println(char c){ + + public void println(char c) { + notImplemented(); } - public void clear(){ + + public void clear() { + notImplemented(); } - public void print(boolean b){ + + public void print(boolean b) { + notImplemented(); } - public void print(String s){ + + public void print(String s) { printWriter.print(s); } - public void println(String s){ + + public void println(String s) { printWriter.print(s); } - public void print(char c){ + + public void print(char c) { + notImplemented(); } + public void write(char[] c, int i1, int i2) { + notImplemented(); } - public void println(char[] c){ + + public void println(char[] c) { + notImplemented(); } - public void println(boolean b){ + + public void println(boolean b) { + notImplemented(); } - public void clearBuffer(){ + + public void clearBuffer() { + notImplemented(); } - public void print(Object o){ + + public void print(Object o) { + notImplemented(); } - public void println(long l){ + + public void println(long l) { + notImplemented(); } - public void println(int i){ + + public void println(int i) { + notImplemented(); } - public void print(char[] c){ + + public void print(char[] c) { + notImplemented(); } - public void println(float f){ + + public void println(float f) { + notImplemented(); } - public void println(double d){ + + public void println(double d) { + notImplemented(); } - public int getRemaining(){ + + public int getRemaining() { + notImplemented(); return -1; } - public void println(Object o){ + + public void println(Object o) { + notImplemented(); } - public void verify(){ + public void verify() { printWriter.flush(); expectedData.setActual(stringWriter.toString()); expectedData.verify(); Index: MockServletContext.java =================================================================== RCS file: /cvsroot/mockobjects/mockobjects-java/src/j2ee/common/com/mockobjects/servlet/MockServletContext.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -r1.2 -r1.3 --- MockServletContext.java 28 Mar 2002 18:16:54 -0000 1.2 +++ MockServletContext.java 19 Jun 2002 15:26:22 -0000 1.3 @@ -9,7 +9,7 @@ public class MockServletContext extends MockObject implements ServletContext{ private HashMap attributes = new HashMap(); private Set resourcePaths; - private List realPaths = new ArrayList(); + private ReturnObjectList realPaths = new ReturnObjectList("real path"); private URL resource; private HashMap initParameters = new HashMap(); private ExpectationValue expectedLogValue = new ExpectationValue("log"); @@ -68,11 +68,11 @@ } public void addRealPath(String realPath){ - this.realPaths.add(realPath); + this.realPaths.addObjectToReturn(realPath); } public String getRealPath(String string){ - return realPaths.remove(0).toString(); + return realPaths.nextReturnObject().toString(); } public Enumeration getServletNames(){ |