cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1429231 - in /cxf/trunk: rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/ tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/ tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/
Date Sat, 05 Jan 2013 08:04:24 GMT
Author: ema
Date: Sat Jan  5 08:04:23 2013
New Revision: 1429231

URL: http://svn.apache.org/viewvc?rev=1429231&view=rev
Log:
[CXF-4729]:Support @XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL) in Exception class

Added:
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEcho.java
  (with props)
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEchoImpl.java
  (with props)
    cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderException.java
  (with props)
Modified:
    cxf/trunk/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.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=1429231&r1=1429230&r2=1429231&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
Sat Jan  5 08:04:23 2013
@@ -36,7 +36,9 @@ import java.util.logging.Level;
 import java.util.logging.Logger;
 
 import javax.xml.bind.JAXBContext;
+import javax.xml.bind.annotation.XmlAccessOrder;
 import javax.xml.bind.annotation.XmlAccessType;
+import javax.xml.bind.annotation.XmlAccessorOrder;
 import javax.xml.bind.annotation.XmlList;
 import javax.xml.bind.annotation.XmlType;
 import javax.xml.bind.annotation.adapters.XmlAdapter;
@@ -469,6 +471,7 @@ class JAXBSchemaInitializer extends Serv
                 break;
             }
         }
+        XmlAccessorOrder xmlAccessorOrder = cls.getAnnotation(XmlAccessorOrder.class);
         XmlType xmlTypeAnno = cls.getAnnotation(XmlType.class);
         String[] propertyOrder = null;
         boolean respectXmlTypeNS = false;
@@ -556,7 +559,6 @@ class JAXBSchemaInitializer extends Serv
             exEle.setSchemaTypeName(getTypeName(beanInfo));
             exEle.setMinOccurs(0);
             seq.getItems().add(exEle);
-
         }
         
         if (propertyOrder != null && propertyOrder.length == seq.getItems().size())
{
@@ -565,6 +567,11 @@ class JAXBSchemaInitializer extends Serv
             LOG.log(Level.WARNING, "propOrder in @XmlType doesn't define all schema elements
:" 
                 + Arrays.toString(propertyOrder));
         }
+        
+        if (xmlAccessorOrder != null && xmlAccessorOrder.value().equals(XmlAccessOrder.ALPHABETICAL)
+            && propertyOrder == null) {
+            sort(seq);
+        }
        
         schemas.addCrossImports();
         part.setProperty(JAXBDataBinding.class.getName() + ".CUSTOM_EXCEPTION", Boolean.TRUE);
@@ -651,4 +658,16 @@ class JAXBSchemaInitializer extends Serv
         
         });
     }
+    //sort to Alphabetical order
+    private void sort(final XmlSchemaSequence seq) {
+        Collections.sort(seq.getItems(), new Comparator<XmlSchemaSequenceMember>()
{
+            public int compare(XmlSchemaSequenceMember o1, XmlSchemaSequenceMember o2) {
+                XmlSchemaElement element1 = (XmlSchemaElement)o1;
+                XmlSchemaElement element2 = (XmlSchemaElement)o2;
+                return element1.getName().compareTo(element2.getName());
+            }
+        
+        });
+    }
+    
 }

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEcho.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEcho.java?rev=1429231&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEcho.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEcho.java
Sat Jan  5 08:04:23 2013
@@ -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.cxf.tools.fortest.exception;
+
+import javax.jws.WebService;
+
+@WebService(targetNamespace = "http://cxf.apache.org/test/HelloService", name = "HelloService")
+public interface OrderEcho {
+    String echo(String request) throws OrderException;
+}
\ No newline at end of file

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEcho.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEcho.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEchoImpl.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEchoImpl.java?rev=1429231&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEchoImpl.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEchoImpl.java
Sat Jan  5 08:04:23 2013
@@ -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.exception;
+
+import javax.jws.WebService;
+
+@WebService(serviceName = "HelloService", 
+            portName = "HelloPort", 
+            endpointInterface = "org.apache.cxf.tools.fortest.exception.OrderEcho", 
+            targetNamespace = "http://cxf.apache.org/test/HelloService")
+public class OrderEchoImpl {
+    public String echo(String request) throws OrderException {
+        return "Response";
+    }
+
+}
\ No newline at end of file

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEchoImpl.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEchoImpl.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderException.java
URL: http://svn.apache.org/viewvc/cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderException.java?rev=1429231&view=auto
==============================================================================
--- cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderException.java
(added)
+++ cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderException.java
Sat Jan  5 08:04:23 2013
@@ -0,0 +1,51 @@
+/**
+ * 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.exception;
+
+import javax.xml.bind.annotation.XmlAccessOrder;
+import javax.xml.bind.annotation.XmlAccessorOrder;
+
+@javax.xml.ws.WebFault
+@XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL)
+public class OrderException extends SuperException {
+    private static final long serialVersionUID = 1L;
+    private String summary;
+    private String from;
+
+    public OrderException(String message) {
+        super(message);
+    }
+
+    public void setSummary(String summary) {
+        this.summary = summary;
+    }
+
+    public void setFrom(String from) {
+        this.from = from;
+    }
+
+    public String getSummary() {
+        return summary;
+    }
+
+    public String getFrom() {
+        return from;
+    }
+
+}

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderException.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderException.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

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=1429231&r1=1429230&r2=1429231&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
Sat Jan  5 08:04:23 2013
@@ -723,8 +723,33 @@ public class JavaToProcessorTest extends
         assertTrue(summaryIndex > -1);
         assertTrue(fromIndex > -1);
         assertTrue(idIndex > -1);
-        assertTrue(fromIndex > summaryIndex && idIndex > fromIndex);
+        assertTrue(fromIndex > summaryIndex && idIndex > fromIndex);      
 
+    }
+    
+    @Test
+    public void testXmlAccessorOrderInException() throws Exception {
+        env.put(ToolConstants.CFG_OUTPUTFILE, output.getPath() + "/exception_order.wsdl");
+        env.put(ToolConstants.CFG_CLASSNAME, "org.apache.cxf.tools.fortest.exception.OrderEchoImpl");
+        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_order.wsdl");
+        assertTrue(wsdlFile.exists());
+        String wsdlContent = getStringFromFile(wsdlFile).replaceAll("  ", " ");
+
+        int fromIndex = wsdlContent.indexOf("<xs:element name=\"from\"");
+        int idIndex = wsdlContent.indexOf("<xs:element name=\"id\"");
+        int summaryIndex = wsdlContent.indexOf("<xs:element name=\"summary\"");
+        
         
+        assertTrue(fromIndex > -1);
+        assertTrue(idIndex > -1);
+        assertTrue(summaryIndex > -1);
+        assertTrue(summaryIndex > idIndex && idIndex > fromIndex);        
     }
     
     



Mime
View raw message