01: /*
02: * Copyright 2002,2004 The Apache Software Foundation.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
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-27 00:06:03 +1100 (Sun, 27 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("Could not find Jelly script: "
47: + scriptname + " in package of class: "
48: + getClass().getName());
49: }
50: jelly.setUrl(url);
51:
52: String exturl = url.toExternalForm();
53: int lastSlash = exturl.lastIndexOf("/");
54: String extBase = exturl.substring(0, lastSlash + 1);
55: URL baseurl = new URL(extBase);
56: context.setCurrentURL(baseurl);
57: }
58:
59: protected Jelly getJelly() {
60: return jelly;
61: }
62:
63: protected JellyContext getJellyContext() {
64: return context;
65: }
66:
67: protected XMLOutput getXMLOutput() {
68: return xmlOutput;
69: }
70:
71: private Jelly jelly = null;
72: private JellyContext context = null;
73: private XMLOutput xmlOutput = null;
74:
75: }
|