WriterOutputStream extends OutputStream { public String getEncoding() { return _charsetName; } WriterOutputStream(Writer writer);  WriterOutputStream(Writer writer, String charsetName);  WriterOutputStream(
		Writer writer, String charsetName, boolean autoFlush);  WriterOutputStream(
		Writer writer, String charsetName, int outputBufferSize);  WriterOutputStream(
		Writer writer, String charsetName, int outputBufferSize,
		boolean autoFlush); @Override void close(); @Override void flush(); String getEncoding(); @Override void write(byte[] bytes); @Override void write(byte[] bytes, int offset, int length); @Override void write(int b);  }
@Test public void testConstructor() { DummyWriter dummyWriter = new DummyWriter(); WriterOutputStream writerOutputStream = new WriterOutputStream( dummyWriter); Assert.assertSame(dummyWriter, _getWriter(writerOutputStream)); Assert.assertSame( StringPool.DEFAULT_CHARSET_NAME, writerOutputStream.getEncoding()); Assert.assertEquals( _getDefaultOutputBufferSize(), _getOutputBufferSize(writerOutputStream)); Assert.assertFalse(_isAutoFlush(writerOutputStream)); writerOutputStream = new WriterOutputStream(dummyWriter, null); Assert.assertSame(dummyWriter, _getWriter(writerOutputStream)); Assert.assertSame( StringPool.DEFAULT_CHARSET_NAME, writerOutputStream.getEncoding()); Assert.assertEquals( _getDefaultOutputBufferSize(), _getOutputBufferSize(writerOutputStream)); Assert.assertFalse(_isAutoFlush(writerOutputStream)); String encoding = "US-ASCII"; writerOutputStream = new WriterOutputStream(dummyWriter, encoding); Assert.assertSame(dummyWriter, _getWriter(writerOutputStream)); Assert.assertSame(encoding, writerOutputStream.getEncoding()); Assert.assertEquals( _getDefaultOutputBufferSize(), _getOutputBufferSize(writerOutputStream)); Assert.assertFalse(_isAutoFlush(writerOutputStream)); writerOutputStream = new WriterOutputStream( dummyWriter, encoding, true); Assert.assertSame(dummyWriter, _getWriter(writerOutputStream)); Assert.assertSame(encoding, writerOutputStream.getEncoding()); Assert.assertEquals( _getDefaultOutputBufferSize(), _getOutputBufferSize(writerOutputStream)); Assert.assertTrue(_isAutoFlush(writerOutputStream)); writerOutputStream = new WriterOutputStream(dummyWriter, encoding, 32); Assert.assertSame(dummyWriter, _getWriter(writerOutputStream)); Assert.assertSame(encoding, writerOutputStream.getEncoding()); Assert.assertEquals(1, _getInputBufferSize(writerOutputStream)); Assert.assertEquals(32, _getOutputBufferSize(writerOutputStream)); Assert.assertFalse(_isAutoFlush(writerOutputStream)); writerOutputStream = new WriterOutputStream( dummyWriter, encoding, 32, true); Assert.assertSame(dummyWriter, _getWriter(writerOutputStream)); Assert.assertSame(encoding, writerOutputStream.getEncoding()); Assert.assertEquals(1, _getInputBufferSize(writerOutputStream)); Assert.assertEquals(32, _getOutputBufferSize(writerOutputStream)); Assert.assertTrue(_isAutoFlush(writerOutputStream)); writerOutputStream = new WriterOutputStream( dummyWriter, encoding, 0, true); Assert.assertSame(dummyWriter, _getWriter(writerOutputStream)); Assert.assertSame(encoding, writerOutputStream.getEncoding()); Assert.assertEquals(1, _getInputBufferSize(writerOutputStream)); Assert.assertEquals( _getDefaultOutputBufferSize(), _getOutputBufferSize(writerOutputStream)); Assert.assertTrue(_isAutoFlush(writerOutputStream)); try { new WriterOutputStream(dummyWriter, encoding, 0, false); Assert.fail(); } catch (IllegalArgumentException illegalArgumentException) { Assert.assertEquals( "Output buffer size 0 must be a positive number", illegalArgumentException.getMessage()); } }