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.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("Could not find Jelly script: "
59: + script + " in package of class: "
60: + this .getClass().getName());
61: }
62: this .jelly.setUrl(url);
63: }
64:
65: public void testDummyXMLOutput() throws Exception {
66: // without validation
67: setUp("producesOutput.jelly");
68: Script script = this .jelly.compileScript();
69: script.run(this .context, this .xmlOutput);
70: assertTrue("should have set 'foo' variable to 'bar'",
71: this .context.getVariable("foo").equals("bar"));
72:
73: }
74:
75: }
|