### Question:
NoClosePipedOutputStream extends OutputStream { public void write(int b) throws IOException { if (sink == null) { throw new IOException("Pipe not connected"); } sink.receive(b); } NoClosePipedOutputStream(NoClosePipedInputStream snk);  NoClosePipedOutputStream(); synchronized void connect(NoClosePipedInputStream snk); void write(int b); void write(byte b[], int off, int len);  }### Answer:
@Test public void testNotConnectedIntWrite () { try { out.write(testValue); fail("This test should have thrown an IOException already"); } catch (IOException e) { assertEquals("Pipe not connected", e.getMessage()); return; } fail("This test should have caught an IOException"); }
@Test public void testNotConnectedByteWrite () { try { out.write(testByte, 0, 1); fail("This test should have thrown an IOException already"); } catch (IOException e) { assertEquals("Pipe not connected", e.getMessage()); return; } catch (NullPointerException e) { fail("The byte is most likely null"); } catch (IndexOutOfBoundsException e) { fail ("The offset or write length is invalid"); } fail("This test should have caught an IOException"); }