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  
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  /* Emacs configuration
85   * Local variables:        **
86   * mode:             java  **
87   * c-basic-offset:   4     **
88   * indent-tabs-mode: nil   **
89   * End:                    **
90   */