author | Jaroslav Tulach <jtulach@netbeans.org> |
Sat, 14 Jun 2008 09:53:06 +0200 | |
changeset 65 | 4db7ceebd2b3 |
permissions | -rw-r--r-- |
jtulach@65 | 1 |
|
jtulach@65 | 2 |
package api.usage; |
jtulach@65 | 3 |
|
jtulach@65 | 4 |
import api.Writer; |
jtulach@65 | 5 |
import java.io.IOException; |
jtulach@65 | 6 |
import java.io.StringWriter; |
jtulach@65 | 7 |
import java.io.StringWriter; |
jtulach@65 | 8 |
import org.junit.Before; |
jtulach@65 | 9 |
import org.junit.Test; |
jtulach@65 | 10 |
import static org.junit.Assert.*; |
jtulach@65 | 11 |
|
jtulach@65 | 12 |
/** Converting the Crypto example to the APIs that split client and provider |
jtulach@65 | 13 |
* concerns and do not mix delegation and subclassing. |
jtulach@65 | 14 |
* |
jtulach@65 | 15 |
* @author Jaroslav Tulach <jaroslav.tulach@apidesign.org> |
jtulach@65 | 16 |
*/ |
jtulach@65 | 17 |
public class BufferedWriterCryptoTest { |
jtulach@65 | 18 |
private StringWriter writer; |
jtulach@65 | 19 |
|
jtulach@65 | 20 |
|
jtulach@65 | 21 |
public BufferedWriterCryptoTest() { |
jtulach@65 | 22 |
} |
jtulach@65 | 23 |
|
jtulach@65 | 24 |
@Before |
jtulach@65 | 25 |
public void setUp() { |
jtulach@65 | 26 |
writer = new StringWriter(); |
jtulach@65 | 27 |
} |
jtulach@65 | 28 |
|
jtulach@65 | 29 |
@Test |
jtulach@65 | 30 |
public void testBehaviourOfRealBufferInJDKWorksFine() throws IOException { |
jtulach@65 | 31 |
Writer bufferedWriter = CryptoWriter.create(Writer.create(writer)); |
jtulach@65 | 32 |
bufferedWriter.write("VMS"); |
jtulach@65 | 33 |
bufferedWriter.flush(); |
jtulach@65 | 34 |
assertEquals("Converted", "WNT", writer.toString()); |
jtulach@65 | 35 |
} |
jtulach@65 | 36 |
|
jtulach@65 | 37 |
} |