1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/samples/delegatingwriterfinal/src-test/api/usage/BufferedWriterCryptoTest.java Sat Jun 14 09:53:06 2008 +0200
1.3 @@ -0,0 +1,37 @@
1.4 +
1.5 +package api.usage;
1.6 +
1.7 +import api.Writer;
1.8 +import java.io.IOException;
1.9 +import java.io.StringWriter;
1.10 +import java.io.StringWriter;
1.11 +import org.junit.Before;
1.12 +import org.junit.Test;
1.13 +import static org.junit.Assert.*;
1.14 +
1.15 +/** Converting the Crypto example to the APIs that split client and provider
1.16 + * concerns and do not mix delegation and subclassing.
1.17 + *
1.18 + * @author Jaroslav Tulach <jaroslav.tulach@apidesign.org>
1.19 + */
1.20 +public class BufferedWriterCryptoTest {
1.21 + private StringWriter writer;
1.22 +
1.23 +
1.24 + public BufferedWriterCryptoTest() {
1.25 + }
1.26 +
1.27 + @Before
1.28 + public void setUp() {
1.29 + writer = new StringWriter();
1.30 + }
1.31 +
1.32 + @Test
1.33 + public void testBehaviourOfRealBufferInJDKWorksFine() throws IOException {
1.34 + Writer bufferedWriter = CryptoWriter.create(Writer.create(writer));
1.35 + bufferedWriter.write("VMS");
1.36 + bufferedWriter.flush();
1.37 + assertEquals("Converted", "WNT", writer.toString());
1.38 + }
1.39 +
1.40 +}
1.41 \ No newline at end of file