Skip to content

Commit c4a3d56

Browse files
committed
add tests for StandardInputSupplier
1 parent 81e5676 commit c4a3d56

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package io.github.benas.unixstream;
2+
3+
import org.junit.Before;
4+
import org.junit.Test;
5+
import org.junit.runner.RunWith;
6+
import org.mockito.Mock;
7+
import org.mockito.Mockito;
8+
import org.mockito.junit.MockitoJUnitRunner;
9+
10+
import java.io.BufferedReader;
11+
import java.io.IOException;
12+
13+
import static org.mockito.Mockito.verify;
14+
15+
@RunWith(MockitoJUnitRunner.class)
16+
public class StandardInputSupplierTest {
17+
18+
@Mock
19+
private BufferedReader bufferedReader;
20+
@Mock
21+
private IOException exception;
22+
23+
private StandardInputSupplier standardInputSupplier;
24+
25+
@Before
26+
public void setUp() throws Exception {
27+
standardInputSupplier = new StandardInputSupplier(bufferedReader);
28+
}
29+
30+
@Test
31+
public void get() throws Exception {
32+
standardInputSupplier.get();
33+
34+
verify(bufferedReader).readLine();
35+
}
36+
37+
@Test(expected = RuntimeException.class)
38+
public void get_whenBufferedReaderThrowsException() throws Exception {
39+
Mockito.when(bufferedReader.readLine()).thenThrow(exception);
40+
41+
standardInputSupplier.get();
42+
}
43+
44+
}

0 commit comments

Comments
 (0)