View Javadoc

1   package liquibase.util;
2   
3   import static junit.framework.Assert.assertEquals;
4   import org.junit.Test;
5   
6   import java.io.ByteArrayInputStream;
7   import java.io.IOException;
8   import java.io.StringReader;
9   
10  public class StreamUtilTest {
11  
12      @Test
13      public void testGetStreamContents() throws IOException {
14          byte[] contents = "TEST2".getBytes();
15          ByteArrayInputStream stream = new ByteArrayInputStream(contents);
16          String result = StreamUtil.getStreamContents(stream);
17          assertEquals("TEST2", result);
18      }
19  
20      @Test
21      public void testGetReaderContents() throws IOException {
22          String contents = "TEST";
23          StringReader reader = new StringReader(contents);
24          String result = StreamUtil.getReaderContents(reader);
25          assertEquals(contents, result);
26      }
27  
28  }