1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.apache.commons.jelly.test.xml;
17
18 import java.net.URL;
19
20 import junit.framework.TestCase;
21 import junit.framework.TestSuite;
22
23 import org.apache.commons.jelly.Jelly;
24 import org.apache.commons.jelly.JellyContext;
25 import org.apache.commons.jelly.Script;
26 import org.apache.commons.jelly.XMLOutput;
27
28 /***
29 * Confirm that <i>XMLOutput.createDummyXMLOutput()</i>
30 * doesn't do anything funky.
31 *
32 * @author Morgan Delagrange
33 * @version $Revision: 155420 $
34 */
35 public class TestDummyXMLOutput extends TestCase {
36
37 Jelly jelly = null;
38 JellyContext context = null;
39 XMLOutput xmlOutput = null;
40
41 public TestDummyXMLOutput(String name) {
42 super(name);
43 }
44
45 public static TestSuite suite() throws Exception {
46 return new TestSuite(TestDummyXMLOutput.class);
47 }
48
49 public void setUp(String scriptName) throws Exception {
50 this.context = new JellyContext();
51 this.xmlOutput = XMLOutput.createDummyXMLOutput();
52
53 this.jelly = new Jelly();
54
55 String script = scriptName;
56 URL url = this.getClass().getResource(script);
57 if ( url == null ) {
58 throw new Exception(
59 "Could not find Jelly script: " + script
60 + " in package of class: " + this.getClass().getName()
61 );
62 }
63 this.jelly.setUrl(url);
64 }
65
66 public void testDummyXMLOutput() throws Exception {
67
68 setUp("producesOutput.jelly");
69 Script script = this.jelly.compileScript();
70 script.run(this.context,this.xmlOutput);
71 assertTrue("should have set 'foo' variable to 'bar'",
72 this.context.getVariable("foo").equals("bar"));
73
74 }
75
76 }