KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > composer > util > QuoteFilterInputStreamTest


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
13
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14
//
15
//All Rights Reserved.
16
package org.columba.mail.gui.composer.util;
17
18 import java.io.ByteArrayInputStream JavaDoc;
19 import java.io.IOException JavaDoc;
20 import java.io.InputStream JavaDoc;
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 JavaDoc {
29         String JavaDoc line = "This is a test";
30         InputStream JavaDoc in = new ByteArrayInputStream JavaDoc(line.getBytes());
31
32         StringBuffer JavaDoc result = StreamUtils.readCharacterStream(new QuoteFilterInputStream(
33                     in));
34         assertTrue(result.toString().equals(line.replaceAll("(?m)^(.*)$", "> $1")));
35     }
36
37     public void testMultiLiner1() throws IOException JavaDoc {
38         String JavaDoc line = "This is a test\nForget the rest\n\n";
39         InputStream JavaDoc in = new ByteArrayInputStream JavaDoc(line.getBytes());
40
41         StringBuffer JavaDoc result = StreamUtils.readCharacterStream(new QuoteFilterInputStream(
42                     in));
43         assertTrue(result.toString().equals(line.replaceAll("(?m)^(.*)$", "> $1")));
44     }
45
46     public void testMultiLiner2() throws IOException JavaDoc {
47         String JavaDoc line = "This is a test\nForget the rest\n\n\n";
48         InputStream JavaDoc in = new ByteArrayInputStream JavaDoc(line.getBytes());
49
50         StringBuffer JavaDoc result = StreamUtils.readCharacterStream(new QuoteFilterInputStream(
51                     in));
52         assertTrue(result.toString().equals(line.replaceAll("(?m)^(.*)$", "> $1")));
53     }
54
55     public void testMultiLiner3() throws IOException JavaDoc {
56         String JavaDoc line = "\nThis is a test\nForget the rest\n\n\n";
57         InputStream JavaDoc in = new ByteArrayInputStream JavaDoc(line.getBytes());
58
59         StringBuffer JavaDoc result = StreamUtils.readCharacterStream(new QuoteFilterInputStream(
60                     in));
61         assertTrue(result.toString().equals(line.replaceAll("(?m)^(.*)$", "> $1")));
62     }
63 }
64
Popular Tags