StreamDataBodyPart extends FormDataBodyPart { protected static MediaType getDefaultMediaType() { return MediaType.APPLICATION_OCTET_STREAM_TYPE; } StreamDataBodyPart();  StreamDataBodyPart(final String name, final InputStream streamEntity);  StreamDataBodyPart(final String name, final InputStream streamEntity, final String filename);  StreamDataBodyPart(final String name, final InputStream streamEntity,
                              final String filename,
                              final MediaType mediaType); @Override void setValue(final MediaType mediaType, final Object value); @Override void setValue(final String value); @Override void setEntity(final Object entity); void setStreamEntity(final InputStream streamEntity); void setStreamEntity(final InputStream streamEntity, MediaType mediaType); void setFilename(final String filename); InputStream getStreamEntity(); String getFilename();  }
@Test public void testCreateStreamEntityNullMediaType() { MediaType expectedMediaType = StreamDataBodyPart.getDefaultMediaType(); cut = new StreamDataBodyPart("foo", new ByteArrayInputStream(new byte[] {}), "bar.txt", null); MediaType actualMediaType = cut.getMediaType(); assertEquals(expectedMediaType, actualMediaType); }
@Test public void testStreamEntityStream() { MediaType expectedMediaType = StreamDataBodyPart.getDefaultMediaType(); InputStream expectedInputStream = new ByteArrayInputStream(new byte[] {0x002, 0x003}); assertSetEntityStream(expectedMediaType, expectedInputStream); }
@Test public void testGetDefaultMediaType() { MediaType expected = MediaType.APPLICATION_OCTET_STREAM_TYPE; MediaType actual = StreamDataBodyPart.getDefaultMediaType(); assertEquals(expected, actual); }