You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-commits@axis.apache.org by ve...@apache.org on 2016/04/18 21:58:34 UTC

svn commit: r1739815 - in /axis/axis2/java/core/trunk/modules/adb: ./ src/org/apache/axis2/databinding/utils/ test/org/apache/axis2/databinding/utils/

Author: veithen
Date: Mon Apr 18 19:58:34 2016
New Revision: 1739815

URL: http://svn.apache.org/viewvc?rev=1739815&view=rev
Log:
AXIS2-5751: Correctly handle anyType (Object) properties with null values.

Added:
    axis/axis2/java/core/trunk/modules/adb/test/org/apache/axis2/databinding/utils/ComplexTypeWithAnyTypeElement.java   (with props)
Modified:
    axis/axis2/java/core/trunk/modules/adb/pom.xml
    axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
    axis/axis2/java/core/trunk/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java

Modified: axis/axis2/java/core/trunk/modules/adb/pom.xml
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb/pom.xml?rev=1739815&r1=1739814&r2=1739815&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb/pom.xml (original)
+++ axis/axis2/java/core/trunk/modules/adb/pom.xml Mon Apr 18 19:58:34 2016
@@ -57,7 +57,12 @@
             <groupId>xmlunit</groupId>
             <artifactId>xmlunit</artifactId>
             <scope>test</scope>
-        </dependency>       
+        </dependency>
+        <dependency>
+            <groupId>org.apache.ws.commons.axiom</groupId>
+            <artifactId>xml-truth</artifactId>
+            <scope>test</scope>
+        </dependency>
         <dependency>
             <groupId>org.apache.geronimo.specs</groupId>
             <artifactId>geronimo-javamail_1.4_spec</artifactId>

Modified: axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java?rev=1739815&r1=1739814&r2=1739815&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java (original)
+++ axis/axis2/java/core/trunk/modules/adb/src/org/apache/axis2/databinding/utils/BeanUtil.java Mon Apr 18 19:58:34 2016
@@ -354,7 +354,7 @@ public class BeanUtil {
                 }else {
                     addTypeQname(elemntNameSpace, propertyQnameValueList, property,
                                  beanName, processingDocLitBare);
-                    if (Object.class.equals(ptype)) {
+                    if (Object.class.equals(ptype) && value != null) {
                         //this is required to match this element prefix as
                         //root element's prefix.
                         QName qNamefortheType = (QName) typeTable

Modified: axis/axis2/java/core/trunk/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java?rev=1739815&r1=1739814&r2=1739815&view=diff
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java (original)
+++ axis/axis2/java/core/trunk/modules/adb/test/org/apache/axis2/databinding/utils/BeanUtilTest.java Mon Apr 18 19:58:34 2016
@@ -34,6 +34,9 @@ import javax.activation.DataHandler;
 import javax.mail.util.ByteArrayDataSource;
 import javax.xml.namespace.QName;
 
+import static com.google.common.truth.Truth.assertAbout;
+import static org.apache.axiom.truth.xml.XMLTruth.xml;
+
 import java.io.ByteArrayInputStream;
 import java.math.BigInteger;
 import java.util.List;
@@ -283,5 +286,14 @@ public class BeanUtilTest extends TestCa
 	    return new String(theChars);
 	      }
   
-   
+    /**
+     * Regression test for AXIS2-5751.
+     */
+    public void testSerializeAnyTypeNull() {
+        assertAbout(xml())
+                .that(BeanUtil.getPullParser(new ComplexTypeWithAnyTypeElement(), new QName("root"), null, false, false))
+                .ignoringNamespaceDeclarations()
+                .ignoringNamespacePrefixes()
+                .hasSameContentAs("<root><prop xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:nil='true'/></root>");
+    }
 }

Added: axis/axis2/java/core/trunk/modules/adb/test/org/apache/axis2/databinding/utils/ComplexTypeWithAnyTypeElement.java
URL: http://svn.apache.org/viewvc/axis/axis2/java/core/trunk/modules/adb/test/org/apache/axis2/databinding/utils/ComplexTypeWithAnyTypeElement.java?rev=1739815&view=auto
==============================================================================
--- axis/axis2/java/core/trunk/modules/adb/test/org/apache/axis2/databinding/utils/ComplexTypeWithAnyTypeElement.java (added)
+++ axis/axis2/java/core/trunk/modules/adb/test/org/apache/axis2/databinding/utils/ComplexTypeWithAnyTypeElement.java Mon Apr 18 19:58:34 2016
@@ -0,0 +1,31 @@
+/*
+ * 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.axis2.databinding.utils;
+
+public class ComplexTypeWithAnyTypeElement {
+    private Object prop;
+
+    public Object getProp() {
+        return prop;
+    }
+
+    public void setProp(Object prop) {
+        this.prop = prop;
+    }
+}

Propchange: axis/axis2/java/core/trunk/modules/adb/test/org/apache/axis2/databinding/utils/ComplexTypeWithAnyTypeElement.java
------------------------------------------------------------------------------
    svn:eol-style = native