@Test
public void testReadingFromFile() throws Exception {
final File tempFileIn = testFolder.newFile("utfdatain.txt");
final FileSink fileSink = newFileSink().binary(true);
final HttpSource source = newHttpSource();
/* I want to go to Japan. */
final String stringToPostInJapanese = "\u65e5\u672c\u306b\u884c\u304d\u305f\u3044\u3002";
// Let's source from an UTF16 file.
Charset inCharset = Charset.forName("UTF-16");
OutputStream os = new FileOutputStream(tempFileIn);
StreamUtils.copy(stringToPostInJapanese, inCharset, os);
os.close();
final String streamName = generateStreamName();
final String stream = String.format("%s | %s", source, fileSink);
stream().create(streamName, stream);
source.ensureReady().useContentType(String.format("text/plain;charset=%s", inCharset)).postFromFile(tempFileIn);
assertThat(fileSink, eventually(hasContentsThat(equalTo(stringToPostInJapanese))));
}