cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r931765 - in /cxf/trunk/rt/databinding/aegis/src: main/java/org/apache/cxf/aegis/type/basic/ main/java/org/apache/cxf/aegis/type/encoded/ test/java/org/apache/cxf/aegis/type/encoded/
Date Thu, 08 Apr 2010 03:21:27 GMT
Author: dkulp
Date: Thu Apr  8 03:21:26 2010
New Revision: 931765

URL: http://svn.apache.org/viewvc?rev=931765&view=rev
Log:
[CXF=2695] Support xsi:nil on all struct child elements

Added:
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct5.xml
Modified:
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java?rev=931765&r1=931764&r2=931765&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
Thu Apr  8 03:21:26 2010
@@ -175,7 +175,7 @@ public class BeanType extends AegisType 
 
                         writeProperty(name, target, writeObj, clazz, propertyTypeInfo);
                     } else {
-                        if (!propertyTypeInfo.isNillable(name)) {
+                        if (!alwaysAllowNillables() && !propertyTypeInfo.isNillable(name))
{
                             throw new DatabindingException(name.getLocalPart() 
                                                            + " is nil, but not nillable.");
 
@@ -200,6 +200,10 @@ public class BeanType extends AegisType 
             throw new DatabindingException("Could not create class: " + e.getMessage(), e);
         }
     }
+    
+    protected boolean alwaysAllowNillables() {
+        return false;
+    }
 
     protected AegisType getElementType(QName name, BeanTypeInfo beanTypeInfo, 
                                   MessageReader reader, Context context) {

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java?rev=931765&r1=931764&r2=931765&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java
Thu Apr  8 03:21:26 2010
@@ -50,6 +50,11 @@ public class StructType extends BeanType
     public StructType(BeanTypeInfo info) {
         super(info);
     }
+    
+    //soap-encoding always allow xsi:nil=true to be set
+    protected boolean alwaysAllowNillables() {
+        return true;
+    }
 
     /**
      * Gets the BeanTypeInfo using an unqualified name.

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java?rev=931765&r1=931764&r2=931765&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java
Thu Apr  8 03:21:26 2010
@@ -102,6 +102,12 @@ public class StructTypeTest extends Abst
         // Test writing
         Element element = writeRef(po);
         validatePurchaseOrder(element);
+
+        // Test reading - no namespace on nested elements, xsi:nil (CXF-2695)
+        reader = new ElementReader(getClass().getResourceAsStream("struct5.xml"));
+        po = (PurchaseOrder) purchaseOrderType.readObject(reader, getLocalContext());
+        validatePurchaseOrder(po, true);
+        reader.getXMLStreamReader().close();
     }
 
     @Test
@@ -143,12 +149,19 @@ public class StructTypeTest extends Abst
     }
 
     private void validatePurchaseOrder(PurchaseOrder purchaseOrder) {
+        validatePurchaseOrder(purchaseOrder, false);
+    }
+    private void validatePurchaseOrder(PurchaseOrder purchaseOrder, boolean nilZip) {
         assertNotNull(purchaseOrder);
         assertNotNull(purchaseOrder.getShipping());
         assertEquals("1234 Riverside Drive", purchaseOrder.getShipping().getStreet());
         assertEquals("Gainesville", purchaseOrder.getShipping().getCity());
         assertEquals("FL", purchaseOrder.getShipping().getState());
-        assertEquals("30506", purchaseOrder.getShipping().getZip());
+        if (nilZip) {
+            assertNull(purchaseOrder.getShipping().getZip());
+        } else {
+            assertEquals("30506", purchaseOrder.getShipping().getZip());
+        }
         assertNotNull(purchaseOrder.getBilling());
         assertEquals("1234 Fake Street", purchaseOrder.getBilling().getStreet());
         assertEquals("Las Vegas", purchaseOrder.getBilling().getCity());

Added: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct5.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct5.xml?rev=931765&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct5.xml
(added)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/struct5.xml
Thu Apr  8 03:21:26 2010
@@ -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.
+-->
+<b:po xmlns:b="urn:Bean" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
+  <shipping>
+      <street>1234 Riverside Drive</street>
+      <city>Gainesville</city>
+      <state>FL</state>
+      <zip xsi:nil="true"/>
+  </shipping>
+  <billing>
+      <street>1234 Fake Street</street>
+      <city>Las Vegas</city>
+      <state>NV</state>
+      <zip>89102</zip>
+  </billing>
+</b:po>
\ No newline at end of file



Mime
View raw message