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.apache.cxf.aegis.client;
19:
20: import java.lang.reflect.Method;
21:
22: import javax.xml.ws.Holder;
23:
24: import org.w3c.dom.Document;
25:
26: import org.apache.cxf.aegis.AbstractAegisTest;
27: import org.apache.cxf.aegis.util.XmlConstants;
28: import org.apache.cxf.frontend.ClientProxyFactoryBean;
29: import org.apache.cxf.frontend.ServerFactoryBean;
30: import org.apache.cxf.service.factory.ReflectionServiceFactoryBean;
31: import org.apache.cxf.service.invoker.BeanInvoker;
32: import org.junit.Before;
33: import org.junit.Ignore;
34: import org.junit.Test;
35:
36: public class HeaderTest extends AbstractAegisTest {
37: @Before
38: public void setUp() throws Exception {
39: super .setUp();
40:
41: ReflectionServiceFactoryBean factory = new ReflectionServiceFactoryBean() {
42: public boolean isHeader(Method method, int j) {
43: return true;
44: }
45:
46: protected boolean isInParam(Method method, int j) {
47: return j == 0;
48: }
49:
50: protected boolean isOutParam(Method method, int j) {
51: return j == -1 || j == 1;
52: }
53:
54: };
55:
56: factory.setInvoker(new BeanInvoker(new EchoImpl()));
57:
58: ServerFactoryBean svrFac = new ServerFactoryBean();
59: svrFac.setAddress("Echo");
60: setupAegis(svrFac);
61: svrFac.setServiceFactory(factory);
62: svrFac.setServiceClass(Echo.class);
63: svrFac.setBus(getBus());
64: svrFac.create();
65: }
66:
67: @Test
68: @Ignore
69: public void testHeaders() throws Exception {
70: ClientProxyFactoryBean proxyFac = new ClientProxyFactoryBean();
71: proxyFac.setAddress("Echo");
72: proxyFac.setServiceClass(Echo.class);
73: proxyFac.setBus(getBus());
74: setupAegis(proxyFac.getClientFactoryBean());
75:
76: Echo echo = (Echo) proxyFac.create();
77:
78: Holder<String> h = new Holder<String>();
79: assertEquals("hi", echo.echo("hi", h));
80: assertEquals("header2", h.value);
81:
82: Document wsdl = getWSDLDocument("Echo");
83:
84: addNamespace("wsdlsoap", XmlConstants.WSDL11_NS);
85: assertValid(
86: "//wsdl:input/wsdlsoap:header[@message='tns:echoRequestHeaders'][@part='in0']",
87: wsdl);
88: assertValid(
89: "//wsdl:output/wsdlsoap:header[@message='tns:echoResponseHeaders'][@part='out']",
90: wsdl);
91: assertValid(
92: "//wsdl:output/wsdlsoap:header[@message='tns:echoResponseHeaders'][@part='out0']",
93: wsdl);
94: }
95: }
|