You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by ba...@apache.org on 2006/11/28 18:25:16 UTC

svn commit: r480131 - in /webservices/axis2/trunk/java/modules/jaxws: ./ src/org/apache/axis2/jaxws/description/ src/org/apache/axis2/jaxws/description/impl/ src/org/apache/axis2/jaxws/spi/ test-resources/wsdl/ test/org/apache/axis2/jaxws/description/ ...

Author: barrettj
Date: Tue Nov 28 09:25:08 2006
New Revision: 480131

URL: http://svn.apache.org/viewvc?view=rev&rev=480131
Log:
Add support for Service.getPorts(); previously always returned null.  Also added associated tests.

Added:
    webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/WSDLMultiTests.wsdl
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImplTests.java
      - copied, changed from r479618, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionTests.java
Removed:
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionTests.java
Modified:
    webservices/axis2/trunk/java/modules/jaxws/maven.xml
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescription.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescriptionWSDL.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
    webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
    webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java

Modified: webservices/axis2/trunk/java/modules/jaxws/maven.xml
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/maven.xml?view=diff&rev=480131&r1=480130&r2=480131
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/maven.xml (original)
+++ webservices/axis2/trunk/java/modules/jaxws/maven.xml Tue Nov 28 09:25:08 2006
@@ -157,6 +157,14 @@
     	    <classpath location="${compiled.classes.dir}"/>
     	    <arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/AnyType.wsdl"/>
     	 </java>
+
+    	<ant:echo>Generating java from WSDLMultiTests.wsdl</ant:echo>
+    	<java classname="com.sun.tools.xjc.Driver" fork="true"> 
+    	    <jvmarg line="${maven.junit.jvmargs}"/>
+    	    <classpath refid="maven.dependency.classpath"/>
+    	    <classpath location="${compiled.classes.dir}"/>
+    	    <arg line="-d ${schema.generated.src.dir} -quiet -wsdl ${wsdl.source.dir}/WSDLMultiTests.wsdl"/>
+    	 </java>
     	 	
     	<!-- Compile the generated classes -->
     	<ant:echo>Compiling generated schema</ant:echo>

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescription.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescription.java?view=diff&rev=480131&r1=480130&r2=480131
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescription.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescription.java Tue Nov 28 09:25:08 2006
@@ -1,5 +1,7 @@
 package org.apache.axis2.jaxws.description;
 
+import java.util.List;
+
 import javax.xml.namespace.QName;
 
 import org.apache.axis2.client.ServiceClient;
@@ -63,6 +65,13 @@
 
     public abstract QName getServiceQName();
     
-
+    /**
+     * Returns a list of the ports for this serivce.  The ports returned are the
+     * - Ports declared ports for this Service.  They can be delcared in the WSDL
+     *   or via annotations.
+     * - Dynamic ports added to the service
+     * @return
+     */
+    public List<QName> getPorts();
 
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescriptionWSDL.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescriptionWSDL.java?view=diff&rev=480131&r1=480130&r2=480131
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescriptionWSDL.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/ServiceDescriptionWSDL.java Tue Nov 28 09:25:08 2006
@@ -1,8 +1,10 @@
 package org.apache.axis2.jaxws.description;
 
 import java.net.URL;
+import java.util.Map;
 
 import javax.wsdl.Definition;
+import javax.wsdl.Service;
 
 import org.apache.axis2.jaxws.util.WSDLWrapper;
 
@@ -11,6 +13,9 @@
     public abstract WSDLWrapper getWSDLWrapper();
     public abstract WSDLWrapper getGeneratedWsdlWrapper();
 
+    public Service getWSDLService();
+    public Map getWSDLPorts();
+    
     public abstract URL getWSDLLocation();
     
     public Definition getWSDLDefinition();

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java?view=diff&rev=480131&r1=480130&r2=480131
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImpl.java Tue Nov 28 09:25:08 2006
@@ -22,6 +22,8 @@
 import java.util.HashMap;
 import java.util.Hashtable;
 import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
 
 import javax.wsdl.Definition;
 import javax.wsdl.Port;
@@ -97,6 +99,9 @@
             throw ExceptionFactory.makeWebServiceException(Messages.getMessage("serviceDescErr1", serviceClass.getName()));
         }
         
