1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.betwixt.introspection;
19
20 import junit.framework.TestCase;
21
22 import org.apache.commons.betwixt.ElementDescriptor;
23 import org.apache.commons.betwixt.XMLBeanInfo;
24 import org.apache.commons.betwixt.XMLIntrospector;
25
26
27
28
29 public class TestInterfaceIntrospection extends TestCase {
30
31 public void testSuperInterfaceIntrospection() throws Exception {
32
33 XMLIntrospector introspector = new XMLIntrospector();
34
35 XMLBeanInfo beanInfo = introspector.introspect(ICopyableDateRange.class);
36 ElementDescriptor[] childDescriptors = beanInfo.getElementDescriptor().getElementDescriptors();
37
38 assertEquals("Date range child elements", 2, childDescriptors.length);
39 int code = 0;
40 for (int i=0; i<2; i++)
41 {
42 String name = childDescriptors[i].getPropertyName();
43 if ("startDate".equals(name))
44 {
45 code += 1;
46 }
47 if ("endDate".equals(name))
48 {
49 code += 2;
50 }
51 }
52 assertEquals("Expected date range elements", 3, code);
53 }
54
55
56 public void testSuperInterfaceIntrospectionWithDotBetwixt() throws Exception {
57
58 XMLIntrospector introspector = new XMLIntrospector();
59
60 XMLBeanInfo beanInfo = introspector.introspect(ILaughingCount.class);
61 ElementDescriptor[] childDescriptors = beanInfo.getElementDescriptor().getElementDescriptors();
62
63 assertEquals("Laughing count child elements", 1, childDescriptors.length);
64 assertEquals("Laughing count super interface matched", "count", childDescriptors[0].getPropertyName());
65 assertEquals("Laughing count super interface matched", Integer.TYPE, childDescriptors[0].getPropertyType());
66 assertNotNull("Laughing count updater matched", childDescriptors[0].getUpdater());
67 }
68
69 }