@Test public void shouldCloseInputStream() throws IOException { final TestInputStream in = new TestInputStream(); AbstractPart mock = createPartWithInputStream(name, in); OutputStream out = mock(OutputStream.class); Part part = new TestPart(name, mock); part.write(out); assertThat(in.isClosed(), is(Boolean.TRUE)); }
@Override public void write(OutputStream out) throws IOException { writeContentDisposition(out); writeName(out); writeExtraHeaderIfNotNull(out); writeCRLF(out); writeContentTypeIfNotNull(out); writeCRLF(out); writeContent(out); writeCRLF(out); }
AbstractPart implements Part { @Override public void write(OutputStream out) throws IOException { writeContentDisposition(out); writeName(out); writeExtraHeaderIfNotNull(out); writeCRLF(out); writeContentTypeIfNotNull(out); writeCRLF(out); writeContent(out); writeCRLF(out); } }
AbstractPart implements Part { @Override public void write(OutputStream out) throws IOException { writeContentDisposition(out); writeName(out); writeExtraHeaderIfNotNull(out); writeCRLF(out); writeContentTypeIfNotNull(out); writeCRLF(out); writeContent(out); writeCRLF(out); } AbstractPart(String name); }
AbstractPart implements Part { @Override public void write(OutputStream out) throws IOException { writeContentDisposition(out); writeName(out); writeExtraHeaderIfNotNull(out); writeCRLF(out); writeContentTypeIfNotNull(out); writeCRLF(out); writeContent(out); writeCRLF(out); } AbstractPart(String name); @Override void write(OutputStream out); @Override String getName(); }
AbstractPart implements Part { @Override public void write(OutputStream out) throws IOException { writeContentDisposition(out); writeName(out); writeExtraHeaderIfNotNull(out); writeCRLF(out); writeContentTypeIfNotNull(out); writeCRLF(out); writeContent(out); writeCRLF(out); } AbstractPart(String name); @Override void write(OutputStream out); @Override String getName();  }