1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.apache.ws.scout.registry.infomodel;
18
19 import java.util.ArrayList;
20 import java.util.Collection;
21 import java.util.HashSet;
22
23 import javax.xml.registry.JAXRException;
24 import javax.xml.registry.infomodel.Slot;
25
26 import junit.framework.TestCase;
27
28
29
30
31 public class SlotTest extends TestCase {
32 private Slot slot;
33
34 public void testEmptySlot() throws JAXRException {
35 slot = new SlotImpl();
36 assertNull(slot.getName());
37 assertNull(slot.getSlotType());
38 assertNotNull(slot.getValues());
39 assertTrue(slot.getValues().isEmpty());
40 }
41
42 public void testName() throws JAXRException {
43 slot.setName("Test Name");
44 assertEquals("Test Name", slot.getName());
45 }
46
47 public void testType() throws JAXRException {
48 slot.setSlotType("Test Type");
49 assertEquals("Test Type", slot.getSlotType());
50 }
51
52 public void testValues() throws JAXRException {
53
54 Collection<String> values = new ArrayList<String>();
55 values.add("Value 1");
56 values.add("Value 2");
57 values.add("Value 2");
58 slot.setValues(values);
59
60 values = new HashSet<String>();
61 values.add("Value 1");
62 values.add("Value 2");
63 assertEquals(values, slot.getValues());
64 }
65
66 public void testNullValues() throws JAXRException {
67 try {
68 slot.setValues(null);
69 fail("Expected IllegalArgumentException");
70 } catch (IllegalArgumentException e) {
71
72 }
73 }
74
75 public void testEquals() throws JAXRException {
76 Slot slot1 = new SlotImpl();
77 Slot slot2 = new SlotImpl();
78 assertTrue(slot1.equals(slot2));
79 slot1.setName("test");
80 assertFalse(slot1.equals(slot2));
81 slot2.setName("test");
82 assertTrue(slot1.equals(slot2));
83 slot1.setName(null);
84 assertFalse(slot1.equals(slot2));
85 }
86
87 protected void setUp() throws Exception {
88 super.setUp();
89 slot = new SlotImpl();
90 }
91 }