### Question:
StringUtil { public static String read( Reader reader ) throws IOException { return IoUtil.read(reader); } private  StringUtil(); static String combineLines( String[] lines ); static String combineLines( String[] lines,
                                       char separator ); static List<String> splitLines( final String content ); static String createString( String pattern,
                                       Object... parameters ); static String createString( final char charToRepeat,
                                       int numberOfRepeats ); static String setLength( String original,
                                    int length,
                                    char padChar ); static String justifyRight( String str,
                                       final int width,
                                       char padWithChar ); static String justifyLeft( String str,
                                      final int width,
                                      char padWithChar ); static String justifyCenter( String str,
                                        final int width,
                                        char padWithChar ); static String truncate( Object obj,
                                   int maxLength ); static String truncate( Object obj,
                                   int maxLength,
                                   String suffix ); static String read( Reader reader ); static String read( InputStream stream ); static void write( String content,
                              OutputStream stream ); static void write( String content,
                              Writer writer ); static String getStackTrace( Throwable throwable ); static String normalize( String text ); static String getHexString( byte[] bytes ); static byte[] fromHexString( String hexadecimal ); static final String[] EMPTY_STRING_ARRAY; }### Answer:
@Test public void readShouldReturnEmptyStringForNullInputStream() throws Exception { assertThat(StringUtil.read((InputStream)null), is("")); }
@Test public void readShouldReturnEmptyStringForNullReader() throws Exception { assertThat(StringUtil.read((Reader)null), is("")); }
@Test public void readShouldReadInputStreamCorrectlyAndShouldCloseStream() throws Exception { String content = "This is the way to grandma's house."; InputStream stream = new ByteArrayInputStream(content.getBytes()); InputStreamWrapper wrapper = new InputStreamWrapper(stream); assertThat(wrapper.isClosed(), is(false)); assertThat(StringUtil.read(wrapper), is(content)); assertThat(wrapper.isClosed(), is(true)); for (int i = 0; i != 10; ++i) { content += content; } stream = new ByteArrayInputStream(content.getBytes()); wrapper = new InputStreamWrapper(stream); assertThat(wrapper.isClosed(), is(false)); assertThat(StringUtil.read(wrapper), is(content)); assertThat(wrapper.isClosed(), is(true)); }
@Test public void readShouldReadReaderCorrectlyAndShouldCloseStream() throws Exception { String content = "This is the way to grandma's house."; Reader reader = new StringReader(content); ReaderWrapper wrapper = new ReaderWrapper(reader); assertThat(wrapper.isClosed(), is(false)); assertThat(StringUtil.read(wrapper), is(content)); assertThat(wrapper.isClosed(), is(true)); for (int i = 0; i != 10; ++i) { content += content; } reader = new StringReader(content); wrapper = new ReaderWrapper(reader); assertThat(wrapper.isClosed(), is(false)); assertThat(StringUtil.read(wrapper), is(content)); assertThat(wrapper.isClosed(), is(true)); }