Author: senaka
Date: Sun Oct 26 11:13:29 2008
New Revision: 708016

URL: http://svn.apache.org/viewvc?rev=708016&view=rev
Log:
Working implementation of JMS Map Message support. This system makes a few 
assumptions which are needed to be corrected. There is also a requirement to 
fix the implementation in JMSSender.

Added:
    
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLMapRequestResponseMessageTestCase.java
Modified:
    
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
    
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
    
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java
    
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java
    
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/MapTestCase.java
    
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSClient.java
    
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseClient.java
    
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSTransportTest.java

Modified: 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java?rev=708016&r1=708015&r2=708016&view=diff
==============================================================================
--- 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
 (original)
+++ 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/jms/src/main/java/org/apache/axis2/transport/jms/JMSSender.java
 Sun Oct 26 11:13:29 2008
@@ -37,6 +37,10 @@
 import javax.jms.Queue;
 import javax.activation.DataHandler;
 import javax.naming.Context;
+import javax.xml.stream.XMLStreamException;
+
+import java.beans.XMLDecoder;
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.UnsupportedEncodingException;
@@ -444,6 +448,33 @@
                             }
                         }
                     }
+                } else if (wrapper != null && wrapper.getFirstOMChild() != 
null) {
+                // FIXME: The incoming payload might come from a non-JMS 
source, in that case,
+                // we don't get a OMSourcedElement. This issue must be sorted 
and the creation 
+                // of the OMSourcedElement must happen at the most optimal 
location.
+                    OMNode firstChild = wrapper.getFirstOMChild();
+                    ByteArrayOutputStream baosForMap = new 
ByteArrayOutputStream();
+                    try {
+                        firstChild.serialize(baosForMap);
+                    } catch (XMLStreamException e) {
+                        handleException("Error serializing binary content of 
element : " +
+                                BaseConstants.DEFAULT_MAP_WRAPPER, e);
+                    }
+                    ByteArrayInputStream bais = new 
ByteArrayInputStream(baosForMap.toByteArray());
+                    XMLDecoder decoder = new XMLDecoder(bais);
+                    Object result = decoder.readObject();
+                    decoder.close();
+                    if (result != null) {
+                        Map map = (Map)result;
+                        Iterator it = map.keySet().iterator();
+                        while (it.hasNext()) {
+                            Object key = it.next();
+                            Object value = map.get(key);
+                            if (key != null && value != null && key instanceof 
String) {
+                                mapMsg.setObject((String)key, value);
+                            }
+                        }
+                    }
                 }
             } else {
                 message = session.createTextMessage();  // default
@@ -501,7 +532,34 @@
                         }
                     }
                 }
-            }   
+            } else if (wrapper != null && wrapper.getFirstOMChild() != null) {
+            // FIXME: The incoming payload might come from a non-JMS source, 
in that case,
+            // we don't get a OMSourcedElement. This issue must be sorted and 
the creation 
+            // of the OMSourcedElement must happen at the most optimal 
location.
+                OMNode firstChild = wrapper.getFirstOMChild();
+                ByteArrayOutputStream baos = new ByteArrayOutputStream();
+                try {
+                    firstChild.serialize(baos);
+                } catch (XMLStreamException e) {
+                    handleException("Error serializing binary content of 
element : " +
+                            BaseConstants.DEFAULT_MAP_WRAPPER, e);
+                }
+                ByteArrayInputStream bais = new 
ByteArrayInputStream(baos.toByteArray());
+                XMLDecoder decoder = new XMLDecoder(bais);
+                Object result = decoder.readObject();
+                decoder.close();
+                if (result != null) {
+                    Map map = (Map)result;
+                    Iterator it = map.keySet().iterator();
+                    while (it.hasNext()) {
+                        Object key = it.next();
+                        Object value = map.get(key);
+                        if (key != null && value != null && key instanceof 
String) {
+                            mapMsg.setObject((String)key, value);
+                        }
+                    }
+                }
+            }
         }
 
         // set the JMS correlation ID if specified

Modified: 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java?rev=708016&r1=708015&r2=708016&view=diff
==============================================================================
--- 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
 (original)
+++ 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/TransportTestSuiteBuilder.java
 Sun Oct 26 11:13:29 2008
