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.impl;
021:
022: import junit.framework.TestCase;
023: import org.apache.axis2.jaxws.description.ServiceDescription;
024:
025: import javax.xml.namespace.QName;
026: import javax.xml.ws.WebServiceException;
027: import java.net.URL;
028:
029: /**
030: * This test validates the error checking and internal functioning of the ServiceDescription class.
031: * These tests are the construction of a a ServiceDescription. Direct tests of the functionality of
032: * a ServiceDescription and other Description classes is done in WSDLDescriptionTests.
033: */
034: public class ServiceDescriptionImplTests extends TestCase {
035: private static final String namespaceURI = "http://org.apache.axis2.jaxws.description.ServiceDescriptionTests";
036: private static final String localPart = "EchoService";
037: private static final QName serviceQName = new QName(namespaceURI,
038: localPart);
039:
040: public void testNullWSDL() {
041:
042: QName uniqueQName = new QName(namespaceURI, localPart
043: + "_testNullWSDL");
044: ServiceDescription serviceDescription = new ServiceDescriptionImpl(
045: null, uniqueQName, javax.xml.ws.Service.class);
046: assertNotNull("Service description not created with null WSDL",
047: serviceDescription);
048: }
049:
050: public void testNullServiceName() {
051:
052: try {
053: ServiceDescription serviceDescription = new ServiceDescriptionImpl(
054: null, null, javax.xml.ws.Service.class);
055: fail("Exception for null Service Name not thrown.");
056: } catch (WebServiceException e) {
057: // Expected path
058: // TODO Message text changed
059: //assertEquals("Did not receive correct exception", "Invalid Service class. The service QName cannot be null.", e.getMessage());
060: }
061: }
062:
063: public void testInvalidServiceClass() {
064: try {
065: ServiceDescription serviceDescription = new ServiceDescriptionImpl(
066: null, serviceQName, Object.class);
067: fail("Exception for invalid Service class not thrown.");
068: } catch (WebServiceException e) {
069: // Expected path
070: // TODO Message text changed
071: //assertEquals("Did not receive correct exception", "Invalid Service Class; must be assignable to javax.xml.ws.Service", e.getMessage());
072: }
073: }
074:
075: public void testNullServiceClass() {
076: try {
077: ServiceDescription serviceDescription = new ServiceDescriptionImpl(
078: null, serviceQName, null);
079: fail("Exception for invalid Service class not thrown.");
080: } catch (WebServiceException e) {
081: // Expected path
082: // TODO Message text changed
083: //assertEquals("Did not receive correct exception", "Invalid Service Class; cannot be null", e.getMessage());
084: }
085:
086: }
087:
088: public void testValidServiceSubclass() {
089: QName uniqueQName = new QName(namespaceURI, localPart
090: + "_testValidServiceSubclass");
091: ServiceDescription serviceDescription = new ServiceDescriptionImpl(
092: null, uniqueQName, ServiceSubclass.class);
093: assertNotNull(
094: "Service description not created with valid Service subclass",
095: serviceDescription);
096: }
097: }
098:
099: class ServiceSubclass extends javax.xml.ws.Service {
100:
101: protected ServiceSubclass(URL wsdlDocumentLocation,
102: QName serviceName) {
103: super(wsdlDocumentLocation, serviceName);
104: }
105: }
|