1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22 package org.apache.struts2.sitegraph;
23
24 import java.io.File;
25 import java.io.InputStream;
26 import java.io.StringWriter;
27 import java.net.URL;
28
29 import org.apache.struts2.StrutsTestCase;
30 import org.apache.struts2.dispatcher.Dispatcher;
31
32 import com.opensymphony.xwork2.util.ClassLoaderUtil;
33
34 /***
35 */
36 public class SiteGraphTest extends StrutsTestCase {
37 public void testWebFlow() throws Exception {
38
39
40
41 URL url = ClassLoaderUtil.getResource("org/apache/struts2/sitegraph/struts.xml", SiteGraphTest.class);
42 File file = new File(url.toString().substring(5));
43 String dir = file.getParent();
44
45 SiteGraph siteGraph = new SiteGraph(dir, dir, dir, "");
46 StringWriter writer = new StringWriter();
47 siteGraph.setWriter(writer);
48 siteGraph.prepare();
49
50 URL compare = SiteGraphTest.class.getResource("out.txt");
51 StringBuffer buffer = new StringBuffer(128);
52 InputStream in = compare.openStream();
53 byte[] buf = new byte[4096];
54 int nbytes;
55
56 while ((nbytes = in.read(buf)) > 0) {
57 buffer.append(new String(buf, 0, nbytes));
58 }
59
60 in.close();
61 assertEquals(buffer.toString().replaceAll("\r\n", "\n"), writer.toString().replaceAll("\r\n", "\n"));
62 }
63 }