View Javadoc

1   package searls.jasmine.io;
2   
3   import static org.powermock.api.mockito.PowerMockito.*;
4   
5   import static org.junit.Assert.*;
6   import static org.hamcrest.Matchers.*;
7   import java.io.IOException;
8   import java.io.InputStream;
9   
10  import org.apache.commons.io.IOUtils;
11  import org.junit.Before;
12  import org.junit.Test;
13  import org.junit.runner.RunWith;
14  import org.powermock.core.classloader.annotations.PrepareForTest;
15  import org.powermock.modules.junit4.PowerMockRunner;
16  
17  @RunWith(PowerMockRunner.class)
18  @PrepareForTest(IOUtils.class)
19  public class IOUtilsWrapperTest {
20  	private IOUtilsWrapper sut = new IOUtilsWrapper();
21  	private InputStream inputStream = mock(InputStream.class);
22  
23  	@Before
24  	public void powerfullyMockStaticClasses() {
25  		mockStatic(IOUtils.class);
26  	}
27  	
28  	@Test
29  	public void shouldDelegateToString() throws IOException {
30  		String expected = "pants";
31  		when(IOUtils.toString(inputStream)).thenReturn(expected );
32  		
33  		String result = sut.toString(inputStream);
34  		
35  		assertThat(result,is(expected));
36  	}
37  }