[jboss-svn-commits] JBL Code SVN: r24896 - in labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src: test/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 Jan 23 13:10:31 EST 2009


Author: beve
Date: 2009-01-23 13:10:31 -0500 (Fri, 23 Jan 2009)
New Revision: 24896

Added:
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSDynamicClient.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSEndpoint.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSMethod.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/SOAPClientUnitTest.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/wise.core-properties
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/resources/wise-core.properties
Modified:
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
   labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/resources/log4j.xml
Log:
Work for https://svn.jboss.org/repos/wise/legacy/tags/ESB4.4 "Handle wise threading/pooling"


Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java	2009-01-23 16:55:00 UTC (rev 24895)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/SOAPClient.java	2009-01-23 18:10:31 UTC (rev 24896)
@@ -24,7 +24,6 @@
 
 import it.javalinux.wise.core.client.InvocationResult;
 import it.javalinux.wise.core.client.WSDynamicClient;
-import it.javalinux.wise.core.client.WSDynamicClientFactory;
 import it.javalinux.wise.core.client.WSEndpoint;
 import it.javalinux.wise.core.client.WSMethod;
 import it.javalinux.wise.core.client.handler.LoggingHandler;
@@ -37,7 +36,11 @@
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
 import javax.xml.ws.handler.Handler;
+
 import org.apache.log4j.Logger;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.actions.AbstractActionPipelineProcessor;
@@ -164,19 +167,25 @@
     private final String endPointName;
     private final String smooksRequestMapperURL;
     private final String smooksResponseMapperURL;
+    private final String operationName;
     private String serviceName;
     private final String username;
     private final String password;
-    // private WSDynamicClient client;
     private final List<String> smooksHandler = new ArrayList<String>();
     private final List<String> customHandlers = new ArrayList<String>();
     private final MessagePayloadProxy payloadProxy;
     private boolean loggingEnabled = false;
