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:
020: package org.apache.axis2.jaxws.description;
021:
022: import java.net.URL;
023:
024: import javax.xml.namespace.QName;
025: import javax.xml.ws.Service;
026: import javax.xml.ws.WebServiceException;
027:
028: import junit.framework.TestCase;
029: import org.apache.axis2.jaxws.spi.ServiceDelegate;
030:
031: /**
032: * Tests building a ServiceDescription using WSDL and the JAXWS Service API.
033: * Note that a ServiceDescription is built when a javax.xml.ws.Service is created. Since that is the actual API
034: * that should be used, this test will create Service objects and then use introspection
035: * to check the underlying ServiceDelegate which contains the ServiceDescription.
036: */
037: public class WSDLTests extends TestCase {
038:
039: public void testValidWSDLService() {
040: Service service = null;
041: ServiceDelegate serviceDelegate = null;
042:
043: String namespaceURI = "http://ws.apache.org/axis2/tests";
044: String localPart = "EchoService";
045: URL wsdlURL = DescriptionTestUtils2.getWSDLURL();
046: assertNotNull(wsdlURL);
047: service = Service.create(wsdlURL, new QName(namespaceURI,
048: localPart));
049: assertNotNull("Service not created", service);
050:
051: serviceDelegate = DescriptionTestUtils2
052: .getServiceDelegate(service);
053: assertNotNull("ServiceDelegate not created", serviceDelegate);
054:
055: ServiceDescription serviceDescription = serviceDelegate
056: .getServiceDescription();
057: assertNotNull("ServiceDescription not created",
058: serviceDescription);
059:
060: // AxisService axisService = serviceDescription.getAxisService();
061: // assertNotNull("AxisService not created", axisService);
062: }
063:
064: public void testInvalidServiceLocalName() {
065: Service service = null;
066:
067: String namespaceURI = "http://ws.apache.org/axis2/tests";
068: String localPart = "BADEchoService";
069: try {
070: URL wsdlURL = DescriptionTestUtils2.getWSDLURL();
071: assertNotNull(wsdlURL);
072: service = Service.create(wsdlURL, new QName(namespaceURI,
073: localPart));
074: fail("Exception should have been thrown for invalid Service name");
075: } catch (WebServiceException e) {
076: // This is the expected flow; it is really more a test of ServiceDelegate that ServiceDescription
077: }
078: }
079:
080: public void testNullWSDLLocation() {
081: Service service = null;
082:
083: String namespaceURI = "http://ws.apache.org/axis2/tests";
084: String localPart = "EchoService_nullWSDL";
085: service = Service.create(new QName(namespaceURI, localPart));
086: assertNotNull("Service not created", service);
087:
088: }
089:
090: public void testNullServiceName() {
091: Service service = null;
092:
093: try {
094: service = Service.create(null);
095: fail("Exception should have been thrown for null Service name");
096: } catch (WebServiceException e) {
097: // This is the expected flow; it is really more a test of ServiceDelegate that ServiceDescription
098: // but we are verifying expected behavior.
099: }
100:
101: }
102: }
|