From bee80d90df6104edff19cbb6a318fac3d64296aa Mon Sep 17 00:00:00 2001 From: antelder Date: Sat, 16 May 2009 08:53:06 +0000 Subject: Create 1.5 release branch from current 1.x trunk git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@775437 13f79535-47bb-0310-9956-ffa450edef68 --- .../itests/mtom/FileTransferMTOMTestCase.java | 122 +++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 branches/sca-java-1.5/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java (limited to 'branches/sca-java-1.5/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java') diff --git a/branches/sca-java-1.5/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java b/branches/sca-java-1.5/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java new file mode 100644 index 0000000000..35bf6888e3 --- /dev/null +++ b/branches/sca-java-1.5/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java @@ -0,0 +1,122 @@ +/* + * 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.tuscany.sca.binding.ws.axis2.itests.mtom; + +import javax.activation.DataHandler; +import javax.activation.FileDataSource; +import java.awt.Image; + +import javax.xml.namespace.QName; +import javax.xml.transform.Source; +import org.apache.axiom.om.OMAbstractFactory; +import org.apache.axiom.om.OMElement; +import org.apache.axiom.om.OMText; +import javax.xml.transform.dom.DOMSource; +import org.apache.axiom.om.OMFactory; +import java.awt.image.BufferedImage; + +import junit.framework.TestCase; +import org.apache.tuscany.sca.host.embedded.SCADomain; +import org.apache.tuscany.sca.binding.ws.axis2.itests.mtom.FileTransferServiceClient; +import org.apache.tuscany.sca.databinding.xml.String2Node; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +public class FileTransferMTOMTestCase extends TestCase { + + private SCADomain domain; + private FileTransferServiceClient filetransfer; + + /** + * Runs once before the tests + */ + @BeforeClass + protected void setUp() throws Exception { + domain = SCADomain.newInstance("org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite"); + filetransfer = domain.getService(FileTransferServiceClient.class, "FileTransferClientComponent"); + } + + /** + * Runs once after the tests + */ + @AfterClass + protected void tearDown() throws Exception { + domain.close(); + } + + @Test + public void testImageFileTransfer() throws Exception { + try { + Image image = new BufferedImage(80, 24, BufferedImage.TYPE_INT_RGB); + assertEquals("File uploaded Sucessfully", filetransfer.uploadImageFileForward(image)); + } catch (Exception ex){ + ex.printStackTrace(); + } + } + + @Test + public void testSourceFileTransfer() throws Exception { + try { + String xml = "ABC"; + Source source = new DOMSource(new String2Node().transform(xml, null)); + assertEquals("File uploaded Sucessfully", filetransfer.uploadSourceFileForward(source)); + } catch (Exception ex){ + ex.printStackTrace(); + } + } + + @Test + public void testDataHandlerFileTransfer() throws Exception { + try { + // For testing purpose lets try uploading LICENSE file. + DataHandler dataHandler = new DataHandler(new FileDataSource("./LICENSE")); + assertEquals("File uploaded Sucessfully", filetransfer.uploadDataHandlerFileForward(dataHandler)); + } catch (Exception ex){ + ex.printStackTrace(); + } + } + + @Test + public void testOMElementFileTransfer() throws Exception { + try { + OMFactory factory = OMAbstractFactory.getOMFactory(); + OMElement imageElement = factory.createOMElement(new QName("image")); + + DataHandler dataHandler = new DataHandler(new FileDataSource("./LICENSE")); + + OMText textData = factory.createOMText(dataHandler, true); + imageElement.addChild(textData); + assertEquals("File uploaded Sucessfully", filetransfer.uploadOMElementFileForward(imageElement)); + } catch (Exception ex){ + ex.printStackTrace(); + } + } + + @Test + public void testSendMyException() throws Exception { + try { + MyException exp = new MyExceptionImpl(); + assertEquals("File uploaded Sucessfully", filetransfer.sendMyExceptionForward(exp)); + } catch (Exception ex){ + ex.printStackTrace(); + } + } +} -- cgit v1.2.3