1
/* Copyright 2003 Elliotte Rusty Harold
3
This library is free software; you can redistribute it and/or modify
4
it under the terms of version 2.1 of the GNU Lesser General Public
5
License as published by the Free Software Foundation.
7
This library is distributed in the hope that it will be useful,
8
but WITHOUT ANY WARRANTY; without even the implied warranty of
9
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
GNU Lesser General Public License for more details.
12
You should have received a copy of the GNU Lesser General Public
13
License along with this library; if not, write to the
14
Free Software Foundation, Inc., 59 Temple Place, Suite 330,
15
Boston, MA 02111-1307 USA
17
You can contact Elliotte Rusty Harold by sending e-mail to
18
elharo@metalab.unc.edu. Please include the word "XOM" in the
19
subject line. The XOM home page is located at http://www.xom.nu/
23
import nu.xom.Attribute;
28
* Tests for the <code>Attribute.Type</code> inner class.
31
* @author Elliotte Rusty Harold
35
public class AttributeTypeTest extends XOMTestCase {
37
public AttributeTypeTest(String name) {
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);
61
assertFalse(Attribute.Type.CDATA.equals(new Integer(1)));
62
assertFalse(Attribute.Type.CDATA.equals(new Text("data")));
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());
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);
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"));
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("]"));
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());