KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > velocity > test > MiscTestCase


1 package org.apache.velocity.test;
2
3 /*
4  * Copyright 2002,2004 The Apache Software Foundation.
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
19 import junit.framework.TestCase;
20 import junit.framework.Test;
21
22 import org.apache.velocity.util.StringUtils;
23
24 /**
25  * Test case for any miscellaneous stuff. If it isn't big, and doesn't fit
26  * anywhere else, it goes here
27  *
28  * @author <a HREF="mailto:geirm@apache.org">Geir Magnusson Jr.</a>
29  * @version $Id: MiscTestCase.java,v 1.1.8.1 2004/03/03 23:23:04 geirm Exp $
30  */

31 public class MiscTestCase extends BaseTestCase
32 {
33     public MiscTestCase()
34     {
35         super("MiscTestCase");
36     }
37
38     public MiscTestCase (String JavaDoc name)
39     {
40         super(name);
41     }
42
43     public static Test suite ()
44     {
45         return new MiscTestCase();
46     }
47
48     public void runTest()
49     {
50         /*
51          * some StringUtils tests
52          */

53
54         String JavaDoc eol = "XY";
55
56         String JavaDoc arg = "XY";
57         String JavaDoc res = StringUtils.chop(arg, 1, eol );
58         assertTrue( "Test 1", res.equals("") );
59
60         arg = "X";
61         res = StringUtils.chop( arg, 1, eol );
62         assertTrue( "Test 2", res.equals("") );
63
64         arg = "ZXY";
65         res = StringUtils.chop( arg, 1, eol );
66         assertTrue( "Test 3", res.equals("Z") );
67
68
69         arg = "Hello!";
70         res = StringUtils.chop( arg, 2, eol );
71         assertTrue( "Test 4", res.equals("Hell"));
72
73     }
74
75 }
76
Popular Tags