1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly;
17
18 import junit.framework.Test;
19 import junit.framework.TestCase;
20 import junit.framework.TestSuite;
21 import junit.textui.TestRunner;
22
23 import org.apache.commons.jelly.impl.TextScript;
24
25 /***
26 * Tests the whitespace triming of scripts.
27 *
28 * @author <a href="mailto:jstrachan@apache.org">James Strachan</a>
29 * @version $Revision: 155420 $
30 */
31 public class TestTrim extends TestCase {
32
33 public static void main(String[] args) {
34 TestRunner.run(suite());
35 }
36
37 public static Test suite() {
38 return new TestSuite(TestTrim.class);
39 }
40
41 public TestTrim(String testName) {
42 super(testName);
43 }
44
45 public void testTrim() throws Exception {
46 TextScript script = new TextScript( " foo " );
47 script.trimWhitespace();
48
49 assertEquals( "foo", script.getText() );
50
51 script = new TextScript( " foo " );
52 script.trimWhitespace();
53
54 assertEquals( "foo", script.getText() );
55
56 script = new TextScript( "foo" );
57 script.trimWhitespace();
58
59 assertEquals( "foo", script.getText() );
60 }
61
62 public void testTrimStart() throws Exception {
63 TextScript script = new TextScript( " foo " );
64 script.trimStartWhitespace();
65
66 assertEquals( "foo ", script.getText() );
67
68 script = new TextScript( " foo " );
69 script.trimStartWhitespace();
70
71 assertEquals( "foo ", script.getText() );
72
73 script = new TextScript( "foo" );
74 script.trimStartWhitespace();
75
76 assertEquals( "foo", script.getText() );
77 }
78
79 public void testTrimEnd() throws Exception {
80 TextScript script = new TextScript( " foo " );
81 script.trimEndWhitespace();
82
83 assertEquals( " foo", script.getText() );
84
85 script = new TextScript( " foo " );
86 script.trimEndWhitespace();
87
88 assertEquals( " foo", script.getText() );
89
90 script = new TextScript( "foo" );
91 script.trimEndWhitespace();
92
93 assertEquals( "foo", script.getText() );
94 }
95 }