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