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.core;
17:
18: import junit.framework.TestSuite;
19:
20: import org.apache.commons.jelly.Script;
21: import org.apache.commons.jelly.test.BaseJellyTest;
22:
23: public class TestBreakTag extends BaseJellyTest {
24:
25: public TestBreakTag(String name) {
26: super (name);
27: }
28:
29: public static TestSuite suite() throws Exception {
30: return new TestSuite(TestBreakTag.class);
31: }
32:
33: public void testSimpleBreakTag() throws Exception {
34: setUpScript("testBreakTag.jelly");
35: Script script = getJelly().compileScript();
36:
37: script.run(getJellyContext(), getXMLOutput());
38:
39: String simpleResult = (String) getJellyContext().getVariable(
40: "simpleResult");
41:
42: assertEquals("simpleResult", "12345", simpleResult);
43: }
44:
45: public void testConditionalBreakTag() throws Exception {
46: setUpScript("testBreakTag.jelly");
47: Script script = getJelly().compileScript();
48:
49: script.run(getJellyContext(), getXMLOutput());
50:
51: String simpleResult = (String) getJellyContext().getVariable(
52: "conditionalResult");
53:
54: assertEquals("conditionalResult", "12345", simpleResult);
55: }
56:
57: public void testVarBreakTag() throws Exception {
58: setUpScript("testBreakTag.jelly");
59: Script script = getJelly().compileScript();
60:
61: script.run(getJellyContext(), getXMLOutput());
62:
63: String varBroken = (String) getJellyContext().getVariable(
64: "varBroken");
65:
66: assertEquals("varBroken", "true", varBroken);
67: }
68:
69: public void testVarNoBreakTag() throws Exception {
70: setUpScript("testBreakTag.jelly");
71: Script script = getJelly().compileScript();
72:
73: script.run(getJellyContext(), getXMLOutput());
74:
75: String varNotBroken = (String) getJellyContext().getVariable(
76: "varNotBroken");
77:
78: assertEquals("varNotBroken", "false", varNotBroken);
79: }
80:
81: }
|