@Test public void readsContentOfEntityStreamAsReader() throws Exception { MediaType mediaType = new MediaType("text", "plain", ImmutableMap.of("charset", "windows-1251")); byte[] data = TEST_CONTENT.getBytes("windows-1251"); Reader result = readerEntityProvider.readFrom(Reader.class, String.class, null, mediaType, null, new ByteArrayInputStream(data)); assertEquals(TEST_CONTENT, CharStreams.toString(result)); }
@Override public Reader readFrom(Class<Reader> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { ApplicationContext context = ApplicationContext.getCurrent(); if (context.isAsynchronous()) { int bufferSize = context.getEverrestConfiguration().getMaxBufferSize(); return new InputStreamReader(IOHelper.bufferStream(entityStream, bufferSize), getCharsetOrUtf8(mediaType)); } return new InputStreamReader(entityStream, getCharsetOrUtf8(mediaType)); }
ReaderEntityProvider implements EntityProvider<Reader> { @Override public Reader readFrom(Class<Reader> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { ApplicationContext context = ApplicationContext.getCurrent(); if (context.isAsynchronous()) { int bufferSize = context.getEverrestConfiguration().getMaxBufferSize(); return new InputStreamReader(IOHelper.bufferStream(entityStream, bufferSize), getCharsetOrUtf8(mediaType)); } return new InputStreamReader(entityStream, getCharsetOrUtf8(mediaType)); } }
ReaderEntityProvider implements EntityProvider<Reader> { @Override public Reader readFrom(Class<Reader> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { ApplicationContext context = ApplicationContext.getCurrent(); if (context.isAsynchronous()) { int bufferSize = context.getEverrestConfiguration().getMaxBufferSize(); return new InputStreamReader(IOHelper.bufferStream(entityStream, bufferSize), getCharsetOrUtf8(mediaType)); } return new InputStreamReader(entityStream, getCharsetOrUtf8(mediaType)); }  }
ReaderEntityProvider implements EntityProvider<Reader> { @Override public Reader readFrom(Class<Reader> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { ApplicationContext context = ApplicationContext.getCurrent(); if (context.isAsynchronous()) { int bufferSize = context.getEverrestConfiguration().getMaxBufferSize(); return new InputStreamReader(IOHelper.bufferStream(entityStream, bufferSize), getCharsetOrUtf8(mediaType)); } return new InputStreamReader(entityStream, getCharsetOrUtf8(mediaType)); }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override Reader readFrom(Class<Reader> type, Type genericType, Annotation[] annotations, MediaType mediaType,
                           MultivaluedMap<String, String> httpHeaders, InputStream entityStream); @Override long getSize(Reader t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(Reader reader, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream); }
ReaderEntityProvider implements EntityProvider<Reader> { @Override public Reader readFrom(Class<Reader> type, Type genericType, Annotation[] annotations, MediaType mediaType, MultivaluedMap<String, String> httpHeaders, InputStream entityStream) throws IOException { ApplicationContext context = ApplicationContext.getCurrent(); if (context.isAsynchronous()) { int bufferSize = context.getEverrestConfiguration().getMaxBufferSize(); return new InputStreamReader(IOHelper.bufferStream(entityStream, bufferSize), getCharsetOrUtf8(mediaType)); } return new InputStreamReader(entityStream, getCharsetOrUtf8(mediaType)); }  @Override boolean isReadable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override Reader readFrom(Class<Reader> type, Type genericType, Annotation[] annotations, MediaType mediaType,
                           MultivaluedMap<String, String> httpHeaders, InputStream entityStream); @Override long getSize(Reader t, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override boolean isWriteable(Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType); @Override void writeTo(Reader reader, Class<?> type, Type genericType, Annotation[] annotations, MediaType mediaType,
                        MultivaluedMap<String, Object> httpHeaders, OutputStream entityStream);  }