Author: alessio.soldano(a)jboss.com
Date: 2012-12-10 13:19:30 -0500 (Mon, 10 Dec 2012)
New Revision: 17063
Added:
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws2150/WEB-INF/wsdl/inner.wsdl
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws2150/WEB-INF/wsdl/Service.wsdl
Log:
[JBWS-3570] Extending testcase
Modified:
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2012-12-10
13:51:55 UTC (rev 17062)
+++
shared-testsuite/trunk/testsuite/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2012-12-10
18:19:30 UTC (rev 17063)
@@ -1,6 +1,6 @@
/*
* JBoss, Home of Professional Open Source.
- * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * Copyright 2012, Red Hat Middleware LLC, and individual contributors
* as indicated by the @author tags. See the copyright.txt file in the
* distribution for a full listing of individual contributors.
*
@@ -22,10 +22,12 @@
package org.jboss.test.ws.jaxws.jbws2150;
import java.net.URL;
+import java.util.Collection;
import javax.management.Attribute;
import javax.management.ObjectName;
import javax.wsdl.Definition;
+import javax.wsdl.Import;
import javax.wsdl.Port;
import javax.wsdl.factory.WSDLFactory;
import javax.wsdl.xml.WSDLReader;
@@ -33,28 +35,30 @@
import javax.xml.ws.Service;
import org.jboss.ws.common.ObjectNameFactory;
+import org.jboss.wsf.spi.management.ServerConfig;
import org.jboss.wsf.test.JBossWSTest;
import com.ibm.wsdl.extensions.soap.SOAPAddressImpl;
/**
* [JBWS-2150] Migrate AddressRewritingTestCase to jaxws
+ *
+ * soap:address rewrite tests
+ *
* @author richard.opalka(a)jboss.com
+ * @author alessio.soldano(a)jboss.com
*/
public final class JBWS2150TestCaseForked extends JBossWSTest
{
private static final ObjectName SERVER_CONFIG_OBJECT_NAME =
ObjectNameFactory.create("jboss.ws:service=ServerConfig");
private static final String NAMESPACE =
"http://test.jboss.org/addressrewrite";
+ private static final String NAMESPACE_IMP =
"http://test.jboss.org/addressrewrite/wsdlimp";
- private String wsdlLocation;
- private String wsdlLocationSec;
private Boolean modifySOAPAddress;
private String webServiceHost;
public void setUp() throws Exception
{
- wsdlLocation = "http://" + getServerHost() +
":8080/jaxws-jbws2150/ValidURL?wsdl";
- wsdlLocationSec = "http://" + getServerHost() +
":8080/jaxws-jbws2150-sec/ValidURL?wsdl";
if (modifySOAPAddress == null)
{
modifySOAPAddress = (Boolean)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"ModifySOAPAddress");
@@ -71,7 +75,8 @@
}
/**
- * Test soap:address rewrite
+ * Test soap:address rewrite with rewrite engine on
+ *
* @throws Exception
*/
public void testRewrite() throws Exception
@@ -80,24 +85,117 @@
deploy("jaxws-jbws2150.war");
try
{
+ final String[] wsdlLocations = new String[4];
+ wsdlLocations[0] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/ValidURL?wsdl";
+ wsdlLocations[1] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/InvalidURL?wsdl";
+ wsdlLocations[2] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl";
+ wsdlLocations[3] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl";
+
+ for (String wsdlLocation : wsdlLocations) {
+ Definition definition = getWSDLDefinition(wsdlLocation);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("http://" + webServiceHost +
":8080/jaxws-jbws2150/ValidURL", address);
+ //avoid invoking on https endpoints as that would require getting the
imported wsdl using https...
+ if (wsdlLocation.equals(wsdlLocations[0]) ||
wsdlLocation.equals(wsdlLocations[1])) {
+ ServiceIface endpoint = getEndpoint(wsdlLocation,
"ValidURLService");
+ assertEquals(endpoint.echo("hello"), "hello");
+ }
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("http://" + webServiceHost +
":8080/jaxws-jbws2150/InvalidURL", address);
+ if (wsdlLocation.equals(wsdlLocations[0]) ||
wsdlLocation.equals(wsdlLocations[1])) {
+ ServiceIface endpoint = getEndpoint(wsdlLocation,
"InvalidURLService");
+ assertEquals(endpoint.echo("hello"), "hello");
+ }
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150/InvalidSecureURL", address);
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150.war");
+ }
+ }
+
+ /**
+ * Test soap:address rewrite with rewrite engine on and the webServiceHost set to a
(fake) load balancer host
+ *
+ * @throws Exception
+ */
+ public void testRewriteLoadBalancer() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String testWebServiceHost = "myloadbalancer.com";
+ setWebServiceHost(testWebServiceHost);
+ deploy("jaxws-jbws2150.war");
+ try
+ {
+ final String[] wsdlLocations = new String[4];
+ wsdlLocations[0] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/ValidURL?wsdl";
+ wsdlLocations[1] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/InvalidURL?wsdl";
+ wsdlLocations[2] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl";
+ wsdlLocations[3] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl";
+
+ for (String wsdlLocation : wsdlLocations) {
+ Definition definition = getWSDLDefinition(wsdlLocation);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("http://" + testWebServiceHost +
":8080/jaxws-jbws2150/ValidURL", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("http://" + testWebServiceHost +
":8080/jaxws-jbws2150/InvalidURL", address);
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("https://" + testWebServiceHost +
":8443/jaxws-jbws2150/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("https://" + testWebServiceHost +
":8443/jaxws-jbws2150/InvalidSecureURL", address);
+
+ //check wsdl import (which is bound to the endpoint currently serving the
wsdl)
+ assertTrue(getWsdlImportAddress(definition).contains(testWebServiceHost));
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150.war");
+ }
+ }
- Definition definition = getWSDLDefinition(wsdlLocation);
-
- String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
- assertEquals("http://" + webServiceHost +
":8080/jaxws-jbws2150/ValidURL", address);
- ServiceIface endpoint = getEndpoint(wsdlLocation, "ValidURLService");
- assertEquals(endpoint.echo("hello"), "hello");
-
- address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
- assertEquals("http://" + webServiceHost +
":8080/jaxws-jbws2150/InvalidURL", address);
- endpoint = getEndpoint(wsdlLocation, "InvalidURLService");
- assertEquals(endpoint.echo("hello"), "hello");
-
- address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
- assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150/ValidSecureURL", address);
-
- address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
- assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150/InvalidSecureURL", address);
+ /**
+ * Test soap:address rewrite with rewrite engine on and the webServiceHost set to
jbossws.undefined.host
+ *
+ * @throws Exception
+ */
+ public void testAutoRewrite() throws Exception
+ {
+ setModifySOAPAddress(true);
+ setWebServiceHost(ServerConfig.UNDEFINED_HOSTNAME);
+ deploy("jaxws-jbws2150.war");
+ try
+ {
+ final String[] wsdlLocations = new String[4];
+ wsdlLocations[0] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/ValidURL?wsdl";
+ wsdlLocations[1] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/InvalidURL?wsdl";
+ wsdlLocations[2] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl";
+ wsdlLocations[3] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl";
+
+ for (String wsdlLocation : wsdlLocations) {
+ Definition definition = getWSDLDefinition(wsdlLocation);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("http://" + getServerHost() +
":8080/jaxws-jbws2150/ValidURL", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("http://" + getServerHost() +
":8080/jaxws-jbws2150/InvalidURL", address);
+
+ //no further checks on the ports forcing https even when getting the wsdl
over http
+ //as there's no way to tell which port to use for the secure access given
the invoked wsdl address (on http)
+ }
}
finally
{
@@ -107,6 +205,7 @@
/**
* [JBWS-454] Test soap:address URL rewrite according to transport guarantee
+ *
* @throws Exception
*/
public void testSecureRewrite() throws Exception
@@ -115,28 +214,81 @@
deploy("jaxws-jbws2150-sec.war");
try
{
- Definition definition = getWSDLDefinition(wsdlLocationSec);
-
- String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
- assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150-sec/ValidURL", address);
-
- address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
- assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150-sec/InvalidURL", address);
-
- address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
- assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150-sec/ValidSecureURL", address);
-
- address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
- assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150-sec/InvalidSecureURL", address);
+ final String[] wsdlLocationsSec = new String[4];
+ wsdlLocationsSec[0] = "http://" + getServerHost() +
":8080/jaxws-jbws2150-sec/ValidURL?wsdl";
+ wsdlLocationsSec[1] = "http://" + getServerHost() +
":8080/jaxws-jbws2150-sec/InvalidURL?wsdl";
+ wsdlLocationsSec[2] = "http://" + getServerHost() +
":8080/jaxws-jbws2150-sec/ValidSecureURL?wsdl";
+ wsdlLocationsSec[3] = "http://" + getServerHost() +
":8080/jaxws-jbws2150-sec/InvalidSecureURL?wsdl";
+
+ for (String wsdlLocationSec : wsdlLocationsSec) {
+ Definition definition = getWSDLDefinition(wsdlLocationSec);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150-sec/ValidURL", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150-sec/InvalidURL", address);
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150-sec/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150-sec/InvalidSecureURL", address);
+ }
}
finally
{
undeploy("jaxws-jbws2150-sec.war");
}
}
+
+ /**
+ * [JBWS-454] Test soap:address URL rewrite according to transport guarantee
+ *
+ * @throws Exception
+ */
+ public void testSecureRewriteLoadBalancer() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String testWebServiceHost = "myloadbalancer.com";
+ setWebServiceHost(testWebServiceHost);
+ deploy("jaxws-jbws2150-sec.war");
+ try
+ {
+ final String[] wsdlLocationsSec = new String[4];
+ wsdlLocationsSec[0] = "http://" + getServerHost() +
":8080/jaxws-jbws2150-sec/ValidURL?wsdl";
+ wsdlLocationsSec[1] = "http://" + getServerHost() +
":8080/jaxws-jbws2150-sec/InvalidURL?wsdl";
+ wsdlLocationsSec[2] = "http://" + getServerHost() +
":8080/jaxws-jbws2150-sec/ValidSecureURL?wsdl";
+ wsdlLocationsSec[3] = "http://" + getServerHost() +
":8080/jaxws-jbws2150-sec/InvalidSecureURL?wsdl";
+
+ for (String wsdlLocationSec : wsdlLocationsSec) {
+ Definition definition = getWSDLDefinition(wsdlLocationSec);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("https://" + testWebServiceHost +
":8443/jaxws-jbws2150-sec/ValidURL", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("https://" + testWebServiceHost +
":8443/jaxws-jbws2150-sec/InvalidURL", address);
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("https://" + testWebServiceHost +
":8443/jaxws-jbws2150-sec/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("https://" + testWebServiceHost +
":8443/jaxws-jbws2150-sec/InvalidSecureURL", address);
+
+ //check wsdl import (which is bound to the endpoint currently serving the
wsdl)
+ assertTrue(getWsdlImportAddress(definition).contains(testWebServiceHost));
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150-sec.war");
+ }
+ }
/**
- * Test no soap:address rewrite
+ * Test soap:address rewrite when the rewrite engine is off
+ *
* @throws Exception
*/
public void testNoRewrite() throws Exception
@@ -145,19 +297,27 @@
deploy("jaxws-jbws2150.war");
try
{
- Definition definition = getWSDLDefinition(wsdlLocation);
-
- String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
- assertEquals("http://somehost:80/somepath", address);
-
- address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
- assertEquals("http://" + webServiceHost +
":8080/jaxws-jbws2150/InvalidURL", address);
-
- address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
- assertEquals("https://somehost:443/some-secure-path", address);
-
- address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
- assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150/InvalidSecureURL", address);
+ final String[] wsdlLocations = new String[4];
+ wsdlLocations[0] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/ValidURL?wsdl";
+ wsdlLocations[1] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/InvalidURL?wsdl";
+ wsdlLocations[2] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl";
+ wsdlLocations[3] = "http://" + getServerHost() +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl";
+
+ for (String wsdlLocation : wsdlLocations) {
+ Definition definition = getWSDLDefinition(wsdlLocation);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("http://somehost:80/somepath", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("http://" + webServiceHost +
":8080/jaxws-jbws2150/InvalidURL", address);
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("https://somehost:443/some-secure-path", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("https://" + webServiceHost +
":8443/jaxws-jbws2150/InvalidSecureURL", address);
+ }
}
finally
{
@@ -170,6 +330,12 @@
Attribute attr = new Attribute("ModifySOAPAddress", value);
getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
}
+
+ private void setWebServiceHost(String value) throws Exception
+ {
+ Attribute attr = new Attribute("WebServiceHost", value);
+ getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
+ }
private ServiceIface getEndpoint(String wsdlLocation, String serviceName) throws
Exception
{
@@ -177,11 +343,13 @@
QName portName = service.getPorts().next();
return service.getPort(portName, ServiceIface.class);
}
-
+
private Definition getWSDLDefinition(String wsdlLocation) throws Exception
{
WSDLFactory wsdlFactory = WSDLFactory.newInstance();
WSDLReader wsdlReader = wsdlFactory.newWSDLReader();
+ wsdlReader.setFeature("javax.wsdl.importDocuments", false);
+ wsdlReader.setFeature("javax.wsdl.verbose", false);
Definition definition = wsdlReader.readWSDL(null, wsdlLocation);
return definition;
@@ -192,5 +360,14 @@
Port port = definition.getService(new QName(NAMESPACE,
serviceName)).getPort(portName);
return ((SOAPAddressImpl)port.getExtensibilityElements().get(0)).getLocationURI();
}
+
+ private String getWsdlImportAddress(Definition definition)
+ {
+ Collection<Import> imports = definition.getImports(NAMESPACE_IMP);
+ if (imports.size() == 1) {
+ return imports.iterator().next().getLocationURI();
+ }
+ return null;
+ }
}
Modified:
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws2150/WEB-INF/wsdl/Service.wsdl
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws2150/WEB-INF/wsdl/Service.wsdl 2012-12-10
13:51:55 UTC (rev 17062)
+++
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws2150/WEB-INF/wsdl/Service.wsdl 2012-12-10
18:19:30 UTC (rev 17063)
@@ -1,5 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<definitions name='HelloService'
targetNamespace='http://test.jboss.org/addressrewrite'
xmlns='http://schemas.xmlsoap.org/wsdl/'
xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
xmlns:tns='http://test.jboss.org/addressrewrite'
xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <import
namespace="http://test.jboss.org/addressrewrite/wsdlimp"
location="inner.wsdl"/>
<types/>
<message name='HelloWs_echo'>
<part name='String_1' type='xsd:string'/>
Added:
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws2150/WEB-INF/wsdl/inner.wsdl
===================================================================
---
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws2150/WEB-INF/wsdl/inner.wsdl
(rev 0)
+++
shared-testsuite/trunk/testsuite/src/test/resources/jaxws/jbws2150/WEB-INF/wsdl/inner.wsdl 2012-12-10
18:19:30 UTC (rev 17063)
@@ -0,0 +1,4 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<definitions
targetNamespace='http://test.jboss.org/addressrewrite/wsdlimp'
xmlns='http://schemas.xmlsoap.org/wsdl/'>
+ <types/>
+</definitions>