@@ -29,6 +29,7 @@
 import java.util.List;
 import java.util.Map;
 import java.util.Set;
+import java.util.TreeMap;
 
 import org.apache.axis2.transport.testkit.channel.AsyncChannel;
 import org.apache.axis2.transport.testkit.channel.RequestResponseChannel;
@@ -51,6 +52,7 @@
 import org.apache.axis2.transport.testkit.tests.async.TextPlainTestCase;
 import org.apache.axis2.transport.testkit.tests.async.XMLAsyncMessageTestCase;
 import 
org.apache.axis2.transport.testkit.tests.echo.XMLRequestResponseMessageTestCase;
+import 
org.apache.axis2.transport.testkit.tests.echo.XMLMapRequestResponseMessageTestCase;
 
 public class TransportTestSuiteBuilder {
     static class ResourceRelation<T> {
@@ -104,6 +106,8 @@
             new Parameter("param", "value1"),
             new Parameter("param", "value2"),
         });
+
+    private static final Map mapTestMessage = new TreeMap();
     
     private final ManagedTestSuite suite;
     
@@ -126,6 +130,7 @@
     private final ResourceList<RequestResponseChannel> requestResponseChannels 
= new ResourceList<RequestResponseChannel>();
     
     private final 
ResourceList<RequestResponseTestClient<XMLMessage,XMLMessage>> 
xmlRequestResponseClients = new 
ResourceList<RequestResponseTestClient<XMLMessage,XMLMessage>>();
+    private final 
ResourceList<RequestResponseTestClient<XMLMessage,XMLMessage>> 
xmlMapRequestResponseClients = new 
ResourceList<RequestResponseTestClient<XMLMessage,XMLMessage>>();
     
     private final ResourceList<InOutEndpoint> echoEndpoints = new 
ResourceList<InOutEndpoint>();
     
@@ -137,6 +142,8 @@
         } catch (ParseException ex) {
             throw new Error(ex);
         }
+        mapTestMessage.put("string", "name");
+        mapTestMessage.put("int", 1);
     }
     
     public void addEnvironment(Object... resources) {
@@ -189,10 +196,10 @@
         restAsyncEndpoints.add(endpoint, relatedResources);
     }
 
-    public void addMapAsyncEndpoint(AsyncEndpoint<Map> endpoint, Object... 
relatedResources) {
-        mapAsyncEndpoints.add(endpoint, relatedResources);
+    public void addMapAsyncEndpoint(AsyncEndpoint<AxisMessage> endpoint, 
Object... relatedResources) {
+        mapAsyncEndpoints.add(adapt(endpoint, MessageDecoder.AXIS_TO_MAP), 
relatedResources);
     }
-    
+
     public void addRequestResponseChannel(RequestResponseChannel channel, 
Object... relatedResources) {
         requestResponseChannels.add(channel, relatedResources);
     }
@@ -208,6 +215,10 @@
     public void 
addStringRequestResponseTestClient(RequestResponseTestClient<String,String> 
client, Object... relatedResources) {
         xmlRequestResponseClients.add(adapt(client, 
MessageEncoder.XML_TO_STRING, MessageDecoder.STRING_TO_XML), relatedResources);
     }
+
+    public void 
addMapRequestResponseTestClient(RequestResponseTestClient<Map,Map> client, 
Object... relatedResources) {
+        xmlMapRequestResponseClients.add(adapt(client, 
MessageEncoder.XML_TO_MAP, MessageDecoder.MAP_TO_XML), relatedResources);
+    }
     
     public void addEchoEndpoint(InOutEndpoint endpoint, Object... 
relatedResources) {
         echoEndpoints.add(endpoint, relatedResources);
@@ -264,7 +275,7 @@
             for (ResourceRelation<AsyncTestClient<Map>> client : 
mapAsyncClients) {
                 for (ResourceRelation<AsyncEndpoint<Map>> endpoint : 
mapAsyncEndpoints) {
                     Object[] resources = merge(env, channel, client, endpoint);
-                    suite.addTest(new 
MapTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), 
endpoint.getPrimaryResource(), resources));
+                    suite.addTest(new 
MapTestCase(channel.getPrimaryResource(), client.getPrimaryResource(), 
endpoint.getPrimaryResource(), mapTestMessage, resources));
                 }
             }
         }
