You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by th...@apache.org on 2006/10/04 08:42:06 UTC

svn commit: r452763 - in /webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa: EchoRawSwAFileCacheTest.java EchoRawSwAFileInputTest.java EchoRawSwATest.java EchoSwA.java

Author: thilina
Date: Tue Oct  3 23:42:05 2006
New Revision: 452763

URL: http://svn.apache.org/viewvc?view=rev&rev=452763
Log:
Commiting the SOAP with Attachments test cases

Added:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileCacheTest.java   (with props)
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileInputTest.java   (with props)
Modified:
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java
    webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoSwA.java

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileCacheTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileCacheTest.java?view=auto&rev=452763
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileCacheTest.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileCacheTest.java Tue Oct  3 23:42:05 2006
@@ -0,0 +1,66 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.swa;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.engine.Echo;
+import org.apache.axis2.integration.UtilServer;
+import org.apache.axis2.util.Utils;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+public class EchoRawSwAFileCacheTest extends EchoRawSwATest{
+
+    private AxisService service;
+
+
+    public EchoRawSwAFileCacheTest() {
+        super(EchoRawSwAFileCacheTest.class.getName());
+    }
+
+    public EchoRawSwAFileCacheTest(String testName) {
+        super(testName);
+    }
+
+    public static Test suite() {
+        return getTestSetup2(new TestSuite(EchoRawSwAFileCacheTest.class),Constants.TESTING_PATH + "SwA-fileCache-enabledRepository");
+    }
+
+    protected void setUp() throws Exception {
+        service = Utils.createSimpleService(serviceName, EchoSwA.class.getName(),
+                operationName);
+        UtilServer.deployService(service);
+    }
+
+    protected void tearDown() throws Exception {
+        UtilServer.unDeployService(serviceName);
+        UtilServer.unDeployClientService();
+    }
+
+//    public void testEchoXMLASync() throws Exception {
+//        super.testEchoXMLASync();
+//    }
+
+    public void testEchoXMLSync() throws Exception {
+        super.testEchoXMLSync();
+    }
+    
+//    public void testEchoXMLSyncSeperateListener() throws Exception {
+//        super.testEchoXMLSyncSeperateListener();
+//    }
+}

Propchange: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileCacheTest.java
------------------------------------------------------------------------------
    svn:executable = *

Added: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileInputTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileInputTest.java?view=auto&rev=452763
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileInputTest.java (added)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileInputTest.java Tue Oct  3 23:42:05 2006
@@ -0,0 +1,114 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.swa;
+
+import java.io.BufferedReader;
+import java.io.FileInputStream;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.net.Socket;
+import java.net.SocketException;
+
+import javax.xml.namespace.QName;
+
+import junit.framework.Test;
+import junit.framework.TestSuite;
+
+import org.apache.axis2.Constants;
+import org.apache.axis2.description.AxisOperation;
+import org.apache.axis2.description.AxisService;
+import org.apache.axis2.description.InOutAxisOperation;
+import org.apache.axis2.description.Parameter;
+import org.apache.axis2.integration.UtilServer;
+import org.apache.axis2.integration.UtilServerBasedTestCase;
+import org.apache.axis2.receivers.RawXMLINOutMessageReceiver;
+import org.apache.axis2.wsdl.WSDLConstants;
+
+public class EchoRawSwAFileInputTest extends UtilServerBasedTestCase {
+
+    private QName serviceName = new QName("EchoSwAService");
+
+    private QName operationName = new QName("echoAttachment");
+
+    public EchoRawSwAFileInputTest() {
+        super(EchoRawSwAFileInputTest.class.getName());
+    }
+
+    public EchoRawSwAFileInputTest(String testName) {
+        super(testName);
+    }
+
+    public static Test suite() {
+        return getTestSetup2(new TestSuite(EchoRawSwAFileInputTest.class),
+                Constants.TESTING_PATH + "MTOM-enabledRepository");
+    }
+
+    protected void setUp() throws Exception {
+        AxisService service = new AxisService(serviceName.getLocalPart());
+        service.setClassLoader(Thread.currentThread().getContextClassLoader());
+        service.addParameter(new Parameter(
+                Constants.SERVICE_CLASS, EchoSwA.class
+                .getName()));
+        AxisOperation axisOp = new InOutAxisOperation(operationName);
+        axisOp.setMessageReceiver(new RawXMLINOutMessageReceiver());
+        axisOp.setStyle(WSDLConstants.STYLE_DOC);
+        service.addOperation(axisOp);
+        UtilServer.deployService(service);
+
+    }
+
+    protected void tearDown() throws Exception {
+        UtilServer.unDeployService(serviceName);
+    }
+
+    public void testEchoXMLSync() throws Exception {
+        Socket socket = new Socket("127.0.0.1", 5555);
+        OutputStream outStream = socket.getOutputStream();
+        socket.getInputStream();
+        InputStream requestMsgInStream = new FileInputStream("test-resources/swa/swainput.bin");
+        int data;
+        while ((data = requestMsgInStream.read()) != -1) {
+            outStream.write(data);
+        }
+        outStream.flush();
+        socket.shutdownOutput();
+        BufferedReader reader = new BufferedReader(new InputStreamReader(socket
+                .getInputStream()));
+        StringBuffer sb = new StringBuffer();
+
+        String response = reader.readLine();
+        while (null != response) {
+            try {
+                sb.append(response.trim());
+                response = reader.readLine();
+            } catch (SocketException e) {
+                break;
+            }
+        }
+
+        assertTrue(sb.toString().indexOf(
+                "Apache Axis2 - The NExt Generation Web Services Engine") > 0);
+        assertTrue(sb.toString().indexOf("multipart/related") > 0);
+    }
+
+    private InputStream getResourceAsStream(String path) {
+        return this.getClass().getResourceAsStream(path);
+    }
+
+
+}

