Author: ffang
Date: Tue Feb 22 11:53:56 2011
New Revision: 1073302

URL: http://svn.apache.org/viewvc?rev=1073302&view=rev
Log:
[CXF-3353]can't refer to java.lang.Exception in gererated fault code

Added:
    cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3353/
    
cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3353/hello_world.wsdl
Modified:
    
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
    
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm
    
cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java

Modified: 
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java?rev=1073302&r1=1073301&r2=1073302&view=diff
==============================================================================
--- 
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
 (original)
+++ 
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/generators/FaultGenerator.java
 Tue Feb 22 11:53:56 2011
@@ -87,11 +87,16 @@ public class FaultGenerator extends Abst
                     setAttributes("suid", generateTimestampSUID());
                 }
                 setAttributes("expClass", expClz);
+                String exceptionSuperclass = "Exception";
                 for (JavaField jf : expClz.getFields()) {
+                    String jfClassName = jf.getClassName();
+                    if (jfClassName.substring(jfClassName.lastIndexOf(".") + 
1).equals("Exception")) {
+                        exceptionSuperclass = "java.lang.Exception";
+                    }
                     setAttributes("paraName", 
ProcessorUtil.mangleNameToVariableName(jf.getName()));
                 }
                 
-                String exceptionSuperclass = "Exception";
+                
                 if (expClz.getName().equals(exceptionSuperclass)) {
                     exceptionSuperclass = "java.lang.Exception";
                 }

Modified: 
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm
URL: 
http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm?rev=1073302&r1=1073301&r2=1073302&view=diff
==============================================================================
--- 
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm
 (original)
+++ 
cxf/trunk/tools/wsdlto/frontend/jaxws/src/main/java/org/apache/cxf/tools/wsdlto/frontend/jaxws/template/impl.vm
 Tue Feb 22 11:53:56 2011
@@ -94,7 +94,7 @@ public class ${implName} implements $int
             ${method.return.writeDefaultValue(${out}, "            ", 
${method.Name}, "_return")}
             return _return;
 #end
-        } catch (Exception ex) {
+        } catch (java.lang.Exception ex) {
             ex.printStackTrace();
             throw new RuntimeException(ex);
         }

Modified: 
cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
URL: 
http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java?rev=1073302&r1=1073301&r2=1073302&view=diff
==============================================================================
--- 
cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
 (original)
+++ 
cxf/trunk/tools/wsdlto/test/src/test/java/org/apache/cxf/tools/wsdlto/jaxws/CodeGenBugTest.java
 Tue Feb 22 11:53:56 2011
@@ -1175,4 +1175,18 @@ public class CodeGenBugTest extends Abst
         
assertEquals(classLoader.loadClass("org.apache.cxf.bugs3290.services.bug2.MyBugService"),
                      m.getReturnType());
     }
+    
+    @Test
+    public void testCXF3353() throws Exception {
+        try {
+            env.put(ToolConstants.CFG_COMPILE, "compile");
+            env.put(ToolConstants.CFG_OUTPUTDIR, output.getCanonicalPath());
+            env.put(ToolConstants.CFG_CLASSDIR, output.getCanonicalPath() + 
"/classes");
+            env.put(ToolConstants.CFG_WSDLURL, 
getLocation("/wsdl2java_wsdl/cxf3353/hello_world.wsdl"));
+            processor.setContext(env);
+            processor.execute();
+        } catch (Exception e) {
+            fail("shouldn't get exception");
+        }
+    }
 }

Added: 
cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3353/hello_world.wsdl
URL: 
http://svn.apache.org/viewvc/cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3353/hello_world.wsdl?rev=1073302&view=auto
==============================================================================
--- 
cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3353/hello_world.wsdl
 (added)
+++ 
cxf/trunk/tools/wsdlto/test/src/test/resources/wsdl2java_wsdl/cxf3353/hello_world.wsdl
 Tue Feb 22 11:53:56 2011
@@ -0,0 +1,89 @@
+<?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="HelloWorld" 
targetNamespace="http://apache.org/hello_world_soap_http_provider"; 
+    xmlns="http://schemas.xmlsoap.org/wsdl/"; 
+    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
+    xmlns:tns="http://apache.org/hello_world_soap_http_provider";
+    xmlns:x1="http://apache.org/hello_world_soap_http_provider";
+    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"; 
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema";>
+    <wsdl:types>
+        <schema 
targetNamespace="http://apache.org/hello_world_soap_http_provider"; 
+            xmlns="http://www.w3.org/2001/XMLSchema";
+           xmlns:tns="http://apache.org/hello_world_soap_http_provider";
+            elementFormDefault="qualified">
+            <element name="exception">
+                               <complexType>
+                                       <sequence>
+                                               <element name="errorCode" 
type="xsd:string" />
+                                               <element name="message" 
nillable="true" type="xsd:string" />
+                                               <element name="reasonCode" 
nillable="true" type="xsd:string" />
+                                       </sequence>
+                               </complexType>
+                       </element>
+            <element name="pingMe">
+                <complexType/>
+            </element>
+            <element name="pingMeResponse">
+                <complexType/>
+            </element>
+        </schema>
+    </wsdl:types>
+    <wsdl:message name="pingMeRequest">
+        <wsdl:part name="in" element="x1:pingMe"/>
+    </wsdl:message>
+    <wsdl:message name="pingMeResponse">
+        <wsdl:part name="out" element="x1:pingMeResponse"/>
+    </wsdl:message>            
+    <wsdl:message name="serviceException">
+        <wsdl:part name="exception" element="x1:exception"/>
+    </wsdl:message>
+
+    
+    <wsdl:portType name="Greeter">
+        <wsdl:operation name="pingMe">
+            <wsdl:input name="pingMeRequest" message="tns:pingMeRequest"/>
+            <wsdl:output name="pingMeResponse" message="tns:pingMeResponse"/>
+            <wsdl:fault name="exception" message="tns:serviceException"/>
+        </wsdl:operation> 
+    </wsdl:portType>
+    <wsdl:binding name="Greeter_SOAPBinding" type="tns:Greeter">
+        <soap:binding style="document" 
transport="http://schemas.xmlsoap.org/soap/http"/>
+        <wsdl:operation name="pingMe">
+            <soap:operation style="document"/>
+            <wsdl:input>
+                <soap:body use="literal"/>
+            </wsdl:input>
+            <wsdl:output>
+                <soap:body use="literal"/>
+            </wsdl:output>
+            <wsdl:fault name="exception">
+                <soap:fault name="exception" use="literal"/>
+            </wsdl:fault>
+        </wsdl:operation>
+        
+    </wsdl:binding>
+    <wsdl:service name="SOAPService">
+        <wsdl:port binding="tns:Greeter_SOAPBinding" name="SoapPort">
+            <soap:address 
location="http://localhost:19000/SoapContext/SoapPort"/>
+        </wsdl:port>
+    </wsdl:service>
+</wsdl:definitions>
+


Reply via email to