fitnesse.http.MockResponseSender Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of fitnesse Show documentation
Show all versions of fitnesse Show documentation
The fully integrated standalone wiki, and acceptance testing framework.
// Copyright (C) 2003-2009 by Object Mentor, Inc. All rights reserved.
// Released under the terms of the CPL Common Public License version 1.0.
package fitnesse.http;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import util.FileUtil;
public class MockResponseSender implements ResponseSender {
private final OutputStream output;
protected boolean closed;
public MockResponseSender() {
this(new ByteArrayOutputStream());
}
public MockResponseSender(OutputStream output) {
this.output = output;
}
@Override
public void send(byte[] bytes) throws IOException {
output.write(bytes);
}
@Override
public void close() {
closed = true;
}
public String sentData() throws UnsupportedEncodingException {
return ((ByteArrayOutputStream) output).toString(FileUtil.CHARENCODING);
}
public void doSending(Response response) throws IOException {
response.sendTo(this);
assert closed;
}
public boolean isClosed() {
return closed;
}
}