KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > commons > attributes > test > OverrideTestCase


1 /*
2  * Copyright 2003-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.attributes.test;
17
18 import junit.framework.TestCase;
19
20 import org.apache.commons.attributes.Attributes;
21 import org.apache.commons.attributes.Inheritable;
22
23 public class OverrideTestCase extends TestCase {
24     
25     /**
26      * @@OverrideTestCase.OverrideAttribute(1)
27      */

28     public static class OverrideSuper {
29     }
30     
31     /**
32      * @@Inheritable()
33      */

34     public static class OverrideAttribute {
35         
36         private final int value;
37         
38         public OverrideAttribute (int value) {
39             this.value = value;
40         }
41         
42         public int getValue () {
43             return value;
44         }
45         
46         public int hashCode () {
47             return 1;
48         }
49         
50         public boolean equals (Object JavaDoc o) {
51             return o instanceof OverrideAttribute;
52         }
53         
54         public String JavaDoc toString () {
55             return "OverrideAttribute: " + value;
56         }
57     }
58     
59     /**
60      * @@OverrideTestCase.OverrideAttribute(2)
61      */

62     public static class OverrideDerived extends OverrideSuper {
63     }
64     
65     public void testOverride () throws Exception JavaDoc {
66         System.out.println (Attributes.getAttributes (OverrideDerived.class));
67         OverrideAttribute attr = (OverrideAttribute)
68             Attributes.getAttribute (OverrideDerived.class, OverrideAttribute.class);
69         
70         assertEquals (2, attr.getValue ());
71     }
72 }
73
74
Popular Tags