1 16 package org.apache.commons.io.testtools; 17 18 import java.io.IOException ; 19 import java.io.OutputStream ; 20 21 import junit.framework.AssertionFailedError; 22 23 import org.apache.commons.io.output.ProxyOutputStream; 24 25 30 public class YellOnFlushAndCloseOutputStream extends ProxyOutputStream { 31 32 private boolean yellForFlush; 33 private boolean yellForClose; 34 35 40 public YellOnFlushAndCloseOutputStream(OutputStream proxy, boolean yellForFlush, boolean yellForClose) { 41 super(proxy); 42 this.yellForFlush = yellForFlush; 43 this.yellForClose = yellForClose; 44 } 45 46 47 public void flush() throws IOException { 48 if (yellForFlush) { 49 throw new AssertionFailedError("flush() was called on OutputStream"); 50 } 51 super.flush(); 52 } 53 54 55 public void close() throws IOException { 56 if (yellForClose) { 57 throw new AssertionFailedError("close() was called on OutputStream"); 58 } 59 super.close(); 60 } 61 62 } 63 | Popular Tags |