cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1074402 - in /cxf/trunk: rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/simple/ tools/javato/ws/src/test/ja...
Date Fri, 25 Feb 2011 05:35:51 GMT
Author: ema
Date: Fri Feb 25 05:35:50 2011
New Revision: 1074402

URL: http://svn.apache.org/viewvc?rev=1074402&view=rev
Log:
[CXF-3364]:Generate wsdl elements from Exception.class

Added:
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/simple/Caculator.java
Modified:
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java

Modified: cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=1074402&r1=1074401&r2=1074402&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
(original)
+++ cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
Fri Feb 25 05:35:50 2011
@@ -531,6 +531,16 @@ class JAXBSchemaInitializer extends Serv
                 }
             }
         }
+        // Create element in xsd:sequence for Exception.class
+        if (cls.equals(Exception.class)) {
+            JAXBBeanInfo beanInfo = getBeanInfo(java.lang.String.class);
+            XmlSchemaElement exEle = new XmlSchemaElement(schema, false);
+            exEle.setName("message");
+            exEle.setSchemaTypeName(getTypeName(beanInfo));
+            exEle.setMinOccurs(0);
+            seq.getItems().add(exEle);
+
+        }
         part.setProperty(JAXBDataBinding.class.getName() + ".CUSTOM_EXCEPTION", Boolean.TRUE);
     }
 

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java?rev=1074402&r1=1074401&r2=1074402&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
(original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/service/factory/ReflectionServiceFactoryBean.java
Fri Feb 25 05:35:50 2011
@@ -1979,7 +1979,7 @@ public class ReflectionServiceFactoryBea
             Class exClazz = exceptionClasses[i];
 
             // Ignore XFireFaults because they don't need to be declared
-            if (exClazz.equals(Exception.class) || Fault.class.isAssignableFrom(exClazz)
+            if (Fault.class.isAssignableFrom(exClazz)
                 || exClazz.equals(RuntimeException.class) || exClazz.equals(Throwable.class))
{
                 continue;
             }

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/simple/Caculator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/simple/Caculator.java?rev=1074402&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/simple/Caculator.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/simple/Caculator.java
Fri Feb 25 05:35:50 2011
@@ -0,0 +1,33 @@
+/**
+ * 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.simple;
+
+import javax.jws.WebMethod;
+import javax.jws.WebParam;
+import javax.jws.WebService;
+
+@WebService(name = "CalculatorService", targetNamespace = "http://cxf.apache.org/calculator")
+public class Caculator {
+    @WebMethod(operationName = "addNumber")
+    public Integer addNumber(@WebParam(name = "itemA") Integer itemA, @WebParam(name = "ItemB")
Integer itemB)
+        throws java.lang.Exception {
+
+        return itemA + itemB;
+    }
+}

Modified: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?rev=1074402&r1=1074401&r2=1074402&view=diff
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Fri Feb 25 05:35:50 2011
@@ -625,4 +625,33 @@ public class JavaToProcessorTest extends
         assertTrue(xsd, xsd.indexOf("ref=") == -1);
         
     }
+    
+    
+    @Test
+    public void testException() throws Exception {
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/exception.wsdl");
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.simple.Caculator");
+        env.put(ToolConstants.CFG_VERBOSE, ToolConstants.CFG_VERBOSE);
+        try {
+            processor.setEnvironment(env);
+            processor.process();
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+
+        File wsdlFile = new File(output, "exception.wsdl");
+        assertTrue(wsdlFile.exists());
+        // schema element
+        String wsdlContent = getStringFromFile(wsdlFile).replaceAll("  ", " ");
+        assertTrue(wsdlContent.indexOf("<xs:complexType name=\"Exception\">") != -1);
+        assertTrue(wsdlContent.indexOf("<xs:element name=\"Exception\" type=\"tns:Exception\"/>")
!= -1);
+        assertTrue(wsdlContent.indexOf("<xs:element minOccurs=\"0\" name=\"message\" type=\"xs:string\"/>")

+                   != -1);
+        assertTrue(wsdlContent.indexOf("<xs:element minOccurs=\"0\" name=\"message\" type=\"xs:string\"/>")

+                   != -1);
+        assertTrue(wsdlContent.indexOf("<wsdl:part name=\"Exception\" element=\"tns:Exception\">")
!= -1);
+        assertTrue(wsdlContent.indexOf("<wsdl:fault name=\"Exception\" message=\"tns:Exception\">")
!= -1);
+        assertTrue(wsdlContent.indexOf("<soap:fault name=\"Exception\" use=\"literal\"/>")
!= -1);
+
+    }
 }



Mime
View raw message