cleanup work

This commit is contained in:
eugenp
2014-09-18 17:33:26 +03:00
parent 71ffd8fb58
commit 7400fdff98
6 changed files with 47 additions and 3 deletions

View File

@@ -149,7 +149,7 @@ public class JavaInputStreamToXUnitTest {
// tests - InputStream to File
@Test
public final void givenUsingPlainJava_whenConvertingAnInputStreamToAFile_thenCorrect() throws IOException {
public final void givenUsingPlainJava_whenConvertingAnFullInputStreamToAFile_thenCorrect() throws IOException {
final InputStream initialStream = new FileInputStream(new File("src/main/resources/sample.txt"));
final byte[] buffer = new byte[initialStream.available()];
initialStream.read(buffer);
@@ -162,6 +162,22 @@ public class JavaInputStreamToXUnitTest {
IOUtils.closeQuietly(outStream);
}
@Test
public final void givenUsingPlainJava_whenConvertingAnInProgressInputStreamToAFile_thenCorrect() throws IOException {
final InputStream initialStream = new FileInputStream(new File("src/main/resources/sample.txt"));
final File targetFile = new File("src/main/resources/targetFile.tmp");
final OutputStream outStream = new FileOutputStream(targetFile);
final byte[] buffer = new byte[8 * 1024];
int bytesRead;
while ((bytesRead = initialStream.read(buffer)) != -1) {
outStream.write(buffer, 0, bytesRead);
}
IOUtils.closeQuietly(initialStream);
IOUtils.closeQuietly(outStream);
}
@Test
public final void givenUsingGuava_whenConvertingAnInputStreamToAFile_thenCorrect() throws IOException {
final InputStream initialStream = new FileInputStream(new File("src/main/resources/sample.txt"));