1 package org.columba.mail.gui.composer.util; 17 18 import java.io.ByteArrayInputStream ; 19 import java.io.IOException ; 20 import java.io.InputStream ; 21 22 import junit.framework.TestCase; 23 24 import org.columba.core.io.StreamUtils; 25 26 27 public class QuoteFilterInputStreamTest extends TestCase { 28 public void testOneLiner() throws IOException { 29 String line = "This is a test"; 30 InputStream in = new ByteArrayInputStream (line.getBytes()); 31 32 StringBuffer result = StreamUtils.readCharacterStream(new QuoteFilterInputStream( 33 in)); 34 assertTrue(result.toString().equals(line.replaceAll("(?m)^(.*)$", "> $1"))); 35 } 36 37 public void testMultiLiner1() throws IOException { 38 String line = "This is a test\nForget the rest\n\n"; 39 InputStream in = new ByteArrayInputStream (line.getBytes()); 40 41 StringBuffer result = StreamUtils.readCharacterStream(new QuoteFilterInputStream( 42 in)); 43 assertTrue(result.toString().equals(line.replaceAll("(?m)^(.*)$", "> $1"))); 44 } 45 46 public void testMultiLiner2() throws IOException { 47 String line = "This is a test\nForget the rest\n\n\n"; 48 InputStream in = new ByteArrayInputStream (line.getBytes()); 49 50 StringBuffer result = StreamUtils.readCharacterStream(new QuoteFilterInputStream( 51 in)); 52 assertTrue(result.toString().equals(line.replaceAll("(?m)^(.*)$", "> $1"))); 53 } 54 55 public void testMultiLiner3() throws IOException { 56 String line = "\nThis is a test\nForget the rest\n\n\n"; 57 InputStream in = new ByteArrayInputStream (line.getBytes()); 58 59 StringBuffer result = StreamUtils.readCharacterStream(new QuoteFilterInputStream( 60 in)); 61 assertTrue(result.toString().equals(line.replaceAll("(?m)^(.*)$", "> $1"))); 62 } 63 } 64 | Popular Tags |