cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From m...@apache.org
Subject svn commit: r585394 - in /incubator/cxf/trunk/tools: common/src/main/java/org/apache/cxf/tools/common/ javato/ws/src/test/java/org/apache/cxf/tools/fortest/ javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/ javato/ws/src/test/java/org/a...
Date Wed, 17 Oct 2007 06:24:32 GMT
Author: mmao
Date: Tue Oct 16 23:24:31 2007
New Revision: 585394

URL: http://svn.apache.org/viewvc?rev=585394&view=rev
Log:
* Test to show the usage of XmlMimeType


Added:
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/ImageSender.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/ImageSender2.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/MyImage.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/expected_send_image.wsdl
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/expected_send_image2.wsdl
Modified:
    incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
    incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
    incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java

Modified: incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java?rev=585394&r1=585393&r2=585394&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
(original)
+++ incubator/cxf/trunk/tools/common/src/main/java/org/apache/cxf/tools/common/ProcessorTestBase.java
Tue Oct 16 23:24:31 2007
@@ -29,6 +29,7 @@
 import java.net.URLClassLoader;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collection;
 import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
@@ -251,21 +252,15 @@
         assertTagEquals(expected, source, DEFAULT_IGNORE_ATTR, DEFAULT_IGNORE_TAG);
     }
 
