1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.test;
17
18 import java.net.URL;
19
20 import junit.framework.TestCase;
21
22 import org.apache.commons.jelly.Jelly;
23 import org.apache.commons.jelly.JellyContext;
24 import org.apache.commons.jelly.XMLOutput;
25
26 /***
27 * @author Rodney Waldhoff
28 * @version $Revision: 155420 $ $Date: 2005-02-26 14:06:03 +0100 (Sat, 26 Feb 2005) $
29 */
30 public abstract class BaseJellyTest extends TestCase {
31
32 public BaseJellyTest(String name) {
33 super(name);
34 }
35
36 public void setUp() throws Exception {
37 super.setUp();
38 jelly = new Jelly();
39 context = new JellyContext();
40 xmlOutput = XMLOutput.createDummyXMLOutput();
41 }
42
43 protected void setUpScript(String scriptname) throws Exception {
44 URL url = this.getClass().getResource(scriptname);
45 if(null == url) {
46 throw new Exception(
47 "Could not find Jelly script: " + scriptname
48 + " in package of class: " + getClass().getName()
49 );
50 }
51 jelly.setUrl(url);
52
53 String exturl = url.toExternalForm();
54 int lastSlash = exturl.lastIndexOf("/");
55 String extBase = exturl.substring(0,lastSlash+1);
56 URL baseurl = new URL(extBase);
57 context.setCurrentURL(baseurl);
58 }
59
60 protected Jelly getJelly() {
61 return jelly;
62 }
63
64 protected JellyContext getJellyContext() {
65 return context;
66 }
67
68 protected XMLOutput getXMLOutput() {
69 return xmlOutput;
70 }
71
72 private Jelly jelly = null;
73 private JellyContext context = null;
74 private XMLOutput xmlOutput = null;
75
76 }