-
-    public SOAPClient( ConfigTree config ) throws ConfigurationException {
+    
+    private WSDynamicClient client;
+    
+    final ConcurrentMap<String, WSEndpoint> endpointMap = new ConcurrentHashMap<String, WSEndpoint>();
+    
+    public SOAPClient(final ConfigTree config ) throws ConfigurationException 
+    {
         wsdl = config.getRequiredAttribute("wsdl");
         soapAction = config.getRequiredAttribute("SOAPAction");
         endPointName = config.getRequiredAttribute("EndPointName");
+        operationName = config.getAttribute("operationName");
         smooksRequestMapperURL = config.getAttribute("SmooksRequestMapper");
         smooksResponseMapperURL = config.getAttribute("SmooksResponseMapper");
         serviceName = config.getAttribute("serviceName");
@@ -186,135 +195,210 @@
         logger.info(config.getAttribute("LoggingMessages"));
         loggingEnabled = Boolean.parseBoolean(config.getAttribute("LoggingMessages"));
         logger.info("loggingEnabled:" + loggingEnabled);
-        ConfigTree[] handlersConfig;
+        
         if (config.getAttribute("smooks-handler-config") != null) {
             smooksHandler.add(config.getAttribute("smooks-handler-config"));
         }
+        
         if (config.getAttribute("custom-handlers") != null) {
             for (String className : config.getAttribute("custom-handlers").split(";")) {
                 customHandlers.add(className);
             }
 
         }
-        handlersConfig = config.getChildren("custom-handlers");
-
+        
         payloadProxy = new MessagePayloadProxy(config);
-
+        
+        logger.info(this);
     }
+    
+    public Message process(final Message message) throws ActionProcessingException 
+    {
+        WSDynamicClient client = createClient(wsdl, serviceName, username, password);
+        WSEndpoint endpoint = getEndpoint(client);
+        
+        Object payload = getMessagePayload(message);
+        addSmooksHandlers(endpoint, payload);
+        addCustomHandlers(endpoint);
+        addLoggingHandler(endpoint);
+        
+        WSMethod wsMethod = getWSMethodFromEndpoint(operationName, endpoint);
 
-    @Override
-    public void initialise() throws ActionLifecycleException {
-        super.initialise();
+        InvocationResult result;
+        try 
+        {
+            result = wsMethod.invoke(payload, createSmooksMapper(smooksRequestMapperURL));
+        } 
+        catch (final WiseException e) 
+        {
+            throw new ActionProcessingException("Could not call method" + this.soapAction, e);
+        }
+        return mapResponseToMessage(message, result, createSmooksMapper(smooksResponseMapperURL));
     }
-
-    @Override
-    public void destroy() throws ActionLifecycleException {
-    	try {
-            WSDynamicClientFactory.getInstace().clearCache();
-        } catch (Exception e) {
-            throw new ActionLifecycleException("Error durinfg wise client cache cleaning", e);
-        }
-        
-        try {
-            if (smooksRequestMapperURL != null) {
-              SmooksCache.getInstance().put(smooksRequestMapperURL, null);
+    
+    synchronized WSDynamicClient createClient(final String wsdl, final String serviceName, final String username, final String password) throws ActionProcessingException
+    {
+        if (client == null)
+        {
+            try
+            {
+                client = new WSDynamicClientFactory().create(wsdl, serviceName, username, password);
+            } 
+            catch (final WiseException e)
+            {
+                throw new ActionProcessingException(e.getMessage(), e);
             }
-        } catch (Exception e) {
-            throw new ActionLifecycleException("Error while trying to clean SmooksCache", e);
         }
-        
-        try {
-            if (smooksResponseMapperURL != null) {
-                  SmooksCache.getInstance().put(smooksResponseMapperURL, null);
-            } 
-        } catch (Exception e) {
-            throw new ActionLifecycleException("Error while trying to clean SmooksCache", e);
-        }
+        return client;
     }
 
-    public Message process( final Message message ) throws ActionProcessingException {
-        Object params;
-        WSDynamicClient client = null;
-        // get client from cache
-        try {
-            client = WSDynamicClientFactory.getInstace().getClient(wsdl, serviceName, username, password);
-        } catch (Exception e) {
-            e.printStackTrace();
-            throw new ActionProcessingException("Error durinfg wise client creation", e);
-        }
-
-        try {
-            params = payloadProxy.getPayload(message);
-        } catch (MessageDeliverException e) {
-            throw new ActionProcessingException("Could not locate SOAP message parameters from payload", e);
-        }
-
-        // if (params.isEmpty()) {
-        // logger.warn("Params Map found in message, but the map is empty.");
-        // }
-        Map<String, WSEndpoint> endpointsMap = client.processEndpoints();
+    private WSEndpoint getEndpoint(final WSDynamicClient client)
+    {
+        Map<String, WSEndpoint> endpointsMap = getEndpoints(client);
+        
         WSEndpoint endpoint;
         if (endPointName != null) {
             endpoint = endpointsMap.get(endPointName);
         } else {
             endpoint = endpointsMap.values().iterator().next();
         }
+        return endpoint;
+    }
 
-        for (String config : smooksHandler) {
+    private Object getMessagePayload(final Message message) throws ActionProcessingException
+    {
+        try 
+        {
+            return payloadProxy.getPayload(message);
+        } 
+        catch (final MessageDeliverException e) 
+        {
+            throw new ActionProcessingException("Could not locate SOAP message parameters from payload", e);
+        }
+    }
+
+    private void addSmooksHandlers(final WSEndpoint endpoint, final Object params)
+    {
+        for (String config : smooksHandler) 
+        {
             logger.info("adding smooks handler:" + config);
-            if (params instanceof Map) {
+            if (params instanceof Map) 
+            {
                 endpoint.addHandler(new SmooksHandler(config, (Map)params));
-            } else {
+            } 
+            else 
+            {
                 endpoint.addHandler(new SmooksHandler(config, null));
             }
         }
+    }
 
-        for (String config : customHandlers) {
+    private void addCustomHandlers(final WSEndpoint endpoint)
+    {
+        for (String config : customHandlers) 
+        {
             logger.info("adding custom handler:" + config);
-            try {
+            try 
+            {
                 Class<?> clazz = Thread.currentThread().getContextClassLoader().loadClass(config);
                 endpoint.addHandler((Handler)clazz.newInstance());
-            } catch (Exception e) {
+            } 
+            catch (final Exception e) 
+            {
                 logger.info("Failed during custom handler addition:" + e.getLocalizedMessage());
             }
         }
+    }
 
-        if (loggingEnabled) {
+    private void addLoggingHandler(final WSEndpoint endpoint)
+    {
+        if (loggingEnabled) 
+        {
             logger.info("adding logging handler");
             endpoint.addHandler(new LoggingHandler());
         }
+    }
 
+    private WSMethod getWSMethodFromEndpoint(final String name, final WSEndpoint endpoint) throws ActionProcessingException
+    {
         Map<String, WSMethod> wsmethodsMap = endpoint.getWSMethods();
-        WSMethod wsMethod = wsmethodsMap.get(soapAction);
-        if (wsMethod == null)
+        WSMethod wsMethod = wsmethodsMap.get(name);
+        if (wsMethod != null)
         {
-            throw new ActionProcessingException("No WsMethod found for " + this.soapAction);
+            return wsMethod;
         }
-
-        InvocationResult result;
-        try {
-            WiseMapper mapper = null;
-            if (this.smooksRequestMapperURL != null) {
-                mapper = new SmooksMapper(this.smooksRequestMapperURL, "smook/report/report.html");
-            }
-            result = wsMethod.invoke(params, mapper);
-        } catch (WiseException e) {
-            throw new ActionProcessingException("Could not call method" + this.soapAction, e);
+        throw new ActionProcessingException("No WSMethod found for " + name);
+    }
+    
+    
+    Map<String, WSEndpoint> getEndpoints(final WSDynamicClient client)
+    {
+        if (endpointMap.isEmpty())
+        {
+            Map<String, WSEndpoint> processEndpoints = client.processEndpoints();
+            endpointMap.putAll(processEndpoints);
         }
+        return endpointMap;
+        
+    }
 
-        WiseMapper mapper = null;
-        if (this.smooksResponseMapperURL != null) {
-            mapper = new SmooksMapper(this.smooksResponseMapperURL, "smook/report/report.html");
-        }
-        // And process the response into the message...
-
-        try {
+    private Message mapResponseToMessage(final Message message, final InvocationResult result, final WiseMapper mapper) throws ActionProcessingException
+    {
+        try 
+        {
             payloadProxy.setPayload(message, result.getMappedResult(mapper));
-        } catch (Exception e) {
+        } 
+        catch (final Exception e) 
+        {
             throw new ActionProcessingException("Could not set payload to SOAP message", e);
         }
-
         return message;
     }
 
+    private WiseMapper createSmooksMapper(final String url)
+    {
+        if (url != null) {
+            return new SmooksMapper(url, "smook/report/report.html");
+        }
+        return null;
+    }
+
+    @Override
+    public void destroy() throws ActionLifecycleException 
+    {
+        try 
+        {
+            if (smooksRequestMapperURL != null) 
+            {
+              SmooksCache.getInstance().put(smooksRequestMapperURL, null);
+            }
+        } 
+        catch (final  Exception e) 
+        {
+            throw new ActionLifecycleException("Error while trying to clean SmooksCache", e);
+        }
+        
+        try 
+        {
+            if (smooksResponseMapperURL != null) 
+            {
+                  SmooksCache.getInstance().put(smooksResponseMapperURL, null);
+            } 
+        } 
+        catch (final Exception e) 
+        {
+            throw new ActionLifecycleException("Error while trying to clean SmooksCache", e);
+        }
+    }
+    
+    @Override
+    public String toString()
+    {
+        return "Wise SOAPClient [wsdl=" + wsdl + ", soapAction=" + soapAction + ", endPointName=" + endPointName + ", serviceName=" + serviceName + ", smooksRequestMapperURL=" + smooksRequestMapperURL + ", smooksResponseMapperURL=" + smooksResponseMapperURL + "]";
+    }
+    
+    String getOperationName()
+    {
+        return operationName;
+    }
 }

Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/main/java/org/jboss/soa/esb/actions/soap/wise/WSDynamicClientFactory.java	2009-01-23 18:10:31 UTC (rev 24896)
@@ -0,0 +1,141 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software 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.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.actions.soap.wise;
+
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.StringWriter;
+import java.net.HttpURLConnection;
+import java.net.URL;
+import org.apache.commons.lang.StringUtils;
+import org.jboss.internal.soa.esb.assertion.AssertArgument;
+import sun.misc.BASE64Encoder;
+import it.javalinux.wise.core.client.WSDynamicClient;
+import it.javalinux.wise.core.exceptions.WiseConnectionException;
+import it.javalinux.wise.core.exceptions.WiseException;
+import it.javalinux.wise.core.utils.IDGenerator;
+import it.javalinux.wise.core.utils.IOUtils;
+import it.javalinux.wise.core.utils.WiseProperties;
+
+/**
+ * Factory for {@link WSDynamicClient}. 
+ * Lifted from {@link it.javalinux.wise.core.client.WSDynamicClientFactory}.
+ * <p/>
+ */
+public class WSDynamicClientFactory
+{
+    private static final String WISE_PROPERTIES_FILE = "wise-core.properties";
+    
+    public WSDynamicClient create(final String wsdl, final String name, final String username, final String password) throws WiseException
+    {
+        AssertArgument.isNotNull(name, "name");
+        AssertArgument.isNotNull(wsdl, "wsdl");
+        
+        final WiseProperties wiseProperties = new WiseProperties(WISE_PROPERTIES_FILE);
+        
+        String usableWsdl = wsdl;
+        if (wsdl.startsWith("http://"))
+        {
+            usableWsdl = downloadWsdl(wsdl, username, password, wiseProperties);
+        }
+        
+        final WSDynamicClient client = new WSDynamicClient(wiseProperties);
+        client.init(usableWsdl, name, username, password);
+        return client;
+    }
+    
+    private String downloadWsdl(String wsdlURL, String userName, String password, WiseProperties wiseProperties) throws WiseConnectionException
+    {
+        if (StringUtils.trimToNull(userName) == null || StringUtils.trimToNull(password) == null)
+        {
+            return this.transferWSDL(wsdlURL, null, wiseProperties);
+        } 
+        else
+        {
+            return this.transferWSDL(wsdlURL, new StringBuffer(userName).append(":").append(password).toString(), wiseProperties);
+        }
+    }
+
+    private String transferWSDL(String wsdlURL, String userPassword, WiseProperties wiseProperties) throws WiseConnectionException
+    {
+        String filePath = null;
+        try
+        {
+            URL endpoint = new URL(wsdlURL);
+            // Create the connection
+            HttpURLConnection conn = (HttpURLConnection) endpoint.openConnection();
+            conn.setDoOutput(false);
+            conn.setDoInput(true);
+            conn.setUseCaches(false);
+            conn.setRequestMethod("GET");
+            conn.setRequestProperty("Accept", "text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5");
+            // set Connection close, otherwise we get a keep-alive
+            // connection
+            // that gives us fragmented answers.
+            conn.setRequestProperty("Connection", "close");
+            // BASIC AUTH
+            if (userPassword != null)
+            {
+                conn.setRequestProperty("Authorization", "Basic " + (new BASE64Encoder()).encode(userPassword.getBytes()));
+            }
+            // Read response
+            InputStream is = null;
+            if (conn.getResponseCode() == 200)
+            {
+                is = conn.getInputStream();
+            } 
+            else
+            {
+                is = conn.getErrorStream();
+                InputStreamReader isr = new InputStreamReader(is);
+                StringWriter sw = new StringWriter();
+                char[] buf = new char[200];
+                int read = 0;
+                while (read != -1)
+                {
+                    read = isr.read(buf);
+                    sw.write(buf);
+                }
+                throw new WiseConnectionException("Remote server's response is an error: " + sw.toString());
+            }
+            // saving file
+            File file = new File(wiseProperties.getProperty("wise.tmpDir"), new StringBuffer("Wise").append(IDGenerator.nextVal()).append(".xml").toString());
+            OutputStream fos = new BufferedOutputStream(new FileOutputStream(file));
+            IOUtils.copyStream(fos, is);
+            fos.close();
+            is.close();
+            filePath = file.getPath();
+        } 
+        catch (WiseConnectionException wce)
+        {
+            throw wce;
+        } 
+        catch (Exception e)
+        {
+            throw new WiseConnectionException("Wsdl download failed!", e);
+        }
+        return filePath;
+    }
+}
\ No newline at end of file

Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSDynamicClient.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSDynamicClient.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSDynamicClient.java	2009-01-23 18:10:31 UTC (rev 24896)
@@ -0,0 +1,32 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software 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.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.actions.soap.wise;
+
+import it.javalinux.wise.core.client.WSDynamicClient;
+import it.javalinux.wise.core.utils.WiseProperties;
+
+public class MockWSDynamicClient extends WSDynamicClient
+{
+    public MockWSDynamicClient(WiseProperties wiseProperties)
+    {
+        super(wiseProperties);
+    }
+}

Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSEndpoint.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSEndpoint.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSEndpoint.java	2009-01-23 18:10:31 UTC (rev 24896)
@@ -0,0 +1,46 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software 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.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.actions.soap.wise;
+
+import it.javalinux.wise.core.client.WSEndpoint;
+import it.javalinux.wise.core.client.WSMethod;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class MockWSEndpoint extends WSEndpoint
+{
+    private final String keyName;
+    
+    public MockWSEndpoint(final String keyName)
+    {
+        this.keyName = keyName;
+        
+    }
+    @Override
+    public synchronized Map<String, WSMethod> getWSMethods()
+    {
+        HashMap<String, WSMethod> map = new HashMap<String, WSMethod>();
+        map.put(keyName, new MockWSMethod(null, this));
+        return map;
+    }
+
+}

Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSMethod.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSMethod.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/MockWSMethod.java	2009-01-23 18:10:31 UTC (rev 24896)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software 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.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.actions.soap.wise;
+
+import it.javalinux.wise.core.client.InvocationResult;
+import it.javalinux.wise.core.client.WSEndpoint;
+import it.javalinux.wise.core.client.WSMethod;
+import it.javalinux.wise.core.exceptions.WiseException;
+import it.javalinux.wise.core.mapper.WiseMapper;
+
+import java.lang.reflect.Method;
+import java.util.Collections;
+import java.util.Map;
+
+/**
+ * 
+ * @author <a href="mailto:dbevenius at jboss.com">Daniel Bevenius</a>
+ * 
+ */
+public class MockWSMethod extends WSMethod
+{
+    public MockWSMethod(Method method, WSEndpoint endpoint)
+    {
+        super(method, endpoint);
+    }
+
+    @Override
+    public InvocationResult invoke(Object args, WiseMapper mapper) throws WiseException
+    {
+        Map<String, Object> emptyHolder = Collections.emptyMap();
+        return new InvocationResult(null, null, emptyHolder);
+    }
+}

Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/SOAPClientUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/SOAPClientUnitTest.java	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/SOAPClientUnitTest.java	2009-01-23 18:10:31 UTC (rev 24896)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, Home of Professional Open Source Copyright 2009, Red Hat Middleware
+ * LLC, and individual contributors by the @authors tag. See the copyright.txt
+ * in the distribution for a full listing of individual contributors.
+ * 
+ * This is free software; you can redistribute it and/or modify it under the
+ * terms of the GNU Lesser General Public License as published by the Free
+ * Software Foundation; either version 2.1 of the License, or (at your option)
+ * any later version.
+ * 
+ * This software 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.
+ * 
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this software; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the FSF
+ * site: http://www.fsf.org.
+ */
+package org.jboss.soa.esb.actions.soap.wise;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import it.javalinux.wise.core.client.WSDynamicClient;
+import it.javalinux.wise.core.client.WSEndpoint;
+import it.javalinux.wise.core.exceptions.WiseException;
+import it.javalinux.wise.core.utils.WiseProperties;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.JUnit4TestAdapter;
+
+import org.jboss.soa.esb.ConfigurationException;
+import org.jboss.soa.esb.actions.ActionLifecycleException;
+import org.jboss.soa.esb.actions.ActionProcessingException;
+import org.jboss.soa.esb.helpers.ConfigTree;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * Unit test for {@link SOAPClient}.
+ * <p/>
+ */
+public class SOAPClientUnitTest
+{
+    private static File workingDir;
+    private String wsdl = "http://127.0.0.1:8080/Quickstart_webservice_consumer_wise/HelloWorldWS?wsdl";
+    private String soapAction = "sayHello";
+    private String endPointName = "HelloWorldPort";
+    private String serviceName = "HelloWorldService";
+
+    @BeforeClass
+    public static void setup()
+    {
+        workingDir = new File("working");
+        workingDir.mkdir();
+    }
+    
+    @AfterClass
+    public static void teardown()
+    {
+        workingDir.delete();
+    }
+    
+    @Test
+    public void configOperationName() throws ConfigurationException, ActionProcessingException, ActionLifecycleException
+    {
+        final String operationName = "sayHello";
+        final ConfigTree config = createConfig(operationName);
+        final SOAPClient client = new MockSOAPClient(config);
+        
+        assertNotNull(client.getOperationName());
+        assertEquals(operationName, client.getOperationName());
+    }
+    
+    public static junit.framework.Test suite()
+    {
+        return new JUnit4TestAdapter(SOAPClientUnitTest.class);
+    }
+    
+    private ConfigTree createConfig(final String operationName)
+    {
+        final ConfigTree configTree = new ConfigTree("wise-soap-client");
+        configTree.setAttribute("wsdl", wsdl);
+        configTree.setAttribute("SOAPAction", soapAction);
+        configTree.setAttribute("EndPointName", endPointName);
+        configTree.setAttribute("serviceName", serviceName);
+        configTree.setAttribute("operationName", operationName);
+        return configTree;
+    }
+    
+    private class MockSOAPClient extends SOAPClient
+    {
+        public MockSOAPClient(ConfigTree config) throws ConfigurationException
+        {
+            super(config);
+        }
+        
+        @Override
+        WSDynamicClient createClient(final String wsdl, final String serviceName, final String username, final String password) throws ActionProcessingException
+        {
+            try
+            {
+                return new MockWSDynamicClient(new WiseProperties("wise-core.properties"));
+            } 
+            catch (WiseException e)
+            {
+                throw new ActionProcessingException(e.getMessage(), e);
+            }
+        }
+        
+        @Override
+        Map<String, WSEndpoint> getEndpoints(final WSDynamicClient client)
+        {
+            HashMap<String, WSEndpoint> map = new HashMap<String, WSEndpoint>();
+            map.put(endPointName, new MockWSEndpoint(soapAction));
+            return map;
+        }
+    }
+    
+}

Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/wise.core-properties
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/wise.core-properties	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/java/org/jboss/soa/esb/actions/soap/wise/wise.core-properties	2009-01-23 18:10:31 UTC (rev 24896)
@@ -0,0 +1,4 @@
+wise.tmpDir=working
+wise.forceImportObject=true
+wise.keepGeneratedSources=false
+wise.wsImporter.verbose=false

Modified: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/resources/log4j.xml
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/resources/log4j.xml	2009-01-23 16:55:00 UTC (rev 24895)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/resources/log4j.xml	2009-01-23 18:10:31 UTC (rev 24896)
@@ -34,14 +34,14 @@
    <!-- Limit categories -->
    <!-- ================ -->
 
-   <category name="org.jbpm">
-      <priority value="INFO"/>
+   <category name="org.milyn">
+      <priority value="ERROR"/>
    </category>
    <category name="org.hibernate">
       <priority value="ERROR"/>
    </category>
    <category name="org.jboss">
-      <priority value="WARN"/>
+      <priority value="ERROR"/>
    </category>
    <category name="org.jboss.soa.esb">
       <priority value="ERROR"/>
@@ -53,8 +53,15 @@
       <priority value="ERROR"/>
    </category>
    <category name="org.jboss.soa.esb.services.jbpm">
-      <priority value="DEBUG"/>
+      <priority value="ERROR"/>
    </category>
+   <category name="com.eviware.soapui">
+      <priority value="ERROR"/>
+   </category>
+   <category name="httpclient">
+      <priority value="ERROR"/>
+   </category>
+
    <!-- ======================= -->
    <!-- Setup the Root category -->
    <!-- ======================= -->

Added: labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/resources/wise-core.properties
===================================================================
--- labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/resources/wise-core.properties	                        (rev 0)
+++ labs/jbossesb/branches/JBESB_4_4_GA_CP/product/services/soap/src/test/resources/wise-core.properties	2009-01-23 18:10:31 UTC (rev 24896)
@@ -0,0 +1,4 @@
+wise.tmpDir=/tmp
+wise.forceImportObject=true
+wise.keepGeneratedSources=true
+wise.wsImporter.verbose=true




More information about the jboss-svn-commits mailing list