/sigmah/src/test/java/org/sigmah/server/mock/MockServletOutputStream.java

http://sigma-h.googlecode.com/ · Java · 33 lines · 19 code · 7 blank · 7 comment · 0 complexity · 52606bbcf1a9955121b5822e4208f4c1 MD5 · raw file

  1. /*
  2. * All Sigmah code is released under the GNU General Public License v3
  3. * See COPYRIGHT.txt and LICENSE.txt.
  4. */
  5. package org.sigmah.server.mock;
  6. import javax.servlet.ServletOutputStream;
  7. import java.io.ByteArrayOutputStream;
  8. import java.io.IOException;
  9. /**
  10. * @author Alex Bertram
  11. */
  12. public class MockServletOutputStream extends ServletOutputStream {
  13. private ByteArrayOutputStream baos = new ByteArrayOutputStream();
  14. public void flush() throws IOException {
  15. baos.flush();
  16. }
  17. public void write(byte[] b) throws IOException {
  18. baos.write(b);
  19. }
  20. @Override
  21. public void write(int b) throws IOException {
  22. byte[] ba = new byte[1];
  23. ba[0] = (byte) b;
  24. baos.write(ba);
  25. }
  26. }