Author: asoldano
Date: 2014-08-22 05:48:45 -0400 (Fri, 22 Aug 2014)
New Revision: 18858
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java
Log:
[JBWS-3785] Improving JBWS2150TestCaseForked to cover uri scheme addition (as well as
port/secure-port which were not covered yet)
Modified:
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java
===================================================================
---
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2014-08-22
09:47:18 UTC (rev 18857)
+++
stack/cxf/trunk/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2014-08-22
09:48:45 UTC (rev 18858)
@@ -119,7 +119,10 @@
protected static Boolean modifySOAPAddress;
protected static String webServiceHost;
+ protected static int webServicePort;
+ protected static int webServiceSecurePort;
protected static String webServicePath;
+ protected static String webServiceUriScheme;
public JBWS2150TestSetup() {
super(JBWS2150TestCaseForked.class, null);
@@ -129,7 +132,10 @@
{
modifySOAPAddress = (Boolean)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"ModifySOAPAddress");
webServiceHost = (String)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"WebServiceHost");
+ webServicePort = (Integer)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"WebServicePort");
+ webServiceSecurePort =
(Integer)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"WebServiceSecurePort");
webServicePath = (String)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"WebServicePathRewriteRule");
+ webServiceUriScheme =
(String)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"WebServiceUriScheme");
super.setUp();
}
}
@@ -145,8 +151,14 @@
getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
attr = new Attribute("WebServiceHost",
JBWS2150TestSetup.webServiceHost);
getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
+ attr = new Attribute("WebServicePort",
JBWS2150TestSetup.webServicePort);
+ getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
+ attr = new Attribute("WebServiceSecurePort",
JBWS2150TestSetup.webServiceSecurePort);
+ getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
attr = new Attribute("WebServicePathRewriteRule",
JBWS2150TestSetup.webServicePath);
getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
+ attr = new Attribute("WebServiceUriScheme",
JBWS2150TestSetup.webServiceUriScheme);
+ getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
}
private String getWebServiceHost() {
@@ -595,6 +607,31 @@
}
/**
+ * Test soap:address rewrite with rewrite engine on , the webServiceHost set to a
(fake) load balancer host (code-first endpoint) and forced https scheme
+ *
+ * @throws Exception
+ */
+ public void testRewriteLoadBalancerCodeFirstForceHttps() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String testWebServiceHost = "myloadbalancer.com";
+ setWebServiceHost(testWebServiceHost);
+ setWebServiceSecurePort(443);
+ setWebServiceUriScheme("https");
+ deploy("jaxws-jbws2150-codefirst.war");
+ try
+ {
+ Definition definition = getWSDLDefinition("http://" + getServerHost()
+ ":8080/jaxws-jbws2150-codefirst/CodeFirstService?wsdl");
+ String address = getPortAddress(definition, "CodeFirstService",
"CodeFirstPort");
+ assertEquals("https://" + testWebServiceHost +
"/jaxws-jbws2150-codefirst/CodeFirstService", address);
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150-codefirst.war");
+ }
+ }
+
+ /**
* Basically the same as the test above; even if rewrite is off, we still get the
loadbalancer address in the wsdl
* for code-first endpoint, as there's no user provided wsdl with a different
address in it.
*
@@ -820,6 +857,342 @@
}
}
+ /**
+ * Test soap:address rewrite with rewrite engine on and forced https scheme and secure
port
+ *
+ * @throws Exception
+ */
+ public void testRewriteForceHttpsSchemeAndPorts() throws Exception
+ {
+ setModifySOAPAddress(true);
+ setWebServiceUriScheme("https");
+ setWebServiceSecurePort(8192);
+ deploy("jaxws-jbws2150.war");
+ try
+ {
+ final Map<String, String> wsdlLocationsMap = new HashMap<String,
String>();
+ final Map<String, String> importMap = new HashMap<String,
String>();
+ final String serverHost = getServerHost();
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl", getWebServiceHost());
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidURL?wsdl", getWebServiceHost());
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl", getWebServiceHost());
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl", getWebServiceHost());
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl", "https://" + getWebServiceHost()
+ ":8192/jaxws-jbws2150/ValidURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidURL?wsdl", "https://" +
getWebServiceHost() + ":8192/jaxws-jbws2150/InvalidURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl", "https://" +
getWebServiceHost() + ":8192/jaxws-jbws2150/ValidSecureURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl", "https://" +
getWebServiceHost() + ":8192/jaxws-jbws2150/InvalidSecureURL?wsdl=inner.wsdl");
+ if (isTestsuiteServerHostLocalhost()) {
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidURL?wsdl",
getWebServiceHost());
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidURL?wsdl",
getWebServiceHost());
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidSecureURL?wsdl",
getWebServiceHost());
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidSecureURL?wsdl",
getWebServiceHost());
+ importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidURL?wsdl",
"https://" + getWebServiceHost() +
":8192/jaxws-jbws2150/ValidURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidURL?wsdl",
"https://" + getWebServiceHost() +
":8192/jaxws-jbws2150/InvalidURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidSecureURL?wsdl",
"https://" + getWebServiceHost() +
":8192/jaxws-jbws2150/ValidSecureURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidSecureURL?wsdl",
"https://" + getWebServiceHost() +
":8192/jaxws-jbws2150/InvalidSecureURL?wsdl=inner.wsdl");
+ }
+
+ for (Entry<String, String> entry : wsdlLocationsMap.entrySet()) {
+ String wsdlLocation = entry.getKey();
+ String host = entry.getValue();
+ Definition definition = getWSDLDefinition(wsdlLocation);
+ //avoid invoking on https endpoints as that would require getting the
imported wsdl using https...
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("https://" + host +
":8192/jaxws-jbws2150/ValidURL", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("https://" + host +
":8192/jaxws-jbws2150/InvalidURL", address);
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("https://" + host +
":8192/jaxws-jbws2150/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("https://" + host +
":8192/jaxws-jbws2150/InvalidSecureURL", address);
+
+ //check wsdl import address rewrite (we expect a rewritten version of the
same base address used to fetch the wsdl)
+ assertEquals(importMap.get(wsdlLocation), getWsdlImportAddress(definition));
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150.war");
+ }
+ }
+
+ /**
+ * Test soap:address rewrite with rewrite engine on, the webServiceHost set to a
(fake) load balancer host and forced https uri scheme
+ *
+ * @throws Exception
+ */
+ public void testRewriteLoadBalancerForceHttps() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String testWebServiceHost = "myloadbalancer.com";
+ setWebServiceHost(testWebServiceHost);
+ setWebServiceUriScheme("https");
+ deploy("jaxws-jbws2150.war");
+ try
+ {
+ final Map<String, String> wsdlLocationsMap = new HashMap<String,
String>();
+ final Map<String, String> importMap = new HashMap<String,
String>();
+ final String serverHost = getServerHost();
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl", testWebServiceHost);
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidURL?wsdl", testWebServiceHost);
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl", testWebServiceHost);
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl", testWebServiceHost);
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl", "https://" + testWebServiceHost
+ ":8443/jaxws-jbws2150/ValidURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidURL?wsdl", "https://" +
testWebServiceHost + ":8443/jaxws-jbws2150/InvalidURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl", "https://" +
testWebServiceHost + ":8443/jaxws-jbws2150/ValidSecureURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl", "https://" +
testWebServiceHost + ":8443/jaxws-jbws2150/InvalidSecureURL?wsdl=inner.wsdl");
+ if (isTestsuiteServerHostLocalhost()) {
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidURL?wsdl",
testWebServiceHost);
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidURL?wsdl",
testWebServiceHost);
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidSecureURL?wsdl",
testWebServiceHost);
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidSecureURL?wsdl",
testWebServiceHost);
+ importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidURL?wsdl",
"https://" + testWebServiceHost +
":8443/jaxws-jbws2150/ValidURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidURL?wsdl",
"https://" + testWebServiceHost +
":8443/jaxws-jbws2150/InvalidURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidSecureURL?wsdl",
"https://" + testWebServiceHost +
":8443/jaxws-jbws2150/ValidSecureURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidSecureURL?wsdl",
"https://" + testWebServiceHost +
":8443/jaxws-jbws2150/InvalidSecureURL?wsdl=inner.wsdl");
+ }
+
+ for (Entry<String, String> entry : wsdlLocationsMap.entrySet()) {
+ String wsdlLocation = entry.getKey();
+ String host = entry.getValue();
+ Definition definition = getWSDLDefinition(wsdlLocation);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("https://" + host +
":8443/jaxws-jbws2150/ValidURL", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("https://" + host +
":8443/jaxws-jbws2150/InvalidURL", address);
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("https://" + host +
":8443/jaxws-jbws2150/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("https://" + host +
":8443/jaxws-jbws2150/InvalidSecureURL", address);
+
+ //check wsdl import address rewrite (we expect a rewritten version of the
same base address used to fetch the wsdl)
+ assertEquals(importMap.get(wsdlLocation), getWsdlImportAddress(definition));
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150.war");
+ }
+ }
+
+ /**
+ * Test soap:address rewrite with rewrite engine on, the webServiceHost set to
jbossws.undefined.host and forced http uri scheme
+ *
+ * @throws Exception
+ */
+ public void testAutoRewriteForceHttp() throws Exception
+ {
+ setModifySOAPAddress(true);
+ setWebServiceHost(ServerConfig.UNDEFINED_HOSTNAME);
+ deploy("jaxws-jbws2150.war");
+ try
+ {
+ final Map<String, String> wsdlLocationsMap = new HashMap<String,
String>();
+ final Map<String, String> importMap = new HashMap<String,
String>();
+ final String serverHost = getServerHost();
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl", serverHost);
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidURL?wsdl", serverHost);
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl", serverHost);
+ wsdlLocationsMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl", serverHost);
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl", "http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidURL?wsdl", "http://" + serverHost +
":8080/jaxws-jbws2150/InvalidURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl", "http://" + serverHost +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl", "http://" + serverHost +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl=inner.wsdl");
+ if (isTestsuiteServerHostLocalhost()) {
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidURL?wsdl",
"127.0.0.1");
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidURL?wsdl",
"127.0.0.1");
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidSecureURL?wsdl",
"127.0.0.1");
+
wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidSecureURL?wsdl",
"127.0.0.1");
+ importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidURL?wsdl",
"http://127.0.0.1:8080/jaxws-jbws2150/ValidURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidURL?wsdl",
"http://127.0.0.1:8080/jaxws-jbws2150/InvalidURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/ValidSecureURL?wsdl",
"http://127.0.0.1:8080/jaxws-jbws2150/ValidSecureURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidSecureURL?wsdl",
"http://127.0.0.1:8080/jaxws-jbws2150/InvalidSecureURL?wsdl=inner.wsdl");
+ }
+
+ for (Entry<String, String> entry : wsdlLocationsMap.entrySet()) {
+ String wsdlLocation = entry.getKey();
+ String host = entry.getValue();
+ Definition definition = getWSDLDefinition(wsdlLocation);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("http://" + host +
":8080/jaxws-jbws2150/ValidURL", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("http://" + host +
":8080/jaxws-jbws2150/InvalidURL", address);
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("http://" + host +
":8080/jaxws-jbws2150/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("http://" + host +
":8080/jaxws-jbws2150/InvalidSecureURL", address);
+
+ assertEquals(importMap.get(wsdlLocation), getWsdlImportAddress(definition));
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150.war");
+ }
+ }
+
+ /**
+ * Test soap:address URL rewrite according to transport guarantee is overridden by
forced http uri scheme
+ *
+ * @throws Exception
+ */
+ public void testSecureRewriteOverriddenByForcedHttp() throws Exception
+ {
+ setModifySOAPAddress(true);
+ setWebServiceUriScheme("http");
+ setWebServicePort(80);
+ deploy("jaxws-jbws2150-sec.war");
+ try
+ {
+ final Map<String, String> wsdlLocationsSecMap = new HashMap<String,
String>();
+ final Map<String, String> importMap = new HashMap<String,
String>();
+ final String serverHost = getServerHost();
+ wsdlLocationsSecMap.put("http://" + serverHost +
":8080/jaxws-jbws2150-sec/ValidURL?wsdl", getWebServiceHost());
+ wsdlLocationsSecMap.put("http://" + serverHost +
":8080/jaxws-jbws2150-sec/InvalidURL?wsdl", getWebServiceHost());
+ wsdlLocationsSecMap.put("http://" + serverHost +
":8080/jaxws-jbws2150-sec/ValidSecureURL?wsdl", getWebServiceHost());
+ wsdlLocationsSecMap.put("http://" + serverHost +
":8080/jaxws-jbws2150-sec/InvalidSecureURL?wsdl", getWebServiceHost());
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150-sec/ValidURL?wsdl", "http://" +
getWebServiceHost() + "/jaxws-jbws2150-sec/ValidURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150-sec/InvalidURL?wsdl", "http://" +
getWebServiceHost() + "/jaxws-jbws2150-sec/InvalidURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150-sec/ValidSecureURL?wsdl", "http://" +
getWebServiceHost() + "/jaxws-jbws2150-sec/ValidSecureURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150-sec/InvalidSecureURL?wsdl", "http://" +
getWebServiceHost() + "/jaxws-jbws2150-sec/InvalidSecureURL?wsdl=inner.wsdl");
+ if (isTestsuiteServerHostLocalhost()) {
+
wsdlLocationsSecMap.put("http://127.0.0.1:8080/jaxws-jbws2150-sec/ValidURL?wsdl",
getWebServiceHost());
+
wsdlLocationsSecMap.put("http://127.0.0.1:8080/jaxws-jbws2150-sec/InvalidURL?wsdl",
getWebServiceHost());
+
wsdlLocationsSecMap.put("http://127.0.0.1:8080/jaxws-jbws2150-sec/ValidSecureURL?wsdl",
getWebServiceHost());
+
wsdlLocationsSecMap.put("http://127.0.0.1:8080/jaxws-jbws2150-sec/InvalidSecureURL?wsdl",
getWebServiceHost());
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150-sec/ValidURL?wsdl",
"http://" + getWebServiceHost() +
"/jaxws-jbws2150-sec/ValidURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150-sec/InvalidURL?wsdl",
"http://" + getWebServiceHost() +
"/jaxws-jbws2150-sec/InvalidURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150-sec/ValidSecureURL?wsdl",
"http://" + getWebServiceHost() +
"/jaxws-jbws2150-sec/ValidSecureURL?wsdl=inner.wsdl");
+
importMap.put("http://127.0.0.1:8080/jaxws-jbws2150-sec/InvalidSecureURL?wsdl",
"http://" + getWebServiceHost() +
"/jaxws-jbws2150-sec/InvalidSecureURL?wsdl=inner.wsdl");
+ }
+
+ for (Entry<String, String> entry : wsdlLocationsSecMap.entrySet()) {
+ String wsdlLocationSec = entry.getKey();
+ String host = entry.getValue();
+ Definition definition = getWSDLDefinition(wsdlLocationSec);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("http://" + host +
"/jaxws-jbws2150-sec/ValidURL", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("http://" + host +
"/jaxws-jbws2150-sec/InvalidURL", address);
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("http://" + host +
"/jaxws-jbws2150-sec/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("http://" + host +
"/jaxws-jbws2150-sec/InvalidSecureURL", address);
+
+ //check wsdl import address rewrite (we expect a rewritten version of the
same base address used to fetch the wsdl)
+ assertEquals(importMap.get(wsdlLocationSec),
getWsdlImportAddress(definition));
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150-sec.war");
+ }
+ }
+
+ /**
+ * Test soap:address rewrite when a path rewrite rule is specified and https scheme is
forced.
+ *
+ * @throws Exception
+ */
+ public void testRewriteWithPathRuleAndForcedHttps() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String expectedContext = "xx/jaxws-jbws2150";
+ final String sedCmd = "s/jaxws-jbws2150/xx\\/jaxws-jbws2150/g";
+ setWebServicePathRewriteRule(sedCmd);
+ setWebServiceUriScheme("https");
+ deploy("jaxws-jbws2150.war");
+ try
+ {
+ final String serverHost = getServerHost();
+ final List<String> wsdlLocations = new LinkedList<String>();
+ final Map<String, String> importMap = new HashMap<String,
String>();
+ wsdlLocations.add("http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl");
+ wsdlLocations.add("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidURL?wsdl");
+ wsdlLocations.add("http://" + serverHost +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl");
+ wsdlLocations.add("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl", "https://" + serverHost +
":8443/" + expectedContext + "/ValidURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidURL?wsdl", "https://" + serverHost +
":8443/" + expectedContext + "/InvalidURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/ValidSecureURL?wsdl", "https://" + serverHost +
":8443/" + expectedContext + "/ValidSecureURL?wsdl=inner.wsdl");
+ importMap.put("http://" + serverHost +
":8080/jaxws-jbws2150/InvalidSecureURL?wsdl", "https://" + serverHost
+ ":8443/" + expectedContext + "/InvalidSecureURL?wsdl=inner.wsdl");
+
+ for (final String wsdlLocation : wsdlLocations)
+ {
+ Definition definition = getWSDLDefinition(wsdlLocation);
+
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("https://" + serverHost + ":8443/" +
expectedContext + "/ValidURL", address);
+
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("https://" + serverHost + ":8443/" +
expectedContext + "/InvalidURL", address);
+
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("https://" + serverHost + ":8443/" +
expectedContext + "/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("https://" + serverHost + ":8443/" +
expectedContext + "/InvalidSecureURL", address);
+
+ //check wsdl import address rewrite (we expect a rewritten version of the
same base address used to fetch the wsdl)
+ assertEquals(importMap.get(wsdlLocation), getWsdlImportAddress(definition));
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150.war");
+ }
+ }
+
+ /**
+ * Test soap:address rewrite for code-first endpoints when a path rewrite rule is
specified, auto-rewrite is on
+ * (wsdl host prop set to ServerConfig.UNDEFINED_HOSTNAME) and https scheme is forced
+ *
+ * @throws Exception
+ */
+ public void testAutoRewriteCodeFirstPathRuleAndForcedHttps() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String expectedContext = "xx/jaxws-jbws2150-codefirst";
+ final String sedCmd =
"s/jaxws-jbws2150-codefirst/xx\\/jaxws-jbws2150-codefirst/g";
+ setWebServicePathRewriteRule(sedCmd);
+ setWebServiceHost(ServerConfig.UNDEFINED_HOSTNAME);
+ setWebServiceUriScheme("https");
+ deploy("jaxws-jbws2150-codefirst.war");
+ try
+ {
+ String serverHost = getServerHost();
+ final String wsdlLocation = "http://" + serverHost +
":8080/jaxws-jbws2150-codefirst/CodeFirstService?wsdl";
+
+ Definition definition = getWSDLDefinition(wsdlLocation);
+ String address = getPortAddress(definition, "CodeFirstService",
"CodeFirstPort");
+ assertEquals("https://" + serverHost + ":8443/" +
expectedContext +"/CodeFirstService", address);
+ if (isTestsuiteServerHostLocalhost()) {
+ definition =
getWSDLDefinition("http://127.0.0.1:8080/jaxws-jbws2150-codefirst/CodeFirstService?wsdl");
+ address = getPortAddress(definition, "CodeFirstService",
"CodeFirstPort");
+ assertEquals("https://127.0.0.1:8443/" + expectedContext
+"/CodeFirstService", address);
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150-codefirst.war");
+ }
+ }
+
private void checkWsdlAndInvokeCodeFirstEndpoint(String testHost, String
expectedWsdlHost, boolean setTargetAddress) throws Exception {
final String addr = "http://" + testHost +
":8080/jaxws-jbws2150-codefirst/CodeFirstService";
final String wsdlLocation = addr + "?wsdl";
@@ -851,12 +1224,30 @@
getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
}
- public void setWebServicePathRewriteRule(String value) throws Exception
+ private void setWebServicePort(int value) throws Exception
{
+ Attribute attr = new Attribute("WebServicePort", value);
+ getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
+ }
+
+ private void setWebServiceSecurePort(int value) throws Exception
+ {
+ Attribute attr = new Attribute("WebServiceSecurePort", value);
+ getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
+ }
+
+ private void setWebServicePathRewriteRule(String value) throws Exception
+ {
Attribute attr = new Attribute("WebServicePathRewriteRule", value);
getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
}
+ private void setWebServiceUriScheme(String value) throws Exception
+ {
+ Attribute attr = new Attribute("WebServiceUriScheme", value);
+ getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
+ }
+
private ServiceIface getEndpoint(String wsdlLocation, String serviceName) throws
Exception
{
List<WebServiceFeature> features = new
LinkedList<WebServiceFeature>();