Przeglądaj źródła

Add a horrible unit test for StreamUtils.

pull/49/head
Greg Holmes 9 lat temu
rodzic
commit
f9206098c0
1 zmienionych plików z 12 dodań i 0 usunięć
  1. 12
    0
      test/com/dmdirc/util/io/StreamUtilsTest.java

+ 12
- 0
test/com/dmdirc/util/io/StreamUtilsTest.java Wyświetl plik

24
 
24
 
25
 import java.io.Closeable;
25
 import java.io.Closeable;
26
 import java.io.IOException;
26
 import java.io.IOException;
27
+import java.io.InputStream;
27
 
28
 
28
 import org.junit.Test;
29
 import org.junit.Test;
29
 import org.junit.runner.RunWith;
30
 import org.junit.runner.RunWith;
30
 import org.mockito.Mock;
31
 import org.mockito.Mock;
31
 import org.mockito.runners.MockitoJUnitRunner;
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
 import static org.mockito.Mockito.doThrow;
37
 import static org.mockito.Mockito.doThrow;
38
+import static org.mockito.Mockito.spy;
34
 import static org.mockito.Mockito.verify;
39
 import static org.mockito.Mockito.verify;
35
 
40
 
36
 @SuppressWarnings("resource")
41
 @SuppressWarnings("resource")
45
         StreamUtils.close(null);
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
     @Test
60
     @Test
49
     public void testCloseWithIoException() throws IOException {
61
     public void testCloseWithIoException() throws IOException {
50
         doThrow(new IOException("Oops")).when(closeable).close();
62
         doThrow(new IOException("Oops")).when(closeable).close();

Ładowanie…
Anuluj
Zapisz