cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From e..@apache.org
Subject svn commit: r1429241 - in /cxf/branches/2.5.x-fixes: ./ 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 09:47:35 GMT
Author: ema
Date: Sat Jan  5 09:47:35 2013
New Revision: 1429241

URL: http://svn.apache.org/viewvc?rev=1429241&view=rev
Log:
Merged revisions 1429236 via svnmerge from 
https://svn.apache.org/repos/asf/cxf/branches/2.6.x-fixes

................
  r1429236 | ema | 2013-01-05 16:40:03 +0800 (Sat, 05 Jan 2013) | 9 lines
  
  Merged revisions 1429231 via svnmerge from 
  https://svn.apache.org/repos/asf/cxf/trunk
  
  ........
    r1429231 | ema | 2013-01-05 16:04:23 +0800 (Sat, 05 Jan 2013) | 1 line
    
    [CXF-4729]:Support @XmlAccessorOrder(XmlAccessOrder.ALPHABETICAL) in Exception class
  ........
................

Added:
    cxf/branches/2.5.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEcho.java
      - copied unchanged from r1429236, cxf/branches/2.6.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEcho.java
    cxf/branches/2.5.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEchoImpl.java
      - copied unchanged from r1429236, cxf/branches/2.6.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderEchoImpl.java
    cxf/branches/2.5.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderException.java
      - copied unchanged from r1429236, cxf/branches/2.6.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/fortest/exception/OrderException.java
Modified:
    cxf/branches/2.5.x-fixes/   (props changed)
    cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
    cxf/branches/2.5.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
--- svn:mergeinfo (added)
+++ svn:mergeinfo Sat Jan  5 09:47:35 2013
@@ -0,0 +1,2 @@
+/cxf/branches/2.6.x-fixes:1429236
+/cxf/trunk:1429231

Propchange: cxf/branches/2.5.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.

Modified: cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java?rev=1429241&r1=1429240&r2=1429241&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
(original)
+++ cxf/branches/2.5.x-fixes/rt/databinding/jaxb/src/main/java/org/apache/cxf/jaxb/JAXBSchemaInitializer.java
Sat Jan  5 09:47:35 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;
@@ -465,6 +467,7 @@ class JAXBSchemaInitializer extends Serv
                 break;
             }
         }
+        XmlAccessorOrder xmlAccessorOrder = cls.getAnnotation(XmlAccessorOrder.class);
         XmlType xmlTypeAnno = cls.getAnnotation(XmlType.class);
         String[] propertyOrder = null;
         boolean respectXmlTypeNS = false;
@@ -552,7 +555,6 @@ class JAXBSchemaInitializer extends Serv
             exEle.setSchemaTypeName(getTypeName(beanInfo));
             exEle.setMinOccurs(0);
             seq.getItems().add(exEle);
-
         }
         
         if (propertyOrder != null && propertyOrder.length == seq.getItems().size())
{
@@ -561,6 +563,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);
@@ -647,4 +654,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());
+            }
+        
+        });
+    }
+    
 }

Modified: cxf/branches/2.5.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.5.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java?rev=1429241&r1=1429240&r2=1429241&view=diff
==============================================================================
--- cxf/branches/2.5.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
(original)
+++ cxf/branches/2.5.x-fixes/tools/javato/ws/src/test/java/org/apache/cxf/tools/java2wsdl/processor/JavaToProcessorTest.java
Sat Jan  5 09:47:35 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