Author: jliu Date: Fri May 25 03:30:47 2007 New Revision: 541612 URL: http://svn.apache.org/viewvc?view=rev&rev=541612 Log: Test case for CXF-689
Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.gif (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.html (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.jpeg1 (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.jpeg2 (with props) incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.text incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.xml (with props) Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java?view=diff&rev=541612&r1=541611&r2=541612 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/ClientServerSwaTest.java Fri May 25 03:30:47 2007 @@ -18,17 +18,25 @@ */ package org.apache.cxf.systest.swa; +import java.awt.Image; import java.io.InputStream; +import java.net.URL; import javax.activation.DataHandler; +import javax.imageio.ImageIO; import javax.mail.util.ByteArrayDataSource; +import javax.xml.transform.Source; +import javax.xml.transform.stream.StreamSource; import javax.xml.ws.Holder; import org.apache.cxf.swa.SwAService; import org.apache.cxf.swa.SwAServiceInterface; import org.apache.cxf.swa.types.DataStruct; +import org.apache.cxf.swa.types.OutputResponseAll; +import org.apache.cxf.swa.types.VoidRequest; import org.apache.cxf.testutil.common.AbstractBusClientServerTestBase; import org.junit.BeforeClass; +import org.junit.Ignore; import org.junit.Test; public class ClientServerSwaTest extends AbstractBusClientServerTestBase { @@ -93,4 +101,40 @@ String string = new String(b); assertEquals("testfoobar", string); } + + @Test + @Ignore + public void testSwaTypes() throws Exception { + SwAService service = new SwAService(); + + SwAServiceInterface port = service.getSwAServiceHttpPort(); + + URL url1 = this.getClass().getResource("resources/attach.text"); + URL url2 = this.getClass().getResource("resources/attach.html"); + URL url3 = this.getClass().getResource("resources/attach.xml"); + URL url4 = this.getClass().getResource("resources/attach.jpeg1"); + URL url5 = this.getClass().getResource("resources/attach.jpeg2"); + + DataHandler dh1 = new DataHandler(url1); + DataHandler dh2 = new DataHandler(url2); + DataHandler dh3 = new DataHandler(url3); + //DataHandler dh4 = new DataHandler(url4); + //DataHandler dh5 = new DataHandler(url5); + Holder<DataHandler> attach1 = new Holder<DataHandler>(); + attach1.value = dh1; + Holder<DataHandler> attach2 = new Holder<DataHandler>(); + attach2.value = dh2; + Holder<Source> attach3 = new Holder<Source>(); + attach3.value = new StreamSource(dh3.getInputStream()); + Holder<Image> attach4 = new Holder<Image>(); + Holder<Image> attach5 = new Holder<Image>(); + attach4.value = ImageIO.read(url4); + attach5.value = ImageIO.read(url5); + VoidRequest request = new VoidRequest(); + OutputResponseAll response = port.echoAllAttachmentTypes(request, attach1, attach2, attach3, attach4, + attach5); + assertNotNull(response); + + } + } Modified: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java?view=diff&rev=541612&r1=541611&r2=541612 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java (original) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/SwAServiceImpl.java Fri May 25 03:30:47 2007 @@ -18,16 +18,22 @@ */ package org.apache.cxf.systest.swa; +import java.awt.Image; import java.io.IOException; import java.io.InputStream; import javax.activation.DataHandler; import javax.jws.WebService; import javax.mail.util.ByteArrayDataSource; +import javax.xml.transform.Source; import javax.xml.ws.Holder; +import javax.xml.ws.WebServiceException; import org.apache.cxf.swa.SwAServiceInterface; import org.apache.cxf.swa.types.DataStruct; +import org.apache.cxf.swa.types.OutputResponseAll; +import org.apache.cxf.swa.types.VoidRequest; + @WebService(endpointInterface = "org.apache.cxf.swa.SwAServiceInterface", serviceName = "SwAService", @@ -67,5 +73,60 @@ e.printStackTrace(); } } - + + public OutputResponseAll echoAllAttachmentTypes(VoidRequest request, Holder<DataHandler> attach1, + Holder<DataHandler> attach2, Holder<Source> attach3, + Holder<Image> attach4, Holder<Image> attach5) { + try { + System.out.println("Enter echoAllAttachmentTypes() ......"); + OutputResponseAll theResponse = new OutputResponseAll(); + theResponse.setResult("ok"); + theResponse.setReason("ok"); + if (attach1 == null || attach1.value == null) { + System.err.println("attach1.value is null (unexpected)"); + theResponse.setReason("attach1.value is null (unexpected)"); + theResponse.setResult("not ok"); + } + if (attach2 == null || attach2.value == null) { + System.err.println("attach2.value is null (unexpected)"); + if (theResponse.getReason().equals("ok")) { + theResponse.setReason("attach2.value is null (unexpected)"); + } else { + theResponse.setReason(theResponse.getReason() + "\nattach2.value is null (unexpected)"); + } + theResponse.setResult("not ok"); + } + if (attach3 == null || attach3.value == null) { + System.err.println("attach3.value is null (unexpected)"); + if (theResponse.getReason().equals("ok")) { + theResponse.setReason("attach3.value is null (unexpected)"); + } else { + theResponse.setReason(theResponse.getReason() + "\nattach3.value is null (unexpected)"); + } + theResponse.setResult("not ok"); + } + if (attach4 == null || attach4.value == null) { + System.err.println("attach4.value is null (unexpected)"); + if (theResponse.getReason().equals("ok")) { + theResponse.setReason("attach4.value is null (unexpected)"); + } else { + theResponse.setReason(theResponse.getReason() + "\nattach4.value is null (unexpected)"); + } + theResponse.setResult("not ok"); + } + if (attach5 == null || attach5.value == null) { + System.err.println("attach5.value is null (unexpected)"); + if (theResponse.getReason().equals("ok")) { + theResponse.setReason("attach5.value is null (unexpected)"); + } else { + theResponse.setReason(theResponse.getReason() + "\nattach5.value is null (unexpected)"); + } + theResponse.setResult("not ok"); + } + System.out.println("Leave echoAllAttachmentTypes() ......"); + return theResponse; + } catch (Exception e) { + throw new WebServiceException(e.getMessage()); + } + } } Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.gif URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.gif?view=auto&rev=541612 ============================================================================== Binary file - no diff available. Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.gif ------------------------------------------------------------------------------ svn:mime-type = image/gif Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.html URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.html?view=auto&rev=541612 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.html (added) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.html Fri May 25 03:30:47 2007 @@ -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. + */ +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN"> +<head> +<title>This is a title</title> +</head> +<body bgcolor="#ffffff"> +<center><h1>This is a starting point</h1></center><hr> +<h2>This is a header</h2> +<p>This is a paragraph</p> +<ul> +<li><p>This is a bullet</p></li> +</ul> +</body> +</html> Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.html ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.html ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.html ------------------------------------------------------------------------------ svn:mime-type = text/html Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.jpeg1 URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.jpeg1?view=auto&rev=541612 ============================================================================== Binary file - no diff available. Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.jpeg1 ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.jpeg2 URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.jpeg2?view=auto&rev=541612 ============================================================================== Binary file - no diff available. Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.jpeg2 ------------------------------------------------------------------------------ svn:mime-type = application/octet-stream Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.text URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.text?view=auto&rev=541612 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.text (added) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.text Fri May 25 03:30:47 2007 @@ -0,0 +1,18 @@ +/** + * 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. + */ Added: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.xml URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.xml?view=auto&rev=541612 ============================================================================== --- incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.xml (added) +++ incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.xml Fri May 25 03:30:47 2007 @@ -0,0 +1,18 @@ +/** + * 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. + */ \ No newline at end of file Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.xml ------------------------------------------------------------------------------ svn:eol-style = native Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.xml ------------------------------------------------------------------------------ svn:keywords = Rev Date Propchange: incubator/cxf/trunk/systests/src/test/java/org/apache/cxf/systest/swa/resources/attach.xml ------------------------------------------------------------------------------ svn:mime-type = text/xml Modified: incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl?view=diff&rev=541612&r1=541611&r2=541612 ============================================================================== --- incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl (original) +++ incubator/cxf/trunk/testutils/src/main/resources/wsdl/swa-mime.wsdl Fri May 25 03:30:47 2007 @@ -40,6 +40,19 @@ </xsd:element> <xsd:element name="text" type="xsd:string"/> + <xsd:element name="VoidRequest" type="types:VoidRequest"/> + <xsd:complexType name="VoidRequest"> + <xsd:sequence/> + </xsd:complexType> + + <xsd:element name="OutputResponseAll" type="types:OutputResponseAll"/> + <xsd:complexType name="OutputResponseAll"> + <xsd:sequence> + <xsd:element name="result" type="xsd:string"/> + <xsd:element name="reason" type="xsd:string"/> + </xsd:sequence> + </xsd:complexType> + </xsd:schema> <xsd:schema targetNamespace="http://ws-i.org/profiles/basic/1.1/xsd" @@ -67,7 +80,25 @@ <wsdl:part name="text" element="types:text" /> <wsdl:part name="data" type="xsd:base64Binary" /> </wsdl:message> - + + <wsdl:message name="messageInputAllAttachmentTypes"> + <wsdl:part name="request" element="types:VoidRequest"/> + <wsdl:part name="attach1" type="xsd:string"/> + <wsdl:part name="attach2" type="xsd:string"/> + <wsdl:part name="attach3" type="xsd:string"/> + <wsdl:part name="attach4" type="xsd:base64Binary"/> + <wsdl:part name="attach5" type="xsd:base64Binary"/> + </wsdl:message> + + <wsdl:message name="messageOutputAllAttachmentTypes"> + <wsdl:part name="response" element="types:OutputResponseAll"/> + <wsdl:part name="attach1" type="xsd:string"/> + <wsdl:part name="attach2" type="xsd:string"/> + <wsdl:part name="attach3" type="xsd:string"/> + <wsdl:part name="attach4" type="xsd:base64Binary"/> + <wsdl:part name="attach5" type="xsd:base64Binary"/> + </wsdl:message> + <wsdl:portType name="SwAServiceInterface"> <wsdl:operation name="echoDataRef"> @@ -80,6 +111,11 @@ <wsdl:output message="tns:echoDataResponse" /> </wsdl:operation> + <wsdl:operation name="echoAllAttachmentTypes"> + <wsdl:input message="tns:messageInputAllAttachmentTypes"/> + <wsdl:output message="tns:messageOutputAllAttachmentTypes"/> + </wsdl:operation> + </wsdl:portType> <wsdl:binding name="SwAServiceBinding" type="tns:SwAServiceInterface"> @@ -117,6 +153,54 @@ </mime:part> </mime:multipartRelated> </wsdl:output> + </wsdl:operation> + + <wsdl:operation name="echoAllAttachmentTypes"> + <soap:operation/> + <wsdl:input> + <mime:multipartRelated> + <mime:part> + <soap:body parts="request" use="literal"/> + </mime:part> + <mime:part> + <mime:content part="attach1" type="text/plain"/> + </mime:part> + <mime:part> + <mime:content part="attach2" type="text/html"/> + </mime:part> + <mime:part> + <mime:content part="attach3" type="text/xml"/> + </mime:part> + <mime:part> + <mime:content part="attach4" type="image/jpeg"/> + </mime:part> + <mime:part> + <mime:content part="attach5" type="image/jpeg"/> + </mime:part> + </mime:multipartRelated> + </wsdl:input> + <wsdl:output> + <mime:multipartRelated> + <mime:part> + <soap:body parts="response" use="literal"/> + </mime:part> + <mime:part> + <mime:content part="attach1" type="text/plain"/> + </mime:part> + <mime:part> + <mime:content part="attach2" type="text/html"/> + </mime:part> + <mime:part> + <mime:content part="attach3" type="text/xml"/> + </mime:part> + <mime:part> + <mime:content part="attach4" type="image/jpeg"/> + </mime:part> + <mime:part> + <mime:content part="attach5" type="image/jpeg"/> + </mime:part> + </mime:multipartRelated> + </wsdl:output> </wsdl:operation> </wsdl:binding>