Added: 
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/testkit/listener/XMLRequestResponseMessageTestCase.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/testkit/listener/XMLRequestResponseMessageTestCase.java?rev=681205&view=auto
==============================================================================
--- 
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/testkit/listener/XMLRequestResponseMessageTestCase.java
 (added)
+++ 
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/testkit/listener/XMLRequestResponseMessageTestCase.java
 Wed Jul 30 14:13:51 2008
@@ -0,0 +1,78 @@
+/*
+ *  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.synapse.transport.testkit.listener;
+
+import javax.xml.namespace.QName;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMFactory;
+import org.apache.axis2.AxisFault;
+import org.apache.axis2.Constants;
+import org.apache.axis2.context.MessageContext;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.InOutAxisOperation;
+import org.apache.axis2.engine.AxisConfiguration;
+import org.apache.axis2.receivers.AbstractInOutMessageReceiver;
+
+public class XMLRequestResponseMessageTestCase<C extends 
RequestResponseChannel<?>> extends 
ListenerTestCase<C,XMLRequestResponseMessageSender<? super C>> {
+    private final XMLMessageType xmlMessageType;
+    private final MessageTestData data;
+    
+    // TODO: realign order of arguments with XMLAsyncMessageTestCase 
constructor
+    public XMLRequestResponseMessageTestCase(C channel, 
XMLRequestResponseMessageSender<? super C> sender, String name, ContentTypeMode 
contentTypeMode, String contentType, XMLMessageType xmlMessageType, 
MessageTestData data) {
+        super(channel, sender, name, contentTypeMode, contentType);
+        this.xmlMessageType = xmlMessageType;
+        this.data = data;
+    }
+
+    @Override
+    protected void runTest() throws Throwable {
+        AxisService service = new AxisService("EchoService");
+        AxisOperation operation = new 
InOutAxisOperation(DefaultOperationDispatcher.DEFAULT_OPERATION_NAME);
+        operation.setMessageReceiver(new AbstractInOutMessageReceiver() {
+            @Override
+            public void invokeBusinessLogic(MessageContext inMessage, 
MessageContext outMessage) throws AxisFault {
+                
System.out.println(inMessage.getProperty(Constants.OUT_TRANSPORT_INFO));
+                System.out.println(inMessage.getEnvelope());
+                outMessage.setEnvelope(inMessage.getEnvelope());
+            }
+        });
+        service.addOperation(operation);
+        channel.setupService(service);
+        if (contentTypeMode == ContentTypeMode.SERVICE) {
+            channel.getSetup().setupContentType(service, contentType);
+        }
+        
+        AxisConfiguration axisConfiguration = server.getAxisConfiguration();
+        axisConfiguration.addService(service);
+        try {
+            OMFactory factory = xmlMessageType.getOMFactory();
+            OMElement orgElement = factory.createOMElement(new QName("root"));
+            orgElement.setText(data.getText());
+            OMElement element = sender.sendMessage(channel, 
server.getEPR(service), contentType, data.getCharset(), xmlMessageType, 
orgElement);
+            assertEquals(orgElement.getQName(), element.getQName());
+            assertEquals(orgElement.getText(), element.getText());
+        } finally {
+            Thread.sleep(1000);
+            axisConfiguration.removeService(service.getName());
+        }
+    }
+}

Propchange: 
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/testkit/listener/XMLRequestResponseMessageTestCase.java
------------------------------------------------------------------------------
    svn:mergeinfo = 

Modified: 
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSFileChannel.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSFileChannel.java?rev=681205&r1=681204&r2=681205&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSFileChannel.java
 (original)
+++ 
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSFileChannel.java
 Wed Jul 30 14:13:51 2008
@@ -25,9 +25,10 @@
 import org.apache.axis2.description.TransportInDescription;
 import org.apache.axis2.description.TransportOutDescription;
 import org.apache.synapse.transport.testkit.listener.AbstractChannel;
+import org.apache.synapse.transport.testkit.listener.AsyncChannel;
 import 
org.apache.synapse.transport.vfs.VFSTransportListenerTest.TestStrategyImpl;
 
-public class VFSFileChannel extends 
AbstractChannel<VFSTransportListenerTest.TestStrategyImpl> {
+public class VFSFileChannel extends 
AbstractChannel<VFSTransportListenerTest.TestStrategyImpl> implements 
AsyncChannel<VFSTransportListenerTest.TestStrategyImpl> {
     private final File requestFile;
     
     public VFSFileChannel(TestStrategyImpl setup, File requestFile) {

Modified: 
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTransportListenerTest.java
URL: 
http://svn.apache.org/viewvc/synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTransportListenerTest.java?rev=681205&r1=681204&r2=681205&view=diff
==============================================================================
--- 
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTransportListenerTest.java
 (original)
+++ 
synapse/trunk/java/modules/transports/src/test/java/org/apache/synapse/transport/vfs/VFSTransportListenerTest.java
 Wed Jul 30 14:13:51 2008
@@ -22,18 +22,19 @@
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
+import java.util.LinkedList;
+import java.util.List;
 
 import junit.framework.TestCase;
 import junit.framework.TestSuite;
 
 import org.apache.axis2.description.AxisService;
-import org.apache.synapse.transport.testkit.listener.AxisMessageSender;
+import org.apache.synapse.transport.testkit.listener.AxisAsyncMessageSender;
 import org.apache.synapse.transport.testkit.listener.BinaryPayloadSender;
-import org.apache.synapse.transport.testkit.listener.Channel;
 import org.apache.synapse.transport.testkit.listener.ContentTypeMode;
 import org.apache.synapse.transport.testkit.listener.ListenerTestSetup;
 import org.apache.synapse.transport.testkit.listener.ListenerTestSuite;
-import org.apache.synapse.transport.testkit.listener.XMLMessageSender;
+import org.apache.synapse.transport.testkit.listener.XMLAsyncMessageSender;
 
 /**
  * TransportListenerTestTemplate implementation for the VFS transport.
@@ -46,10 +47,10 @@
         }
     }
     
-    private static class MessageSenderImpl extends BinaryPayloadSender {
+    private static class MessageSenderImpl extends 
BinaryPayloadSender<VFSFileChannel> {
         @Override
-        public void sendMessage(Channel<?> channel, String endpointReference, 
String contentType, byte[] content) throws Exception {
-            OutputStream out = new 
FileOutputStream(((VFSFileChannel)channel).getRequestFile());
+        public void sendMessage(VFSFileChannel channel, String 
endpointReference, String contentType, byte[] content) throws Exception {
+            OutputStream out = new FileOutputStream(channel.getRequestFile());
             out.write(content);
             out.close();
         }
@@ -60,8 +61,11 @@
         ListenerTestSuite suite = new ListenerTestSuite(false);
         TestStrategyImpl setup = new TestStrategyImpl();
         VFSFileChannel channel = new VFSFileChannel(setup, new 
File("target/vfs3/req/in").getAbsoluteFile());
-        BinaryPayloadSender vfsSender = new MessageSenderImpl();
-        for (XMLMessageSender sender : new XMLMessageSender[] { vfsSender, new 
AxisMessageSender() }) {
+        MessageSenderImpl vfsSender = new MessageSenderImpl();
+        List<XMLAsyncMessageSender<? super VFSFileChannel>> senders = new 
LinkedList<XMLAsyncMessageSender<? super VFSFileChannel>>();
+        senders.add(vfsSender);
+        senders.add(new AxisAsyncMessageSender());
+        for (XMLAsyncMessageSender<? super VFSFileChannel> sender : senders) {
             suite.addSOAPTests(channel, sender, ContentTypeMode.SERVICE);
             suite.addPOXTests(channel, sender, ContentTypeMode.SERVICE);
             // Since VFS has no Content-Type header, SwA is not supported.


Reply via email to