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 org.apache.axis2.description.AxisOperation;
022: import org.apache.axis2.description.Parameter;
023:
024: import javax.jws.WebParam;
025: import javax.jws.WebService;
026: import javax.xml.namespace.QName;
027: import javax.xml.ws.Holder;
028:
029: import java.util.ArrayList;
030:
031: import junit.framework.TestCase;
032:
033: /**
034: *
035: */
036: public class MustUnderstandTests extends TestCase {
037:
038: public void testHeaderParameters() {
039: // Test IN and INOUT header paramaters in SEI
040: ServiceDescription svcDesc = DescriptionFactory
041: .createServiceDescription(HeaderParameters.class);
042: assertNotNull(svcDesc);
043: EndpointDescription epDescs[] = svcDesc
044: .getEndpointDescriptions();
045: assertNotNull(epDescs);
046: assertEquals(1, epDescs.length);
047: EndpointInterfaceDescription epiDesc = epDescs[0]
048: .getEndpointInterfaceDescription();
049: assertNotNull(epiDesc);
050:
051: OperationDescription opDescs[] = epiDesc.getOperations();
052: assertNotNull(opDescs);
053: assertEquals(1, opDescs.length);
054: OperationDescription opDesc = opDescs[0];
055: assertEquals("echoString", opDesc.getOperationName());
056:
057: AxisOperation axisOperation = opDesc.getAxisOperation();
058: assertNotNull(axisOperation);
059: Parameter understoodQNamesParameter = axisOperation
060: .getParameter(OperationDescription.HEADER_PARAMETER_QNAMES);
061: assertNotNull(understoodQNamesParameter);
062: ArrayList understoodQNames = (ArrayList) understoodQNamesParameter
063: .getValue();
064: assertEquals(4, understoodQNames.size());
065:
066: assertTrue(understoodQNames.contains(new QName(
067: "webservice.namespace", "renamedParam1")));
068: assertTrue(understoodQNames.contains(new QName(
069: "webservice.namespace", "arg1")));
070: assertTrue(understoodQNames.contains(new QName(
071: "webparam.namespace", "arg2")));
072: assertFalse(understoodQNames.contains(new QName(
073: "webservice.namespace", "outOnly")));
074: assertFalse(understoodQNames.contains(new QName(
075: "webservice.namespace", "arg3")));
076: assertTrue(understoodQNames.contains(new QName(
077: "webservice.namespace", "inOut")));
078: assertFalse(understoodQNames.contains(new QName(
079: "webservice.namespace", "arg4")));
080: assertFalse(understoodQNames.contains(new QName(
081: "webservice.namespace", "notInHeader")));
082: assertFalse(understoodQNames.contains(new QName(
083: "webservice.namespace", "arg5")));
084:
085: }
086: }
087:
088: @WebService(targetNamespace="webservice.namespace")
089: class HeaderParameters {
090: public String echoString(
091: @WebParam(name="renamedParam1",header=true)
092: String param1,
093: @WebParam(header=true)
094: String param2,
095: @WebParam(targetNamespace="webparam.namespace",header=true)
096: String param3,
097: @WebParam(mode=WebParam.Mode.OUT,header=true)
098: Holder<String> outOnly,
099: @WebParam(name="inOut",mode=WebParam.Mode.INOUT,header=true)
100: Holder<String> inOut, String notInHeader) {
101: return null;
102: }
103: }
|