KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > avalon > framework > test > EnumTestCase


1 /*
2
3  ============================================================================
4                    The Apache Software License, Version 1.1
5  ============================================================================
6  
7  Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
8  
9  Redistribution and use in source and binary forms, with or without modifica-
10  tion, are permitted provided that the following conditions are met:
11  
12  1. Redistributions of source code must retain the above copyright notice,
13     this list of conditions and the following disclaimer.
14  
15  2. Redistributions in binary form must reproduce the above copyright notice,
16     this list of conditions and the following disclaimer in the documentation
17     and/or other materials provided with the distribution.
18  
19  3. The end-user documentation included with the redistribution, if any, must
20     include the following acknowledgment: "This product includes software
21     developed by the Apache Software Foundation (http://www.apache.org/)."
22     Alternately, this acknowledgment may appear in the software itself, if
23     and wherever such third-party acknowledgments normally appear.
24  
25  4. The names "Jakarta", "Apache Avalon", "Avalon Excalibur", "Avalon
26     Framework" and "Apache Software Foundation" must not be used to endorse
27     or promote products derived from this software without prior written
28     permission. For written permission, please contact apache@apache.org.
29  
30  5. Products derived from this software may not be called "Apache", nor may
31     "Apache" appear in their name, without prior written permission of the
32     Apache Software Foundation.
33  
34  THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
35  INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
36  FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
37  APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
38  INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
39  DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
40  OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
41  ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
42  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
43  THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
44  
45  This software consists of voluntary contributions made by many individuals
46  on behalf of the Apache Software Foundation and was originally created by
47  Stefano Mazzocchi <stefano@apache.org>. For more information on the Apache
48  Software Foundation, please see <http://www.apache.org/>.
49  
50 */

51 package org.apache.avalon.framework.test;
52
53 import junit.framework.TestCase;
54 import org.apache.avalon.framework.Enum;
55
56 /**
57  * TestCase for Enum.
58  *
59  * @author <a HREF="mailto:leo.sutic@insprieinfrastructure.com">Leo Sutic</a>
60  */

61 public class EnumTestCase
62     extends TestCase
63 {
64     private final static class Color extends Enum JavaDoc
65     {
66         public static final Color RED = new Color( "Red" );
67         public static final Color GREEN = new Color( "Green" );
68         public static final Color BLUE = new Color( "Blue" );
69         
70         private Color( final String JavaDoc color )
71         {
72             super( color );
73         }
74     }
75     
76     private final static class OtherColor extends Enum JavaDoc
77     {
78         public static final OtherColor RED = new OtherColor( "Red" );
79         public static final OtherColor GREEN = new OtherColor( "Green" );
80         public static final OtherColor BLUE = new OtherColor( "Blue" );
81         
82         private OtherColor( final String JavaDoc color )
83         {
84             super( color );
85         }
86     }
87     
88     public EnumTestCase( final String JavaDoc name )
89     {
90         super( name );
91     }
92     
93     public void testEquality ()
94     {
95         assertTrue( Color.RED.equals( Color.RED ) );
96         assertTrue( Color.GREEN.equals( Color.GREEN ) );
97         assertTrue( Color.BLUE.equals( Color.BLUE ) );
98         
99         assertTrue( !OtherColor.RED.equals( Color.RED ) );
100         assertTrue( !OtherColor.GREEN.equals( Color.GREEN ) );
101         assertTrue( !OtherColor.BLUE.equals( Color.BLUE ) );
102         
103         assertTrue( !Color.RED.equals( OtherColor.RED ) );
104         assertTrue( !Color.GREEN.equals( OtherColor.GREEN ) );
105         assertTrue( !Color.BLUE.equals( OtherColor.BLUE ) );
106         
107         assertTrue( !Color.RED.equals( Color.GREEN ) );
108         assertTrue( !Color.GREEN.equals( Color.BLUE ) );
109         assertTrue( !Color.BLUE.equals( Color.RED ) );
110     }
111 }
112
Popular Tags