001: /*
002: * Licensed to the Apache Software Foundation (ASF) under one
003: * or more contributor license agreements. See the NOTICE file
004: * distributed with this work for additional information
005: * regarding copyright ownership. The ASF licenses this file
006: * to you under the Apache License, Version 2.0 (the
007: * "License"); you may not use this file except in compliance
008: * with the License. You may obtain a copy of the License at
009: *
010: * http://www.apache.org/licenses/LICENSE-2.0
011: *
012: * Unless required by applicable law or agreed to in writing,
013: * software distributed under the License is distributed on an
014: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
015: * KIND, either express or implied. See the License for the
016: * specific language governing permissions and limitations
017: * under the License.
018: */
019: package org.apache.axis2.jaxws.description;
020:
021: import junit.framework.TestCase;
022: import org.apache.axis2.description.AxisOperation;
023: import org.apache.axis2.description.AxisService;
024:
025: import javax.jws.WebParam;
026: import javax.jws.WebService;
027: import javax.jws.soap.SOAPBinding;
028: import javax.xml.namespace.QName;
029: import javax.xml.ws.Holder;
030:
031: /**
032: * Validate that the information needed to resolve an incoming Doc/Lit/Bare message is setup
033: * correctly via annotations.
034: */
035: public class DocLitBareResolveOperationTests extends TestCase {
036: private ServiceDescription svcDesc;
037: private EndpointDescription endpointDesc;
038: private AxisService axisService;
039:
040: protected void setUp() {
041: if (svcDesc == null) {
042: svcDesc = DescriptionFactory
043: .createServiceDescription(DLBResolveOperation.class);
044: assertNotNull(svcDesc);
045: EndpointDescription[] epDescs = svcDesc
046: .getEndpointDescriptions();
047: assertNotNull(epDescs);
048: assertEquals(1, epDescs.length);
049: endpointDesc = epDescs[0];
050: axisService = endpointDesc.getAxisService();
051: assertNotNull(axisService);
052: }
053: }
054:
055: public void testDocLitBareSingleInParam() {
056: QName operationQName = new QName("", "op1");
057: AxisOperation axisOperationFromOpName = axisService
058: .getOperation(operationQName);
059: assertNotNull(axisOperationFromOpName);
060:
061: QName messageElementQName = new QName(
062: "org.apache.axis2.jaxws.description.DLBResolveOperation",
063: "op1param1PartName");
064: AxisOperation axisOperationFromElement = axisService
065: .getOperationByMessageElementQName(messageElementQName);
066: assertNotNull(axisOperationFromElement);
067: assertEquals(axisOperationFromOpName, axisOperationFromElement);
068:
069: QName wrongMessageElementQName = new QName(
070: "org.apache.axis2.jaxws.description.DLBResolveOperation",
071: "wrongElementName");
072: AxisOperation axisOperationFromWrongElement = axisService
073: .getOperationByMessageElementQName(wrongMessageElementQName);
074: assertNull(axisOperationFromWrongElement);
075:
076: QName wrongMessageElementNSQName = new QName("wrong.namespace",
077: "op1param1PartName");
078: AxisOperation axisOperationFromWrongElementNS = axisService
079: .getOperationByMessageElementQName(wrongMessageElementNSQName);
080: assertNull(axisOperationFromWrongElementNS);
081:
082: }
083:
084: public void testDocLitBareSingleInOutParam() {
085: QName operationQName = new QName("", "op2");
086: AxisOperation axisOperationFromOpName = axisService
087: .getOperation(operationQName);
088: assertNotNull(axisOperationFromOpName);
089:
090: QName messageElementQName = new QName(
091: "org.apache.axis2.jaxws.description.DLBResolveOperation",
092: "op2param1PartName");
093: AxisOperation axisOperationFromElement = axisService
094: .getOperationByMessageElementQName(messageElementQName);
095: assertNotNull(axisOperationFromElement);
096: assertEquals(axisOperationFromOpName, axisOperationFromElement);
097: }
098:
099: public void testDocLitBareTwoInParams() {
100: QName operationQName = new QName("", "op3");
101: AxisOperation axisOperationFromOpName = axisService
102: .getOperation(operationQName);
103: assertNotNull(axisOperationFromOpName);
104:
105: QName messageElementQName = new QName(
106: "org.apache.axis2.jaxws.description.DLBResolveOperation",
107: "op3param1PartName");
108: AxisOperation axisOperationFromElement = axisService
109: .getOperationByMessageElementQName(messageElementQName);
110: assertNotNull(axisOperationFromElement);
111: assertEquals(axisOperationFromOpName, axisOperationFromElement);
112:
113: QName wrongMessageElementQName = new QName(
114: "org.apache.axis2.jaxws.description.DLBResolveOperation",
115: "op3param2PartName");
116: AxisOperation axisOperationFromWrongElement = axisService
117: .getOperationByMessageElementQName(wrongMessageElementQName);
118: assertNull(axisOperationFromWrongElement);
119:
120: }
121:
122: public void testDocLitBareOutParamOnly() {
123: QName operationQName = new QName("", "op4");
124: AxisOperation axisOperationFromOpName = axisService
125: .getOperation(operationQName);
126: assertNotNull(axisOperationFromOpName);
127:
128: QName messageElementQName = new QName(
129: "org.apache.axis2.jaxws.description.DLBResolveOperation",
130: "op4param1PartName");
131: AxisOperation axisOperationFromElement = axisService
132: .getOperationByMessageElementQName(messageElementQName);
133: assertNull(axisOperationFromElement);
134:
135: }
136:
137: public void testDocLitBareOutParamFirst() {
138: QName operationQName = new QName("", "op5");
139: AxisOperation axisOperationFromOpName = axisService
140: .getOperation(operationQName);
141: assertNotNull(axisOperationFromOpName);
142:
143: QName messageElementQName = new QName(
144: "org.apache.axis2.jaxws.description.DLBResolveOperation",
145: "op5param2PartName");
146: AxisOperation axisOperationFromElement = axisService
147: .getOperationByMessageElementQName(messageElementQName);
148: assertNotNull(axisOperationFromElement);
149: assertEquals(axisOperationFromOpName, axisOperationFromElement);
150:
151: QName wrongMessageElementQName = new QName(
152: "org.apache.axis2.jaxws.description.DLBResolveOperation",
153: "op5param1PartName");
154: AxisOperation axisOperationFromWrongElement = axisService
155: .getOperationByMessageElementQName(wrongMessageElementQName);
156: assertNull(axisOperationFromWrongElement);
157:
158: }
159:
160: public void testDocLitBareDefaultPartAnno() {
161: QName operationQName = new QName("", "op6");
162: AxisOperation axisOperationFromOpName = axisService
163: .getOperation(operationQName);
164: assertNotNull(axisOperationFromOpName);
165:
166: QName messageElementQName = new QName(
167: "http://description.jaxws.axis2.apache.org/", "op6");
168: AxisOperation axisOperationFromElement = axisService
169: .getOperationByMessageElementQName(messageElementQName);
170: assertNotNull(axisOperationFromElement);
171: assertEquals(axisOperationFromOpName, axisOperationFromElement);
172:
173: }
174:
175: public void testDocLitBareNoParams() {
176: QName operationQName = new QName("", "op7");
177: AxisOperation axisOperationFromOpName = axisService
178: .getOperation(operationQName);
179: assertNotNull(axisOperationFromOpName);
180:
181: QName messageElementQName = new QName(
182: "http://description.jaxws.axis2.apache.org/", "op7");
183: AxisOperation axisOperationFromElement = axisService
184: .getOperationByMessageElementQName(messageElementQName);
185: assertNull(axisOperationFromElement);
186:
187: }
188:
189: public void testDocLitBareHeaderParamFirst() {
190: QName operationQName = new QName("", "op8");
191: AxisOperation axisOperationFromOpName = axisService
192: .getOperation(operationQName);
193: assertNotNull(axisOperationFromOpName);
194:
195: QName messageElementQName = new QName(
196: "org.apache.axis2.jaxws.description.DLBResolveOperation",
197: "op8param2PartName");
198: AxisOperation axisOperationFromElement = axisService
199: .getOperationByMessageElementQName(messageElementQName);
200: assertNotNull(axisOperationFromElement);
201: assertEquals(axisOperationFromOpName, axisOperationFromElement);
202:
203: QName wrongMessageElementQName = new QName(
204: "org.apache.axis2.jaxws.description.DLBResolveOperation",
205: "op8param1PartName");
206: AxisOperation axisOperationFromWrongElement = axisService
207: .getOperationByMessageElementQName(wrongMessageElementQName);
208: assertNull(axisOperationFromWrongElement);
209: }
210:
211: public void testDocLitWrapped() {
212: QName operationQName = new QName("", "op10");
213: AxisOperation axisOperationFromOpName = axisService
214: .getOperation(operationQName);
215: assertNotNull(axisOperationFromOpName);
216:
217: QName messageElementQName = new QName(
218: "org.apache.axis2.jaxws.description.DLBResolveOperation",
219: "op10param1PartName");
220: AxisOperation axisOperationFromElement = axisService
221: .getOperationByMessageElementQName(messageElementQName);
222: assertNull(axisOperationFromElement);
223: }
224: }
225:
226: @WebService
227: class DLBResolveOperation {
228:
229: @SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,parameterStyle=SOAPBinding.ParameterStyle.BARE)
230: public void op1(
231: @WebParam(targetNamespace="org.apache.axis2.jaxws.description.DLBResolveOperation",name="op1param1PartName")
232: int param1) {
233: }
234:
235: @SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,parameterStyle=SOAPBinding.ParameterStyle.BARE)
236: public void op2(
237: @WebParam(targetNamespace="org.apache.axis2.jaxws.description.DLBResolveOperation",name="op2param1PartName",mode=WebParam.Mode.INOUT)
238: Holder<Integer> param1) {
239: }
240:
241: @SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,parameterStyle=SOAPBinding.ParameterStyle.BARE)
242: public void op3(
243: @WebParam(targetNamespace="org.apache.axis2.jaxws.description.DLBResolveOperation",name="op3param1PartName",mode=WebParam.Mode.INOUT)
244: Holder<Integer> param1,
245: @WebParam(targetNamespace="org.apache.axis2.jaxws.description.DLBResolveOperation",name="op3param2PartName",mode=WebParam.Mode.IN)
246: int param2) {
247: }
248:
249: @SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,parameterStyle=SOAPBinding.ParameterStyle.BARE)
250: public void op4(
251: @WebParam(targetNamespace="org.apache.axis2.jaxws.description.DLBResolveOperation",name="op4param1PartName",mode=WebParam.Mode.OUT)
252: Holder<Integer> param1) {
253: }
254:
255: @SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,parameterStyle=SOAPBinding.ParameterStyle.BARE)
256: public void op5(
257: @WebParam(targetNamespace="org.apache.axis2.jaxws.description.DLBResolveOperation",name="op5param1PartName",mode=WebParam.Mode.OUT)
258: Holder<Integer> param1,
259: @WebParam(targetNamespace="org.apache.axis2.jaxws.description.DLBResolveOperation",name="op5param2PartName",mode=WebParam.Mode.IN)
260: int param2) {
261: }
262:
263: @SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,parameterStyle=SOAPBinding.ParameterStyle.BARE)
264: public void op6(@WebParam
265: int param1) {
266: }
267:
268: @SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,parameterStyle=SOAPBinding.ParameterStyle.BARE)
269: public void op7() {
270: }
271:
272: @SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,parameterStyle=SOAPBinding.ParameterStyle.BARE)
273: public void op8(
274: @WebParam(targetNamespace="org.apache.axis2.jaxws.description.DLBResolveOperation",name="op8param1PartName",mode=WebParam.Mode.IN,header=true)
275: Integer param1,
276: @WebParam(targetNamespace="org.apache.axis2.jaxws.description.DLBResolveOperation",name="op8param2PartName",mode=WebParam.Mode.IN)
277: int param2) {
278: }
279:
280: @SOAPBinding(style=SOAPBinding.Style.DOCUMENT,use=SOAPBinding.Use.LITERAL,parameterStyle=SOAPBinding.ParameterStyle.WRAPPED)
281: public void op10(
282: @WebParam(targetNamespace="org.apache.axis2.jaxws.description.DLBResolveOperation",name="op10param1PartName")
283: int param1) {
284: }
285:
286: }
|