+        // TODO: On the client side, we should not support partial WSDL; i.e. if the WSDL is specified it must be
+        //       complete and must contain the ServiceQName.  This is how the Sun RI behaves on the client.
+        //       When this is fixed, the check in ServiceDelegate(URL, QName, Class) should be removed
         this.wsdlURL = wsdlURL;
         // TODO: The serviceQName needs to be verified between the argument/WSDL/Annotation
         this.serviceQName = serviceQName;
@@ -804,5 +809,56 @@
             defn = getWSDLWrapper().getDefinition();
         }
         return defn;
+    }
+    
+    public Service getWSDLService() {
+        Service returnWSDLService = null;
+        Definition defn = getWSDLDefinition();
+        if (defn != null) {
+            returnWSDLService = defn.getService(getServiceQName());
+        }
+        return returnWSDLService;
+    }
+    
+    public Map getWSDLPorts() {
+        Service wsdlService = getWSDLService();
+        if (wsdlService != null) {
+            return wsdlService.getPorts();
+        }
+        else {
+            return null;
+        }
+    }
+
+    public List<QName> getPorts() {
+        ArrayList<QName> portList = new ArrayList<QName>();
+        // Note that we don't cache these results because the list of ports can be added
+        // to via getPort(...) and addPort(...).
+
+        // If the WSDL is specified, get the list of ports under this service
+        Map wsdlPortsMap = getWSDLPorts();
+        if (wsdlPortsMap != null) {
+            Iterator wsdlPortsIterator = wsdlPortsMap.values().iterator();
+            // Note that the WSDL Ports do not have a target namespace associated with them.
+            // JAXWS says to use the TNS from the Service.
+            String serviceTNS = getServiceQName().getNamespaceURI();
+            for (Port wsdlPort = null; wsdlPortsIterator.hasNext(); ) {
+                wsdlPort = (Port) wsdlPortsIterator.next();
+                String wsdlPortLocalPart = wsdlPort.getName();
+                portList.add(new QName(serviceTNS, wsdlPortLocalPart));
+            }
+        }
+
+        // Go through the list of Endpoints that have been created and add any
+        // not already in the list.  This will include ports added to the Service
+        // via getPort(...) and addPort(...)
+        EndpointDescription[] endpointDescArray = getEndpointDescriptions();
+        for (EndpointDescription endpointDesc : endpointDescArray) {
+            QName endpointPortQName = endpointDesc.getPortQName();
+            if (!portList.contains(endpointPortQName)) {
+                portList.add(endpointPortQName);
+            }
+        }
+        return portList;
     }
 }

Modified: webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java?view=diff&rev=480131&r1=480130&r2=480131
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/src/org/apache/axis2/jaxws/spi/ServiceDelegate.java Tue Nov 28 09:25:08 2006
@@ -74,6 +74,8 @@
     		throw ExceptionFactory.makeWebServiceException(Messages.getMessage("serviceDelegateConstruct0", ""));
     	}
         serviceDescription = DescriptionFactory.createServiceDescription(url, serviceQname, clazz);
