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