@@ -281,6 +292,12 @@
                     }
                 }
             }
+            for 
(ResourceRelation<RequestResponseTestClient<XMLMessage,XMLMessage>> client : 
xmlMapRequestResponseClients) {
+                for (ResourceRelation<InOutEndpoint> endpoint : echoEndpoints) 
{
+                    Object[] resources = merge(env, channel, client, endpoint);
+                    suite.addTest(new 
XMLMapRequestResponseMessageTestCase(channel.getPrimaryResource(), 
client.getPrimaryResource(), endpoint.getPrimaryResource(), 
XMLMessage.Type.SOAP11, mapTestMessage, resources));
+                }
+            }
         }
     }
     

Modified: 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java?rev=708016&r1=708015&r2=708016&view=diff
==============================================================================
--- 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java
 (original)
+++ 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageDecoder.java
 Sun Oct 26 11:13:29 2008
@@ -19,26 +19,34 @@
 
 package org.apache.axis2.transport.testkit.message;
 
+import java.beans.XMLDecoder;
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.StringReader;
 import java.util.Iterator;
 import java.util.LinkedList;
 import java.util.List;
+import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.mail.internet.ContentType;
+import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 
 import junit.framework.Assert;
 
 import org.apache.axiom.attachments.Attachments;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMDataSourceExt;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMNode;
+import org.apache.axiom.om.OMSourcedElement;
 import org.apache.axiom.om.OMText;
+import org.apache.axiom.om.ds.MapDataSource;
 import org.apache.axiom.om.impl.builder.StAXOMBuilder;
 import org.apache.axiom.om.util.StAXUtils;
 import org.apache.axiom.soap.SOAPEnvelope;
+import org.apache.axiom.soap.SOAPFactory;
 import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
 import org.apache.axis2.transport.base.BaseConstants;
 import org.apache.axis2.transport.testkit.message.RESTMessage.Parameter;
@@ -58,6 +66,24 @@
             return baos.toByteArray();
         }
     };
+
+    MessageDecoder<AxisMessage,Map> AXIS_TO_MAP =
+        new MessageDecoder<AxisMessage,Map>() {
+
+        public Map decode(ContentType contentType, AxisMessage message) throws 
Exception {
+            SOAPEnvelope envelope = message.getEnvelope();
+            OMElement wrapper = envelope.getBody().getFirstElement();
+            Assert.assertEquals(BaseConstants.DEFAULT_MAP_WRAPPER, 
wrapper.getQName());
+            OMNode firstChild = wrapper.getFirstOMChild();
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            firstChild.serialize(baos);
+            ByteArrayInputStream bais = new 
ByteArrayInputStream(baos.toByteArray());
+            XMLDecoder decoder = new XMLDecoder(bais);
+            Object result = decoder.readObject();
+            decoder.close();
+            return (Map)result;
+        }
+    };
     
     MessageDecoder<AxisMessage,String> AXIS_TO_STRING =
         new MessageDecoder<AxisMessage,String>() {
@@ -136,6 +162,19 @@
             }
         }
     };