+        // TODO: This check should be done when the Service Description is created above; that should throw this exception.
+        // That is because we (following the behavior of the RI) require the WSDL be fully specified (not partial) on the client
         if (isValidWSDLLocation()) {
             if(!isServiceDefined(serviceQname)){
             	throw ExceptionFactory.makeWebServiceException(Messages.getMessage("serviceDelegateConstruct0", serviceQname.toString(), url.toString()));
@@ -240,7 +242,7 @@
      * @see javax.xml.ws.spi.ServiceDelegate#getPorts()
      */
     public Iterator<QName> getPorts() {
-        return null;
+        return getServiceDescription().getPorts().iterator();
     }
     
     /*

Added: webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/WSDLMultiTests.wsdl
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/WSDLMultiTests.wsdl?view=auto&rev=480131
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/WSDLMultiTests.wsdl (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test-resources/wsdl/WSDLMultiTests.wsdl Tue Nov 28 09:25:08 2006
@@ -0,0 +1,136 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+
+<definitions name="AddNumbers" targetNamespace="http://org/test/wsdlmultitests"
+	xmlns:tns="http://org/test/wsdlmultitests" xmlns="http://schemas.xmlsoap.org/wsdl/"
+	xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+	xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/">
+
+
+	<types>
+		<xsd:schema xmlns="http://www.w3.org/2001/XMLSchema"
+			elementFormDefault="qualified" targetNamespace="http://org/test/wsdlmultitests">
+			<element name="addNumbersResponse">
+				<complexType>
+					<sequence>
+						<element name="return" type="xsd:int" />
+					</sequence>
+				</complexType>
+			</element>
+
+			<element name="addNumbers">
+				<complexType>
+					<sequence>
+						<element name="arg0" type="xsd:int" />
+						<element name="arg1" type="xsd:int" />
+					</sequence>
+				</complexType>
+			</element>
+
+			<element name="AddNumbersFault">
+				<complexType>
+					<sequence>
+						<element name="faultInfo" type="xsd:string" />
+						<element name="message" type="xsd:string" />
+					</sequence>
+				</complexType>
+			</element>
+
+			<element name="oneWayInt">
+				<complexType>
+					<sequence>
+						<element name="arg0" type="xsd:int" />
+					</sequence>
+				</complexType>
+			</element>
+
+		</xsd:schema>
+	</types>
+
+	<message name="addNumbers">
+		<part name="parameters" element="tns:addNumbers" />
+	</message>
+	<message name="addNumbersResponse">
+		<part name="result" element="tns:addNumbersResponse" />
+	</message>
+	<message name="addNumbersFault">
+		<part name="AddNumbersFault" element="tns:AddNumbersFault" />
+	</message>
+	<message name="oneWayInt">
+		<part name="parameters" element="tns:oneWayInt" />
+	</message>
+
+	<portType name="AddNumbersPortType">
+		<operation name="addNumbers">
+			<input message="tns:addNumbers" name="add" />
+			<output message="tns:addNumbersResponse" name="addResponse" />
+			<fault name="addNumbersFault" message="tns:addNumbersFault" />
+		</operation>
+		<operation name="oneWayInt">
+			<input message="tns:oneWayInt" />
+		</operation>
+	</portType>
+	<binding name="AddNumbersBinding" type="tns:AddNumbersPortType">
+		<soap:binding transport="http://schemas.xmlsoap.org/soap/http"
+			style="document" />
+		<operation name="addNumbers">
+			<soap:operation soapAction="" />
+			<input>
+				<soap:body use="literal" />
+			</input>
+			<output>
+				<soap:body use="literal" />
+			</output>
+			<fault name="addNumbersFault">
+				<soap:fault name="addNumbersFault" use="literal" />
+			</fault>
+		</operation>
+		<operation name="oneWayInt">
+			<soap:operation soapAction="" />
+			<input>
+				<soap:body use="literal" />
+			</input>
+		</operation>
+	</binding>
+	
+	<!--
+		IMPORTANT NOTE: These ports are not intended to be connected too!  This test is simply for
+		WSDL processing and Service.addPort(...) and Service.getPort(...) validation; no attempt is
+		made to actually connect to the endpoints defined below; there is no implementation and no
+		valid endpoint at those addresses.	
+	-->
+	
+	<service name="AddNumbersService1">
+		<port name="AddNumbersPortS1P1" binding="tns:AddNumbersBinding">
+			<soap:address
+				location="http://localhost:9080/AddNumber/AddNumbersImplServiceS1P1" />
+		</port>
+		<port name="AddNumbersPortS1P2" binding="tns:AddNumbersBinding">
+			<soap:address
+				location="http://localhost:9080/AddNumber/AddNumbersImplServiceS1P2" />
+		</port>
+		<port name="AddNumbersPortS1P3" binding="tns:AddNumbersBinding">
+			<soap:address
+				location="http://localhost:9080/AddNumber/AddNumbersImplServiceS1P3" />
+		</port>
+	</service>
+	<service name="AddNumbersService2">
+		<port name="AddNumbersPortS2P1" binding="tns:AddNumbersBinding">
+			<soap:address
+				location="http://localhost:9080/AddNumber/AddNumbersImplServiceS2P1" />
+		</port>
+		<port name="AddNumbersPortS2P2" binding="tns:AddNumbersBinding">
+			<soap:address
+				location="http://localhost:9080/AddNumber/AddNumbersImplServiceS2P2" />
+		</port>
+		<port name="AddNumbersPortS2P3" binding="tns:AddNumbersBinding">
+			<soap:address
+				location="http://localhost:9080/AddNumber/AddNumbersImplServiceS2P3" />
+		</port>
+				<port name="AddNumbersPortS2P4" binding="tns:AddNumbersBinding">
+			<soap:address
+				location="http://localhost:9080/AddNumber/AddNumbersImplServiceS2P4" />
+		</port>
+		
+	</service>
+</definitions>

Added: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java?view=auto&rev=480131
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java (added)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/ServiceTests.java Tue Nov 28 09:25:08 2006
@@ -0,0 +1,257 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.axis2.jaxws.description;
+
+import java.net.URL;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+import javax.xml.ws.Service;
+import javax.xml.ws.WebServiceException;
+import org.apache.axis2.jaxws.spi.ServiceDelegate;
+
+import org.apache.axis2.jaxws.sample.addnumbers.AddNumbersPortType;
+
+import junit.framework.TestCase;
+
+public class ServiceTests extends TestCase {
+    private static String VALID_SERVICE_NAMESPACE = "http://org/test/wsdlmultitests";
+    private static String VALID_SERVICE_LOCALPART_1 = "AddNumbersService1";
+    private static String VALID_SERVICE_LOCALPART_2 = "AddNumbersService2";
+    private static String VALID_PORT_S1P1 = "AddNumbersPortS1P1";
+    private static String VALID_PORT_S1P2 = "AddNumbersPortS1P2";
+    private static String VALID_PORT_S1P3 = "AddNumbersPortS1P3";
+    private static String VALID_PORT_S2P1 = "AddNumbersPortS2P1";
+    private static String VALID_PORT_S2P2 = "AddNumbersPortS2P2";
+    private static String VALID_PORT_S2P3 = "AddNumbersPortS2P3";
+    private static String VALID_PORT_S2P4 = "AddNumbersPortS2P4";
+
+    public void testInvalidServiceNamespace() {
+        URL wsdlURL = DescriptionTestUtils.getWSDLURL("WSDLMultiTests.wsdl");
+        QName invalidServiceQN = new QName("invalidServiceNamespace", VALID_SERVICE_LOCALPART_1);
+        try {
+            Service invalidService = Service.create(wsdlURL, invalidServiceQN);
+            fail("Created service with invalid namespace");
+        }
+        catch (WebServiceException ex) {
+            // Expected code path
+        }
+        catch (Exception ex) {
+            fail("Caught unexpected exception " + ex.toString());
+        }
+    }
+    public void testInvalidServiceLocalPart() {
+        URL wsdlURL = DescriptionTestUtils.getWSDLURL("WSDLMultiTests.wsdl");
+        QName invalidServiceQN = new QName(VALID_SERVICE_NAMESPACE, "invalidServiceName");
+        try {
+            Service invalidService = Service.create(wsdlURL, invalidServiceQN);
+            fail("Created service with invalid namespace");
+        }
+        catch (WebServiceException ex) {
+            // Expected code path
+        }
+        catch (Exception ex) {
+            fail("Caught unexpected exception " + ex.toString());
+        }
+    }
+    
+    public void testValidSameService() {
+        URL wsdlURL = DescriptionTestUtils.getWSDLURL("WSDLMultiTests.wsdl");
+        
+        QName validService1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+        Service validService1 = Service.create(wsdlURL, validService1QN);
+        assertNotNull(validService1);
+
+        QName validService2QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+        Service validService2 = Service.create(wsdlURL, validService2QN);
+        assertNotNull(validService2);
+        
+    }
+
+    public void testValidMultiServices() {
+        URL wsdlURL = DescriptionTestUtils.getWSDLURL("WSDLMultiTests.wsdl");
+        
+        QName validService1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+        Service validService1 = Service.create(wsdlURL, validService1QN);
+        assertNotNull(validService1);
+
+        QName validService2QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_2);
+        Service validService2 = Service.create(wsdlURL, validService2QN);
+        assertNotNull(validService2);
+        assertNotSame(validService1, validService2);
+        
+    }
+    
+    public void testGetServiceDeclaredPorts() {
+        URL wsdlURL = DescriptionTestUtils.getWSDLURL("WSDLMultiTests.wsdl");
+
+        QName service1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+        Service service1 = Service.create(wsdlURL, service1QN);
+        assertNotNull(service1);
+        ServiceDelegate service1Delegate = DescriptionTestUtils.getServiceDelegate(service1);
+        assertNotNull (service1Delegate);
+        ServiceDescription service1Desc = service1Delegate.getServiceDescription();
+        assertNotNull(service1Desc);
+        List<QName> service1PortsList = service1Desc.getPorts();
+        assertNotNull(service1PortsList);
+        assertEquals(3, service1PortsList.size());
+        Iterator<QName> service1PortIterator = service1.getPorts();
+        assertQNameIteratorSameAsList(service1PortIterator, service1PortsList);
+
+        QName service2QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_2);
+        Service service2 = Service.create(wsdlURL, service2QN);
+        assertNotNull(service2);
+        ServiceDelegate service2Delegate = DescriptionTestUtils.getServiceDelegate(service2);
+        assertNotNull (service2Delegate);
+        ServiceDescription service2Desc = service2Delegate.getServiceDescription();
+        assertNotNull(service2Desc);
+        List<QName> service2PortsList = service2Desc.getPorts();
+        assertNotNull(service2PortsList);
+        assertEquals(4, service2PortsList.size());
+        Iterator<QName> service2PortIterator = service2.getPorts();
+        assertQNameIteratorSameAsList(service2PortIterator, service2PortsList);
+    }
+
+    public void testGetServiceAddedPorts() {
+        URL wsdlURL = DescriptionTestUtils.getWSDLURL("WSDLMultiTests.wsdl");
+
+        QName service1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+        Service service1 = Service.create(wsdlURL, service1QN);
+        assertNotNull(service1);
+        ServiceDelegate service1Delegate = DescriptionTestUtils.getServiceDelegate(service1);
+        assertNotNull (service1Delegate);
+        ServiceDescription service1Desc = service1Delegate.getServiceDescription();
+        assertNotNull(service1Desc);
+        List<QName> service1PortsList = service1Desc.getPorts();
+        assertNotNull(service1PortsList);
+        assertEquals(3, service1PortsList.size());
+        service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P1"), null, null);
+        service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P2"), null, null);
+        service1PortsList = service1Desc.getPorts();
+        assertEquals(5, service1PortsList.size());
+        Iterator<QName> service1PortIterator = service1.getPorts();
+        assertQNameIteratorSameAsList(service1PortIterator, service1PortsList);
+
+        QName service2QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_2);
+        Service service2 = Service.create(wsdlURL, service2QN);
+        assertNotNull(service2);
+        ServiceDelegate service2Delegate = DescriptionTestUtils.getServiceDelegate(service2);
+        assertNotNull (service2Delegate);
+        ServiceDescription service2Desc = service2Delegate.getServiceDescription();
+        assertNotNull(service2Desc);
+        List<QName> service2PortsList = service2Desc.getPorts();
+        assertNotNull(service2PortsList);
+        assertEquals(4, service2PortsList.size());
+        service2.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS2P1"), null, null);
+        service2.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS2P2"), null, null);
+        service2PortsList = service2Desc.getPorts();
+        assertEquals(6, service2PortsList.size());
+        Iterator<QName> service2PortIterator = service2.getPorts();
+        assertQNameIteratorSameAsList(service2PortIterator, service2PortsList);
+    }
+    
+    public void testGetServiceDeclaredPortsAfterGetPort() {
+        URL wsdlURL = DescriptionTestUtils.getWSDLURL("WSDLMultiTests.wsdl");
+
+        QName service1QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_1);
+        Service service1 = Service.create(wsdlURL, service1QN);
+        assertNotNull(service1);
+        ServiceDelegate service1Delegate = DescriptionTestUtils.getServiceDelegate(service1);
+        assertNotNull (service1Delegate);
+        ServiceDescription service1Desc = service1Delegate.getServiceDescription();
+        assertNotNull(service1Desc);
+        List<QName> service1PortsList = service1Desc.getPorts();
+        assertNotNull(service1PortsList);
+        assertEquals(3, service1PortsList.size());
+        AddNumbersPortType addNumbersPortS1P1 = service1.getPort(new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S1P1), AddNumbersPortType.class); 
+        service1PortsList = service1Desc.getPorts();
+        assertEquals(3, service1PortsList.size());
+        AddNumbersPortType addNumbersPortS1P3 = service1.getPort(new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S1P3), AddNumbersPortType.class); 
+        assertEquals(3, service1PortsList.size());
+        service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P1"), null, null);
+        service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P2"), null, null);
+        service1PortsList = service1Desc.getPorts();
+        assertEquals(5, service1PortsList.size());
+        Iterator<QName> service1PortIterator = service1.getPorts();
+        assertQNameIteratorSameAsList(service1PortIterator, service1PortsList);
+        
+        QName service2QN = new QName(VALID_SERVICE_NAMESPACE, VALID_SERVICE_LOCALPART_2);
+        Service service2 = Service.create(wsdlURL, service2QN);
+        assertNotNull(service2);
+        ServiceDelegate service2Delegate = DescriptionTestUtils.getServiceDelegate(service2);
+        assertNotNull (service2Delegate);
+        ServiceDescription service2Desc = service2Delegate.getServiceDescription();
+        assertNotNull(service2Desc);
+        List<QName> service2PortsList = service2Desc.getPorts();
+        assertNotNull(service2PortsList);
+        assertEquals(4, service2PortsList.size());
+        AddNumbersPortType addNumbersPortS2P1 = service2.getPort(new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S2P1), AddNumbersPortType.class); 
+        service2PortsList = service2Desc.getPorts();
+        assertEquals(4, service2PortsList.size());
+        AddNumbersPortType addNumbersPortS2P3 = service2.getPort(new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S2P3), AddNumbersPortType.class); 
+        assertEquals(4, service2PortsList.size());
+        AddNumbersPortType addNumbersPortS2P4 = service2.getPort(new QName(VALID_SERVICE_NAMESPACE, VALID_PORT_S2P4), AddNumbersPortType.class); 
+        assertEquals(4, service2PortsList.size());
+        service2.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS2P1"), null, null);
+        service2.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS2P2"), null, null);
+        service2PortsList = service2Desc.getPorts();
+        assertEquals(6, service2PortsList.size());
+        Iterator<QName> service2PortIterator = service2.getPorts();
+        assertQNameIteratorSameAsList(service2PortIterator, service2PortsList);
+    }
+    
+    public void testDynamicService() {
+        QName service1QN = new QName(VALID_SERVICE_NAMESPACE, "DynamicService1");
+        Service service1 = Service.create(null, service1QN);
+        assertNotNull(service1);
+        ServiceDelegate service1Delegate = DescriptionTestUtils.getServiceDelegate(service1);
+        assertNotNull (service1Delegate);
+        ServiceDescription service1Desc = service1Delegate.getServiceDescription();
+        assertNotNull(service1Desc);
+        List<QName> service1PortsList = service1Desc.getPorts();
+        assertNotNull(service1PortsList);
+        assertTrue(service1PortsList.isEmpty());
+        assertEquals(0, service1PortsList.size());
+        AddNumbersPortType addNumbersPortS1P1 = service1.getPort(new QName(VALID_SERVICE_NAMESPACE, "dynamicPortS1P1"), AddNumbersPortType.class); 
+        service1PortsList = service1Desc.getPorts();
+        assertEquals(1, service1PortsList.size());
+        AddNumbersPortType addNumbersPortS1P3 = service1.getPort(new QName(VALID_SERVICE_NAMESPACE, "dynamicPortS1P2"), AddNumbersPortType.class); 
+        service1PortsList = service1Desc.getPorts();
+        assertEquals(2, service1PortsList.size());
+        service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P1"), null, null);
+        service1.addPort(new QName(VALID_SERVICE_NAMESPACE, "addedPortS1P2"), null, null);
+        service1PortsList = service1Desc.getPorts();
+        assertEquals(4, service1PortsList.size());
+        Iterator<QName> service1PortIterator = service1.getPorts();
+        assertQNameIteratorSameAsList(service1PortIterator, service1PortsList);
+    }
+    
+    private void assertQNameIteratorSameAsList(Iterator<QName> iterator, List<QName> list) {
+        int iteratorSize = 0;
+        for (QName iteratorElement = null; iterator.hasNext(); ) { 
+            iteratorElement = iterator.next();
+            iteratorSize++;
+            assertTrue(list.contains(iteratorElement));
+        }
+        assertEquals(list.size(), iteratorSize);
+    }
+}

Copied: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImplTests.java (from r479618, webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionTests.java)
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImplTests.java?view=diff&rev=480131&p1=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionTests.java&r1=479618&p2=webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImplTests.java&r2=480131
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionTests.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/description/impl/ServiceDescriptionImplTests.java Tue Nov 28 09:25:08 2006
@@ -1,21 +1,24 @@
 /*
- * Copyright 2004,2005 The Apache Software Foundation.
- * Copyright 2006 International Business Machines Corp.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * 
  *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
+ *      
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
  */
 
 
+
 package org.apache.axis2.jaxws.description.impl;
 
 import java.net.URL;
@@ -34,7 +37,7 @@
  * a ServiceDescription.  Direct tests of the functionality of a ServiceDescription
  * and other Description classes is done in WSDLDescriptionTests.
  */
-public class ServiceDescriptionTests extends TestCase {
+public class ServiceDescriptionImplTests extends TestCase {
     private static final String namespaceURI= "http://org.apache.axis2.jaxws.description.ServiceDescriptionTests";
     private static final String localPart = "EchoService";
     private static final QName serviceQName = new QName(namespaceURI, localPart);

Modified: webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java?view=diff&rev=480131&r1=480130&r2=480131
==============================================================================
--- webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java (original)
+++ webservices/axis2/trunk/java/modules/jaxws/test/org/apache/axis2/jaxws/framework/JAXWSTest.java Tue Nov 28 09:25:08 2006
@@ -29,13 +29,14 @@
 import org.apache.axis2.jaxws.description.AnnotationServiceImplWithDBCTests;
 import org.apache.axis2.jaxws.description.GetDescFromBindingProvider;
 import org.apache.axis2.jaxws.description.PartialWSDLTests;
+import org.apache.axis2.jaxws.description.ServiceTests;
 import org.apache.axis2.jaxws.description.ServiceAnnotationTests;
 import org.apache.axis2.jaxws.description.ValidateWSDLTests;
 import org.apache.axis2.jaxws.description.WSDLDescriptionTests;
 import org.apache.axis2.jaxws.description.WSDLTests;
 import org.apache.axis2.jaxws.description.WrapperPackageTests;
 import org.apache.axis2.jaxws.description.builder.DescriptionBuilderTests;
-import org.apache.axis2.jaxws.description.impl.ServiceDescriptionTests;
+import org.apache.axis2.jaxws.description.impl.ServiceDescriptionImplTests;
 import org.apache.axis2.jaxws.dispatch.SOAP12Dispatch;
 import org.apache.axis2.jaxws.dispatch.DispatchTestSuite;
 import org.apache.axis2.jaxws.exception.ExceptionFactoryTests;
@@ -100,7 +101,7 @@
         suite.addTestSuite(ServiceAnnotationTests.class);
         suite.addTestSuite(WSDLTests.class);
         suite.addTestSuite(DescriptionBuilderTests.class);
-        suite.addTestSuite(ServiceDescriptionTests.class);
+        suite.addTestSuite(ServiceDescriptionImplTests.class);
         suite.addTestSuite(WSDLDescriptionTests.class);
         suite.addTestSuite(AnnotationDescriptionTests.class);
         suite.addTestSuite(AnnotationServiceImplDescriptionTests.class);
@@ -110,6 +111,7 @@
         suite.addTestSuite(ValidateWSDLTests.class);
         suite.addTestSuite(GetDescFromBindingProvider.class);
         suite.addTestSuite(WrapperPackageTests.class);
+        suite.addTestSuite(ServiceTests.class);
         
         suite.addTestSuite(HandlerChainProcessorTests.class);
         suite.addTestSuite(JaxwsMessageBundleTests.class);



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org