01: package com.opensymphony.webwork.sitegraph;
02:
03: import com.opensymphony.util.FileUtils;
04: import com.opensymphony.util.ClassLoaderUtil;
05: import com.opensymphony.webwork.WebWorkTestCase;
06:
07: import java.io.File;
08: import java.io.StringWriter;
09: import java.io.InputStream;
10: import java.net.URL;
11:
12: /**
13: * User: plightbo
14: * Date: Jun 25, 2005
15: * Time: 4:18:28 PM
16: */
17: public class SiteGraphTest extends WebWorkTestCase {
18: public void testWebFlow() throws Exception {
19:
20: // TODO: remove me
21: if (true)
22: return;
23:
24: // use the classloader rather than relying on the
25: // working directory being an assumed value when
26: // running the test: so let's get this class's parent dir
27: URL url = ClassLoaderUtil.getResource(
28: "com/opensymphony/webwork/sitegraph/xwork.xml",
29: SiteGraphTest.class);
30:
31: File file = new File(url.toString().substring(5));
32: String dir = file.getParent();
33:
34: SiteGraph siteGraph = new SiteGraph(dir, dir, dir, "");
35: StringWriter writer = new StringWriter();
36: siteGraph.setWriter(writer);
37: siteGraph.prepare();
38:
39: URL compare = SiteGraphTest.class.getResource("out.txt");
40: StringBuffer buffer = new StringBuffer(128);
41: InputStream in = compare.openStream();
42: byte[] buf = new byte[4096];
43: int nbytes;
44:
45: while ((nbytes = in.read(buf)) > 0) {
46: buffer.append(new String(buf, 0, nbytes));
47: }
48:
49: in.close();
50: assertEquals(buffer.toString().replaceAll("\r\n", "\n"), writer
51: .toString().replaceAll("\r\n", "\n"));
52: }
53: }
|