KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > net > sf > uitags > util > VelocityAdapterTest


1 /**
2  * Mar 28, 2005
3  *
4  * Copyright 2004 uitags
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package net.sf.uitags.util;
19
20 import junit.framework.TestCase;
21 import net.sf.uitags.util.UiString;
22 import net.sf.uitags.util.VelocityAdapter;
23
24 /**
25  * Tests {@link net.sf.uitags.util.VelocityAdapter}.
26  * The fact that this class compiles indicates
27  * that the class under test and the utility classes it uses
28  * are publicly accessible, which is <i>really important</i> in order
29  * to allow <i>Velocity</i> template to use the classes.
30  *
31  * @author hgani
32  * @version $Id$
33  */

34 public class VelocityAdapterTest extends TestCase {
35   /**
36    * Instance of the class under test.
37    */

38   private VelocityAdapter velocityAdapter;
39
40   /**
41    * Main method for the tests.
42    *
43    * @param args main arguments
44    */

45   public static void main(String JavaDoc[] args) {
46     junit.textui.TestRunner.run(VelocityAdapterTest.class);
47   }
48
49   /** {@inheritDoc} */
50   protected void setUp() throws Exception JavaDoc {
51     super.setUp();
52     this.velocityAdapter = new VelocityAdapter();
53   }
54
55   /** {@inheritDoc} */
56   protected void tearDown() throws Exception JavaDoc {
57     super.tearDown();
58     this.velocityAdapter = null;
59   }
60
61   /**
62    * Ensures that {@link VelocityAdapter#createUiString(String)}
63    * returns appropriate instance.
64    */

65   public void testCreateUiString() {
66     UiString str = this.velocityAdapter.createUiString("");
67     assertNotSame(this.velocityAdapter.createUiString(""), str);
68   }
69
70   /**
71    * Ensures that {@link VelocityAdapter#getArrayLength(Object[])}
72    * returns correct array length.
73    */

74   public void testGetArrayLength() {
75     String JavaDoc[] testArray = new String JavaDoc[] { "a", "b", "c", "d"};
76     assertEquals(
77         testArray.length, this.velocityAdapter.getArrayLength(testArray));
78   }
79 }
80
Popular Tags