1 package test.atlassian.mail;
2
3 import com.atlassian.mail.HtmlToTextConverter;
4 import junit.framework.TestCase;
5 import org.apache.commons.lang.SystemUtils;
6
7 import java.io.IOException;
8
9 public class TestHtmlToTextConverter extends TestCase
10 {
11 public void testParagraphsAndBreaks() throws IOException
12 {
13 assertEquals("I am a fish\nas am I\n\nand me",
14 new HtmlToTextConverter().convert("<p>I am a fish<br>as am I<p>and me"));
15 }
16
17
18
19
20
21
22
23
24
25 public void testXHTMLBreaks() throws IOException
26 {
27 final String expected;
28 if (SystemUtils.isJavaVersionAtLeast(160))
29 {
30 expected = "I am a fish\nas am I\nand me";
31 }
32 else
33 {
34 expected = "I am a fish\n>as am I\nand me";
35 }
36
37 assertEquals(expected, new HtmlToTextConverter().convert("I am a fish<br />as am I<br></br>and me"));
38 }
39
40
41
42
43
44 public void testIgnoreHeader() throws IOException
45 {
46 assertEquals("I am a fish\nToo",
47 new HtmlToTextConverter().convert("<head><title>Fish</title><p>I am a fish<br>Too"));
48 }
49 }