Propchange: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwAFileInputTest.java
------------------------------------------------------------------------------
    svn:executable = *

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java?view=diff&rev=452763&r1=452762&r2=452763
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoRawSwATest.java Tue Oct  3 23:42:05 2006
@@ -95,7 +95,7 @@
 
 
     public void testEchoXMLSync() throws Exception {
-        OMElement payload = createEnvelope();
+
         Options options = new Options();
         options.setTo(targetEPR);
         options.setProperty(Constants.Configuration.ENABLE_SWA, Constants.VALUE_TRUE);

Modified: webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoSwA.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoSwA.java?view=diff&rev=452763&r1=452762&r2=452763
==============================================================================
--- webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoSwA.java (original)
+++ webservices/axis2/trunk/java/modules/integration/test/org/apache/axis2/swa/EchoSwA.java Tue Oct  3 23:42:05 2006
@@ -35,25 +35,26 @@
  */
 
 public class EchoSwA {
-    private OperationContext opcts;
+    private OperationContext operationContext;
 
     public EchoSwA() {
     }
 
     public void setOperationContext(OperationContext oc) throws AxisFault {
-        opcts = oc;
+        operationContext = oc;
     }
 
     public OMElement echoAttachment(OMElement omEle) throws AxisFault {
         OMElement child = (OMElement) omEle.getFirstOMChild();
         OMAttribute attr = child.getAttribute(new QName("href"));
         String contentID = attr.getAttributeValue();
-        Attachments attachment = (Attachments) (opcts.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)).getAttachmentMap();
         contentID = contentID.trim();
-
         if (contentID.substring(0, 3).equalsIgnoreCase("cid")) {
             contentID = contentID.substring(4);
         }
+        
+        Attachments attachment = (Attachments) (operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)).getAttachmentMap();
+ 
         DataHandler dataHandler = attachment.getDataHandler(contentID);
         OMText textNode = new OMTextImpl(dataHandler, omEle.getOMFactory());
         omEle.build();
@@ -64,8 +65,8 @@
     
     public OMElement echoOMElement(OMElement omEle) throws AxisFault {
         OMElement child = (OMElement) omEle.getFirstOMChild();
-        Attachments attachment = (Attachments) (opcts.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)).getAttachmentMap();
-        opcts.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE).setAttachmentMap(attachment);
+        Attachments attachment = (Attachments) (operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE)).getAttachmentMap();
+        operationContext.getMessageContext(WSDLConstants.MESSAGE_LABEL_OUT_VALUE).setAttachmentMap(attachment);
         
         omEle.build();
         return omEle;



---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org