|
1 |
| |
|
2 |
| |
|
3 |
| |
|
4 |
| |
|
5 |
| |
|
6 |
| |
|
7 |
| |
|
8 |
| |
|
9 |
| |
|
10 |
| |
|
11 |
| |
|
12 |
| |
|
13 |
| |
|
14 |
| |
|
15 |
| |
|
16 |
| |
|
17 |
| |
|
18 |
| |
|
19 |
| |
|
20 |
| |
|
21 |
| |
|
22 |
| package nu.xom.tests; |
|
23 |
| |
|
24 |
| import nu.xom.Attribute; |
|
25 |
| import nu.xom.Element; |
|
26 |
| |
|
27 |
| |
|
28 |
| |
|
29 |
| |
|
30 |
| |
|
31 |
| |
|
32 |
| |
|
33 |
| |
|
34 |
| |
|
35 |
| |
|
36 |
| |
|
37 |
| public class AttributesTest extends XOMTestCase { |
|
38 |
| |
|
39 |
2
| public AttributesTest(String name) {
|
|
40 |
2
| super(name);
|
|
41 |
| } |
|
42 |
| |
|
43 |
| private Element threeAttributes; |
|
44 |
| private Element noAttributes; |
|
45 |
| |
|
46 |
| |
|
47 |
2
| protected void setUp() {
|
|
48 |
2
| noAttributes = new Element("test");
|
|
49 |
2
| threeAttributes = new Element("test");
|
|
50 |
2
| threeAttributes.addAttribute(new Attribute("att1", "value1"));
|
|
51 |
2
| threeAttributes.addAttribute(new Attribute("att2", "value2"));
|
|
52 |
2
| threeAttributes.addAttribute(new Attribute("att3", "value3"));
|
|
53 |
| } |
|
54 |
| |
|
55 |
1
| public void testSize() {
|
|
56 |
1
| assertEquals(0, noAttributes.getAttributeCount());
|
|
57 |
1
| assertEquals(3, threeAttributes.getAttributeCount());
|
|
58 |
| } |
|
59 |
| |
|
60 |
1
| public void testGetOutOfBounds() {
|
|
61 |
| |
|
62 |
1
| try {
|
|
63 |
1
| noAttributes.getAttribute(0);
|
|
64 |
0
| fail("Should have thrown IndexOutOfBoundsException");
|
|
65 |
| } |
|
66 |
| catch (IndexOutOfBoundsException success) { |
|
67 |
1
| assertNotNull(success.getMessage());
|
|
68 |
| } |
|
69 |
1
| try {
|
|
70 |
1
| threeAttributes.getAttribute(4);
|
|
71 |
| } |
|
72 |
| catch (IndexOutOfBoundsException success) { |
|
73 |
1
| assertNotNull(success.getMessage());
|
|
74 |
| } |
|
75 |
1
| try {
|
|
76 |
1
| threeAttributes.getAttribute(-1);
|
|
77 |
| } |
|
78 |
| catch (IndexOutOfBoundsException success) { |
|
79 |
1
| assertNotNull(success.getMessage());
|
|
80 |
| } |
|
81 |
| |
|
82 |
| } |
|
83 |
| |
|
84 |
| } |