+
+    MessageDecoder<Map,XMLMessage> MAP_TO_XML =
+        new MessageDecoder<Map,XMLMessage>() {
+
+        public XMLMessage decode(ContentType contentType, Map message) throws 
Exception {
+            SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+            QName wrapperQName = BaseConstants.DEFAULT_MAP_WRAPPER;
+            OMElement wrapper = factory.createOMElement(new 
MapDataSource(message, wrapperQName.getLocalPart(),
+                factory.createOMNamespace(wrapperQName.getNamespaceURI(), 
wrapperQName.getPrefix())), wrapperQName.getLocalPart(),
+                factory.createOMNamespace(wrapperQName.getNamespaceURI(), 
wrapperQName.getPrefix()));
+            return new XMLMessage(wrapper, XMLMessage.Type.SOAP11);
+        }
+    };
     
     MessageDecoder<String,XMLMessage> STRING_TO_XML =
         new MessageDecoder<String,XMLMessage>() {

Modified: 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java?rev=708016&r1=708015&r2=708016&view=diff
==============================================================================
--- 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java
 (original)
+++ 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/message/MessageEncoder.java
 Sun Oct 26 11:13:29 2008
@@ -19,17 +19,23 @@
 
 package org.apache.axis2.transport.testkit.message;
 
+import java.beans.XMLDecoder;
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.StringWriter;
+import java.util.Map;
 
 import javax.activation.DataHandler;
 import javax.mail.internet.ContentType;
+import javax.xml.namespace.QName;
 
 import org.apache.axiom.attachments.ByteArrayDataSource;
 import org.apache.axiom.om.OMAbstractFactory;
 import org.apache.axiom.om.OMElement;
 import org.apache.axiom.om.OMOutputFormat;
+import org.apache.axiom.om.ds.MapDataSource;
 import org.apache.axiom.om.impl.MIMEOutputUtils;
+import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axiom.soap.SOAP12Constants;
 import org.apache.axiom.soap.SOAPEnvelope;
 import org.apache.axiom.soap.SOAPFactory;
@@ -115,6 +121,27 @@
             return sw.toString();
         }
     };
+
+    MessageEncoder<XMLMessage,Map> XML_TO_MAP =
+        new MessageEncoder<XMLMessage,Map>() {
+
+        public ContentType getContentType(ClientOptions options, ContentType 
contentType) throws Exception {
+            return new ContentType(SOAP11Constants.SOAP_11_CONTENT_TYPE);
+        }
+
+        public Map encode(ClientOptions options, XMLMessage message) throws 
Exception {
+            ByteArrayOutputStream baos = new ByteArrayOutputStream();
+            OMOutputFormat outputFormat = new OMOutputFormat();
+            outputFormat.setCharSetEncoding(options.getCharset());
+            outputFormat.setIgnoreXMLDeclaration(true);
+            message.getPayload().getFirstElement().serializeAndConsume(baos, 
outputFormat);
+            ByteArrayInputStream bais = new 
ByteArrayInputStream(baos.toByteArray());
+            XMLDecoder decoder = new XMLDecoder(bais);
+            Object result = decoder.readObject();
+            decoder.close();
+            return (Map)result;
+        }
+    };
     
     MessageEncoder<byte[],AxisMessage> BINARY_WRAPPER =
         new MessageEncoder<byte[],AxisMessage>() {
@@ -136,6 +163,27 @@
             return result;
         }
     };
