KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > jelly > core > TestGetStaticTag


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 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 JavaDoc name) {
31         super(name);
32     }
33
34
35     public static TestSuite suite() throws Exception JavaDoc {
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 JavaDoc {
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 JavaDoc(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 JavaDoc {
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 /* Emacs configuration
86  * Local variables: **
87  * mode: java **
88  * c-basic-offset: 4 **
89  * indent-tabs-mode: nil **
90  * End: **
91  */

92
Popular Tags