NIHVIVO-1460 implement more stub methods to enable testing.
This commit is contained in:
parent
48b4f16ed2
commit
192b722de3
1 changed files with 28 additions and 18 deletions
|
@ -4,6 +4,7 @@ package stubs.javax.servlet.http;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.PrintWriter;
|
||||
import java.io.StringWriter;
|
||||
import java.util.Locale;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
|
@ -19,11 +20,22 @@ public class HttpServletResponseStub implements HttpServletResponse {
|
|||
// ----------------------------------------------------------------------
|
||||
|
||||
private String redirectLocation;
|
||||
private int status = 200;
|
||||
private String errorMessage;
|
||||
private StringWriter outputWriter = new StringWriter();
|
||||
|
||||
public String getRedirectLocation() {
|
||||
return redirectLocation;
|
||||
}
|
||||
|
||||
public int getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Stub methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -33,6 +45,22 @@ public class HttpServletResponseStub implements HttpServletResponse {
|
|||
this.redirectLocation = location;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int status) throws IOException {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int status, String message) throws IOException {
|
||||
this.status = status;
|
||||
this.errorMessage = message;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintWriter getWriter() throws IOException {
|
||||
return new PrintWriter(outputWriter);
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
// Un-implemented methods
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -73,12 +101,6 @@ public class HttpServletResponseStub implements HttpServletResponse {
|
|||
"HttpServletResponseStub.getOutputStream() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public PrintWriter getWriter() throws IOException {
|
||||
throw new RuntimeException(
|
||||
"HttpServletResponseStub.getWriter() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommitted() {
|
||||
throw new RuntimeException(
|
||||
|
@ -181,18 +203,6 @@ public class HttpServletResponseStub implements HttpServletResponse {
|
|||
"HttpServletResponseStub.encodeUrl() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int arg0) throws IOException {
|
||||
throw new RuntimeException(
|
||||
"HttpServletResponseStub.sendError() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendError(int arg0, String arg1) throws IOException {
|
||||
throw new RuntimeException(
|
||||
"HttpServletResponseStub.sendError() not implemented.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDateHeader(String arg0, long arg1) {
|
||||
throw new RuntimeException(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue