cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1514015 - in /cxf/branches/2.6.x-fixes/rt/databinding/aegis/src: main/java/org/apache/cxf/aegis/type/basic/ test/java/org/apache/cxf/aegis/inheritance/
Date Wed, 14 Aug 2013 19:48:09 GMT
Author: dkulp
Date: Wed Aug 14 19:48:09 2013
New Revision: 1514015

URL: http://svn.apache.org/r1514015
Log:
Merged revisions 1514009 via  git cherry-pick from
https://svn.apache.org/repos/asf/cxf/branches/2.7.x-fixes

........
  r1514009 | dkulp | 2013-08-14 15:17:04 -0400 (Wed, 14 Aug 2013) | 11 lines

  Merged revisions 1514008 via  git cherry-pick from
  https://svn.apache.org/repos/asf/cxf/trunk

  ........
    r1514008 | dkulp | 2013-08-14 15:13:43 -0400 (Wed, 14 Aug 2013) | 3 lines

    [CXF-5176] Aegis inheritance: inherited xml attributes appear twice
    Patch applied

  ........

........

Modified:
    cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
    cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/AbstractUser.java
    cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritancePOJOTest.java
    cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritanceService.java

Modified: cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java?rev=1514015&r1=1514014&r2=1514015&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanType.java
Wed Aug 14 19:48:09 2013
@@ -359,6 +359,10 @@ public class BeanType extends AegisType 
 
         for (QName name : inf.getAttributes()) {
 
+            if (isInheritedProperty(inf, name)) {
+                continue;
+            }
+
             Object value = readProperty(object, name);
             if (value != null) {
                 AegisType type = getType(inf, name);
@@ -385,11 +389,10 @@ public class BeanType extends AegisType 
 
         for (QName name : inf.getElements()) {
 
-            if (inf.isExtension()
-                && inf.getPropertyDescriptorFromMappedName(name).getReadMethod().getDeclaringClass()
!= inf
-                    .getTypeClass()) {
+            if (isInheritedProperty(inf, name)) {
                 continue;
             }
+
             Object value = readProperty(object, name);
 
             AegisType defaultType = getType(inf, name);
@@ -414,6 +417,15 @@ public class BeanType extends AegisType 
         }
     }
 
+    /**
+     * @return true if the given beanType is extended and its given property is inherited
from parent classes
+     */
+    private boolean isInheritedProperty(BeanTypeInfo beanTypeInfo, QName propertyQName) {
+        return beanTypeInfo.isExtension()
+               && beanTypeInfo.getPropertyDescriptorFromMappedName(propertyQName).getReadMethod().
+                getDeclaringClass() != beanTypeInfo.getTypeClass();
+    }
+
     protected void writeElement(QName name, Object value,
                                 AegisType type, MessageWriter writer, Context context) {
 
@@ -522,13 +534,14 @@ public class BeanType extends AegisType 
         BeanTypeInfo inf = getTypeInfo();
 
         for (QName name : inf.getAttributes()) {
+            if (isInheritedProperty(inf, name)) {
+                continue;
+            }
             deps.add(inf.getType(name));
         }
 
         for (QName name : inf.getElements()) {
-            if (inf.isExtension()
-                && inf.getPropertyDescriptorFromMappedName(name).getReadMethod().getDeclaringClass()
!= inf
-                    .getTypeClass()) {
+            if (isInheritedProperty(inf, name)) {
                 continue;
             }
             deps.add(inf.getType(name));
@@ -716,14 +729,8 @@ public class BeanType extends AegisType 
         // Write out schema for elements
         for (QName name : inf.getElements()) {
 
-            if (isExtension) {
-                PropertyDescriptor pd = inf.getPropertyDescriptorFromMappedName(name);
-
-                // assert pd.getReadMethod() != null && pd.getWriteMethod() != null;
-
-                if (pd.getReadMethod().getDeclaringClass() != inf.getTypeClass()) {
-                    continue;
-                }
+            if (isInheritedProperty(inf, name)) {
+                continue;
             }
 
             XmlSchemaElement element = new XmlSchemaElement(root, false);
@@ -771,6 +778,11 @@ public class BeanType extends AegisType 
 
         // Write out schema for attributes
         for (QName name : inf.getAttributes()) {
+
+            if (isInheritedProperty(inf, name)) {
+                continue;
+            }
+
             XmlSchemaAttribute attribute = new XmlSchemaAttribute(root, false);
             complex.getAttributes().add(attribute);
             attribute.setName(name.getLocalPart());

Modified: cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/AbstractUser.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/AbstractUser.java?rev=1514015&r1=1514014&r2=1514015&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/AbstractUser.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/AbstractUser.java
Wed Aug 14 19:48:09 2013
@@ -21,10 +21,14 @@
  */
 package org.apache.cxf.aegis.inheritance;
 
+import org.apache.cxf.aegis.type.java5.XmlAttribute;
+
 // @XmlType(namespace="urn:xfire:inheritance")
 public abstract class AbstractUser {
     private String name;
 
+    private String nickname;
+
     public String getName() {
         return name;
     }
@@ -32,4 +36,13 @@ public abstract class AbstractUser {
     public void setName(String name) {
         this.name = name;
     }
+
+    @XmlAttribute
+    public String getNickname() {
+        return nickname;
+    }
+
+    public void setNickname(String nickname) {
+        this.nickname = nickname;
+    }
 }

Modified: cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritancePOJOTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritancePOJOTest.java?rev=1514015&r1=1514014&r2=1514015&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritancePOJOTest.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritancePOJOTest.java
Wed Aug 14 19:48:09 2013
@@ -70,13 +70,16 @@ public class InheritancePOJOTest extends
         String extension = "/xsd:complexContent/xsd:extension[@base='tns:AbstractUser']";
         assertValid(employeeType + extension, d);
         assertValid(employeeType + extension + "/xsd:sequence/xsd:element[@name='division']",
d);
-        // assertValid("count(" + employeeType + extension +
-        // "/xsd:sequence/*)=1", d);
+
+        // Check elements/attributes from abstract type are not in the extended type
+        assertInvalid(employeeType + extension + "/xsd:sequence/xsd:element[@name='name']",
d);
+        assertInvalid(employeeType + "/xsd:attribute[@name='nickname']", d);
 
         // check for BaseUser as abstract
         String baseUserType = types + "xsd:complexType[(@name='AbstractUser') and (@abstract='true')]";
         assertValid(baseUserType, d);
         assertValid(baseUserType + "/xsd:sequence/xsd:element[@name='name']", d);
+        assertValid(baseUserType + "/xsd:attribute[@name='nickname']", d);
         // assertValid("count(" + baseUserType + "/xsd:sequence/*)=1", d);
     }
 

Modified: cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritanceService.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritanceService.java?rev=1514015&r1=1514014&r2=1514015&view=diff
==============================================================================
--- cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritanceService.java
(original)
+++ cxf/branches/2.6.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/inheritance/InheritanceService.java
Wed Aug 14 19:48:09 2013
@@ -26,6 +26,7 @@ public class InheritanceService {
         Employee e = new Employee();
         e.setDivision("foo");
         e.setName("Dan D. Man");
+        e.setNickname("bar");
         return e;
     }
 



Mime
View raw message