/sigmah/src/test/java/org/sigmah/server/mock/MockServletOutputStream.java
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 6package org.sigmah.server.mock; 7 8import javax.servlet.ServletOutputStream; 9import java.io.ByteArrayOutputStream; 10import java.io.IOException; 11 12/** 13 * @author Alex Bertram 14 */ 15public class MockServletOutputStream extends ServletOutputStream { 16 17 private ByteArrayOutputStream baos = new ByteArrayOutputStream(); 18 19 public void flush() throws IOException { 20 baos.flush(); 21 } 22 23 public void write(byte[] b) throws IOException { 24 baos.write(b); 25 } 26 27 @Override 28 public void write(int b) throws IOException { 29 byte[] ba = new byte[1]; 30 ba[0] = (byte) b; 31 baos.write(ba); 32 } 33}