@Test
public void testClose() throws IOException {

	// Normal close
	MarkerOutputStream markerOutputStream = new MarkerOutputStream();
	try (OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
			markerOutputStream)) {
		Assert.assertFalse(markerOutputStream._closed);
		outputStreamWriter.close();
		Assert.assertTrue(markerOutputStream._closed);
		markerOutputStream._closed = false;
		try {
			outputStreamWriter.write(0);
			Assert.fail();
		}
		catch (IOException ioException) {
			Assert.assertEquals("Stream closed", ioException.getMessage());
		}
	}
	Assert.assertFalse(markerOutputStream._closed);
	// Exception close
	final IOException ioException1 = new IOException();
	OutputStreamWriter outputStreamWriter = new OutputStreamWriter(
		new UnsyncByteArrayOutputStream() {
			@Override
			public void close() throws IOException {
				throw ioException1;
			}
		});
	// First close
	try {
		outputStreamWriter.close();
		Assert.fail();
	}
	catch (IOException ioException2) {
		Assert.assertSame(ioException2, ioException1);
	}
	// Second close to check first close indeed changed the state
	outputStreamWriter.close();
}