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