| 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 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
public abstract class BaseJellyTest extends TestCase { |
| 31 |
|
|
| 32 |
|
public BaseJellyTest(String name) { |
| 33 |
910 |
super(name); |
| 34 |
910 |
} |
| 35 |
|
|
| 36 |
|
public void setUp() throws Exception { |
| 37 |
910 |
super.setUp(); |
| 38 |
910 |
jelly = new Jelly(); |
| 39 |
845 |
context = new JellyContext(); |
| 40 |
845 |
xmlOutput = XMLOutput.createDummyXMLOutput(); |
| 41 |
845 |
} |
| 42 |
|
|
| 43 |
|
protected void setUpScript(String scriptname) throws Exception { |
| 44 |
624 |
URL url = this.getClass().getResource(scriptname); |
| 45 |
624 |
if(null == url) { |
| 46 |
0 |
throw new Exception( |
| 47 |
|
"Could not find Jelly script: " + scriptname |
| 48 |
|
+ " in package of class: " + getClass().getName() |
| 49 |
|
); |
| 50 |
|
} |
| 51 |
624 |
jelly.setUrl(url); |
| 52 |
|
|
| 53 |
624 |
String exturl = url.toExternalForm(); |
| 54 |
624 |
int lastSlash = exturl.lastIndexOf("/"); |
| 55 |
624 |
String extBase = exturl.substring(0,lastSlash+1); |
| 56 |
624 |
URL baseurl = new URL(extBase); |
| 57 |
624 |
context.setCurrentURL(baseurl); |
| 58 |
624 |
} |
| 59 |
|
|
| 60 |
|
protected Jelly getJelly() { |
| 61 |
624 |
return jelly; |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
protected JellyContext getJellyContext() { |
| 65 |
2665 |
return context; |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
protected XMLOutput getXMLOutput() { |
| 69 |
988 |
return xmlOutput; |
| 70 |
|
} |
| 71 |
|
|
| 72 |
910 |
private Jelly jelly = null; |
| 73 |
910 |
private JellyContext context = null; |
| 74 |
910 |
private XMLOutput xmlOutput = null; |
| 75 |
|
|
| 76 |
|
} |