From 2298c8abcd82dffe2c187a096ec6f969f1133bc7 Mon Sep 17 00:00:00 2001 From: ramkumar Date: Thu, 19 Feb 2009 08:36:37 +0000 Subject: Fixes for TUSCANY-2840-Part3 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@745779 13f79535-47bb-0310-9956-ffa450edef68 --- .../ws/axis2/itests/mtom/FileTransferClient.java | 5 ++- .../itests/mtom/FileTransferMTOMTestCase.java | 28 ++++++++------- .../ws/axis2/itests/mtom/FileTransferService.java | 10 +++--- .../itests/mtom/FileTransferServiceClient.java | 3 +- .../axis2/itests/mtom/FileTransferServiceImpl.java | 13 ++++--- .../binding/ws/axis2/itests/mtom/MyException.java | 26 ++++++++++++++ .../ws/axis2/itests/mtom/MyExceptionAdapter.java | 31 ++++++++++++++++ .../ws/axis2/itests/mtom/MyExceptionImpl.java | 26 ++++++++++++++ .../binding/ws/axis2/itests/mtom/filetransfer.wsdl | 42 +++++++++++++++++++--- .../itests/mtom/filetransferservice.composite | 7 ++-- 10 files changed, 158 insertions(+), 33 deletions(-) create mode 100644 branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyException.java create mode 100644 branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionAdapter.java create mode 100644 branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionImpl.java diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java index b59a380684..cf5e4947d6 100644 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferClient.java @@ -23,7 +23,6 @@ import org.osoa.sca.annotations.Reference; import org.osoa.sca.annotations.Service; import java.awt.Image; import org.apache.axiom.om.OMElement; -import org.apache.axiom.om.impl.llom.OMElementImpl; import javax.xml.transform.Source; /** @@ -51,4 +50,8 @@ public class FileTransferClient implements FileTransferServiceClient { public String uploadOMElementFileForward (OMElement attachment) throws Exception { return fileTransferService.uploadOMElementFile(attachment); } + + public String sendMyExceptionForward (MyException attachment) throws Exception { + return fileTransferService.sendMyException(attachment); + } } diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java index a342fa2414..35bf6888e3 100644 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferMTOMTestCase.java @@ -27,11 +27,11 @@ 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.impl.llom.OMElementImpl; 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; @@ -43,6 +43,7 @@ import org.junit.Test; public class FileTransferMTOMTestCase extends TestCase { private SCADomain domain; + private FileTransferServiceClient filetransfer; /** * Runs once before the tests @@ -50,6 +51,7 @@ public class FileTransferMTOMTestCase extends TestCase { @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"); } /** @@ -64,8 +66,6 @@ public class FileTransferMTOMTestCase extends TestCase { public void testImageFileTransfer() throws Exception { try { Image image = new BufferedImage(80, 24, BufferedImage.TYPE_INT_RGB); - - FileTransferServiceClient filetransfer = domain.getService(FileTransferServiceClient.class, "FileTransferClientComponent"); assertEquals("File uploaded Sucessfully", filetransfer.uploadImageFileForward(image)); } catch (Exception ex){ ex.printStackTrace(); @@ -77,8 +77,6 @@ public class FileTransferMTOMTestCase extends TestCase { try { String xml = "ABC"; Source source = new DOMSource(new String2Node().transform(xml, null)); - - FileTransferServiceClient filetransfer = domain.getService(FileTransferServiceClient.class, "FileTransferClientComponent"); assertEquals("File uploaded Sucessfully", filetransfer.uploadSourceFileForward(source)); } catch (Exception ex){ ex.printStackTrace(); @@ -88,10 +86,8 @@ public class FileTransferMTOMTestCase extends TestCase { @Test public void testDataHandlerFileTransfer() throws Exception { try { - // For testing purpose lets try uploading FileTransferClient.java file. + // For testing purpose lets try uploading LICENSE file. DataHandler dataHandler = new DataHandler(new FileDataSource("./LICENSE")); - - FileTransferServiceClient filetransfer = domain.getService(FileTransferServiceClient.class, "FileTransferClientComponent"); assertEquals("File uploaded Sucessfully", filetransfer.uploadDataHandlerFileForward(dataHandler)); } catch (Exception ex){ ex.printStackTrace(); @@ -102,17 +98,23 @@ public class FileTransferMTOMTestCase extends TestCase { public void testOMElementFileTransfer() throws Exception { try { OMFactory factory = OMAbstractFactory.getOMFactory(); - OMElement imageElement = factory.createOMElement(new QName("image")); + OMElement imageElement = factory.createOMElement(new QName("image")); - // For testing purpose lets try uploading FileTransferClient.java file. DataHandler dataHandler = new DataHandler(new FileDataSource("./LICENSE")); OMText textData = factory.createOMText(dataHandler, true); imageElement.addChild(textData); - - FileTransferServiceClient filetransfer = domain.getService(FileTransferServiceClient.class, "FileTransferClientComponent"); 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(); } diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java index 270c8b5283..ab7fc9c43a 100644 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferService.java @@ -20,8 +20,6 @@ package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; import org.osoa.sca.annotations.Remotable; import javax.activation.DataHandler; -import javax.jws.soap.SOAPBinding; - import java.awt.Image; import javax.xml.transform.Source; import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; @@ -30,7 +28,6 @@ import org.apache.axiom.om.OMElement; /** * This is the business interface of the MTOM FileTransfer service. */ -@SOAPBinding(style = SOAPBinding.Style.DOCUMENT) @Remotable public interface FileTransferService { @@ -38,9 +35,12 @@ public interface FileTransferService { public String uploadSourceFile(Source attachment) throws Exception; - public String uploadDataHandlerFile(DataHandler attachment) throws Exception; + public String uploadDataHandlerFile(DataHandler attachment) throws Exception; - //@XmlJavaTypeAdapter(value=OMElementXmlAdapter.class) public String uploadOMElementFile(OMElement attachment) throws Exception; + + //This method uses an user defined interface MyException as parameter type. + public String sendMyException(@XmlJavaTypeAdapter(MyExceptionAdapter.class) MyException attachment) + throws Exception; } diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceClient.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceClient.java index ca906b1802..5fc95441b0 100644 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceClient.java +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceClient.java @@ -35,7 +35,8 @@ public interface FileTransferServiceClient { public String uploadDataHandlerFileForward (DataHandler attachment) throws Exception; - //@XmlJavaTypeAdapter(value=OMElementXmlAdapter.class) public String uploadOMElementFileForward (OMElement attachment) throws Exception; + + public String sendMyExceptionForward (MyException attachment) throws Exception; } diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java index 57b1a49f19..cc757e5e33 100644 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/FileTransferServiceImpl.java @@ -21,7 +21,6 @@ package org.apache.tuscany.sca.binding.ws.axis2.itests.mtom; import org.osoa.sca.annotations.Service; import javax.activation.DataHandler; import java.awt.Image; -import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; import javax.xml.transform.Source; import org.apache.axiom.om.OMElement; @@ -44,11 +43,15 @@ public class FileTransferServiceImpl implements FileTransferService { public String uploadDataHandlerFile(DataHandler attachment) throws Exception { System.out.println("Content type = " + attachment.toString()); return "File uploaded Sucessfully"; - } + } - //@XmlJavaTypeAdapter(value=OMElementXmlAdapter.class) public String uploadOMElementFile(OMElement attachment) throws Exception { - System.out.println("Content type = " + attachment.toString()); - return "File uploaded Sucessfully"; + System.out.println("Content type = " + attachment.toString()); + return "File uploaded Sucessfully"; + } + + public String sendMyException(MyException attachment) throws Exception { + System.out.println("Content type = " + attachment.toString()); + return "File uploaded Sucessfully"; } } diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyException.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyException.java new file mode 100644 index 0000000000..5ecc22572b --- /dev/null +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyException.java @@ -0,0 +1,26 @@ +/* + * 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; + +//@XmlJavaTypeAdapter(MyExceptionAdapter.class) +public interface MyException { + + public String getMessage(); + +} diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionAdapter.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionAdapter.java new file mode 100644 index 0000000000..4c4e8a3fcf --- /dev/null +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionAdapter.java @@ -0,0 +1,31 @@ +/* + * 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.xml.bind.annotation.adapters.XmlAdapter; + +public class MyExceptionAdapter extends XmlAdapter { + public MyException unmarshal(MyExceptionImpl v) { + return v; + } + + public MyExceptionImpl marshal(MyException v) { + return (MyExceptionImpl)v; + } +} diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionImpl.java b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionImpl.java new file mode 100644 index 0000000000..1bd9b9b1a0 --- /dev/null +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/java/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/MyExceptionImpl.java @@ -0,0 +1,26 @@ +/* + * 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; + +public class MyExceptionImpl extends Exception implements MyException { + + public String getMessage() { + return "good job......"; + } +} diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl index bc5d3ce7ca..df52fff9b1 100644 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransfer.wsdl @@ -40,7 +40,7 @@ - + @@ -54,7 +54,7 @@ - + @@ -68,7 +68,7 @@ - + @@ -82,7 +82,21 @@ - + + + + + + + + + + + + + + + @@ -117,6 +131,13 @@ + + + + + + + @@ -135,6 +156,10 @@ + + + + @@ -175,6 +200,15 @@ + + + + + + + + + diff --git a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite index f1d5891070..beba2512da 100644 --- a/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite +++ b/branches/sca-java-1.x/modules/binding-ws-axis2/src/test/resources/org/apache/tuscany/sca/binding/ws/axis2/itests/mtom/filetransferservice.composite @@ -25,8 +25,8 @@ - - + + @@ -34,8 +34,7 @@ - - + -- cgit v1.2.3