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