ContentHolder { public void outputClose() { switch (state) { case NONE: break; case OUTPUT: case OUTPUT_STREAM: case OUTPUT_WRITER: if (outputCloseShouldFlush()) { if (writer != null && writer.checkError()) { throw badState("Error in the PrintWriter"); } if (os != null) { try { os.flush(); } catch (IOException e) { throw new IllegalStateException(e); } } } writer = null; break; default: throw badState("Not in output state"); } state = State.OUTPUT_CLOSED; } ContentHolder(Object self, int length, State state); final Object self(); final Charset getDefaultCharset(); final void setDefaultCharset(Charset defaultCharset); final int getLength(); final void setLength(int length); final State getState(); final IllegalStateException badState(String message); Charset getCharset(); final OutputStream outputOut(); final PrintWriter outputWriter(); void outputClose(); final InputStream inputIn(); final BufferedReader inputReader(); @Override String toString();  }
@Test(expected = IllegalStateException.class) public void testCloseNotInput() { ContentHolder contentHolder = new ContentHolder("", -1, ContentHolder.State.INPUT); contentHolder.outputClose(); }