1 11 package org.jivesoftware.util; 12 13 import junit.framework.TestCase; 14 15 20 public class IntEnumTest extends TestCase { 21 22 27 public IntEnumTest (String name){ 28 super(name); 29 } 30 31 static public class TestIntEnum extends IntEnum{ 32 public TestIntEnum(String name, int value){ 33 super(name,value); 34 register(this); 35 } 36 public static TestIntEnum getTypeFromInt(int value){ 37 return (TestIntEnum) getEnumFromInt(TestIntEnum.class,value); 38 } 39 } 40 43 public void testStaticEnumUniqueEnforcement(){ 44 IntEnum e = new IntEnum("plain",1); 45 IntEnum.register(e); 46 new TestIntEnum("test",1); assertEquals("plain",IntEnum.getEnumFromInt(IntEnum.class,1).getName()); 48 assertEquals("test",TestIntEnum.getTypeFromInt(1).getName()); 49 } 50 } | Popular Tags |