@Test(expected = UnsupportedEncodingException.class) public void exceptions_in_append_charSequence() throws IOException { final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public Writer append(final CharSequence csq) throws IOException { throw new UnsupportedEncodingException("Bah"); } }; try (ProxyWriter proxy = new ProxyWriter(osw)) { proxy.append("ABCE"); } }
@Test(expected = UnsupportedEncodingException.class) public void exceptions_in_append_charSequence_offset() throws IOException { final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public Writer append(final CharSequence csq, final int start, final int end) throws IOException { throw new UnsupportedEncodingException("Bah"); } }; try (ProxyWriter proxy = new ProxyWriter(osw)) { proxy.append("ABCE", 1, 2); } }
@Test(expected = UnsupportedEncodingException.class) public void exceptions_in_append_char() throws IOException { final OutputStreamWriter osw = new OutputStreamWriter(new ByteArrayOutputStream()) { @Override public void write(final int c) throws IOException { throw new UnsupportedEncodingException("Bah"); } }; try (ProxyWriter proxy = new ProxyWriter(osw)) { proxy.append('c'); } }
@Test public void nullCharSequencec() throws Exception { final ProxyWriter proxy = new ProxyWriter(new NullWriter()); proxy.append(null); proxy.close(); }
@Test public void appendCharSequence() throws Exception { final StringBuilderWriter writer = new StringBuilderWriter(); final ProxyWriter proxy = new ProxyWriter(writer); proxy.append("ABC"); assertEquals("ABC", writer.toString()); proxy.close(); }
@Test public void appendChar() throws Exception { final StringBuilderWriter writer = new StringBuilderWriter(); final ProxyWriter proxy = new ProxyWriter(writer); proxy.append('c'); assertEquals("c", writer.toString()); proxy.close(); }
@Test public void appendCharSequence_with_offset() throws Exception { final StringBuilderWriter writer = new StringBuilderWriter(); final ProxyWriter proxy = new ProxyWriter(writer); proxy.append("ABC", 1, 3); proxy.flush(); assertEquals("BC", writer.toString()); proxy.close(); }
@Override public Writer append(CharSequence csq, int start, int end) throws IOException { super.append(csq, start, end); branch.append(csq, start, end); return this; }
@Override public Writer append(CharSequence csq, int start, int end) throws IOException { super.append(csq, start, end); branch.append(csq, start, end); return this; }
@Override public Writer append(CharSequence csq) throws IOException { super.append(csq); branch.append(csq); return this; }
@Override public Writer append(char c) throws IOException { super.append(c); branch.append(c); return this; }
@Override public Writer append(char c) throws IOException { super.append(c); branch.append(c); return this; }
@Override public Writer append(CharSequence csq) throws IOException { super.append(csq); branch.append(csq); return this; }