01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
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: * @author <a href='http://jakarta.apache.org/commons'>Jakarta Commons Team</a>, <a href='http://www.apache.org'>Apache Software Foundation</a>
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
36: .introspect(ICopyableDateRange.class);
37: ElementDescriptor[] childDescriptors = beanInfo
38: .getElementDescriptor().getElementDescriptors();
39:
40: assertEquals("Date range child elements", 2,
41: childDescriptors.length);
42: int code = 0;
43: for (int i = 0; i < 2; i++) {
44: String name = childDescriptors[i].getPropertyName();
45: if ("startDate".equals(name)) {
46: code += 1;
47: }
48: if ("endDate".equals(name)) {
49: code += 2;
50: }
51: }
52: assertEquals("Expected date range elements", 3, code);
53: }
54:
55: public void testSuperInterfaceIntrospectionWithDotBetwixt()
56: throws Exception {
57:
58: XMLIntrospector introspector = new XMLIntrospector();
59:
60: XMLBeanInfo beanInfo = introspector
61: .introspect(ILaughingCount.class);
62: ElementDescriptor[] childDescriptors = beanInfo
63: .getElementDescriptor().getElementDescriptors();
64:
65: assertEquals("Laughing count child elements", 1,
66: childDescriptors.length);
67: assertEquals("Laughing count super interface matched", "count",
68: childDescriptors[0].getPropertyName());
69: assertEquals("Laughing count super interface matched",
70: Integer.TYPE, childDescriptors[0].getPropertyType());
71: assertNotNull("Laughing count updater matched",
72: childDescriptors[0].getUpdater());
73: }
74:
75: }
|