1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.commons.betwixt.dotbetwixt;
19
20 import junit.framework.Test;
21 import junit.framework.TestSuite;
22
23 import org.apache.commons.betwixt.ElementDescriptor;
24 import org.apache.commons.betwixt.XMLBeanInfo;
25 import org.apache.commons.betwixt.XMLIntrospector;
26 import org.apache.commons.betwixt.xmlunit.XmlTestCase;
27
28
29
30
31
32
33 public class TestIntrospection extends XmlTestCase {
34
35
36
37 public static Test suite() {
38 return new TestSuite(TestIntrospection.class);
39 }
40
41
42
43 public TestIntrospection(String testName) {
44 super(testName);
45 }
46
47
48
49 public void testClassAttribute() throws Exception {
50
51
52
53
54 XMLIntrospector introspector = new XMLIntrospector();
55 XMLBeanInfo beanInfo = introspector.introspect(ExampleBean.class);
56 ElementDescriptor[] elementDescriptors = beanInfo.getElementDescriptor().getElementDescriptors();
57 ElementDescriptor elementsElementDescriptor = null;
58 for ( int i=0, size = elementDescriptors.length; i<size ; i++ ) {
59 if ( "example".equals( elementDescriptors[i].getLocalName() ) ) {
60 elementsElementDescriptor = elementDescriptors[i];
61 }
62 }
63
64 assertNotNull("Element descriptor for elements not found", elementsElementDescriptor);
65 assertEquals(
66 "Class property not set",
67 ExampleImpl.class,
68 elementsElementDescriptor.getImplementationClass());
69 }
70 }
71