[jboss-svn-commits] JBL Code SVN: r20835 - in labs/jbossesb/trunk/product: rosetta/tests/src/org/jboss/soa/esb/listeners and 8 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Jun 28 05:55:40 EDT 2008
Author: tfennelly
Date: 2008-06-28 05:55:40 -0400 (Sat, 28 Jun 2008)
New Revision: 20835
Added:
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbr/
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbr/JBRServer.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbr/StaticRequestResponseHandler.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/MBeanSoapUIInvoker.java
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClient_Response_UnitTest.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/MockSOAPClient.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/SOAPClient_Request_UnitTest.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/expected-soap-request.xml
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/request-test-01.wsdl
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/soapclient-request-config-01.xml
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/soapclient-request-config-02.xml
Removed:
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java
labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java
Modified:
labs/jbossesb/trunk/product/rosetta/build.xml
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/SetPayloadAction.java
labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/TestEnvironmentUtil.java
labs/jbossesb/trunk/product/samples/quickstarts/https_2way_ssl/src/org/jboss/soa/esb/samples/https/server/HttpRequestPrinter.java
labs/jbossesb/trunk/product/samples/quickstarts/huge-split-enrich-transform-route/03_High_Price/src/org/jboss/soa/esb/example/highprice/Address.java
labs/jbossesb/trunk/product/services/soap/build.xml
labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
Log:
http://jira.jboss.com/jira/browse/JBESB-1795
Modified: labs/jbossesb/trunk/product/rosetta/build.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/build.xml 2008-06-28 09:27:01 UTC (rev 20834)
+++ labs/jbossesb/trunk/product/rosetta/build.xml 2008-06-28 09:55:40 UTC (rev 20835)
@@ -88,6 +88,7 @@
<fileset dir="${org.jboss.esb.internal.dest}/tests/"
includes="org/jboss/soa/esb/testutils/**/*.class"/>
<fileset dir="tests/src" includes="org/jboss/soa/esb/testutils/*.properties"/>
+ <fileset dir="tests/src" includes="org/jboss/soa/esb/testutils/*.xml"/>
<fileset dir="${org.jboss.esb.internal.dest}/tests/"
includes="org/jboss/soa/esb/common/tests/*.class"/>
<fileset dir="${org.jboss.esb.internal.dest}/tests/"
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/SetPayloadAction.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/SetPayloadAction.java 2008-06-28 09:27:01 UTC (rev 20834)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/SetPayloadAction.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -1,18 +1,22 @@
/*
- Milyn - Copyright (C) 2006
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License (version 2.1) as published by the Free Software
- Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- See the GNU Lesser General Public License for more details:
- http://www.gnu.org/licenses/lgpl.txt
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
package org.jboss.soa.esb.listeners;
import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/TestEnvironmentUtil.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/TestEnvironmentUtil.java 2008-06-28 09:27:01 UTC (rev 20834)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/TestEnvironmentUtil.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -5,8 +5,8 @@
import java.io.*;
import java.sql.DriverManager;
+import java.sql.SQLException;
import java.sql.Statement;
-import java.sql.SQLException;
import java.util.Properties;
public class TestEnvironmentUtil
@@ -15,7 +15,7 @@
public static String getUserDir()
{
- return getUserDir("product");
+ return getUserDir("product");
}
public static String getBaseDir()
@@ -128,7 +128,7 @@
database = "hsqldb";
//Bring up hsql on default port 9001
try {
- HsqldbUtil.startHsqldb(TestEnvironmentUtil.getUserDir() + "build/hsqltestdb", "juddi");
+ HsqldbUtil.startHsqldb(TestEnvironmentUtil.getProductDir() + "build/hsqltestdb", "juddi");
} catch (Exception e) {
TestCase.fail("Failed to start HSQLDB: " + e.getMessage());
}
@@ -137,7 +137,7 @@
} //add and test your own database..
//Get the registry-schema create scripts
- String sqlDir = TestEnvironmentUtil.getUserDir() + "install/jUDDI-registry/sql/" + database + "/";
+ String sqlDir = TestEnvironmentUtil.getProductDir() + "install/jUDDI-registry/sql/" + database + "/";
//Drop what is there now, if exists. We want to start fresh.
String sqlDropCmd = null;
try {
@@ -150,8 +150,8 @@
String sqlCreateCmd = null;
try {
sqlCreateCmd = FileUtil.readStream(is).trim().replaceAll("\\$\\{prefix}", "");
- } catch (IOException e) {
- TestCase.fail("Failed to read create_database.sql: " + e.getMessage());
+ } catch (Exception e) {
+ TestCase.fail("Failed to read '" + resource + "' from classpath: " + e.getMessage());
}
String sqlInsertPubCmd = null;
try {
@@ -176,7 +176,35 @@
stmnt.execute(sqlInsertPubCmd);
}
-
+
+ public static String getProductDir() {
+ File workingDir = new File(new File("./").getAbsolutePath());
+
+ // are we in the project root dir...
+ if(isProjectRootDir(workingDir)) {
+ return "product/";
+ } else {
+ // OK... drop back dir-by-dir until we reach the 'product' dir or the filesys root....
+ StringBuilder stringBuilder = new StringBuilder("product/");
+ File parentDir = workingDir.getParentFile();
+
+ while(parentDir != null && !isProjectRootDir(parentDir)) {
+ stringBuilder.insert(0, "../");
+ parentDir = parentDir.getParentFile();
+ }
+
+ if(parentDir == null) {
+ throw new RuntimeException("Unable to establish the relative location of the project's 'product' directory from current working directory '" + workingDir.getAbsolutePath() + "'.");
+ }
+
+ return stringBuilder.toString();
+ }
+ }
+
+ private static boolean isProjectRootDir(File dir) {
+ return new File(dir, "product/services/jbossesb").exists();
+ }
+
public static void stopJAXRDatabase() throws Exception {
Properties props = getJuddiProperties();
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbr/JBRServer.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbr/JBRServer.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbr/JBRServer.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.testutils.jbr;
+
+import org.jboss.remoting.InvokerLocator;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.transport.Connector;
+
+import java.util.Map;
+import java.util.HashMap;
+
+/**
+ * JBoss Remoting Server utility for testing.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class JBRServer {
+
+ private String serverURI;
+ private Connector connector;
+ private boolean isStarted = false;
+
+ public JBRServer(String serverURI, ServerInvocationHandler handler) throws Exception {
+ this(serverURI, handler, new HashMap<String, String>());
+ }
+
+ public JBRServer(String serverURI, ServerInvocationHandler handler, Map<String, String> connectorConfig) throws Exception {
+ InvokerLocator locator = new InvokerLocator(serverURI);
+
+ this.serverURI = serverURI;
+ connector = new Connector(locator, connectorConfig);
+ connector.create();
+ connector.addInvocationHandler(handler.getClass().getName(), handler);
+ }
+
+ public void start() throws Exception {
+ if(isStarted) {
+ throw new RuntimeException("Server '" + serverURI + "' already started.");
+ }
+ connector.start();
+ isStarted = true;
+ }
+
+ public void stop() {
+ if(!isStarted) {
+ throw new RuntimeException("Server '" + serverURI + "' not started.");
+ }
+ connector.stop();
+ isStarted = false;
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbr/JBRServer.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbr/StaticRequestResponseHandler.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbr/StaticRequestResponseHandler.java (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbr/StaticRequestResponseHandler.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -0,0 +1,92 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.testutils.jbr;
+
+import junit.framework.TestCase;
+import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.jboss.remoting.InvocationRequest;
+import org.jboss.remoting.ServerInvocationHandler;
+import org.jboss.remoting.ServerInvoker;
+import org.jboss.remoting.callback.InvokerCallbackHandler;
+import org.jboss.soa.esb.testutils.StringUtils;
+
+import javax.management.MBeanServer;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.UnsupportedEncodingException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class StaticRequestResponseHandler implements ServerInvocationHandler {
+
+ private String response;
+ private String expectedRequest;
+
+ public StaticRequestResponseHandler(String response) {
+ this.response = response;
+ }
+
+ public StaticRequestResponseHandler(InputStream response) {
+ this.response = readStream(response);
+ }
+
+ public void setExpectedRequest(String expectedRequest) {
+ this.expectedRequest = expectedRequest;
+ }
+
+ public void setExpectedRequest(InputStream expectedRequest) {
+ this.expectedRequest = readStream(expectedRequest);
+ }
+
+ public Object invoke(InvocationRequest invocationRequest) throws Throwable {
+ if(expectedRequest != null) {
+ String payload = (String) invocationRequest.getParameter();
+ TestCase.assertTrue(StringUtils.equalsIgnoreLinebreaks(expectedRequest, payload, false));
+ }
+ return response;
+ }
+
+ private String readStream(InputStream response) {
+ try {
+ return StreamUtils.readStreamString(response, "UTF-8");
+ } catch (UnsupportedEncodingException e) {
+ throw new RuntimeException("Error reading stream.");
+ } finally {
+ try {
+ response.close();
+ } catch (IOException e) {
+ throw new RuntimeException("Error closing stream.");
+ }
+ }
+ }
+
+ public void setMBeanServer(MBeanServer mBeanServer) {
+ }
+
+ public void setInvoker(ServerInvoker serverInvoker) {
+ }
+
+ public void addListener(InvokerCallbackHandler invokerCallbackHandler) {
+ }
+
+ public void removeListener(InvokerCallbackHandler invokerCallbackHandler) {
+ }
+}
Property changes on: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbr/StaticRequestResponseHandler.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/samples/quickstarts/https_2way_ssl/src/org/jboss/soa/esb/samples/https/server/HttpRequestPrinter.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/https_2way_ssl/src/org/jboss/soa/esb/samples/https/server/HttpRequestPrinter.java 2008-06-28 09:27:01 UTC (rev 20834)
+++ labs/jbossesb/trunk/product/samples/quickstarts/https_2way_ssl/src/org/jboss/soa/esb/samples/https/server/HttpRequestPrinter.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -1,18 +1,22 @@
/*
- Milyn - Copyright (C) 2006
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License (version 2.1) as published by the Free Software
- Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- See the GNU Lesser General Public License for more details:
- http://www.gnu.org/licenses/lgpl.txt
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
package org.jboss.soa.esb.samples.https.server;
import org.jboss.soa.esb.actions.AbstractActionLifecycle;
Modified: labs/jbossesb/trunk/product/samples/quickstarts/huge-split-enrich-transform-route/03_High_Price/src/org/jboss/soa/esb/example/highprice/Address.java
===================================================================
--- labs/jbossesb/trunk/product/samples/quickstarts/huge-split-enrich-transform-route/03_High_Price/src/org/jboss/soa/esb/example/highprice/Address.java 2008-06-28 09:27:01 UTC (rev 20834)
+++ labs/jbossesb/trunk/product/samples/quickstarts/huge-split-enrich-transform-route/03_High_Price/src/org/jboss/soa/esb/example/highprice/Address.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -1,18 +1,22 @@
/*
- Milyn - Copyright (C) 2006
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Lesser General Public
- License (version 2.1) as published by the Free Software
- Foundation.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-
- See the GNU Lesser General Public License for more details:
- http://www.gnu.org/licenses/lgpl.txt
-*/
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
package org.jboss.soa.esb.example.highprice;
import java.io.Serializable;
Modified: labs/jbossesb/trunk/product/services/soap/build.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soap/build.xml 2008-06-28 09:27:01 UTC (rev 20834)
+++ labs/jbossesb/trunk/product/services/soap/build.xml 2008-06-28 09:55:40 UTC (rev 20835)
@@ -16,6 +16,11 @@
<!-- Adding the Smooks jars... -->
<fileset dir="../smooks/lib/ext" includes="*.jar"/>
+
+ <!-- Stuff required for testing... -->
+ <fileset dir="../../lib/ext" includes="*.jar"/>
+ <fileset dir="../soapui-client/src/lib" includes="*.jar"/>
+ <pathelement location="../soapui-client/target/classes" />
</path>
</project>
Copied: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/MBeanSoapUIInvoker.java (from rev 20792, labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java)
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/MBeanSoapUIInvoker.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/MBeanSoapUIInvoker.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap;
+
+import org.jboss.mx.util.MBeanServerLocator;
+import org.xml.sax.SAXException;
+
+import javax.management.*;
+import java.util.Map;
+import java.util.Properties;
+import java.io.IOException;
+
+/**
+ * Invoker the soapui-client Service.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class MBeanSoapUIInvoker implements SoapUIInvoker {
+
+ private static final String[] buildRequestSig = new String[] {String.class.getName(), String.class.getName(), Map.class.getName(), Properties.class.getName(), String.class.getName(), String.class.getName()};
+ private static final String[] getEndpointSig = new String[] {String.class.getName(), Properties.class.getName()};
+ private MBeanServer mbeanServer;
+ private ObjectName serviceName;
+
+ public MBeanSoapUIInvoker() {
+ // Lookup the MBean ObjectName for the soapUI service (in soapui-client.sar)...
+ try {
+ mbeanServer = MBeanServerLocator.locateJBoss();
+ serviceName = new ObjectName("jboss.esb:service=SoapUIClientService");
+ } catch (MalformedObjectNameException e) {
+ throw new IllegalStateException("Unexpected exception.", e);
+ }
+ }
+
+ /**
+ * Build a SOAP request for the specified operation on the specified WSDL.
+ *
+ * @param wsdl WSDL URL.
+ * @param operation Operation name.
+ * @param params Message parameter map.
+ * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
+ * @param smooksResource {@link org.milyn.Smooks} transformation configuration resource file.
+ * Null if no transformations are to be performed on the SOAP message before serializing it
+ * for return.
+ * @param soapNs the SOAP namespace. If null one of the defaults will be used:
+ * http://schemas.xmlsoap.org/soap/envelope/
+ * http://www.w3.org/2003/05/soap-envelope
+ * @return The SOAP Message.
+ * @throws java.io.IOException Failed to load WSDL.
+ * @throws UnsupportedOperationException Operation not supported on specified WSDL.
+ * @throws org.xml.sax.SAXException Failed to parse the SOAP UI generated request message.
+ */
+ public String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException {
+ try {
+ return (String) mbeanServer.invoke(serviceName, "buildRequest", new Object[] {wsdl, operation, params, httpClientProps, smooksResource, soapNs}, buildRequestSig);
+ } catch (InstanceNotFoundException e) {
+ throw new UnsupportedOperationException("SOAP UI Client Service not found under name '" + serviceName.getCanonicalName() + "'. This service must be deployed before this action can be used.", e);
+ } catch (MBeanException e) {
+ rethrowException(e);
+ } catch (ReflectionException e) {
+ rethrowException(e);
+ }
+
+ throw new RuntimeException("Unexpected code exit point reached!");
+ }
+
+ /**
+ * Get the 1st endpoint from the specified WSDL.
+ *
+ * @param wsdl WSDL URL.
+ * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
+ * @return The operation endpoint URL.
+ * @throws IOException Failed to load WSDL.
+ */
+ public String getEndpoint(String wsdl, Properties httpClientProps) throws IOException {
+ try {
+ return (String) mbeanServer.invoke(serviceName, "getEndpoint", new Object[] {wsdl, httpClientProps}, getEndpointSig);
+ } catch (InstanceNotFoundException e) {
+ throw new UnsupportedOperationException("SOAP UI Client Service not found under name '" + serviceName.getCanonicalName() + "'. This service must be deployed before this action can be used.", e);
+ } catch (MBeanException e) {
+ if(e.getCause() instanceof IOException) {
+ throw (IOException)e.getCause();
+ }
+ throw new RuntimeException(e);
+ } catch (ReflectionException e) {
+ if(e.getCause() instanceof IOException) {
+ throw (IOException)e.getCause();
+ }
+ throw new RuntimeException(e);
+ }
+ }
+
+ private void rethrowException(Throwable e) throws IOException, UnsupportedOperationException, SAXException {
+ Throwable cause = e.getCause();
+
+ if(cause instanceof IOException) {
+ throw (IOException)cause;
+ } else if(cause instanceof UnsupportedOperationException) {
+ throw (UnsupportedOperationException)cause;
+ } else if(cause instanceof SAXException) {
+ throw (SAXException)cause;
+ } else {
+ throw new RuntimeException(e);
+ }
+ }
+
+}
Property changes on: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/MBeanSoapUIInvoker.java
___________________________________________________________________
Name: svn:eol-style
+ native
Modified: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2008-06-28 09:27:01 UTC (rev 20834)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SOAPClient.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -28,6 +28,7 @@
import java.util.Properties;
import java.net.URI;
import java.net.URISyntaxException;
+import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.parsers.DocumentBuilder;
@@ -281,6 +282,7 @@
private QNameMap responseXStreamQNameMap = new QNameMap();
private Properties httpClientProps = new Properties();
private HttpClient httpclient;
+ private String endpointUrl;
private MessagePayloadProxy payloadProxy;
public SOAPClient(ConfigTree config) throws ConfigurationException {
@@ -310,6 +312,8 @@
// to the HttpClientFacatory...
extractHttpClientProps(config);
httpclient = HttpClientFactory.createHttpClient(httpClientProps);
+
+ endpointUrl = config.getAttribute("endpointUrl");
}
private void createPayloadProxy(ConfigTree config) {
@@ -336,9 +340,17 @@
public void initialise() throws ActionLifecycleException {
super.initialise();
// Create the SoapUIInvoker instance for this SOAPClient...
- soapUIInvoker = new SoapUIInvoker();
+ soapUIInvoker = new MBeanSoapUIInvoker();
}
-
+
+ public SoapUIInvoker getSoapUIInvoker() {
+ return soapUIInvoker;
+ }
+
+ public void setSoapUIInvoker(SoapUIInvoker soapUIInvoker) {
+ this.soapUIInvoker = soapUIInvoker;
+ }
+
@Override
public void destroy() throws ActionLifecycleException {
if (httpclient != null) {
@@ -420,7 +432,11 @@
String endpoint;
try {
- endpoint = soapUIInvoker.getEndpoint(wsdl, httpClientProps);
+ if(endpointUrl != null) {
+ endpoint = endpointUrl;
+ } else {
+ endpoint = soapUIInvoker.getEndpoint(wsdl, httpClientProps);
+ }
} catch (IOException e) {
throw new ActionProcessingException("soapUI Client Service invocation failed.", e);
Deleted: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java 2008-06-28 09:27:01 UTC (rev 20834)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -1,124 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
- */
-package org.jboss.soa.esb.actions.soap;
-
-import org.jboss.mx.util.MBeanServerLocator;
-import org.xml.sax.SAXException;
-
-import javax.management.*;
-import java.util.Map;
-import java.util.Properties;
-import java.io.IOException;
-
-/**
- * Invoker the soapui-client Service.
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class SoapUIInvoker {
-
- private static final String[] buildRequestSig = new String[] {String.class.getName(), String.class.getName(), Map.class.getName(), Properties.class.getName(), String.class.getName(), String.class.getName()};
- private static final String[] getEndpointSig = new String[] {String.class.getName(), Properties.class.getName()};
- private MBeanServer mbeanServer;
- private ObjectName serviceName;
-
- public SoapUIInvoker() {
- // Lookup the MBean ObjectName for the soapUI service (in soapui-client.sar)...
- try {
- mbeanServer = MBeanServerLocator.locateJBoss();
- serviceName = new ObjectName("jboss.esb:service=SoapUIClientService");
- } catch (MalformedObjectNameException e) {
- throw new IllegalStateException("Unexpected exception.", e);
- }
- }
-
- /**
- * Build a SOAP request for the specified operation on the specified WSDL.
- *
- * @param wsdl WSDL URL.
- * @param operation Operation name.
- * @param params Message parameter map.
- * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
- * @param smooksResource {@link org.milyn.Smooks} transformation configuration resource file.
- * Null if no transformations are to be performed on the SOAP message before serializing it
- * for return.
- * @param soapNs the SOAP namespace. If null one of the defaults will be used:
- * http://schemas.xmlsoap.org/soap/envelope/
- * http://www.w3.org/2003/05/soap-envelope
- * @return The SOAP Message.
- * @throws java.io.IOException Failed to load WSDL.
- * @throws UnsupportedOperationException Operation not supported on specified WSDL.
- * @throws org.xml.sax.SAXException Failed to parse the SOAP UI generated request message.
- */
- public String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException {
- try {
- return (String) mbeanServer.invoke(serviceName, "buildRequest", new Object[] {wsdl, operation, params, httpClientProps, smooksResource, soapNs}, buildRequestSig);
- } catch (InstanceNotFoundException e) {
- throw new UnsupportedOperationException("SOAP UI Client Service not found under name '" + serviceName.getCanonicalName() + "'. This service must be deployed before this action can be used.", e);
- } catch (MBeanException e) {
- rethrowException(e);
- } catch (ReflectionException e) {
- rethrowException(e);
- }
-
- throw new RuntimeException("Unexpected code exit point reached!");
- }
-
- /**
- * Get the 1st endpoint from the specified WSDL.
- *
- * @param wsdl WSDL URL.
- * @param httpClientProps {@link org.apache.commons.httpclient.HttpClient} creation properties.
- * @return The operation endpoint URL.
- * @throws IOException Failed to load WSDL.
- */
- public String getEndpoint(String wsdl, Properties httpClientProps) throws IOException {
- try {
- return (String) mbeanServer.invoke(serviceName, "getEndpoint", new Object[] {wsdl, httpClientProps}, getEndpointSig);
- } catch (InstanceNotFoundException e) {
- throw new UnsupportedOperationException("SOAP UI Client Service not found under name '" + serviceName.getCanonicalName() + "'. This service must be deployed before this action can be used.", e);
- } catch (MBeanException e) {
- if(e.getCause() instanceof IOException) {
- throw (IOException)e.getCause();
- }
- throw new RuntimeException(e);
- } catch (ReflectionException e) {
- if(e.getCause() instanceof IOException) {
- throw (IOException)e.getCause();
- }
- throw new RuntimeException(e);
- }
- }
-
- private void rethrowException(Throwable e) throws IOException, UnsupportedOperationException, SAXException {
- Throwable cause = e.getCause();
-
- if(cause instanceof IOException) {
- throw (IOException)cause;
- } else if(cause instanceof UnsupportedOperationException) {
- throw (UnsupportedOperationException)cause;
- } else if(cause instanceof SAXException) {
- throw (SAXException)cause;
- } else {
- throw new RuntimeException(e);
- }
- }
-
-}
Added: labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/SoapUIInvoker.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -0,0 +1,16 @@
+package org.jboss.soa.esb.actions.soap;
+
+import org.xml.sax.SAXException;
+
+import java.util.Map;
+import java.util.Properties;
+import java.io.IOException;
+
+/**
+ * @author
+ */
+public interface SoapUIInvoker {
+ String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException;
+
+ String getEndpoint(String wsdl, Properties httpClientProps) throws IOException;
+}
Deleted: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java 2008-06-28 09:27:01 UTC (rev 20834)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -1,126 +0,0 @@
-package org.jboss.soa.esb.actions.soap;
-
-import java.util.Map;
-import java.io.IOException;
-
-import junit.framework.TestCase;
-
-import org.jboss.internal.soa.esb.util.StreamUtils;
-import org.jboss.soa.esb.ConfigurationException;
-import org.jboss.soa.esb.testutils.ESBConfigUtil;
-import org.jboss.soa.esb.actions.ActionProcessingException;
-import org.jboss.soa.esb.actions.soap.beans.Order;
-import org.jboss.soa.esb.helpers.ConfigTree;
-import org.jboss.soa.esb.message.Message;
-import org.jboss.soa.esb.message.format.MessageFactory;
-import org.xml.sax.SAXException;
-
-/**
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class SOAPClientUnitTest extends TestCase {
-
- private ESBConfigUtil configUtil;
-
- public SOAPClientUnitTest() throws IOException, SAXException, ConfigurationException {
- configUtil = new ESBConfigUtil(getClass().getResourceAsStream("soapclient-config-01.xml"));
- }
-
- public void test_XStream_ResponseProcessing() throws ConfigurationException, ActionProcessingException {
- ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-01");
- SOAPClient soapClient = new SOAPClient(actionConfig);
- Message message = MessageFactory.getInstance().getMessage();
-
- soapClient.processResponse(message, response_01);
- assertEquals(true, message.getBody().get());
-
- soapClient.processResponse(message, response_02);
- assertEquals(false, message.getBody().get());
- }
-
- @SuppressWarnings("unchecked")
- public void test_OgnlMap_ResponseProcessing_1() throws ConfigurationException, ActionProcessingException {
- ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-02");
- SOAPClient soapClient = new SOAPClient(actionConfig);
- Message message = MessageFactory.getInstance().getMessage();
-
- soapClient.processResponse(message, response_01);
- Map<String, String> response = (Map<String, String>) message.getBody().get();
- assertEquals("true", response.get("customerOrderAck"));
-
- soapClient.processResponse(message, response_02);
- response = (Map<String, String>) message.getBody().get();
- assertEquals("false", response.get("customerOrderAck"));
- }
-
- public void test_OgnlMap_ResponseProcessing_2() throws ConfigurationException, ActionProcessingException {
- ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-05");
- SOAPClient soapClient = new SOAPClient(actionConfig);
- String responseString = new String(StreamUtils.readStream(getClass().getResourceAsStream("soap-message-01.xml")));
- Message message = MessageFactory.getInstance().getMessage();
-
- soapClient.processResponse(message, responseString);
- Order order = (Order) message.getBody().get();
- //assertEquals();
- }
-
- @SuppressWarnings("unchecked")
- public void test_OgnlMap_ResponseProcessing_3() throws ConfigurationException, ActionProcessingException {
- ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-02");
- SOAPClient soapClient = new SOAPClient(actionConfig);
- String responseString = new String(StreamUtils.readStream(getClass().getResourceAsStream("soap-message-01.xml")));
- Message message = MessageFactory.getInstance().getMessage();
-
- soapClient.processResponse(message, responseString);
- Map<String, String> responseMap = (Map<String, String>) message.getBody().get();
-
- assertEquals("{customerOrder.orderheader.customerName=Tom Fennelly, customerOrder.items[0].partNumber=1, customerOrder.items[0].description=desc-1, customerOrder.items[0].quantity=1, customerOrder.items[0].price=1.1, customerOrder.items[0].extensionAmount=1, customerOrder.items[1].partNumber=2, customerOrder.items[1].description=desc-2, customerOrder.items[1].quantity=2, customerOrder.items[1].price=2.2, customerOrder.items[1].extensionAmount=2}", responseMap.toString());
- }
-
- public void test_No_ResponseProcessing() throws ConfigurationException, ActionProcessingException {
- ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-03");
- SOAPClient soapClient = new SOAPClient(actionConfig);
- Message message = MessageFactory.getInstance().getMessage();
-
- soapClient.processResponse(message, response_01);
- assertEquals(response_01, message.getBody().get());
- }
-
- public void test_ResponseLocation() throws ConfigurationException, ActionProcessingException {
- ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-04");
- SOAPClient soapClient = new SOAPClient(actionConfig);
- Message message = MessageFactory.getInstance().getMessage();
-
- soapClient.processResponse(message, response_01);
- assertEquals(response_01, message.getBody().get("myTestLocation"));
- }
-
- public void test_getEndpointOperation() throws ConfigurationException, ActionProcessingException {
- ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-07");
- SOAPClient soapClient = new SOAPClient(actionConfig);
- assertEquals("SendSalesOrderNotification", soapClient.getEndpointOperation());
- }
-
- public void test_soapSetSOAPNameSpace() throws ConfigurationException, ActionProcessingException {
- String expectedSOAPNS = "http://www.w3.org/2003/05/soap-envelope";
- ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-07");
- actionConfig.setAttribute( "SOAPNS", expectedSOAPNS );
- SOAPClient soapClient = new SOAPClient(actionConfig);
- assertEquals( expectedSOAPNS, soapClient.getSoapNS());
- }
-
-
- private static String response_01 =
- "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
- "\t<soapenv:Header/>\n" +
- "\t<soapenv:Body>\n" +
- "\t\t<aetgt:customerOrderAck xmlns:aetgt=\"http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd\">true</aetgt:customerOrderAck>\n" +
- "\t</soapenv:Body>\n" +
- "</soapenv:Envelope>";
- private static String response_02 =
- "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
- "\t<soapenv:Body>\n" +
- "\t\t<aetgt:customerOrderAck xmlns:aetgt=\"http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd\">false</aetgt:customerOrderAck>\n" +
- "\t</soapenv:Body>\n" +
- "</soapenv:Envelope>";
-}
Copied: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClient_Response_UnitTest.java (from rev 20792, labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClientUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClient_Response_UnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClient_Response_UnitTest.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -0,0 +1,126 @@
+package org.jboss.soa.esb.actions.soap;
+
+import java.util.Map;
+import java.io.IOException;
+
+import junit.framework.TestCase;
+
+import org.jboss.internal.soa.esb.util.StreamUtils;
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.testutils.ESBConfigUtil;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.actions.soap.beans.Order;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.xml.sax.SAXException;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class SOAPClient_Response_UnitTest extends TestCase {
+
+ private ESBConfigUtil configUtil;
+
+ public SOAPClient_Response_UnitTest() throws IOException, SAXException, ConfigurationException {
+ configUtil = new ESBConfigUtil(getClass().getResourceAsStream("soapclient-config-01.xml"));
+ }
+
+ public void test_XStream_ResponseProcessing() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-01");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, response_01);
+ assertEquals(true, message.getBody().get());
+
+ soapClient.processResponse(message, response_02);
+ assertEquals(false, message.getBody().get());
+ }
+
+ @SuppressWarnings("unchecked")
+ public void test_OgnlMap_ResponseProcessing_1() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-02");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, response_01);
+ Map<String, String> response = (Map<String, String>) message.getBody().get();
+ assertEquals("true", response.get("customerOrderAck"));
+
+ soapClient.processResponse(message, response_02);
+ response = (Map<String, String>) message.getBody().get();
+ assertEquals("false", response.get("customerOrderAck"));
+ }
+
+ public void test_OgnlMap_ResponseProcessing_2() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-05");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ String responseString = new String(StreamUtils.readStream(getClass().getResourceAsStream("soap-message-01.xml")));
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, responseString);
+ Order order = (Order) message.getBody().get();
+ //assertEquals();
+ }
+
+ @SuppressWarnings("unchecked")
+ public void test_OgnlMap_ResponseProcessing_3() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-02");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ String responseString = new String(StreamUtils.readStream(getClass().getResourceAsStream("soap-message-01.xml")));
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, responseString);
+ Map<String, String> responseMap = (Map<String, String>) message.getBody().get();
+
+ assertEquals("{customerOrder.orderheader.customerName=Tom Fennelly, customerOrder.items[0].partNumber=1, customerOrder.items[0].description=desc-1, customerOrder.items[0].quantity=1, customerOrder.items[0].price=1.1, customerOrder.items[0].extensionAmount=1, customerOrder.items[1].partNumber=2, customerOrder.items[1].description=desc-2, customerOrder.items[1].quantity=2, customerOrder.items[1].price=2.2, customerOrder.items[1].extensionAmount=2}", responseMap.toString());
+ }
+
+ public void test_No_ResponseProcessing() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-03");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, response_01);
+ assertEquals(response_01, message.getBody().get());
+ }
+
+ public void test_ResponseLocation() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-04");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ Message message = MessageFactory.getInstance().getMessage();
+
+ soapClient.processResponse(message, response_01);
+ assertEquals(response_01, message.getBody().get("myTestLocation"));
+ }
+
+ public void test_getEndpointOperation() throws ConfigurationException, ActionProcessingException {
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-07");
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ assertEquals("SendSalesOrderNotification", soapClient.getEndpointOperation());
+ }
+
+ public void test_soapSetSOAPNameSpace() throws ConfigurationException, ActionProcessingException {
+ String expectedSOAPNS = "http://www.w3.org/2003/05/soap-envelope";
+ ConfigTree actionConfig = configUtil.getActionConfig("OrderNotificationService", "soapui-client-action-07");
+ actionConfig.setAttribute( "SOAPNS", expectedSOAPNS );
+ SOAPClient soapClient = new SOAPClient(actionConfig);
+ assertEquals( expectedSOAPNS, soapClient.getSoapNS());
+ }
+
+
+ private static String response_01 =
+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
+ "\t<soapenv:Header/>\n" +
+ "\t<soapenv:Body>\n" +
+ "\t\t<aetgt:customerOrderAck xmlns:aetgt=\"http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd\">true</aetgt:customerOrderAck>\n" +
+ "\t</soapenv:Body>\n" +
+ "</soapenv:Envelope>";
+ private static String response_02 =
+ "<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n" +
+ "\t<soapenv:Body>\n" +
+ "\t\t<aetgt:customerOrderAck xmlns:aetgt=\"http://schemas.active-endpoints.com/sample/customerorder/2006/04/CustomerOrder.xsd\">false</aetgt:customerOrderAck>\n" +
+ "\t</soapenv:Body>\n" +
+ "</soapenv:Envelope>";
+}
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/SOAPClient_Response_UnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/MockSOAPClient.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/MockSOAPClient.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/MockSOAPClient.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -0,0 +1,63 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap.request;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
+import org.jboss.soa.esb.actions.soap.SOAPClient;
+import org.jboss.soa.esb.actions.soap.SoapUIInvoker;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.jboss.soa.esb.services.soapui.SoapUIClientService;
+import org.xml.sax.SAXException;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class MockSOAPClient extends SOAPClient {
+
+ public MockSOAPClient(ConfigTree config) throws ConfigurationException {
+ super(config);
+ }
+
+ public void initialise() throws ActionLifecycleException {
+ // intentionally not calling super
+
+ try {
+ SoapUIInvoker soapUIInvoker = new SoapUIInvoker() {
+ private SoapUIClientService service = new SoapUIClientService();
+
+ public String buildRequest(String wsdl, String operation, Map params, Properties httpClientProps, String smooksResource, String soapNs) throws IOException, UnsupportedOperationException, SAXException {
+ return service.buildRequest(wsdl, operation, params, httpClientProps, smooksResource, soapNs);
+ }
+ public String getEndpoint(String wsdl, Properties httpClientProps) throws IOException {
+ return service.getEndpoint(wsdl, httpClientProps);
+ }
+ };
+
+ setSoapUIInvoker(soapUIInvoker);
+ } catch (ConfigurationException e) {
+ throw new ActionLifecycleException("Failed to initialize SoapUIInvoker.", e);
+ }
+ }
+}
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/MockSOAPClient.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/SOAPClient_Request_UnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/SOAPClient_Request_UnitTest.java (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/SOAPClient_Request_UnitTest.java 2008-06-28 09:55:40 UTC (rev 20835)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., 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-2006, JBoss Inc.
+ */
+package org.jboss.soa.esb.actions.soap.request;
+
+import junit.framework.TestCase;
+import org.jboss.soa.esb.client.ServiceInvoker;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.message.format.MessageFactory;
+import org.jboss.soa.esb.testutils.AbstractTestRunner;
+import org.jboss.soa.esb.testutils.jbr.JBRServer;
+import org.jboss.soa.esb.testutils.jbr.StaticRequestResponseHandler;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class SOAPClient_Request_UnitTest extends TestCase {
+
+ public void test_request_no_wsdl_endpoint_override() throws Exception {
+ // soapclient-request-config-01.xml doesn't define an "endpointURL" which would override the wsdl wsEndpoint
+ // being invoked by the SOAPClient...
+ test_request("soapclient-request-config-01.xml", "http://localhost:14999/");
+ }
+
+ public void test_request_wsdl_endpoint_override() throws Exception {
+ // soapclient-request-config-02.xml defines an "endpointURL" which overrides the wsdl wsEndpoint
+ // being invoked by the SOAPClient ("http://localhost:15111/")...
+ test_request("soapclient-request-config-02.xml", "http://localhost:15111/");
+ }
+
+ public void test_request(String esbConfig, String wsEndpoint) throws Exception {
+ JBRServer wsdlServer = new JBRServer("http://localhost:13999/", new StaticRequestResponseHandler(getClass().getResourceAsStream("request-test-01.wsdl")));
+ StaticRequestResponseHandler wsEndpointHandler = new StaticRequestResponseHandler("<response/>");
+ JBRServer wsEndpointServer = new JBRServer(wsEndpoint, wsEndpointHandler);
+
+ // Check the SOAP request coming into the Server...
+ wsEndpointHandler.setExpectedRequest(getClass().getResourceAsStream("expected-soap-request.xml"));
+
+ wsdlServer.start();
+ try {
+ wsEndpointServer.start();
+ try {
+ new AbstractTestRunner() {
+ public void test() throws Exception {
+ ServiceInvoker invoker = new ServiceInvoker("OrderManagement", "GoodbyeService");
+ Message message = MessageFactory.getInstance().getMessage();
+ Map params = new HashMap();
+
+ params.put("sayGoodbye.message", "Goodbye Henry!!");
+ message.getBody().add(params);
+
+ message = invoker.deliverSync(message, 10000);
+
+ String soapResponse = (String) message.getBody().get();
+ assertEquals("<response/>", soapResponse);
+ }
+ }.setServiceConfig(esbConfig).run();
+ } finally {
+ wsEndpointServer.stop();
+ }
+ } finally {
+ wsdlServer.stop();
+ }
+ }
+}
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/SOAPClient_Request_UnitTest.java
___________________________________________________________________
Name: svn:eol-style
+ native
Added: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/expected-soap-request.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/expected-soap-request.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/expected-soap-request.xml 2008-06-28 09:55:40 UTC (rev 20835)
@@ -0,0 +1,9 @@
+<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:good="http://webservice_producer/goodbyeworld">
+ <soapenv:Header/>
+ <soapenv:Body>
+ <good:sayGoodbye>
+ <!--Optional:-->
+ <message>Goodbye Henry!!</message>
+ </good:sayGoodbye>
+ </soapenv:Body>
+</soapenv:Envelope>
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/expected-soap-request.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/request/request-test-01.wsdl
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/request-test-01.wsdl (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/request-test-01.wsdl 2008-06-28 09:55:40 UTC (rev 20835)
@@ -0,0 +1,109 @@
+<definitions name='GoodbyeWorldWSService' targetNamespace='http://webservice_producer/goodbyeworld'
+ xmlns='http://schemas.xmlsoap.org/wsdl/' xmlns:soap='http://schemas.xmlsoap.org/wsdl/soap/'
+ xmlns:tns='http://webservice_producer/goodbyeworld' xmlns:xsd='http://www.w3.org/2001/XMLSchema'>
+ <types>
+ <xs:schema targetNamespace='http://webservice_producer/goodbyeworld' version='1.0'
+ xmlns:tns='http://webservice_producer/goodbyeworld' xmlns:xs='http://www.w3.org/2001/XMLSchema'>
+ <xs:element name='sayAdios' type='tns:sayAdios'/>
+ <xs:element name='sayAdiosResponse' type='tns:sayAdiosResponse'/>
+ <xs:element name='sayGoodbye' type='tns:sayGoodbye'/>
+ <xs:element name='sayGoodbyeResponse' type='tns:sayGoodbyeResponse'/>
+ <xs:element name='sayGoodbyeWithoutResponse' type='tns:sayGoodbyeWithoutResponse'/>
+ <xs:complexType name='sayGoodbye'>
+
+ <xs:sequence>
+ <xs:element minOccurs='0' name='message' type='xs:string'/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name='sayGoodbyeResponse'>
+ <xs:sequence>
+ <xs:element minOccurs='0' name='return' type='xs:string'/>
+ </xs:sequence>
+ </xs:complexType>
+
+ <xs:complexType name='sayAdios'>
+ <xs:sequence>
+ <xs:element minOccurs='0' name='arg0' type='xs:string'/>
+ </xs:sequence>
+ </xs:complexType>
+ <xs:complexType name='sayAdiosResponse'>
+ <xs:sequence>
+ <xs:element minOccurs='0' name='return' type='xs:string'/>
+ </xs:sequence>
+
+ </xs:complexType>
+ <xs:complexType name='sayGoodbyeWithoutResponse'>
+ <xs:sequence>
+ <xs:element minOccurs='0' name='message' type='xs:string'/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:schema>
+ </types>
+ <message name='GoodbyeWorldWS_sayAdiosResponse'>
+
+ <part element='tns:sayAdiosResponse' name='sayAdiosResponse'></part>
+ </message>
+ <message name='GoodbyeWorldWS_sayGoodbye'>
+ <part element='tns:sayGoodbye' name='sayGoodbye'></part>
+ </message>
+ <message name='GoodbyeWorldWS_sayGoodbyeResponse'>
+ <part element='tns:sayGoodbyeResponse' name='sayGoodbyeResponse'></part>
+ </message>
+ <message name='GoodbyeWorldWS_sayAdios'>
+
+ <part element='tns:sayAdios' name='sayAdios'></part>
+ </message>
+ <message name='GoodbyeWorldWS_sayGoodbyeWithoutResponse'>
+ <part element='tns:sayGoodbyeWithoutResponse' name='sayGoodbyeWithoutResponse'></part>
+ </message>
+ <portType name='GoodbyeWorldWS'>
+ <operation name='sayAdios' parameterOrder='sayAdios'>
+ <input message='tns:GoodbyeWorldWS_sayAdios'></input>
+ <output message='tns:GoodbyeWorldWS_sayAdiosResponse'></output>
+
+ </operation>
+ <operation name='sayGoodbye' parameterOrder='sayGoodbye'>
+ <input message='tns:GoodbyeWorldWS_sayGoodbye'></input>
+ <output message='tns:GoodbyeWorldWS_sayGoodbyeResponse'></output>
+ </operation>
+ <operation name='sayGoodbyeWithoutResponse'>
+ <input message='tns:GoodbyeWorldWS_sayGoodbyeWithoutResponse'></input>
+ </operation>
+ </portType>
+
+ <binding name='GoodbyeWorldWSBinding' type='tns:GoodbyeWorldWS'>
+ <soap:binding style='document' transport='http://schemas.xmlsoap.org/soap/http'/>
+ <operation name='sayAdios'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body use='literal'/>
+ </input>
+ <output>
+ <soap:body use='literal'/>
+
+ </output>
+ </operation>
+ <operation name='sayGoodbye'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body use='literal'/>
+ </input>
+ <output>
+ <soap:body use='literal'/>
+
+ </output>
+ </operation>
+ <operation name='sayGoodbyeWithoutResponse'>
+ <soap:operation soapAction=''/>
+ <input>
+ <soap:body use='literal'/>
+ </input>
+ </operation>
+ </binding>
+
+ <service name='GoodbyeWorldWSService'>
+ <port binding='tns:GoodbyeWorldWSBinding' name='GoodbyeWorldWSPort'>
+ <soap:address location='http://127.0.0.1:14999/'/>
+ </port>
+ </service>
+</definitions>
\ No newline at end of file
Copied: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/soapclient-request-config-01.xml (from rev 20792, labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/soapclient-config-01.xml)
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/soapclient-request-config-01.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/soapclient-request-config-01.xml 2008-06-28 09:55:40 UTC (rev 20835)
@@ -0,0 +1,17 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">
+
+ <services>
+ <service category="OrderManagement" name="GoodbyeService" description="Goodbye Service" invmScope="GLOBAL">
+ <actions>
+ <action name="invoke-ws" class="org.jboss.soa.esb.actions.soap.request.MockSOAPClient">
+ <property name="wsdl" value="http://localhost:13999/"/>
+ <!-- Not overridding the the WS endpoint URL with the "endpointUrl" property. SOAPClient will
+ use that defined in the WSDL -->
+ <property name="SOAPAction" value="sayGoodbye"/>
+ </action>
+ </actions>
+ </service>
+ </services>
+
+</jbossesb>
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/soapclient-request-config-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/request/soapclient-request-config-02.xml
===================================================================
--- labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/soapclient-request-config-02.xml (rev 0)
+++ labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/soapclient-request-config-02.xml 2008-06-28 09:55:40 UTC (rev 20835)
@@ -0,0 +1,16 @@
+<?xml version = "1.0" encoding = "UTF-8"?>
+<jbossesb xmlns="http://anonsvn.labs.jboss.com/labs/jbossesb/trunk/product/etc/schemas/xml/jbossesb-1.0.1.xsd" parameterReloadSecs="5">
+
+ <services>
+ <service category="OrderManagement" name="GoodbyeService" description="Goodbye Service" invmScope="GLOBAL">
+ <actions>
+ <action name="invoke-ws" class="org.jboss.soa.esb.actions.soap.request.MockSOAPClient">
+ <property name="wsdl" value="http://localhost:13999/"/>
+ <property name="endpointUrl" value="http://localhost:15111/"/> <!-- Overriding the WS endpoint URL, so not using that defined in the -->
+ <property name="SOAPAction" value="sayGoodbye"/>
+ </action>
+ </actions>
+ </service>
+ </services>
+
+</jbossesb>
Property changes on: labs/jbossesb/trunk/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/request/soapclient-request-config-02.xml
___________________________________________________________________
Name: svn:mime-type
+ text/xml
Name: svn:eol-style
+ native
More information about the jboss-svn-commits
mailing list