ServletInputStreamWrapper extends ServletInputStream { @Override public boolean isFinished() { try { return content.available() == 0; } catch (IOException e) { throw new RuntimeException(e); } } ServletInputStreamWrapper(InputStream content); @Override int read(byte[] b); @Override int read(byte[] b, int off, int len); @Override int read(); @Override boolean isFinished(); @Override boolean isReady(); @Override void setReadListener(ReadListener listener);  }
@Test public void isFinished() throws IOException { when(content.available()).thenReturn(0); boolean result = underTest.isFinished(); assertThat(result, is(true)); }
@Test public void isFinished_Not() throws IOException { when(content.available()).thenReturn(1); boolean result = underTest.isFinished(); assertThat(result, is(false)); }
@Test(expected = RuntimeException.class) public void isFinished_Throws() throws IOException { doThrow(IOException.class).when(content).available(); underTest.isFinished(); }