@Test public void writesStreamingOutputToOutputStream() throws Exception { StreamingOutput streamingOutput = mock(StreamingOutput.class); ByteArrayOutputStream out = new ByteArrayOutputStream(); byte[] streamingOutputContent = "streaming output".getBytes(); doAnswer(invocation -> { out.write(streamingOutputContent); return null; }).when(streamingOutput).write(out); streamOutputEntityProvider.writeTo(streamingOutput, String.class, null, null, null, new MultivaluedHashMap<>(), out); assertArrayEquals(streamingOutputContent, out.toByteArray()); }
@Override public void writeTo(StreamingOutput streamingOutput, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { streamingOutput.write(entityStream); }
StreamOutputEntityProvider implements EntityProvider<StreamingOutput> { @Override public void writeTo(StreamingOutput streamingOutput, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { streamingOutput.write(entityStream); } }
StreamOutputEntityProvider implements EntityProvider<StreamingOutput> { @Override public void writeTo(StreamingOutput streamingOutput, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { streamingOutput.write(entityStream); }  }
StreamOutputEntityProvider implements EntityProvider<StreamingOutput> { @Override public void writeTo(StreamingOutput streamingOutput, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { streamingOutput.write(entityStream); }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override StreamingOutput readFrom(Class<StreamingOutput> type,
                                    Type genericType,
                                    Annotation[] annotations,
                                    MediaType mediaType,
                                    MultivaluedMap<String, String> httpHeaders,
                                    InputStream entityStream); @Override long getSize(StreamingOutput streamingOutput, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(StreamingOutput streamingOutput,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream); }
StreamOutputEntityProvider implements EntityProvider<StreamingOutput> { @Override public void writeTo(StreamingOutput streamingOutput, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream) throws IOException { streamingOutput.write(entityStream); }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override StreamingOutput readFrom(Class<StreamingOutput> type,
                                    Type genericType,
                                    Annotation[] annotations,
                                    MediaType mediaType,
                                    MultivaluedMap<String, String> httpHeaders,
                                    InputStream entityStream); @Override long getSize(StreamingOutput streamingOutput, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(StreamingOutput streamingOutput,
                        Class<?> type,
                        Type genericType,
                        Annotation[] annotations,
                        MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders,
                        OutputStream entityStream);  }