KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > jelly > test > BaseJellyTest


1 /*
2  * Copyright 2002,2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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 JavaDoc;
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 05:06:03 -0800 $
29  */

30 public abstract class BaseJellyTest extends TestCase {
31
32     public BaseJellyTest(String JavaDoc name) {
33         super(name);
34     }
35
36     public void setUp() throws Exception JavaDoc {
37         super.setUp();
38         jelly = new Jelly();
39         context = new JellyContext();
40         xmlOutput = XMLOutput.createDummyXMLOutput();
41     }
42
43     protected void setUpScript(String JavaDoc scriptname) throws Exception JavaDoc {
44         URL JavaDoc url = this.getClass().getResource(scriptname);
45         if(null == url) {
46             throw new Exception JavaDoc(
47                 "Could not find Jelly script: " + scriptname
48                 + " in package of class: " + getClass().getName()
49             );
50         }
51         jelly.setUrl(url);
52
53         String JavaDoc exturl = url.toExternalForm();
54         int lastSlash = exturl.lastIndexOf("/");
55         String JavaDoc extBase = exturl.substring(0,lastSlash+1);
56         URL JavaDoc baseurl = new URL JavaDoc(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 }
77
Popular Tags