1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.jetspeed.util.rewriter;
17
18 import junit.framework.Test;
19 import junit.framework.TestSuite;
20 import java.io.Reader;
21 import java.io.StringReader;
22 import java.io.FileReader;
23 import java.io.BufferedReader;
24
25
26 import org.apache.jetspeed.test.JetspeedTestCase;
27
28 public class TestFrameRewriter extends JetspeedTestCase
29 {
30 static public Test suite()
31 {
32 TestSuite suite = new TestSuite(TestFrameRewriter.class);
33 return(suite);
34 }
35
36 public TestFrameRewriter(String name)
37 {
38 super(name);
39 }
40
41
42
43 private String HTML = "";
44
45 protected void setUp()
46 {
47 StringBuffer buffer = new StringBuffer("");
48 try
49 {
50 FileReader fr = new FileReader("test/testdata/html/frameTest.html");
51 BufferedReader br = new BufferedReader(fr);
52 buffer = new StringBuffer();
53 String currentLine = br.readLine();
54 buffer.append( currentLine );
55 while (currentLine != null)
56 {
57 currentLine = br.readLine();
58 if ( currentLine == null )
59 continue;
60 buffer.append( currentLine );
61 }
62 br.close();
63 } catch (Exception e)
64 {
65 System.err.println("Exception reading test data:" + e);
66 }
67 HTML = buffer.toString();
68 }
69
70 protected void tearDown()
71 {
72 }
73
74
75
76
77 public void testFrames()
78 {
79 Reader reader = null;
80
81 try
82 {
83
84 reader = new StringReader(HTML);
85 HTMLRewriter rewriter = new HTMLRewriter();
86 String result = rewriter.rewrite(reader, null);
87 System.out.println(result);
88 reader.close();
89 reader = null;
90
91 } catch (Exception e)
92 {
93 System.err.println("Exception occurred:" + e.toString());
94 e.printStackTrace();
95 }
96 finally
97 {
98 try
99 {
100 if (null != reader)
101 reader.close();
102 }
103 catch (Exception e)
104 {}
105 }
106 }
107
108
109
110 static public void main(String[] argv)
111 {
112 String[] testCaseName = {TestFrameRewriter.class.getName()};
113 junit.swingui.TestRunner.main(testCaseName);
114 }
115
116 }