Monday, 19 May
2014
Mon, 19 May
'14
2:31 p.m.
Author: asoldano
Date: 2014-05-19 08:31:48 -0400 (Mon, 19 May 2014)
New Revision: 18671
Modified:
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java
Log:
Change to the testcase
Modified:
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java
===================================================================
---
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2014-05-16
14:46:21 UTC (rev 18670)
+++
stack/cxf/branches/rsearls/modules/testsuite/shared-tests/src/test/java/org/jboss/test/ws/jaxws/jbws2150/JBWS2150TestCaseForked.java 2014-05-19
12:31:48 UTC (rev 18671)
@@ -21,7 +21,6 @@
*/
package org.jboss.test.ws.jaxws.jbws2150;
-import java.io.File;
import java.net.URL;
import java.util.Collection;
import java.util.HashMap;
@@ -75,6 +74,7 @@
protected static Boolean modifySOAPAddress;
protected static String webServiceHost;
+ protected static String webServicePath;
public JBWS2150TestSetup() {
super(JBWS2150TestCaseForked.class, null);
@@ -84,6 +84,7 @@
{
modifySOAPAddress = (Boolean)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"ModifySOAPAddress");
webServiceHost = (String)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"WebServiceHost");
+ webServicePath = (String)getServer().getAttribute(SERVER_CONFIG_OBJECT_NAME,
"WebServicePath");
super.setUp();
}
}
@@ -99,6 +100,8 @@
getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
attr = new Attribute("WebServiceHost",
JBWS2150TestSetup.webServiceHost);
getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
+ attr = new Attribute("WebServicePath",
JBWS2150TestSetup.webServicePath);
+ getServer().setAttribute(SERVER_CONFIG_OBJECT_NAME, attr);
}
private String getWebServiceHost() {
@@ -525,82 +528,102 @@
undeploy("jaxws-jbws2150-codefirst.war");
}
}
+
+ /**
+ *
+ *
+ * @throws Exception
+ */
+ public void testRewriteContext() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String addContext = "xx";
+ setWebServicePath(addContext);
+ deploy("jaxws-jbws2150.war");
+ try
+ {
+ final String serverHost = getServerHost();
+ final List<String> wsdlLocations = new LinkedList<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");
+ for (final String wsdlLocation : wsdlLocations)
+ {
+ Definition definition = getWSDLDefinition(wsdlLocation);
- /**
- * Test soap:address replacement of path in URI.
- *
- * @throws Exception
- */
- public void testWebServicePath() throws Exception
- {
- try
- {
- setModifySOAPAddress (true);
- setWebServicePath("xx-jaxws-jbws2150");
- deploy("jaxws-jbws2150.war");
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("http://" + serverHost + ":8080/" +
addContext + "/jaxws-jbws2150/ValidURL", address);
- //---
- final String serverHost = getServerHost();
- final QName serviceName = new QName(NAMESPACE, "ValidURLService");
- final URL wsdlURL = new URL("http://" + serverHost +
":8080/jaxws-jbws2150/ValidURL?wsdl");
- Service service = Service.create(wsdlURL, serviceName);
- URL tmpURL = service.getWSDLDocumentLocation();
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("http://" + serverHost + ":8080/" +
addContext + "/jaxws-jbws2150/InvalidURL", address);
- //---
- /*
- final Map<String, String> wsdlLocationsMap = new HashMap<String,
String>();
- final String serverHost = getServerHost();
- wsdlLocationsMap.put("http://" + serverHost +
":8080/xx-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());
- 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/xx-jaxws-jbws2150/ValidSecureURL?wsdl",
getWebServiceHost());
-
//wsdlLocationsMap.put("http://127.0.0.1:8080/jaxws-jbws2150/InvalidSecureURL?wsdl",
getWebServiceHost());
- }
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("https://" + serverHost + ":8443/" +
addContext + "/jaxws-jbws2150/ValidSecureURL", address);
- for (Entry<String, String> entry : wsdlLocationsMap.entrySet()) {
- String wsdlLocation = entry.getKey();
- String host = entry.getValue();
- Definition definition = getWSDLDefinition(wsdlLocation);
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("https://" + serverHost + ":8443/" +
addContext + "/jaxws-jbws2150/InvalidSecureURL", address);
- String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
- assertEquals("http://" + host +
":8080/jaxws-jbws2150/ValidURL", address);
- //avoid invoking on https endpoints as that would require getting the
imported wsdl using https...
- if (!wsdlLocation.contains("Secure")) {
- ServiceIface endpoint = getEndpoint(wsdlLocation,
"ValidURLService");
- assertEquals(endpoint.echo("hello"), "hello");
- }
+ //check wsdl import (which is bound to the endpoint currently serving the
wsdl)
+ assertTrue(getWsdlImportAddress(definition).contains(addContext +
"/jaxws-jbws2150"));
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150.war");
+ }
+ }
- address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
- assertEquals("http://" + host +
":8080/jaxws-jbws2150/InvalidURL", address);
- // if (!wsdlLocation.contains("Secure")) {
- // ServiceIface endpoint = getEndpoint(wsdlLocation,
"InvalidURLService");
- // assertEquals(endpoint.echo("hello"), "hello");
- // }
+ /**
+ * This is not passing, as the auto rewrite mechanism clashes with the context rewrite
one
+ * (see MetadataBuilder#processAddressRewrite)
+ *
+ * @throws Exception
+ */
+ public void testAutoRewriteContext() throws Exception
+ {
+ setModifySOAPAddress(true);
+ final String addContext = "xx";
+ setWebServicePath(addContext);
+ setWebServiceHost(ServerConfig.UNDEFINED_HOSTNAME);
+ deploy("jaxws-jbws2150.war");
+ try
+ {
+ final String serverHost = getServerHost();
+ final List<String> wsdlLocations = new LinkedList<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");
- address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
- assertEquals("https://" + host +
":8443/jaxws-jbws2150/ValidSecureURL", address);
+ for (final String wsdlLocation : wsdlLocations)
+ {
+ Definition definition = getWSDLDefinition(wsdlLocation);
- // address = getPortAddress(definition,
"InvalidSecureURLService", "InvalidSecureURLPort");
- // assertEquals("https://" + host +
":8443/jaxws-jbws2150/InvalidSecureURL", address);
- }
- */
- } catch (Exception e) { // rls added
- e.printStackTrace(); // rls added
- } // rls added
+ String address = getPortAddress(definition, "ValidURLService",
"ValidURLPort");
+ assertEquals("http://" + serverHost + ":8080/" +
addContext + "/jaxws-jbws2150/ValidURL", address);
- finally
- {
- undeploy("jaxws-jbws2150.war");
- setWebServicePath(null);
- }
- }
+ address = getPortAddress(definition, "InvalidURLService",
"InvalidURLPort");
+ assertEquals("http://" + serverHost + ":8080/" +
addContext + "/jaxws-jbws2150/InvalidURL", address);
- private void checkWsdlAndInvokeCodeFirstEndpoint(String testHost, String
expectedWsdlHost, boolean setTargetAddress) throws Exception {
+ address = getPortAddress(definition, "ValidSecureURLService",
"ValidSecureURLPort");
+ assertEquals("https://" + serverHost + ":8443/" +
addContext + "/jaxws-jbws2150/ValidSecureURL", address);
+
+ address = getPortAddress(definition, "InvalidSecureURLService",
"InvalidSecureURLPort");
+ assertEquals("https://" + serverHost + ":8443/" +
addContext + "/jaxws-jbws2150/InvalidSecureURL", address);
+
+ //check wsdl import (which is bound to the endpoint currently serving the
wsdl)
+ assertTrue(getWsdlImportAddress(definition).contains(addContext +
"/jaxws-jbws2150"));
+ }
+ }
+ finally
+ {
+ undeploy("jaxws-jbws2150.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";