1
2
3
4
5
6
7
8
9
10
11
12
13
14
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.JellyTagException;
22
23 /***
24 * @version $Revision: 1.2 $
25 */
26
27 public class TestGetStaticTag extends BaseJellyTest {
28
29 public TestGetStaticTag(String name) {
30 super(name);
31 }
32
33
34 public static TestSuite suite() throws Exception {
35 return new TestSuite(TestGetStaticTag.class);
36 }
37
38
39 /***
40 * Retrieves Integer.MAX_VALUE using tag and verifies against direct
41 * access.
42 */
43
44 public void testGetIntegerMaxValue() throws Exception {
45
46 setUpScript( "testGetStaticTag.jelly" );
47
48 Script script = getJelly().compileScript();
49
50 getJellyContext().setVariable( "test.Integer.MAX_VALUE",
51 Boolean.TRUE );
52
53 script.run( getJellyContext(), getXMLOutput() );
54
55 assertEquals( new Integer(java.lang.Integer.MAX_VALUE),
56 getJellyContext().getVariable("value" ) );
57 }
58
59
60
61 /***
62 * Retrieves a non-existent field and verifies exception is thrown.
63 */
64
65 public void testInvalidGet() throws Exception {
66
67 setUpScript( "testGetStaticTag.jelly" );
68
69 Script script = getJelly().compileScript();
70
71 getJellyContext().setVariable( "test.InvalidGet", Boolean.TRUE );
72
73 try {
74 script.run( getJellyContext(), getXMLOutput() );
75 } catch(JellyTagException jte) {
76 return;
77 }
78
79 fail("JellyTagException not thrown.");
80 }
81
82 }
83
84
85
86
87
88
89
90