Browse Source

Add a horrible unit test for StreamUtils.

pull/49/head
Greg Holmes 9 years ago
parent
commit
f9206098c0
1 changed files with 12 additions and 0 deletions
  1. 12
    0
      test/com/dmdirc/util/io/StreamUtilsTest.java

+ 12
- 0
test/com/dmdirc/util/io/StreamUtilsTest.java View File

@@ -24,13 +24,18 @@ package com.dmdirc.util.io;
24 24
 
25 25
 import java.io.Closeable;
26 26
 import java.io.IOException;
27
+import java.io.InputStream;
27 28
 
28 29
 import org.junit.Test;
29 30
 import org.junit.runner.RunWith;
30 31
 import org.mockito.Mock;
31 32
 import org.mockito.runners.MockitoJUnitRunner;
32 33
 
34
+import static org.mockito.Matchers.any;
35
+import static org.mockito.Matchers.anyInt;
36
+import static org.mockito.Mockito.atLeastOnce;
33 37
 import static org.mockito.Mockito.doThrow;
38
+import static org.mockito.Mockito.spy;
34 39
 import static org.mockito.Mockito.verify;
35 40
 
36 41
 @SuppressWarnings("resource")
@@ -45,6 +50,13 @@ public class StreamUtilsTest {
45 50
         StreamUtils.close(null);
46 51
     }
47 52
 
53
+    @Test
54
+    public void testReadStream() throws Exception {
55
+        final InputStream inputStream = spy(getClass().getResource("test5.txt").openStream());
56
+        StreamUtils.readStream(inputStream);
57
+        verify(inputStream, atLeastOnce()).read(any(byte[].class), anyInt(), anyInt());
58
+    }
59
+
48 60
     @Test
49 61
     public void testCloseWithIoException() throws IOException {
50 62
         doThrow(new IOException("Oops")).when(closeable).close();

Loading…
Cancel
Save