+
+    MessageEncoder<Map,AxisMessage> MAP_WRAPPER =
+        new MessageEncoder<Map,AxisMessage>() {
+
+        public ContentType getContentType(ClientOptions options, ContentType 
contentType) {
+            return contentType;
+        }
+
+        public AxisMessage encode(ClientOptions options, Map message) throws 
Exception {
+            AxisMessage result = new AxisMessage();
+            result.setMessageType(null);
+            SOAPFactory factory = OMAbstractFactory.getSOAP11Factory();
+            SOAPEnvelope envelope = factory.getDefaultEnvelope();
+            QName wrapperQName = BaseConstants.DEFAULT_MAP_WRAPPER;
+            OMElement wrapper = factory.createOMElement(new 
MapDataSource(message), wrapperQName.getLocalPart(),
+                factory.createOMNamespace(wrapperQName.getNamespaceURI(), 
wrapperQName.getPrefix()));
+            envelope.getBody().addChild(wrapper);
+            result.setEnvelope(envelope);
+            return result;
+        }
+    };
     
     MessageEncoder<String,AxisMessage> TEXT_WRAPPER =
         new MessageEncoder<String,AxisMessage>() {

Modified: 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/MapTestCase.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/MapTestCase.java?rev=708016&r1=708015&r2=708016&view=diff
==============================================================================
--- 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/MapTestCase.java
 (original)
+++ 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/async/MapTestCase.java
 Sun Oct 26 11:13:29 2008
@@ -33,15 +33,16 @@
 @Name("AsyncMap")
 public class MapTestCase extends AsyncMessageTestCase<Map> {
     private static final Random random = new Random();
+    private final Map message;
     
-    public MapTestCase(AsyncChannel channel, AsyncTestClient<Map> client, 
AsyncEndpoint<Map> endpoint, Object... resources) {
+    public MapTestCase(AsyncChannel channel, AsyncTestClient<Map> client, 
AsyncEndpoint<Map> endpoint, Map message, Object... resources) {
         super(channel, client, endpoint, null, null, resources);
+        this.message = message;
     }
     
     @Override
     protected Map prepareMessage() throws Exception {
-        Map content = new TreeMap();
-        return content;
+        return message;
     }
 
     @Override

Added: 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLMapRequestResponseMessageTestCase.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLMapRequestResponseMessageTestCase.java?rev=708016&view=auto
==============================================================================
--- 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLMapRequestResponseMessageTestCase.java
 (added)
+++ 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/testkit/src/main/java/org/apache/axis2/transport/testkit/tests/echo/XMLMapRequestResponseMessageTestCase.java
 Sun Oct 26 11:13:29 2008
@@ -0,0 +1,65 @@
+/*
+ *  Licensed to the Apache Software Foundation (ASF) under one
+ *  or more contributor license agreements.  See the NOTICE file
+ *  distributed with this work for additional information
+ *  regarding copyright ownership.  The ASF licenses this file
+ *  to you under the Apache License, Version 2.0 (the
+ *  "License"); you may not use this file except in compliance
+ *  with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing,
+ *  software distributed under the License is distributed on an
+ *   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ *  KIND, either express or implied.  See the License for the
+ *  specific language governing permissions and limitations
+ *  under the License.
+ */
+
+package org.apache.axis2.transport.testkit.tests.echo;
+
+import java.util.Map;
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axiom.om.ds.MapDataSource;
+import org.apache.axis2.transport.base.BaseConstants;
+import org.apache.axis2.transport.testkit.MessageTestData;
+import org.apache.axis2.transport.testkit.channel.RequestResponseChannel;
+import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
+import org.apache.axis2.transport.testkit.endpoint.InOutEndpoint;
+import org.apache.axis2.transport.testkit.message.XMLMessage;
+import org.apache.axis2.transport.testkit.name.Name;
+
[EMAIL PROTECTED]("EchoMapXML")
+public class XMLMapRequestResponseMessageTestCase extends 
XMLRequestResponseMessageTestCase {
+    private final XMLMessage.Type xmlMessageType;
+    private final Map data;
+    
+    public XMLMapRequestResponseMessageTestCase(RequestResponseChannel 
channel, RequestResponseTestClient<XMLMessage,XMLMessage> client, InOutEndpoint 
endpoint, XMLMessage.Type xmlMessageType, Map data, Object... resources) {
+        super(channel, client, endpoint, xmlMessageType, new 
MessageTestData("UTF8", "", "UTF-8"), resources);
+        this.xmlMessageType = xmlMessageType;
+        this.data = data;
+    }
+
+    @Override
+    protected XMLMessage prepareRequest() throws Exception {
+        OMFactory factory = OMAbstractFactory.getOMFactory();
+        QName wrapperQName = BaseConstants.DEFAULT_MAP_WRAPPER;
+        OMElement wrapper = factory.createOMElement(new MapDataSource(data, 
wrapperQName.getLocalPart(),
+            factory.createOMNamespace(wrapperQName.getNamespaceURI(), 
wrapperQName.getPrefix())), wrapperQName.getLocalPart(),
+            factory.createOMNamespace(wrapperQName.getNamespaceURI(), 
wrapperQName.getPrefix()));
+        return new XMLMessage(wrapper, xmlMessageType);
+    }
+
+    @Override
+    protected void checkResponse(XMLMessage request, XMLMessage response) 
throws Exception {
+        OMElement orgElement = request.getPayload();
+        OMElement element = response.getPayload();
+        assertEquals(orgElement.getQName(), element.getQName());
+        assertEquals(orgElement.toString(), element.toString());
+    }
+}

Modified: 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSClient.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSClient.java?rev=708016&r1=708015&r2=708016&view=diff
==============================================================================
--- 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSClient.java
 (original)
+++ 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSClient.java
 Sun Oct 26 11:13:29 2008
@@ -66,7 +66,7 @@
 
     protected String doSendMessage(ClientOptions options, ContentType 
contentType, T message) throws Exception {
         Message jmsMessage = jmsMessageFactory.createMessage(session, message);
-        if (contentTypeMode == ContentTypeMode.TRANSPORT) {
+        if (contentType != null && contentTypeMode == 
ContentTypeMode.TRANSPORT) {
             jmsMessage.setStringProperty(BaseConstants.CONTENT_TYPE, 
contentType.toString());
         }
         producer.send(jmsMessage);

Modified: 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseClient.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseClient.java?rev=708016&r1=708015&r2=708016&view=diff
==============================================================================
--- 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseClient.java
 (original)
+++ 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSRequestResponseClient.java
 Sun Oct 26 11:13:29 2008
@@ -27,6 +27,7 @@
 import javax.jms.Session;
 import javax.mail.internet.ContentType;
 
+import org.apache.axiom.soap.SOAP11Constants;
 import org.apache.axis2.transport.testkit.client.ClientOptions;
 import org.apache.axis2.transport.testkit.client.RequestResponseTestClient;
 import org.apache.axis2.transport.testkit.message.IncomingMessage;
@@ -57,7 +58,9 @@
         MessageConsumer consumer = 
replySession.createConsumer(replyDestination, "JMSCorrelationID = '" + 
correlationId + "'");
         try {
             Message replyMessage = consumer.receive(8000);
-            return new IncomingMessage<T>(new 
ContentType(replyMessage.getStringProperty("Content-Type")),
+            return new IncomingMessage<T>(new 
ContentType((replyMessage.getStringProperty("Content-Type") != null ?
+                                          
replyMessage.getStringProperty("Content-Type") :
+                                          
SOAP11Constants.SOAP_11_CONTENT_TYPE)),
                                           
jmsMessageFactory.parseMessage(replyMessage));
         } finally {
             consumer.close();

Modified: 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSTransportTest.java
URL: 
http://svn.apache.org/viewvc/webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSTransportTest.java?rev=708016&r1=708015&r2=708016&view=diff
==============================================================================
--- 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSTransportTest.java
 (original)
+++ 
webservices/commons/trunk/scratch/senaka/sci-flex/transport/modules/tests/src/test/java/org/apache/axis2/transport/jms/JMSTransportTest.java
 Sun Oct 26 11:13:29 2008
@@ -74,9 +74,10 @@
         builder.addAxisAsyncTestClient(new AxisAsyncTestClient(), new 
JMSAxisTestClientConfigurator(JMSConstants.JMS_TEXT_MESSAGE));
         builder.addByteArrayAsyncTestClient(new 
JMSAsyncClient<byte[]>(JMSBytesMessageFactory.INSTANCE));
         builder.addStringAsyncTestClient(new 
JMSAsyncClient<String>(JMSTextMessageFactory.INSTANCE));
-        builder.addMapAsyncTestClient(new 
JMSAsyncClient<Map>(JMSMapMessageFactory.INSTANCE));
-        
+        builder.addMapAsyncTestClient(new 
JMSAsyncClient<Map>(JMSMapMessageFactory.INSTANCE), new 
JMSAxisTestClientConfigurator(JMSConstants.JMS_MAP_MESSAGE));
+
         builder.addAxisAsyncEndpoint(new AxisAsyncEndpoint());
+        builder.addMapAsyncEndpoint(new AxisAsyncEndpoint());
         
         builder.addRequestResponseChannel(new 
JMSRequestResponseChannel(JMSConstants.DESTINATION_TYPE_QUEUE, 
JMSConstants.DESTINATION_TYPE_QUEUE, ContentTypeMode.TRANSPORT));
         
@@ -88,6 +89,7 @@
         
         builder.addAxisRequestResponseTestClient(new 
AxisRequestResponseTestClient(), timeoutConfigurator);
         builder.addStringRequestResponseTestClient(new 
JMSRequestResponseClient<String>(JMSTextMessageFactory.INSTANCE));
+        builder.addMapRequestResponseTestClient(new 
JMSRequestResponseClient<Map>(JMSMapMessageFactory.INSTANCE));
         
         builder.addEchoEndpoint(new MockEchoEndpoint());
         builder.addEchoEndpoint(new AxisEchoEndpoint());


Reply via email to