1 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 28 public static class OverrideSuper { 29 } 30 31 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 o) { 51 return o instanceof OverrideAttribute; 52 } 53 54 public String toString () { 55 return "OverrideAttribute: " + value; 56 } 57 } 58 59 62 public static class OverrideDerived extends OverrideSuper { 63 } 64 65 public void testOverride () throws Exception { 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 |