From 3ac402feab3a717044a2b07060490cc89b5c9759 Mon Sep 17 00:00:00 2001 From: nash Date: Sun, 13 Sep 2009 18:06:29 +0000 Subject: Fix TUSCANY-3269 (use host from ?wsdl request in returned WSDL) git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@814373 13f79535-47bb-0310-9956-ffa450edef68 --- .../itests/QuestionMarkWSDLImportTestCase.java | 4 +- .../itests/QuestionMarkWSDLIncludeTestCase.java | 94 +++++++++++++++++++++ .../QuestionMarkWSDLIncludeTestCaseFIXME.java | 98 ---------------------- .../ws/axis2/itests/QuestionMarkWSDLTestCase.java | 7 +- .../itests/soap12/QuestionMarkWSDLTestCase.java | 10 +-- 5 files changed, 100 insertions(+), 113 deletions(-) create mode 100644 branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java delete mode 100644 branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCaseFIXME.java (limited to 'branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org') diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java index b276d8210f..186d2ad746 100644 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLImportTestCase.java @@ -35,7 +35,6 @@ import javax.xml.namespace.QName; import junit.framework.TestCase; -import org.apache.axis2.transport.http.server.HttpUtils; import org.apache.tuscany.sca.host.embedded.SCADomain; /** @@ -69,8 +68,7 @@ public class QuestionMarkWSDLImportTestCase extends TestCase { Port port = service.getPort("AccountSoapPort"); String endpoint = getEndpoint(port); - String ip = HttpUtils.getIpAddress(); - assertEquals("http://" + ip + ":8086/AccountService", endpoint); + assertEquals("http://localhost:8086/AccountService", endpoint); } private String getEndpoint(Port port) { diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java new file mode 100644 index 0000000000..c0133a712e --- /dev/null +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCase.java @@ -0,0 +1,94 @@ +/* + * 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.tuscany.sca.binding.ws.axis2.itests; + +import java.io.BufferedReader; +import java.io.InputStream; +import java.io.InputStreamReader; +import java.net.URL; +import java.util.List; + +import javax.wsdl.Definition; +import javax.wsdl.Port; +import javax.wsdl.Service; +import javax.wsdl.extensions.soap.SOAPAddress; +import javax.wsdl.factory.WSDLFactory; +import javax.wsdl.xml.WSDLReader; +import javax.xml.namespace.QName; + +import junit.framework.TestCase; + +import org.apache.tuscany.sca.host.embedded.SCADomain; + +/** + * Test ?wsdl works and that the returned WSDL has the correct endpoint + * + * @version $Rev: 660340 $ $Date: 2008-05-27 01:08:32 +0100 (Tue, 27 May 2008) $ + */ +public class QuestionMarkWSDLIncludeTestCase extends TestCase { + + private SCADomain domain; + + /** + * Tests ?wsdl works and returns the correct port endpoint from the WSDL + */ + public void testWSDLIncludePortEndpoint() throws Exception { + InputStream inp = new URL("http://localhost:8085/AccountService?wsdl").openStream(); + BufferedReader br = new BufferedReader(new InputStreamReader(inp)); + String line; + while((line = br.readLine()) != null) { + System.out.println(line); + } + br.close(); + + WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); + wsdlReader.setFeature("javax.wsdl.verbose", false); + wsdlReader.setFeature("javax.wsdl.importDocuments", true); + + Definition definition = wsdlReader.readWSDL("http://localhost:8085/AccountService?wsdl"); + assertNotNull(definition); + Service service = definition.getService(new QName("http://accounts/AccountService/$promoted$ep1", "AccountService")); + Port port = service.getPort("AccountSoapPort"); + + String endpoint = getEndpoint(port); + assertEquals("http://localhost:8085/AccountService", endpoint); + } + + private String getEndpoint(Port port) { + List wsdlPortExtensions = port.getExtensibilityElements(); + for (final Object extension : wsdlPortExtensions) { + if (extension instanceof SOAPAddress) { + return ((SOAPAddress) extension).getLocationURI(); + } + } + throw new RuntimeException("no SOAPAddress"); + } + + @Override + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite"); + } + + @Override + protected void tearDown() throws Exception { + domain.close(); + } + +} diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCaseFIXME.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCaseFIXME.java deleted file mode 100644 index 0d10881e7b..0000000000 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLIncludeTestCaseFIXME.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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.tuscany.sca.binding.ws.axis2.itests; - -import java.io.BufferedReader; -import java.io.InputStream; -import java.io.InputStreamReader; -import java.net.URL; -import java.util.List; - -import javax.wsdl.Definition; -import javax.wsdl.Port; -import javax.wsdl.Service; -import javax.wsdl.extensions.soap.SOAPAddress; -import javax.wsdl.factory.WSDLFactory; -import javax.wsdl.xml.WSDLReader; -import javax.xml.namespace.QName; - -import junit.framework.TestCase; - -import org.apache.axis2.transport.http.server.HttpUtils; -import org.apache.tuscany.sca.host.embedded.SCADomain; - -/** - * Test ?wsdl works and that the returned WSDL has the correct endpoint - * - * ********* Currently broken, see TUSCANY-2942 - * - * @version $Rev: 660340 $ $Date: 2008-05-27 01:08:32 +0100 (Tue, 27 May 2008) $ - */ -public class QuestionMarkWSDLIncludeTestCaseFIXME extends TestCase { - - private SCADomain domain; - - /** - * Tests ?wsdl works and returns the correct port endpoint from the WSDL - */ - public void testWSDLIncludePortEndpoint() throws Exception { - InputStream inp = new URL("http://localhost:8085/AccountService?wsdl").openStream(); - BufferedReader br = new BufferedReader(new InputStreamReader(inp)); - String line; - while((line = br.readLine()) != null) { - System.out.println(line); - } - br.close(); - - WSDLReader wsdlReader = WSDLFactory.newInstance().newWSDLReader(); - wsdlReader.setFeature("javax.wsdl.verbose", false); - wsdlReader.setFeature("javax.wsdl.importDocuments", true); - - Definition definition = wsdlReader.readWSDL("http://localhost:8085/AccountService?wsdl"); - assertNotNull(definition); - Service service = definition.getService(new QName("http://accounts/AccountService/$promoted$ep1", "AccountService")); - Port port = service.getPort("AccountSoapPort"); - - String endpoint = getEndpoint(port); - String ip = HttpUtils.getIpAddress(); - assertEquals("http://" + ip + ":8085/AccountService", endpoint); - } - - private String getEndpoint(Port port) { - List wsdlPortExtensions = port.getExtensibilityElements(); - for (final Object extension : wsdlPortExtensions) { - if (extension instanceof SOAPAddress) { - return ((SOAPAddress) extension).getLocationURI(); - } - } - throw new RuntimeException("no SOAPAddress"); - } - - @Override - protected void setUp() throws Exception { - domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/questionmark-wsdl-include.composite"); - } - - @Override - protected void tearDown() throws Exception { - domain.close(); - } - -} diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java index 0508f28e11..0ca84a910e 100644 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/QuestionMarkWSDLTestCase.java @@ -35,7 +35,6 @@ import javax.xml.namespace.QName; import junit.framework.TestCase; -import org.apache.axis2.transport.http.server.HttpUtils; import org.apache.tuscany.sca.host.embedded.SCADomain; /** @@ -70,8 +69,7 @@ public class QuestionMarkWSDLTestCase extends TestCase { Port port = service.getPort("HelloWorldSoapPort"); String endpoint = getEndpoint(port); - String ip = HttpUtils.getIpAddress(); - assertEquals("http://" + ip + ":8085/services/HelloWorldWebService", endpoint); + assertEquals("http://localhost:8085/services/HelloWorldWebService", endpoint); } /** @@ -97,8 +95,7 @@ public class QuestionMarkWSDLTestCase extends TestCase { Port port = service.getPort("HelloWorldPort"); String endpoint = getEndpoint(port); - String ip = HttpUtils.getIpAddress(); - assertEquals("http://" + ip + ":8085/foo/bar", endpoint); + assertEquals("http://localhost:8085/foo/bar", endpoint); } protected String getEndpoint(Port port) { diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCase.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCase.java index 8d378565d4..ee866f77ec 100644 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCase.java +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/soap12/QuestionMarkWSDLTestCase.java @@ -32,7 +32,6 @@ import javax.xml.namespace.QName; import junit.framework.TestCase; -import org.apache.axis2.transport.http.server.HttpUtils; import org.apache.tuscany.sca.host.embedded.SCADomain; /** @@ -61,8 +60,7 @@ public class QuestionMarkWSDLTestCase extends TestCase { Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP11port_http"); String endpoint = getSOAP11Endpoint(port); - String ip = HttpUtils.getIpAddress(); - assertEquals("http://" + ip + ":8085/ep1", endpoint); + assertEquals("http://localhost:8085/ep1", endpoint); } /** @@ -81,8 +79,7 @@ public class QuestionMarkWSDLTestCase extends TestCase { Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP11port_http"); String endpoint = getSOAP11Endpoint(port); - String ip = HttpUtils.getIpAddress(); - assertEquals("http://" + ip + ":8085/ep2", endpoint); + assertEquals("http://localhost:8085/ep2", endpoint); } /** @@ -101,8 +98,7 @@ public class QuestionMarkWSDLTestCase extends TestCase { Port port = service.getPort(newGenerator ? "HelloWorldPort" : "HelloWorldSOAP12port_http"); String endpoint = getSOAP12Endpoint(port); - String ip = HttpUtils.getIpAddress(); - assertEquals("http://" + ip + ":8085/ep3", endpoint); + assertEquals("http://localhost:8085/ep3", endpoint); } protected String getSOAP11Endpoint(Port port) { -- cgit v1.2.3