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;
19:
20: import java.util.ArrayList;
21: import java.util.HashMap;
22: import java.util.List;
23: import java.util.Map;
24:
25: import javax.xml.namespace.QName;
26:
27: import org.apache.cxf.aegis.AbstractAegisTest;
28: import org.apache.cxf.aegis.databinding.AegisDatabinding;
29: import org.apache.cxf.aegis.services.SimpleBean;
30: import org.apache.cxf.endpoint.Server;
31: import org.apache.cxf.feature.LoggingFeature;
32: import org.apache.cxf.frontend.ClientProxyFactoryBean;
33: import org.apache.cxf.frontend.ServerFactoryBean;
34: import org.apache.cxf.service.invoker.BeanInvoker;
35: import org.codehaus.xfire.aegis.inheritance.ws1.WS1;
36: import org.codehaus.xfire.aegis.inheritance.ws1.WS1ExtendedException;
37: import org.codehaus.xfire.aegis.inheritance.ws1.impl.WS1Impl;
38: import org.junit.Test;
39:
40: public class ExceptionInheritanceTest extends AbstractAegisTest {
41: private WS1 client;
42: private Map<String, Object> props;
43:
44: public void setUp() throws Exception {
45: super .setUp();
46:
47: props = new HashMap<String, Object>();
48: props.put(AegisDatabinding.WRITE_XSI_TYPE_KEY, "true");
49:
50: List<String> l = new ArrayList<String>();
51: l.add(SimpleBean.class.getName());
52: l.add(WS1ExtendedException.class.getName());
53:
54: props.put(AegisDatabinding.OVERRIDE_TYPES_KEY, l);
55:
56: ClientProxyFactoryBean pf = new ClientProxyFactoryBean();
57: setupAegis(pf.getClientFactoryBean());
58: pf.setServiceClass(WS1.class);
59: pf.getServiceFactory().setProperties(props);
60: pf.setAddress("local://WS1");
61: pf.setProperties(props);
62:
63: client = (WS1) pf.create();
64:
65: Server server = createService(WS1.class, "WS1", null);
66: new LoggingFeature().initialize(server, null);
67: server.getEndpoint().getService().setInvoker(
68: new BeanInvoker(new WS1Impl()));
69: }
70:
71: @Override
72: protected ServerFactoryBean createServiceFactory(
73: Class serviceClass, String address, QName name) {
74: ServerFactoryBean sf = super .createServiceFactory(serviceClass,
75: address, name);
76: sf.getServiceFactory().setProperties(props);
77: return sf;
78: }
79:
80: @Test
81: public void testClient() throws Exception {
82: try {
83: client.throwException(true);
84: fail("No exception was thrown!");
85: } catch (WS1ExtendedException ex) {
86: Object sb = ex.getSimpleBean();
87: assertTrue(sb instanceof SimpleBean);
88: }
89: }
90:
91: }
|