01: /**
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */package org.codehaus.xfire.aegis.inheritance.intf;
19:
20: import org.w3c.dom.Document;
21:
22: import org.apache.cxf.aegis.AbstractAegisTest;
23: import org.apache.cxf.endpoint.Server;
24: import org.apache.cxf.frontend.ClientProxyFactoryBean;
25: import org.apache.cxf.service.Service;
26: import org.apache.cxf.service.invoker.BeanInvoker;
27: import org.junit.Before;
28: import org.junit.Test;
29:
30: /**
31: * This test ensures that we're handling inheritance of itnerfaces correctly.
32: * Since we can't do multiple parent inheritance in XML schema, which interfaces
33: * require, we just don't allow interface inheritance period.
34: *
35: * @author Dan Diephouse
36: */
37: public class InterfaceInheritanceTest extends AbstractAegisTest {
38:
39: @Before
40: public void setUp() throws Exception {
41: super .setUp();
42: Server server = createService(IInterfaceService.class, null);
43: Service service = server.getEndpoint().getService();
44: service.setInvoker(new BeanInvoker(new InterfaceService()));
45: }
46:
47: @Test
48: public void testClient() throws Exception {
49: ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
50: proxyFac.setAddress("local://IInterfaceService");
51: proxyFac.setServiceClass(IInterfaceService.class);
52: proxyFac.setBus(getBus());
53: setupAegis(proxyFac.getClientFactoryBean());
54:
55: IInterfaceService client = (IInterfaceService) proxyFac
56: .create();
57:
58: IChild child = client.getChild();
59: assertNotNull(child);
60: assertEquals("child", child.getChildName());
61: assertEquals("parent", child.getParentName());
62:
63: IParent parent = client.getChildViaParent();
64: assertEquals("parent", parent.getParentName());
65: assertFalse(parent instanceof IChild);
66:
67: IGrandChild grandChild = client.getGrandChild();
68: assertEquals("parent", grandChild.getParentName());
69:
70: Document wsdl = getWSDLDocument("IInterfaceService");
71: assertValid("//xsd:complexType[@name='IGrandChild']", wsdl);
72: assertValid(
73: "//xsd:complexType[@name='IGrandChild']//xsd:element[@name='grandChildName']",
74: wsdl);
75: assertValid(
76: "//xsd:complexType[@name='IGrandChild']//xsd:element[@name='childName'][1]",
77: wsdl);
78: assertInvalid(
79: "//xsd:complexType[@name='IGrandChild']//xsd:element[@name='childName'][2]",
80: wsdl);
81: assertValid("//xsd:complexType[@name='IChild']", wsdl);
82: assertValid("//xsd:complexType[@name='IParent']", wsdl);
83: assertInvalid(
84: "//xsd:complexType[@name='IChild'][@abstract='true']",
85: wsdl);
86: }
87: }
|