OutputStreamWriter extends Writer { public String getEncoding() { return _charsetName; } OutputStreamWriter(OutputStream outputStream);  OutputStreamWriter(OutputStream outputStream, String charsetName);  OutputStreamWriter(
		OutputStream outputStream, String charsetName, boolean autoFlush);  OutputStreamWriter(
		OutputStream outputStream, String charsetName, int outputBufferSize);  OutputStreamWriter(
		OutputStream outputStream, String charsetName, int outputBufferSize,
		boolean autoFlush); @Override void close(); @Override void flush(); String getEncoding(); @Override void write(char[] chars); @Override void write(char[] chars, int offset, int length); @Override void write(int c); @Override void write(String string); @Override void write(String string, int offset, int length);  }
@Test public void testConstructor() { DummyOutputStream dummyOutputStream = new DummyOutputStream(); OutputStreamWriter outputStreamWriter = new OutputStreamWriter( dummyOutputStream); Assert.assertSame( dummyOutputStream, _getOutputStream(outputStreamWriter)); Assert.assertSame( StringPool.DEFAULT_CHARSET_NAME, outputStreamWriter.getEncoding()); Assert.assertEquals( _getDefaultOutputBufferSize(), _getOutputBufferSize(outputStreamWriter)); Assert.assertFalse(_isAutoFlush(outputStreamWriter)); outputStreamWriter = new OutputStreamWriter(dummyOutputStream, null); Assert.assertSame( dummyOutputStream, _getOutputStream(outputStreamWriter)); Assert.assertSame( StringPool.DEFAULT_CHARSET_NAME, outputStreamWriter.getEncoding()); Assert.assertEquals( _getDefaultOutputBufferSize(), _getOutputBufferSize(outputStreamWriter)); Assert.assertFalse(_isAutoFlush(outputStreamWriter)); String encoding = "US-ASCII"; outputStreamWriter = new OutputStreamWriter( dummyOutputStream, encoding); Assert.assertSame( dummyOutputStream, _getOutputStream(outputStreamWriter)); Assert.assertSame(encoding, outputStreamWriter.getEncoding()); Assert.assertEquals( _getDefaultOutputBufferSize(), _getOutputBufferSize(outputStreamWriter)); Assert.assertFalse(_isAutoFlush(outputStreamWriter)); outputStreamWriter = new OutputStreamWriter( dummyOutputStream, encoding, true); Assert.assertSame( dummyOutputStream, _getOutputStream(outputStreamWriter)); Assert.assertSame(encoding, outputStreamWriter.getEncoding()); Assert.assertEquals( _getDefaultOutputBufferSize(), _getOutputBufferSize(outputStreamWriter)); Assert.assertTrue(_isAutoFlush(outputStreamWriter)); outputStreamWriter = new OutputStreamWriter( dummyOutputStream, encoding, 32); Assert.assertSame( dummyOutputStream, _getOutputStream(outputStreamWriter)); Assert.assertSame(encoding, outputStreamWriter.getEncoding()); Assert.assertEquals(2, _getInputCharBufferSize(outputStreamWriter)); Assert.assertEquals(32, _getOutputBufferSize(outputStreamWriter)); Assert.assertFalse(_isAutoFlush(outputStreamWriter)); outputStreamWriter = new OutputStreamWriter( dummyOutputStream, encoding, 32, true); Assert.assertSame( dummyOutputStream, _getOutputStream(outputStreamWriter)); Assert.assertSame(encoding, outputStreamWriter.getEncoding()); Assert.assertEquals(2, _getInputCharBufferSize(outputStreamWriter)); Assert.assertEquals(32, _getOutputBufferSize(outputStreamWriter)); Assert.assertTrue(_isAutoFlush(outputStreamWriter)); try { new OutputStreamWriter(dummyOutputStream, encoding, 3, true); Assert.fail(); } catch (IllegalArgumentException illegalArgumentException) { Assert.assertEquals( "Output buffer size 3 is less than 4", illegalArgumentException.getMessage()); } }