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.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: public static TestSuite suite() throws Exception {
35: return new TestSuite(TestGetStaticTag.class);
36: }
37:
38: /**
39: * Retrieves Integer.MAX_VALUE using tag and verifies against direct
40: * access.
41: */
42:
43: public void testGetIntegerMaxValue() throws Exception {
44:
45: setUpScript("testGetStaticTag.jelly");
46:
47: Script script = getJelly().compileScript();
48:
49: getJellyContext().setVariable("test.Integer.MAX_VALUE",
50: Boolean.TRUE);
51:
52: script.run(getJellyContext(), getXMLOutput());
53:
54: assertEquals(new Integer(java.lang.Integer.MAX_VALUE),
55: getJellyContext().getVariable("value"));
56: }
57:
58: /**
59: * Retrieves a non-existent field and verifies exception is thrown.
60: */
61:
62: public void testInvalidGet() throws Exception {
63:
64: setUpScript("testGetStaticTag.jelly");
65:
66: Script script = getJelly().compileScript();
67:
68: getJellyContext().setVariable("test.InvalidGet", Boolean.TRUE);
69:
70: try {
71: script.run(getJellyContext(), getXMLOutput());
72: } catch (JellyTagException jte) {
73: return;
74: }
75:
76: fail("JellyTagException not thrown.");
77: }
78:
79: }
80:
81: /* Emacs configuration
82: * Local variables: **
83: * mode: java **
84: * c-basic-offset: 4 **
85: * indent-tabs-mode: nil **
86: * End: **
87: */
|