ReaderResource extends BaseResource implements InternalResource { public String getEncoding() { return this.encoding; } ReaderResource();  ReaderResource(Reader reader);  ReaderResource(Reader reader, ResourceType type );  ReaderResource(Reader reader, String encoding);  ReaderResource(Reader reader, String encoding, ResourceType type ); URL getURL(); InputStream getInputStream(); Reader getReader(); String getEncoding(); boolean isDirectory(); Collection<Resource> listResources(); boolean hasURL(); String toString();  }
@Test public void defaultEncodingInitialization() throws UnsupportedEncodingException { final String anyEncoding = availableCharsets[0].name(); final InputStream istream = new ByteArrayInputStream(new byte[] {}); InputStreamReader ireader = new InputStreamReader(istream, anyEncoding); ReaderResource iresource = new ReaderResource(ireader, null, null); assertEquals(ireader.getEncoding(), iresource.getEncoding()); final String differentEncoding = availableCharsets[1].name(); ireader = new InputStreamReader(istream, differentEncoding); iresource = new ReaderResource(ireader, null, null); assertEquals(ireader.getEncoding(), iresource.getEncoding()); }
@Test public void overwritingEncodingInitialization() throws UnsupportedEncodingException { final String anyEncoding = availableCharsets[0].name(); final InputStream istream = new ByteArrayInputStream(new byte[] {}); final InputStreamReader ireader = new InputStreamReader(istream, anyEncoding); final String overwrittenEncoding = availableCharsets[1].name(); final ReaderResource iresource = new ReaderResource(ireader, overwrittenEncoding, null); assertEquals(overwrittenEncoding, iresource.getEncoding()); assertNotEquals(ireader.getEncoding(), iresource.getEncoding()); }