KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > hudson > util > LineEndNormalizingWriterTest


1 package hudson.util;
2
3 import junit.framework.TestCase;
4
5 import java.io.StringWriter JavaDoc;
6 import java.io.Writer JavaDoc;
7 import java.io.IOException JavaDoc;
8
9 /**
10  * @author Kohsuke Kawaguchi
11  */

12 public class LineEndNormalizingWriterTest extends TestCase {
13     public void test1() throws IOException JavaDoc {
14         StringWriter JavaDoc sw = new StringWriter JavaDoc();
15         Writer JavaDoc w = new LineEndNormalizingWriter(sw);
16
17         w.write("abc\r\ndef\r");
18         w.write("\n");
19
20         assertEquals(sw.toString(),"abc\r\ndef\r\n");
21     }
22
23     public void test2() throws IOException JavaDoc {
24         StringWriter JavaDoc sw = new StringWriter JavaDoc();
25         Writer JavaDoc w = new LineEndNormalizingWriter(sw);
26
27         w.write("abc\ndef\n");
28         w.write("\n");
29
30         assertEquals(sw.toString(),"abc\r\ndef\r\n\r\n");
31     }
32
33     public void test3() throws IOException JavaDoc {
34         StringWriter JavaDoc sw = new StringWriter JavaDoc();
35         Writer JavaDoc w = new LineEndNormalizingWriter(sw);
36
37         w.write("\r\n\n");
38
39         assertEquals(sw.toString(),"\r\n\r\n");
40     }
41 }
42
Popular Tags