-    protected void assertTagEquals(Tag expected, Tag source, 
-                                   final List<String> ignoreAttr, 
-                                   final List<String> ignoreTag) {
-        if (!expected.getName().equals(source.getName())) {
-            throw new ComparisonFailure("Tags not equal: ", 
-                                        expected.getName().toString(), 
-                                        source.getName().toString());
-        }
-
-        for (QName attr : expected.getAttributes()) {
+    protected void assertAttributesEquals(Collection<QName> q1, Collection<QName>
q2, 
+                                          Collection<String> ignoreAttr) {
+        for (QName attr : q1) {
             if (ignoreAttr.contains(attr.getNamespaceURI())) {
                 continue;
             }
             boolean found = false;
-            for (QName attr2 : source.getAttributes()) {
+
+            for (QName attr2 : q2) {
                 if (attr2.getNamespaceURI().equals(attr.getNamespaceURI())) {
                     if (attr2.getLocalPart().equals(attr.getLocalPart())) {
                         found = true;
@@ -277,9 +272,23 @@
                 }
             }
             if (!found) {
-                throw new AssertionError("Attribute: " + attr + " is missing in the source
file.");
+                throw new AssertionError("Attribute: " + attr + " is missing.");
             }
         }
+    }
+
+    protected void assertTagEquals(Tag expected, Tag source, 
+                                   final List<String> ignoreAttr, 
+                                   final List<String> ignoreTag) {
+        if (!expected.getName().equals(source.getName())) {
+            throw new ComparisonFailure("Tags not equal: ", 
+                                        expected.getName().toString(), 
+                                        source.getName().toString());
+        }
+
+        assertAttributesEquals(expected.getAttributes(), source.getAttributes(), ignoreAttr);
+        assertAttributesEquals(source.getAttributes(), expected.getAttributes(), ignoreAttr);
+
         if (!StringUtils.isEmpty(expected.getText())
                 && !expected.getText().equals(source.getText())) {
             throw new ComparisonFailure("Text not equal: ", 
@@ -289,7 +298,8 @@
 
         if (!expected.getTags().isEmpty()) {
             for (Tag expectedTag : expected.getTags()) {
-                if (ignoreTag.contains(expectedTag.getName().getLocalPart())) {
+                if (ignoreTag.contains(expectedTag.getName().getLocalPart()) 
+                    && expectedTag.getTags().isEmpty()) {
                     continue;
                 } 
                 Tag sourceTag = getFromSource(source, expectedTag);
@@ -315,7 +325,6 @@
         throws Exception {
         Tag expectedTag = StAXUtil.getTagTree(expected, attr);
         Tag sourceTag = StAXUtil.getTagTree(source, attr);
-
         assertTagEquals(expectedTag, sourceTag, attr, tag);
     }
 

Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/ImageSender.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/ImageSender.java?rev=585394&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/ImageSender.java
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/ImageSender.java
Tue Oct 16 23:24:31 2007
@@ -0,0 +1,32 @@
+/**
+ * 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.cxf.tools.fortest;
+
+import java.awt.Image;
+import javax.jws.WebService;
+import javax.xml.bind.annotation.XmlMimeType;
+
+@WebService
+public class ImageSender {
+    public void sendImage(@XmlMimeType("image/png") Image photo) {
+        // empty
+    }
+}
+
+

Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/ImageSender2.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/ImageSender2.java?rev=585394&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/ImageSender2.java
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/ImageSender2.java
Tue Oct 16 23:24:31 2007
@@ -0,0 +1,28 @@
+/**
+ * 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.cxf.tools.fortest;
+
+import javax.jws.WebService;
+
+@WebService
+public class ImageSender2 {
+    public void sendImage2(MyImage photo) {
+        // empty
+    }
+}

Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/MyImage.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/MyImage.java?rev=585394&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/MyImage.java
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/MyImage.java
Tue Oct 16 23:24:31 2007
@@ -0,0 +1,27 @@
+/**
+ * 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.cxf.tools.fortest;
+
+import java.awt.Image;
+import javax.xml.bind.annotation.XmlMimeType;
+
+public class MyImage {
+    @XmlMimeType("image/png")
+    protected Image myPhoto;
+}

Modified: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?rev=585394&r1=585393&r2=585394&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Tue Oct 16 23:24:31 2007
@@ -414,5 +414,43 @@
 
         String expectedFile = getClass().getResource("expected/list_expected.wsdl").getFile();
         assertWsdlEquals(new File(expectedFile), new File(output, "/list_test.wsdl"));
+
+    }
+
+    @Test
+    //  TODO: should suppor the XmlMimeType annotation in the SEI
+    public void testMimeTypeInSEI() throws Exception {
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/send_image.wsdl");
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.ImageSender");
+        env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
+        try {
+            processor.setEnvironment(env);
+            processor.process();                  
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        File wsdlFile = new File(output, "send_image.wsdl");
+        assertTrue("Generate Wsdl Fail", wsdlFile.exists());
+        
+        String expectedFile = getClass().getResource("expected/expected_send_image.wsdl").getFile();
+        assertWsdlEquals(new File(expectedFile), wsdlFile);
+    }
+
+    @Test
+    public void testMimeTypeInBean() throws Exception {
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/send_image2.wsdl");
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.ImageSender2");
+        env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
+        try {
+            processor.setEnvironment(env);
+            processor.process();                  
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        File wsdlFile = new File(output, "send_image2.wsdl");
+        assertTrue("Generate Wsdl Fail", wsdlFile.exists());
+        
+        String expectedFile = getClass().getResource("expected/expected_send_image2.wsdl").getFile();
+        assertWsdlEquals(new File(expectedFile), wsdlFile);
     }
 }

Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/expected_send_image.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/expected_send_image.wsdl?rev=585394&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/expected_send_image.wsdl
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/expected_send_image.wsdl
Tue Oct 16 23:24:31 2007
@@ -0,0 +1,68 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<wsdl:definitions name="ImageSenderService" targetNamespace="http://fortest.tools.cxf.apache.org/"
xmlns:tns="http://fortest.tools.cxf.apache.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+  <wsdl:types>
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://fortest.tools.cxf.apache.org/"
attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://fortest.tools.cxf.apache.org/">
+    <xsd:element name="sendImage" type="tns:sendImage"/>
+    <xsd:complexType name="sendImage">
+        <xsd:sequence>
+            <xsd:element minOccurs="0" name="arg0" type="xsd:base64Binary"/>
+        </xsd:sequence>
+    </xsd:complexType>
+    <xsd:element name="sendImageResponse" type="tns:sendImageResponse"/>
+    <xsd:complexType name="sendImageResponse">
+        <xsd:sequence/>
+    </xsd:complexType>
+</xsd:schema>
+  </wsdl:types>
+  <wsdl:message name="sendImageResponse">
+    <wsdl:part name="parameters" element="tns:sendImageResponse">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="sendImage">
+    <wsdl:part name="parameters" element="tns:sendImage">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:portType name="ImageSender">
+    <wsdl:operation name="sendImage">
+      <wsdl:input name="sendImage" message="tns:sendImage">
+    </wsdl:input>
+      <wsdl:output name="sendImageResponse" message="tns:sendImageResponse">
+    </wsdl:output>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="ImageSenderServiceSoapBinding" type="tns:ImageSender">
+    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <wsdl:operation name="sendImage">
+      <soap:operation soapAction="" style="document"/>
+      <wsdl:input name="sendImage">
+        <soap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="sendImageResponse">
+        <soap:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="ImageSenderService">
+    <wsdl:port name="ImageSenderPort" binding="tns:ImageSenderServiceSoapBinding">
+      <soap:address location="http://localhost:9090/hello"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>
\ No newline at end of file

Added: incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/expected_send_image2.wsdl
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/expected_send_image2.wsdl?rev=585394&view=auto
==============================================================================
--- incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/expected_send_image2.wsdl
(added)
+++ incubator/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/expected/expected_send_image2.wsdl
Tue Oct 16 23:24:31 2007
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<wsdl:definitions name="ImageSender2Service" targetNamespace="http://fortest.tools.cxf.apache.org/"
xmlns:tns="http://fortest.tools.cxf.apache.org/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
+  <wsdl:types>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns="http://fortest.tools.cxf.apache.org/"
attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://fortest.tools.cxf.apache.org/">
+    <xs:complexType name="myImage">
+        <xs:sequence>
+            <xs:element xmlns:ns1="http://www.w3.org/2005/05/xmlmime" minOccurs="0" name="myPhoto"
ns1:expectedContentTypes="image/png" type="xs:base64Binary"/>
+        </xs:sequence>
+    </xs:complexType>
+    <xs:element name="sendImage2" type="sendImage2"/>
+    <xs:complexType name="sendImage2">
+        <xs:sequence>
+            <xs:element minOccurs="0" name="arg0" type="myImage"/>
+        </xs:sequence>
+    </xs:complexType>
+    <xs:element name="sendImage2Response" type="sendImage2Response"/>
+    <xs:complexType name="sendImage2Response">
+        <xs:sequence/>
+    </xs:complexType>
+</xs:schema>
+  </wsdl:types>
+  <wsdl:message name="sendImage2">
+    <wsdl:part name="parameters" element="tns:sendImage2">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:message name="sendImage2Response">
+    <wsdl:part name="parameters" element="tns:sendImage2Response">
+    </wsdl:part>
+  </wsdl:message>
+  <wsdl:portType name="ImageSender2">
+    <wsdl:operation name="sendImage2">
+      <wsdl:input name="sendImage2" message="tns:sendImage2">
+    </wsdl:input>
+      <wsdl:output name="sendImage2Response" message="tns:sendImage2Response">
+    </wsdl:output>
+    </wsdl:operation>
+  </wsdl:portType>
+  <wsdl:binding name="ImageSender2ServiceSoapBinding" type="tns:ImageSender2">
+    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
+    <wsdl:operation name="sendImage2">
+      <soap:operation soapAction="" style="document"/>
+      <wsdl:input name="sendImage2">
+        <soap:body use="literal"/>
+      </wsdl:input>
+      <wsdl:output name="sendImage2Response">
+        <soap:body use="literal"/>
+      </wsdl:output>
+    </wsdl:operation>
+  </wsdl:binding>
+  <wsdl:service name="ImageSender2Service">
+    <wsdl:port name="ImageSender2Port" binding="tns:ImageSender2ServiceSoapBinding">
+      <soap:address location="http://localhost:9090/hello"/>
+    </wsdl:port>
+  </wsdl:service>
+</wsdl:definitions>

Modified: incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java?rev=585394&r1=585393&r2=585394&view=diff
==============================================================================
--- incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java
(original)
+++ incubator/cxf/trunk/tools/validator/src/test/java/org/apache/cxf/tools/validator/internal/WSDL11ValidatorTest.java
Tue Oct 16 23:24:31 2007
@@ -35,7 +35,6 @@
         try {
             assertFalse(validator.isValid());
         } catch (Exception e) {
-            e.printStackTrace();
             assertTrue(e.getMessage().indexOf("Caused by {http://apache.org/hello_world/messages}"
                                               + "[portType:GreeterA][operation:sayHi] not
exist.") != -1);
         }



Mime
View raw message