[jboss-svn-commits] JBL Code SVN: r25139 - in labs/jbossesb/trunk/product: services/soap/src/main/java/org/jboss/soa/esb/actions/soap and 2 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Feb 6 10:47:58 EST 2009
Author: tfennelly
Date: 2009-02-06 10:47:58 -0500 (Fri, 06 Feb 2009)
New Revision: 25139
Added:
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/consumer1-wsdl-transform.xml
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisherUnitTest.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-01.xml
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-02.xml
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-04.xml
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.xml
Modified:
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/build.xml
labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/jboss-esb.xml
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlContractPublisher.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlEndpointTransformer.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/JBossWSAdapterContractPublisherUnitTest.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/test-in.wsdl
Log:
https://jira.jboss.org/jira/browse/JBESB-2334
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/build.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/build.xml 2009-02-06 15:06:38 UTC (rev 25138)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/build.xml 2009-02-06 15:47:58 UTC (rev 25139)
@@ -4,14 +4,16 @@
${ant.project.name}
${line.separator}
</description>
-
- <!-- Import the base Ant build script... -->
- <import file="../conf/base-build.xml"/>
+ <property name="additional.deploys" value="consumer1-wsdl-transform.xml" />
+
+ <!-- Import the base Ant build script... -->
+ <import file="../conf/base-build.xml"/>
+
<property name="war.build.dir" location="${build.dir}/war/classes"/>
<target name="quickstart-specific-checks" depends="assert-ws-available"/>
-
+
<target name="quickstart-specific-assemblies" depends="makewar"/>
<target name="makewar" description="make war">
@@ -48,23 +50,23 @@
<target name="undeploy-war" depends="dependencies">
<delete verbose="true" quiet="true"
file="${org.jboss.esb.server.deploy.dir}/${ant.project.name}.war"/>
- </target>
-
- <target name="sendjms" depends="compile">
- <echo>Send ESB message that triggers webservice call</echo>
- <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.webservice_consumer1.test.SendJMSMessage" failonerror="true">
- <arg value="Jimbo"/>
- <classpath refid="exec-classpath"/>
- </java>
-
- </target>
-
- <target name="runtest" depends="compile">
- <echo>Send ESB message that triggers webservice call</echo>
- <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.webservice_consumer1.test.SendEsbMessage" failonerror="true">
- <arg value="Jimbo"/>
- <classpath refid="exec-classpath"/>
- </java>
- </target>
+ </target>
+
+ <target name="sendjms" depends="compile">
+ <echo>Send ESB message that triggers webservice call</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.webservice_consumer1.test.SendJMSMessage" failonerror="true">
+ <arg value="Jimbo"/>
+ <classpath refid="exec-classpath"/>
+ </java>
+
+ </target>
+ <target name="runtest" depends="compile">
+ <echo>Send ESB message that triggers webservice call</echo>
+ <java fork="yes" classname="org.jboss.soa.esb.samples.quickstart.webservice_consumer1.test.SendEsbMessage" failonerror="true">
+ <arg value="Jimbo"/>
+ <classpath refid="exec-classpath"/>
+ </java>
+ </target>
+
</project>
Added: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/consumer1-wsdl-transform.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/consumer1-wsdl-transform.xml (rev 0)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/consumer1-wsdl-transform.xml 2009-02-06 15:47:58 UTC (rev 25139)
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
+ xmlns:g="http://www.milyn.org/xsd/smooks/groovy-1.1.xsd">
+
+ <g:groovy executeOnElement="message,portType">
+ <g:script>
+ DomUtils.removeElement(element, false);
+ </g:script>
+ </g:groovy>
+
+</smooks-resource-list>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/consumer1-wsdl-transform.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/jboss-esb.xml
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/jboss-esb.xml 2009-02-06 15:06:38 UTC (rev 25138)
+++ labs/jbossesb/trunk/product/samples/quickstarts/webservice_consumer1/jboss-esb.xml 2009-02-06 15:47:58 UTC (rev 25139)
@@ -39,9 +39,9 @@
</action>
<action name="soapui-client-action"
class="org.jboss.soa.esb.actions.soap.SOAPClient">
- <property name="wsdl"
- value="http://127.0.0.1:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl" />
- <property name="responseAsOgnlMap" value="true" />
+ <property name="wsdl" value="http://127.0.0.1:8080/Quickstart_webservice_consumer1/HelloWorldWS?wsdl" />
+ <!--property name="wsdlTransform" value="/consumer1-wsdl-transform.xml" / -->
+ <property name="responseAsOgnlMap" value="true" />
<property name="SOAPAction" value="sayHello"/>
</action>
<action name="response-mapper"
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java 2009-02-06 15:06:38 UTC (rev 25138)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisher.java 2009-02-06 15:47:58 UTC (rev 25139)
@@ -27,7 +27,6 @@
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.http.HttpClientFactory;
import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.wsf.spi.deployment.Endpoint;
import org.xml.sax.SAXException;
import org.milyn.container.ExecutionContext;
import org.milyn.Smooks;
@@ -41,7 +40,6 @@
import java.io.StringReader;
import java.io.InputStream;
import java.net.URI;
-import java.net.URL;
import java.util.Properties;
import java.lang.reflect.Proxy;
import java.lang.reflect.InvocationHandler;
@@ -53,11 +51,12 @@
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
public abstract class AbstractWsdlContractPublisher implements ActionContractPublisher, ServletContractPublisher {
-
+
private static Logger logger = Logger.getLogger(AbstractWsdlContractPublisher.class);
public static final String REWRITE_ENDPOINT_URL = "rewrite-endpoint-url";
+ private Properties actionProperties;
private boolean rewriteEndpointUrl = true;
private Smooks transformer;
@@ -67,17 +66,25 @@
* @throws ConfigurationException Bad config.
*/
public void setActionConfig(Action actionConfig) throws ConfigurationException {
- final Properties properties = actionConfig.getProperties();
+ actionProperties = actionConfig.getProperties();
- final String rewriteEndpointUrlVal = properties.getProperty(AbstractWsdlContractPublisher.REWRITE_ENDPOINT_URL);
+ final String rewriteEndpointUrlVal = actionProperties.getProperty(AbstractWsdlContractPublisher.REWRITE_ENDPOINT_URL);
if (rewriteEndpointUrlVal != null) {
rewriteEndpointUrl = !rewriteEndpointUrlVal.equals("false");
}
- initializeEndpointRewriteTransformer();
+ initializeTransformer();
}
/**
+ * Get the action properties.
+ * @return The action properties.
+ */
+ public Properties getActionProperties() {
+ return actionProperties;
+ }
+
+ /**
* Get the WSDL Address.
* @return The WSDL address.
*/
@@ -149,7 +156,7 @@
try {
Properties httpClientProperties = getHttpClientProperties();
- httpClientProperties = (Properties) httpClientProperties.clone();
+ httpClientProperties = (Properties) httpClientProperties.clone();
if(!httpClientProperties.containsKey(HttpClientFactory.TARGET_HOST_URL)) {
httpClientProperties.setProperty(HttpClientFactory.TARGET_HOST_URL, wsdlAddress);
}
@@ -178,7 +185,7 @@
* @param targetProtocol @return The updated WSDL.
*/
protected String updateWsdl(String wsdl, EPR epr, String targetServiceCat, String targetServiceName, String targetProtocol) throws SAXException, IOException, ConfigurationException {
- wsdl = rewriteEndpointAddresses(wsdl, epr, targetServiceCat, targetServiceName, targetProtocol);
+ wsdl = applyTransformer(wsdl, epr, targetServiceCat, targetServiceName, targetProtocol);
return wsdl.trim();
}
@@ -187,13 +194,26 @@
* Initialize the endpoint rewriting transformer.
* @throws ConfigurationException Failed to initialize transformer.
*/
- protected void initializeEndpointRewriteTransformer() throws ConfigurationException {
+ protected void initializeTransformer() throws ConfigurationException {
try {
+ // Initialise the transformer with the rewriting resource configs...
transformer = new Smooks("/org/jboss/soa/esb/actions/soap/wsdltrans.xml");
+
+ // And add the user defined config, if there is one....
+ String wsdlTransformConfig = actionProperties.getProperty("wsdlTransform");
+ if(wsdlTransformConfig != null) {
+ try {
+ transformer.addConfigurations(wsdlTransformConfig);
+ } catch (IOException e) {
+ throw new ConfigurationException("Failed to read the User Defined WSDL Transformation config '" + wsdlTransformConfig + "'.", e);
+ } catch (SAXException e) {
+ throw new ConfigurationException("Failed to read the User Defined WSDL Transformation config '" + wsdlTransformConfig + "'.", e);
+ }
+ }
} catch (IOException e) {
- throw new ConfigurationException("Failed to read the Smooks Transformation config for WSDL.", e);
+ throw new ConfigurationException("Failed to read the Endpoint Transformation config for WSDL.", e);
} catch (SAXException e) {
- throw new ConfigurationException("Failed to read the Smooks Transformation config for WSDL.", e);
+ throw new ConfigurationException("Failed to read the Endpoint Transformation config for WSDL.", e);
}
}
@@ -206,26 +226,23 @@
* @param targetProtocol The target protocol.
* @return The rewritten WSDL.
*/
- private String rewriteEndpointAddresses(String wsdl, EPR epr, String targetServiceCat, String targetServiceName, String targetProtocol) {
- if(!rewriteEndpointUrl && targetProtocol.startsWith("http")) {
- // return the wsdl unchanged...
- return wsdl;
- }
-
+ private String applyTransformer(String wsdl, EPR epr, String targetServiceCat, String targetServiceName, String targetProtocol) {
URI endpointURI = URI.create(epr.getAddr().getAddress());
StringWriter writer = new StringWriter();
ExecutionContext execContext = transformer.createExecutionContext();
+ execContext.setAttribute(WsdlEndpointTransformer.REWRITE_ENDPOINT_URL, rewriteEndpointUrl);
execContext.setAttribute(WsdlEndpointTransformer.ENDPOINT_URI, endpointURI);
- execContext.setAttribute(WsdlEndpointTransformer.TARGET_CAT, targetServiceCat);
- execContext.setAttribute(WsdlEndpointTransformer.TARGET_NAME, targetServiceName);
- execContext.setAttribute(WsdlEndpointTransformer.TARGET_PROTOCOL, targetProtocol);
+ execContext.setAttribute(WsdlEndpointTransformer.TARGET_CAT, (targetServiceCat != null?targetServiceCat:""));
+ execContext.setAttribute(WsdlEndpointTransformer.TARGET_NAME, (targetServiceName != null?targetServiceName:""));
+ execContext.setAttribute(WsdlEndpointTransformer.TARGET_PROTOCOL, (targetProtocol != null?targetProtocol:""));
transformer.filter(new StreamSource(new StringReader(wsdl)), new StreamResult(writer), execContext);
return writer.toString().trim();
}
private class HttpServletRequestHandler implements InvocationHandler {
+
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
if(method.getName().equals("getRequestURL")) {
return new StringBuffer("http://www.jboss.org");
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlContractPublisher.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlContractPublisher.java 2009-02-06 15:06:38 UTC (rev 25138)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlContractPublisher.java 2009-02-06 15:47:58 UTC (rev 25139)
@@ -30,24 +30,16 @@
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
public class WsdlContractPublisher extends AbstractWsdlContractPublisher {
-
- private Properties properties;
public void setActionConfig(Action actionConfig) throws ConfigurationException {
super.setActionConfig(actionConfig);
-
- properties = actionConfig.getProperties();
}
public String getWsdlAddress() {
- return properties.getProperty("wsdl");
+ return getActionProperties().getProperty("wsdl");
}
- public Properties getProperties() {
- return properties;
- }
-
public Properties getHttpClientProperties() {
- return properties;
+ return getActionProperties();
}
}
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlEndpointTransformer.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlEndpointTransformer.java 2009-02-06 15:06:38 UTC (rev 25138)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/WsdlEndpointTransformer.java 2009-02-06 15:47:58 UTC (rev 25139)
@@ -19,12 +19,10 @@
*/
package org.jboss.soa.esb.actions.soap;
-import org.milyn.delivery.dom.DOMElementVisitor;
+import org.milyn.delivery.dom.DOMVisitAfter;
import org.milyn.container.ExecutionContext;
import org.milyn.SmooksException;
import org.milyn.xml.DomUtils;
-import org.milyn.cdr.SmooksResourceConfiguration;
-import org.milyn.cdr.SmooksConfigurationException;
import org.w3c.dom.Element;
import org.apache.log4j.Logger;
@@ -36,24 +34,26 @@
*
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
-public class WsdlEndpointTransformer implements DOMElementVisitor {
+public class WsdlEndpointTransformer implements DOMVisitAfter {
private static Logger logger = Logger.getLogger(WsdlEndpointTransformer.class);
+ public static final String REWRITE_ENDPOINT_URL = "rewriteEndpointUrl";
public static final String ENDPOINT_URI = "endpointURI";
public static final String TARGET_CAT = "targetServiceCat";
public static final String TARGET_NAME = "targetServiceName";
public static final String TARGET_PROTOCOL = "targetProtocol";
- public void setConfiguration(SmooksResourceConfiguration smooksResourceConfiguration) throws SmooksConfigurationException {
- }
-
- public void visitBefore(Element element, ExecutionContext executionContext) throws SmooksException {
- }
-
public void visitAfter(Element element, ExecutionContext executionContext) throws SmooksException {
String elementName = DomUtils.getName(element);
+ boolean rewriteEndpointUrl = (Boolean) executionContext.getAttribute(WsdlEndpointTransformer.REWRITE_ENDPOINT_URL);
+ URI endpointURI = (URI) executionContext.getAttribute(ENDPOINT_URI);
+ if(!rewriteEndpointUrl && endpointURI.getScheme().startsWith("http")) {
+ // Don't perform any rewriting ops...
+ return;
+ }
+
if(elementName.equals("import")) {
transformImport(element, executionContext);
} else if(elementName.equals("binding")) {
@@ -75,9 +75,9 @@
String addParams = "serviceCat=" + targetServiceCat + "&serviceName=" + targetServiceName + "&protocol=" + targetProtocol;
if(locationURI.getQuery() != null) {
- element.setAttribute("location", (locationURI.toString() + "&" + addParams).replace("&", "&"));
+ element.setAttribute("location", (locationURI.toString() + "&" + addParams));
} else {
- element.setAttribute("location", (locationURI.toString() + "?" + addParams).replace("&", "&"));
+ element.setAttribute("location", (locationURI.toString() + "?" + addParams));
}
} catch (URISyntaxException e) {
logger.info("Not processing WSDL import '" + location + "'. Invalid URI.");
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java 2009-02-06 15:06:38 UTC (rev 25138)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WiseWsdlContractPublisher.java 2009-02-06 15:47:58 UTC (rev 25139)
@@ -19,9 +19,6 @@
*/
package org.jboss.soa.esb.actions.soap.wise;
-import org.jboss.soa.esb.listeners.config.Action;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.actions.soap.AbstractWsdlContractPublisher;
import org.jboss.soa.esb.actions.soap.WsdlContractPublisher;
import java.util.Properties;
@@ -32,9 +29,10 @@
* @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
*/
public class WiseWsdlContractPublisher extends WsdlContractPublisher {
+ private Properties properties;
public Properties getHttpClientProperties() {
- Properties httpClientProperties = (Properties) getProperties().clone();
+ Properties httpClientProperties = (Properties) getActionProperties().clone();
String configurators = httpClientProperties.getProperty("configurators");
// Handle potential Http BASIC Auth....
@@ -58,4 +56,8 @@
return httpClientProperties;
}
+
+ public Properties getActionProperties() {
+ return properties;
+ }
}
\ No newline at end of file
Added: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisherUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisherUnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisherUnitTest.java 2009-02-06 15:47:58 UTC (rev 25139)
@@ -0,0 +1,105 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2008, Red Hat Middleware LLC, and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA 02110-1301, USA.
+ *
+ * (C) 2005-2008, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap;
+
+import junit.framework.TestCase;
+
+import java.util.Properties;
+import java.io.File;
+import java.io.StringReader;
+import java.io.InputStreamReader;
+import java.io.IOException;
+import java.net.MalformedURLException;
+import java.net.URI;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+import org.jboss.soa.esb.listeners.config.Action;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.internal.soa.esb.publish.ContractInfo;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.custommonkey.xmlunit.XMLAssert;
+import org.xml.sax.SAXException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class AbstractWsdlContractPublisherUnitTest extends TestCase {
+
+ public void test_transform_01() throws ConfigurationException, IOException, SAXException {
+ Action actionConfig = new Action(null, null, null, new Properties());
+
+ actionConfig.getProperties().setProperty("rewrite-endpoint-url", "true");
+ actionConfig.getProperties().setProperty("wsdlTransform", "/org/jboss/soa/esb/actions/soap/wsdl-transform.xml");
+ execTransformTest(actionConfig, "wsdl-transform.expected-01.xml"); // Both transforms
+ }
+
+ public void test_transform_02() throws ConfigurationException, IOException, SAXException {
+ Action actionConfig = new Action(null, null, null, new Properties());
+
+ actionConfig.getProperties().setProperty("rewrite-endpoint-url", "false");
+ actionConfig.getProperties().setProperty("wsdlTransform", "/org/jboss/soa/esb/actions/soap/wsdl-transform.xml");
+ execTransformTest(actionConfig, "wsdl-transform.expected-02.xml"); // Just the user defined transform
+ }
+
+ public void test_transform_03() throws ConfigurationException, IOException, SAXException {
+ Action actionConfig = new Action(null, null, null, new Properties());
+
+ actionConfig.getProperties().setProperty("rewrite-endpoint-url", "false");
+ execTransformTest(actionConfig, "test-in.wsdl"); // Neither transforms - should be unchanged from the in-wsdl
+ }
+
+ public void test_transform_04() throws ConfigurationException, IOException, SAXException {
+ Action actionConfig = new Action(null, null, null, new Properties());
+
+ actionConfig.getProperties().setProperty("rewrite-endpoint-url", "true");
+ execTransformTest(actionConfig, "wsdl-transform.expected-04.xml"); // Just the url rewriting transform
+ }
+
+ private void execTransformTest(Action actionConfig, String expected) throws ConfigurationException, SAXException, IOException {
+ TestWsdlContractPublisher publisher = new TestWsdlContractPublisher();
+ publisher.setActionConfig(actionConfig);
+ ContractInfo contractInfo = publisher.getContractInfo(new EPR(URI.create("http://x.y.x:8989/")));
+
+ //System.out.println(contractInfo.getData());
+ XMLUnit.setIgnoreWhitespace( true );
+ XMLAssert.assertXMLEqual(new InputStreamReader(getClass().getResourceAsStream(expected)), new StringReader(contractInfo.getData()));
+ }
+
+ private class TestWsdlContractPublisher extends AbstractWsdlContractPublisher {
+
+ public String getWsdlAddress() {
+ // cwd needs to be the root of the "soap" service
+ File testFile = new File("services/soap/src/test/java/org/jboss/soa/esb/actions/soap/test-in.wsdl");
+
+ try {
+ return testFile.toURL().toString();
+ } catch (MalformedURLException e) {
+ fail("Failed to create URL object from file path: " + e.getMessage());
+ return null;
+ }
+ }
+
+ public Properties getHttpClientProperties() {
+ return getActionProperties();
+ }
+ }
+}
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/AbstractWsdlContractPublisherUnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/JBossWSAdapterContractPublisherUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/JBossWSAdapterContractPublisherUnitTest.java 2009-02-06 15:06:38 UTC (rev 25138)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/JBossWSAdapterContractPublisherUnitTest.java 2009-02-06 15:47:58 UTC (rev 25139)
@@ -27,8 +27,12 @@
import org.jboss.soa.esb.listeners.config.Action;
import org.jboss.soa.esb.testutils.StringUtils;
import org.xml.sax.SAXException;
+import org.custommonkey.xmlunit.XMLUnit;
+import org.custommonkey.xmlunit.XMLAssert;
import java.io.IOException;
+import java.io.InputStreamReader;
+import java.io.StringReader;
import java.net.URI;
import java.util.Properties;
@@ -44,10 +48,13 @@
String wsdlOutExpected = new String(StreamUtils.readStream(getClass().getResourceAsStream("test-out-expected.wsdl")));
EPR epr = new EPR(URI.create("socket://x.y.x:8989/"));
- publisher.initializeEndpointRewriteTransformer();
+ publisher.setActionConfig(buildActionConfig(true));
+ publisher.initializeTransformer();
String wsdlOut = publisher.updateWsdl(wsdlIn, epr, "myServiceCat", "myServiceName", "socket");
log.debug(wsdlOut);
- assertTrue("WSDL Update failed. \n\n*** Expected:\n\n" + wsdlOutExpected + "\n\n*** Got:\n\n" + wsdlOut, StringUtils.equalsIgnoreLinebreaks(wsdlOutExpected, wsdlOut, false));
+
+ XMLUnit.setIgnoreWhitespace( true );
+ XMLAssert.assertXMLEqual(new StringReader(wsdlOutExpected), new StringReader(wsdlOut));
}
public void test_http_rewrite() throws ConfigurationException, IOException, SAXException {
@@ -58,10 +65,12 @@
publisher.setActionConfig(buildActionConfig(true));
- publisher.initializeEndpointRewriteTransformer();
+ publisher.initializeTransformer();
String wsdlOut = publisher.updateWsdl(wsdlIn, epr, "myServiceCat", "myServiceName", "http");
log.debug(wsdlOut);
- assertTrue("WSDL Update failed. \n\n*** Expected:\n\n" + wsdlOutExpected + "\n\n*** Got:\n\n" + wsdlOut, StringUtils.equalsIgnoreLinebreaks(wsdlOutExpected, wsdlOut, false));
+
+ XMLUnit.setIgnoreWhitespace( true );
+ XMLAssert.assertXMLEqual(new StringReader(wsdlOutExpected), new StringReader(wsdlOut));
}
public void test_http_norewrite() throws ConfigurationException, IOException, SAXException {
@@ -72,10 +81,11 @@
publisher.setActionConfig(buildActionConfig(false));
- publisher.initializeEndpointRewriteTransformer();
+ publisher.initializeTransformer();
String wsdlOut = publisher.updateWsdl(wsdlIn, epr, "myServiceCat", "myServiceName", "http");
log.debug(wsdlOut);
- assertTrue("WSDL Update failed. \n\n*** Expected:\n\n" + wsdlOutExpected + "\n\n*** Got:\n\n" + wsdlOut, StringUtils.equalsIgnoreLinebreaks(wsdlOutExpected, wsdlOut, false));
+ XMLUnit.setIgnoreWhitespace( true );
+ XMLAssert.assertXMLEqual(new StringReader(wsdlOutExpected), new StringReader(wsdlOut));
}
private Action buildActionConfig(boolean rewriteUrls) {
Modified: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/test-in.wsdl
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/test-in.wsdl 2009-02-06 15:06:38 UTC (rev 25138)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/test-in.wsdl 2009-02-06 15:47:58 UTC (rev 25139)
@@ -1,4 +1,3 @@
-<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webservice_war1/goodbyeworld" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="GoodbyeWorldWSService" targetNamespace="http://webservice_war1/goodbyeworld">
<import location="http://127.0.0.1:8080/contract/contract.jsp?wsdl&resource=MTOMEndpoint_PortType61314.wsdl" namespace="http://org.jboss.ws/xop/doclit"/>
<types/>
Added: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-01.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-01.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-01.xml 2009-02-06 15:47:58 UTC (rev 25139)
@@ -0,0 +1,38 @@
+<definitions name="GoodbyeWorldWSService" targetNamespace="http://webservice_war1/goodbyeworld" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webservice_war1/goodbyeworld" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <import location="http://127.0.0.1:8080/contract/contract.jsp?wsdl&resource=MTOMEndpoint_PortType61314.wsdl&serviceCat=&serviceName=&protocol=" namespace="http://org.jboss.ws/xop/doclit"/>
+ <types/>
+
+
+
+
+
+
+ <binding name="GoodbyeWorldWSBinding" type="tns:ReptilesNotifyWS">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="sayGoodbye">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+ </input>
+ <output>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+
+ </output>
+ </operation>
+ <operation name="sayGoodbyeWithoutResponse">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+ </input>
+ <output>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+
+ </output>
+ </operation>
+ </binding>
+ <service name="GoodbyeWorldWSService">
+ <port binding="tns:GoodbyeWorldWSBinding" name="GoodbyeWorldWSPort">
+ <soap:address location="http://x.y.x:8989/"/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-01.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-02.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-02.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-02.xml 2009-02-06 15:47:58 UTC (rev 25139)
@@ -0,0 +1,38 @@
+<definitions name="GoodbyeWorldWSService" targetNamespace="http://webservice_war1/goodbyeworld" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webservice_war1/goodbyeworld" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <import location="http://127.0.0.1:8080/contract/contract.jsp?wsdl&resource=MTOMEndpoint_PortType61314.wsdl" namespace="http://org.jboss.ws/xop/doclit"/>
+ <types/>
+
+
+
+
+
+
+ <binding name="GoodbyeWorldWSBinding" type="tns:ReptilesNotifyWS">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="sayGoodbye">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+ </input>
+ <output>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+
+ </output>
+ </operation>
+ <operation name="sayGoodbyeWithoutResponse">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+ </input>
+ <output>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+
+ </output>
+ </operation>
+ </binding>
+ <service name="GoodbyeWorldWSService">
+ <port binding="tns:GoodbyeWorldWSBinding" name="GoodbyeWorldWSPort">
+ <soap:address location="http://tfennelly:8080/Quickstart_webservice_jbossws_adapter_01/GoodbyeWorldWS"/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-02.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-04.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-04.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-04.xml 2009-02-06 15:47:58 UTC (rev 25139)
@@ -0,0 +1,55 @@
+<definitions name="GoodbyeWorldWSService" targetNamespace="http://webservice_war1/goodbyeworld" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://webservice_war1/goodbyeworld" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
+ <import location="http://127.0.0.1:8080/contract/contract.jsp?wsdl&resource=MTOMEndpoint_PortType61314.wsdl&serviceCat=&serviceName=&protocol=" namespace="http://org.jboss.ws/xop/doclit"/>
+ <types/>
+ <message name="GoodbyeWorldWS_sayGoodbyeWithoutResponse">
+ <part name="String_1" type="xsd:string"/>
+
+ </message>
+ <message name="GoodbyeWorldWS_sayGoodbye">
+ <part name="String_1" type="xsd:string"/>
+ </message>
+ <message name="GoodbyeWorldWS_sayGoodbyeWithoutResponseResponse"/>
+ <message name="GoodbyeWorldWS_sayGoodbyeResponse">
+ <part name="result" type="xsd:string"/>
+ </message>
+ <portType name="ReptilesNotifyWS">
+
+ <operation name="sayGoodbye" parameterOrder="String_1">
+ <input message="tns:GoodbyeWorldWS_sayGoodbye"/>
+ <output message="tns:GoodbyeWorldWS_sayGoodbyeResponse"/>
+ </operation>
+ <operation name="sayGoodbyeWithoutResponse" parameterOrder="String_1">
+ <input message="tns:GoodbyeWorldWS_sayGoodbyeWithoutResponse"/>
+ <output message="tns:GoodbyeWorldWS_sayGoodbyeWithoutResponseResponse"/>
+ </operation>
+ </portType>
+
+ <binding name="GoodbyeWorldWSBinding" type="tns:ReptilesNotifyWS">
+ <soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
+ <operation name="sayGoodbye">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+ </input>
+ <output>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+
+ </output>
+ </operation>
+ <operation name="sayGoodbyeWithoutResponse">
+ <soap:operation soapAction=""/>
+ <input>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+ </input>
+ <output>
+ <soap:body namespace="http://webservice_war1/goodbyeworld" use="literal"/>
+
+ </output>
+ </operation>
+ </binding>
+ <service name="GoodbyeWorldWSService">
+ <port binding="tns:GoodbyeWorldWSBinding" name="GoodbyeWorldWSPort">
+ <soap:address location="http://x.y.x:8989/"/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.expected-04.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.xml 2009-02-06 15:47:58 UTC (rev 25139)
@@ -0,0 +1,11 @@
+<?xml version="1.0"?>
+<smooks-resource-list xmlns="http://www.milyn.org/xsd/smooks-1.1.xsd"
+ xmlns:g="http://www.milyn.org/xsd/smooks/groovy-1.1.xsd">
+
+ <g:groovy executeOnElement="message,portType">
+ <g:script>
+ DomUtils.removeElement(element, false);
+ </g:script>
+ </g:groovy>
+
+</smooks-resource-list>
\ No newline at end of file
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wsdl-transform.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list