1 21 package nu.xom.tests; 22 23 import nu.xom.Attribute; 24 import nu.xom.Text; 25 26 35 public class AttributeTypeTest extends XOMTestCase { 36 37 public AttributeTypeTest(String name) { 38 super(name); 39 } 40 41 public void testEquals() { 42 assertEquals(Attribute.Type.CDATA, Attribute.Type.CDATA); 43 assertEquals(Attribute.Type.ID, Attribute.Type.ID); 44 assertEquals(Attribute.Type.IDREF, Attribute.Type.IDREF); 45 assertEquals(Attribute.Type.IDREFS, Attribute.Type.IDREFS); 46 assertEquals(Attribute.Type.UNDECLARED, Attribute.Type.UNDECLARED); 47 assertEquals(Attribute.Type.NMTOKEN, Attribute.Type.NMTOKEN); 48 assertEquals(Attribute.Type.NMTOKENS, Attribute.Type.NMTOKENS); 49 assertEquals(Attribute.Type.NOTATION, Attribute.Type.NOTATION); 50 assertEquals(Attribute.Type.ENTITY, Attribute.Type.ENTITY); 51 assertEquals(Attribute.Type.ENTITIES, Attribute.Type.ENTITIES); 52 assertTrue(Attribute.Type.ENTITIES != Attribute.Type.ENTITY); 53 assertTrue(Attribute.Type.CDATA != Attribute.Type.ID); 54 assertTrue(Attribute.Type.ID != Attribute.Type.IDREF); 55 assertTrue(Attribute.Type.ID != Attribute.Type.IDREFS); 56 assertTrue(Attribute.Type.ID != Attribute.Type.NMTOKEN); 57 assertTrue(Attribute.Type.ID != Attribute.Type.NMTOKENS); 58 assertTrue(Attribute.Type.UNDECLARED != Attribute.Type.CDATA); 59 assertTrue(Attribute.Type.NMTOKEN != Attribute.Type.CDATA); 60 61 assertFalse(Attribute.Type.CDATA.equals(new Integer (1))); 62 assertFalse(Attribute.Type.CDATA.equals(new Text("data"))); 63 } 64 65 public void testToString() { 66 assertNotNull(Attribute.Type.CDATA.toString()); 67 assertNotNull(Attribute.Type.ID.toString()); 68 assertNotNull(Attribute.Type.IDREF.toString()); 69 assertNotNull(Attribute.Type.IDREFS.toString()); 70 assertNotNull(Attribute.Type.UNDECLARED.toString()); 71 assertNotNull(Attribute.Type.NMTOKEN.toString()); 72 assertNotNull(Attribute.Type.NMTOKENS.toString()); 73 assertNotNull(Attribute.Type.NOTATION.toString()); 74 assertNotNull(Attribute.Type.ENTITY.toString()); 75 assertNotNull(Attribute.Type.ENTITIES.toString()); 76 77 assertTrue(Attribute.Type.CDATA.toString().length() > 10); 78 assertTrue(Attribute.Type.ID.toString().length() > 10); 79 assertTrue(Attribute.Type.IDREF.toString().length() > 10); 80 assertTrue(Attribute.Type.IDREFS.toString().length() > 10); 81 assertTrue(Attribute.Type.UNDECLARED.toString().length() > 10); 82 assertTrue(Attribute.Type.NMTOKEN.toString().length() > 10); 83 assertTrue(Attribute.Type.NMTOKENS.toString().length() > 10); 84 assertTrue(Attribute.Type.NOTATION.toString().length() > 10); 85 assertTrue(Attribute.Type.ENTITY.toString().length() > 10); 86 assertTrue(Attribute.Type.ENTITIES.toString().length() > 10); 87 88 assertTrue(Attribute.Type.CDATA.toString().startsWith("[Attribute.Type")); 89 assertTrue(Attribute.Type.ID.toString().startsWith("[Attribute.Type")); 90 assertTrue(Attribute.Type.IDREF.toString().startsWith("[Attribute.Type")); 91 assertTrue(Attribute.Type.IDREFS.toString().startsWith("[Attribute.Type")); 92 assertTrue(Attribute.Type.UNDECLARED.toString().startsWith("[Attribute.Type")); 93 assertTrue(Attribute.Type.NMTOKEN.toString().startsWith("[Attribute.Type")); 94 assertTrue(Attribute.Type.NMTOKENS.toString().startsWith("[Attribute.Type")); 95 assertTrue(Attribute.Type.NOTATION.toString().startsWith("[Attribute.Type")); 96 assertTrue(Attribute.Type.ENTITY.toString().startsWith("[Attribute.Type")); 97 assertTrue(Attribute.Type.ENTITIES.toString().startsWith("[Attribute.Type")); 98 99 assertTrue(Attribute.Type.CDATA.toString().endsWith("]")); 100 assertTrue(Attribute.Type.ID.toString().endsWith("]")); 101 assertTrue(Attribute.Type.IDREF.toString().endsWith("]")); 102 assertTrue(Attribute.Type.IDREFS.toString().endsWith("]")); 103 assertTrue(Attribute.Type.UNDECLARED.toString().endsWith("]")); 104 assertTrue(Attribute.Type.NMTOKEN.toString().endsWith("]")); 105 assertTrue(Attribute.Type.NMTOKENS.toString().endsWith("]")); 106 assertTrue(Attribute.Type.NOTATION.toString().endsWith("]")); 107 assertTrue(Attribute.Type.ENTITY.toString().endsWith("]")); 108 assertTrue(Attribute.Type.ENTITIES.toString().endsWith("]")); 109 110 } 111 112 public void testGetName() { 113 assertEquals("ENUMERATION", Attribute.Type.ENUMERATION.getName()); 114 assertEquals("NOTATION", Attribute.Type.NOTATION.getName()); 115 assertEquals("ENTITY", Attribute.Type.ENTITY.getName()); 116 assertEquals("ENTITIES", Attribute.Type.ENTITIES.getName()); 117 assertEquals("CDATA", Attribute.Type.CDATA.getName()); 118 assertEquals("ID", Attribute.Type.ID.getName()); 119 assertEquals("IDREF", Attribute.Type.IDREF.getName()); 120 assertEquals("IDREFS", Attribute.Type.IDREFS.getName()); 121 assertEquals("NMTOKEN", Attribute.Type.NMTOKEN.getName()); 122 assertEquals("NMTOKENS", Attribute.Type.NMTOKENS.getName()); 123 } 124 125 } 126 | Popular Tags |