cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r657376 - in /cxf/trunk/rt/databinding/aegis/src: main/java/org/apache/cxf/aegis/ main/java/org/apache/cxf/aegis/type/ main/java/org/apache/cxf/aegis/type/basic/ main/java/org/apache/cxf/aegis/type/java5/ test/java/org/apache/cxf/aegis/ tes...
Date Sat, 17 May 2008 15:31:10 GMT
Author: bimargulies
Date: Sat May 17 08:31:09 2008
New Revision: 657376

URL: http://svn.apache.org/viewvc?rev=657376&view=rev
Log:
Make attributes unqualified by defaul in Aegis, etc.

Added:
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/QualificationTest.java
  (with props)
Modified:
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreationOptions.java
    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/basic/BeanTypeInfo.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotatedTypeInfo.java
    cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/AnnotatedTypeTest.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/JaxbTypeTest.java
    cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTypeTest.java

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java?rev=657376&r1=657375&r2=657376&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/AegisContext.java Sat
May 17 08:31:09 2008
@@ -23,7 +23,6 @@
 import java.util.Map;
 import java.util.Set;
 
-import javax.xml.bind.annotation.XmlNsForm;
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
@@ -90,9 +89,6 @@
     private boolean mtomUseXmime;
     // this URI goes into the type map.
     private String mappingNamespaceURI;
-    private XmlNsForm elementForm = XmlNsForm.QUALIFIED;
-    private XmlNsForm attributeForm = XmlNsForm.QUALIFIED;
-    
     /**
      * Construct a context.
      */
@@ -132,7 +128,6 @@
      * @param mappingNamespaceURI URI to select mappings based on the encoding.
      */
     public void initialize() {
-        // The use of the XSD URI in the mapping is, MAGIC. 
         // allow spring config of an alternative mapping.
         if (configuration == null) {
             configuration = new TypeCreationOptions();
@@ -140,6 +135,7 @@
         if (typeMapping == null) {
             boolean defaultNillable = configuration.isDefaultNillable();
             TypeMapping baseTM = DefaultTypeMapping.createDefaultTypeMapping(defaultNillable,
mtomUseXmime);
+            // The use of the XSD URI in the mapping is, MAGIC. 
             if (mappingNamespaceURI == null) {
                 mappingNamespaceURI = SOAPConstants.XSD;
             }
@@ -413,37 +409,4 @@
     public void setMappingNamespaceURI(String mappingNamespaceURI) {
         this.mappingNamespaceURI = mappingNamespaceURI;
     }
-
-    /**
-     * The form of elements. 
-     * @return Returns the elementForm.
-     */
-    public XmlNsForm getElementForm() {
-        return elementForm;
-    }
-
-    /**
-     * The form of elements.
-     * @param elementForm The elementForm to set.
-     */
-    public void setElementForm(XmlNsForm elementForm) {
-        this.elementForm = elementForm;
-    }
-
-    /**
-     * The form of attributes. 
-     * @return Returns the attributeForm.
-     */
-    public XmlNsForm getAttributeForm() {
-        return attributeForm;
-    }
-
-    /**
-     * The form for attributes.
-     * @param attributeForm The attributeForm to set.
-     */
-    public void setAttributeForm(XmlNsForm attributeForm) {
-        this.attributeForm = attributeForm;
-    }
-
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreationOptions.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreationOptions.java?rev=657376&r1=657375&r2=657376&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreationOptions.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/TypeCreationOptions.java
Sat May 17 08:31:09 2008
@@ -37,6 +37,8 @@
     private boolean defaultExtensibleAttributes;
     private boolean defaultNillable = true;
     private int defaultMinOccurs;
+    private boolean qualifyElements = true;
+    private boolean qualifyAttributes;
 
     public TypeCreationOptions() {
         super();
@@ -90,4 +92,30 @@
         this.defaultNillable = defaultNillable;
     }
 
+    /** * @return Returns the qualifyElements.
+     */
+    public boolean isQualifyElements() {
+        return qualifyElements;
+    }
+
+    /**
+     * @param qualifyElements The qualifyElements to set.
+     */
+    public void setQualifyElements(boolean qualifyElements) {
+        this.qualifyElements = qualifyElements;
+    }
+
+    /** * @return Returns the qualifyAttributes.
+     */
+    public boolean isQualifyAttributes() {
+        return qualifyAttributes;
+    }
+
+    /**
+     * @param qualifyAttributes The qualifyAttributes to set.
+     */
+    public void setQualifyAttributes(boolean qualifyAttributes) {
+        this.qualifyAttributes = qualifyAttributes;
+    }
+
 }

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=657376&r1=657375&r2=657376&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
Sat May 17 08:31:09 2008
@@ -529,7 +529,7 @@
     }
 
     private String getNameWithPrefix(Element root, String nameNS, String localName) {
-        if (!nameNS.equals(getSchemaType().getNamespaceURI())) {
+        if (!"".equals(nameNS) && !nameNS.equals(getSchemaType().getNamespaceURI()))
{
             Element rootElement = (Element)root.getParent();
             String prefix = null;
             if (rootElement != null) { // can happen with doc/lit/bare

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java?rev=657376&r1=657375&r2=657376&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java
Sat May 17 08:31:09 2008
@@ -39,30 +39,20 @@
 
 public class BeanTypeInfo {
     private Map<QName, QName> mappedName2typeName = new HashMap<QName, QName>();
-
     private Map<QName, String> mappedName2pdName = new HashMap<QName, String>();
-
     private Map<QName, Type> mappedName2type = new HashMap<QName, Type>();
-
     private Class<?> beanClass;
-
     private List<QName> attributes = new ArrayList<QName>();
-
     private List<QName> elements = new ArrayList<QName>();
-
     private PropertyDescriptor[] descriptors;
-
     private TypeMapping typeMapping;
-
     private volatile boolean initialized;
-
     private String defaultNamespace;
-
     private int minOccurs;
-
     private boolean nillable = true;
-
     private boolean isExtension;
+    private boolean qualifyAttributes;
+    private boolean qualifyElements = true;
 
     /**
      * extensibleElements means adding xs:any to WSDL Complex Type Definition
@@ -138,9 +128,9 @@
         String name = pd.getName();
 
         if (isAttribute(pd)) {
-            mapAttribute(name, createMappedName(pd));
+            mapAttribute(name, createMappedName(pd, qualifyAttributes));
         } else if (isElement(pd)) {
-            mapElement(name, createMappedName(pd));
+            mapElement(name, createMappedName(pd, qualifyElements));
         }
     }
 
@@ -245,8 +235,12 @@
      * @param desc
      * @return
      */
-    protected QName createMappedName(PropertyDescriptor desc) {
-        return new QName(getDefaultNamespace(), desc.getName());
+    protected QName createMappedName(PropertyDescriptor desc, boolean qualified) {
+        if (qualified) {
+            return new QName(getDefaultNamespace(), desc.getName());
+        } else {
+            return new QName(null, desc.getName());
+        }
     }
 
     public void mapAttribute(String property, QName mappedName) {
@@ -433,4 +427,30 @@
         return isExtension;
     }
 
+    /** * @return Returns the qualifyAttributes.
+     */
+    public boolean isQualifyAttributes() {
+        return qualifyAttributes;
+    }
+
+    /**
+     * @param qualifyAttributes The qualifyAttributes to set.
+     */
+    public void setQualifyAttributes(boolean qualifyAttributes) {
+        this.qualifyAttributes = qualifyAttributes;
+    }
+
+    /** * @return Returns the qualifyElements.
+     */
+    public boolean isQualifyElements() {
+        return qualifyElements;
+    }
+
+    /**
+     * @param qualifyElements The qualifyElements to set.
+     */
+    public void setQualifyElements(boolean qualifyElements) {
+        this.qualifyElements = qualifyElements;
+    }
+
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java?rev=657376&r1=657375&r2=657376&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
Sat May 17 08:31:09 2008
@@ -72,15 +72,31 @@
             LOG.debug("Found mapping for property " + pd.getName());
 
             style = e.getAttributeValue("style");
-            mappedName = NamespaceHelper.createQName(e, e.getAttributeValue("mappedName"),
-                                                     getDefaultNamespace());
         }
 
         if (style == null) {
             style = "element";
         }
+        
+        boolean element = "element".equals(style);
+        boolean qualify;
+        if (element) {
+            qualify = isQualifyElements();
+        } else {
+            qualify = isQualifyAttributes();
+        }
+        String namespace = null;
+        if (qualify) {
+            namespace = getDefaultNamespace();
+        }
+        
+        if (e != null) {
+            mappedName = NamespaceHelper.createQName(e, e.getAttributeValue("mappedName"),
+                                                     namespace);
+        }
+
         if (mappedName == null) {
-            mappedName = createMappedName(pd);
+            mappedName = createMappedName(pd, qualify);
         }
 
         if (e != null) {

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotatedTypeInfo.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotatedTypeInfo.java?rev=657376&r1=657375&r2=657376&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotatedTypeInfo.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/AnnotatedTypeInfo.java
Sat May 17 08:31:09 2008
@@ -23,6 +23,7 @@
 
 import javax.xml.namespace.QName;
 
+import org.apache.cxf.aegis.type.TypeCreationOptions;
 import org.apache.cxf.aegis.type.TypeMapping;
 import org.apache.cxf.aegis.type.basic.BeanTypeInfo;
 import org.apache.cxf.aegis.util.NamespaceHelper;
@@ -30,13 +31,17 @@
 public class AnnotatedTypeInfo extends BeanTypeInfo {
     private final AnnotationReader annotationReader;
 
-    public AnnotatedTypeInfo(TypeMapping tm, Class typeClass, String ns) {
-        this(tm, typeClass, ns, new AnnotationReader());
+    public AnnotatedTypeInfo(TypeMapping tm, Class typeClass, 
+                             String ns, TypeCreationOptions typeCreationOptions) {
+        this(tm, typeClass, ns, new AnnotationReader(), typeCreationOptions);
     }
 
-    public AnnotatedTypeInfo(TypeMapping tm, Class typeClass, String ns, AnnotationReader
annotationReader) {
+    public AnnotatedTypeInfo(TypeMapping tm, Class typeClass, String ns, AnnotationReader
annotationReader,
+                             TypeCreationOptions typeCreationOptions) {
         super(typeClass, ns);
         this.annotationReader = annotationReader;
+        setQualifyAttributes(typeCreationOptions.isQualifyAttributes());
+        setQualifyElements(typeCreationOptions.isQualifyElements());
         setTypeMapping(tm);
         initialize();
     }
@@ -49,12 +54,15 @@
         if (annotationReader.isIgnored(pd.getReadMethod())) {
             return; 
         }
+        
+        String explicitNamespace = annotationReader.getNamespace(pd.getReadMethod());
+        boolean mustQualify = null != explicitNamespace && !"".equals(explicitNamespace);
 
         String name = pd.getName();
         if (isAttribute(pd)) {
-            mapAttribute(name, createMappedName(pd));
+            mapAttribute(name, createMappedName(pd, mustQualify || isQualifyAttributes()));
         } else if (isElement(pd)) {
-            mapElement(name, createMappedName(pd));
+            mapElement(name, createMappedName(pd, mustQualify || isQualifyElements()));
         }
     }
 
@@ -75,8 +83,13 @@
     }
 
     @Override
-    protected QName createMappedName(PropertyDescriptor desc) {
-        return createQName(desc);
+    protected QName createMappedName(PropertyDescriptor desc, boolean qualify) {
+        QName name = createQName(desc);
+        if (!qualify) {
+            return new QName(null, name.getLocalPart());
+        } else {
+            return name;
+        }
     }
 
     protected QName createQName(PropertyDescriptor desc) {

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java?rev=657376&r1=657375&r2=657376&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/Java5TypeCreator.java
Sat May 17 08:31:09 2008
@@ -203,7 +203,8 @@
         AnnotatedTypeInfo typeInfo = new AnnotatedTypeInfo(
                 getTypeMapping(),
                 info.getTypeClass(),
-                typeName.getNamespaceURI());
+                typeName.getNamespaceURI(),
+                getConfiguration());
 
         typeInfo.setExtensibleElements(annotationReader.isExtensibleElements(
                 info.getTypeClass(),

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java?rev=657376&r1=657375&r2=657376&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
Sat May 17 08:31:09 2008
@@ -54,6 +54,8 @@
 import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
 import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
 import org.apache.cxf.wsdl11.WSDLManagerImpl;
+import org.jdom.Element;
+import org.jdom.output.DOMOutputter;
 import org.junit.Before;
 
 public abstract class AbstractAegisTest extends AbstractCXFTest {
@@ -213,6 +215,23 @@
         
     }
     
+    protected void assertXPathEquals(String xpath, String value, Element element) throws
Exception {
+        org.w3c.dom.Document doc = new DOMOutputter().output(element.getDocument());
+        assertXPathEquals(xpath, value, doc);
+    }
+    
+    protected void assertValid(String xpath, Element element) throws Exception {
+        org.w3c.dom.Document doc = new DOMOutputter().output(element.getDocument());
+        
+        assertValid(xpath, doc);
+    }
+
+    protected void assertInvalid(String xpath, Element element) throws Exception {
+        org.w3c.dom.Document doc = new DOMOutputter().output(element.getDocument());
+        
+        assertInvalid(xpath, doc);
+    }
+    
     protected Document getWSDLDocument(String string) throws WSDLException {
         Definition definition = getWSDLDefinition(string);
         if (definition == null) {

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java?rev=657376&r1=657375&r2=657376&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
Sat May 17 08:31:09 2008
@@ -40,7 +40,6 @@
 import org.apache.cxf.common.util.SOAPConstants;
 import org.jdom.Document;
 import org.jdom.Element;
-import org.jdom.output.DOMOutputter;
 import org.junit.Test;
 
 public class BeanTest extends AbstractAegisTest {
@@ -59,6 +58,7 @@
         mapping = context.getTypeMapping();
     }
 
+    @Test
     public void testBean() throws Exception {
         BeanType type = new BeanType();
         type.setTypeClass(SimpleBean.class);
@@ -98,18 +98,6 @@
         assertValid("/b:root/b:bleh[text()='bleh']", element);
         assertValid("/b:root/b:howdy[text()='howdy']", element);
     }
-
-    private void assertValid(String xpath, Element element) throws Exception {
-        org.w3c.dom.Document doc = new DOMOutputter().output(element.getDocument());
-        
-        assertValid(xpath, doc);
-    }
-
-    private void assertInvalid(String xpath, Element element) throws Exception {
-        org.w3c.dom.Document doc = new DOMOutputter().output(element.getDocument());
-        
-        assertInvalid(xpath, doc);
-    }
     
     @Test
     public void testBeanWithXsiType() throws Exception {

Added: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/QualificationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/QualificationTest.java?rev=657376&view=auto
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/QualificationTest.java
(added)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/QualificationTest.java
Sat May 17 08:31:09 2008
@@ -0,0 +1,89 @@
+/**
+ * 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.aegis.type.basic;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.AegisContext;
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.services.AttributeBean;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeCreationOptions;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.apache.cxf.aegis.xml.jdom.JDOMWriter;
+import org.apache.cxf.common.util.SOAPConstants;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.junit.Test;
+
+public class QualificationTest extends AbstractAegisTest {
+
+    public void setUp() throws Exception {
+        super.setUp();
+    
+        addNamespace("b", "urn:Bean");
+        addNamespace("xyzzy", "urn:xyzzy");
+        addNamespace("xsi", SOAPConstants.XSI_NS);
+    }
+    
+    @Test
+    public void testDefaultUnqualifiedAttribute() throws Exception {
+        AegisContext context = new AegisContext();
+        context.initialize();
+        TypeMapping mapping = context.getTypeMapping();
+        
+        Type type = mapping.getTypeCreator().createType(AttributeBean.class);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        Context messageContext = new Context(context);
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        AttributeBean bean = new AttributeBean();
+        type.writeObject(bean, new JDOMWriter(element), messageContext);
+        assertValid("/b:root[@xyzzy:attrExplicitString]", element);
+        assertXPathEquals("/b:root/@xyzzy:attrExplicitString", "attrExplicit", element);
+        assertValid("/b:root[@attrPlainString]", element);
+        assertXPathEquals("/b:root/@attrPlainString", "attrPlain", element);
+    }
+    
+    @Test
+    public void testDefaultQualifiedAttribute() throws Exception {
+        AegisContext context = new AegisContext();
+        TypeCreationOptions typeCreationOptions = 
+            new TypeCreationOptions();
+        typeCreationOptions.setQualifyAttributes(true);
+        context.setTypeCreationOptions(typeCreationOptions);
+        context.initialize();
+        TypeMapping mapping = context.getTypeMapping();
+        
+        Type type = mapping.getTypeCreator().createType(AttributeBean.class);
+        type.setSchemaType(new QName("urn:Bean", "bean"));
+
+        Context messageContext = new Context(context);
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        AttributeBean bean = new AttributeBean();
+        type.writeObject(bean, new JDOMWriter(element), messageContext);
+        assertValid("/b:root[@xyzzy:attrExplicitString]", element);
+        assertXPathEquals("/b:root/@xyzzy:attrExplicitString", "attrExplicit", element);
+        assertValid("/b:root[@attrPlainString]", element);
+        assertXPathEquals("/b:root/@attrPlainString", "attrPlain", element);
+    }
+}

Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/QualificationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/QualificationTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/AnnotatedTypeTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/AnnotatedTypeTest.java?rev=657376&r1=657375&r2=657376&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/AnnotatedTypeTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/AnnotatedTypeTest.java
Sat May 17 08:31:09 2008
@@ -27,6 +27,7 @@
 import org.apache.cxf.aegis.AbstractAegisTest;
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeCreationOptions;
 import org.apache.cxf.aegis.type.TypeMapping;
 import org.apache.cxf.aegis.type.XMLTypeCreator;
 import org.apache.cxf.aegis.type.basic.BeanType;
@@ -60,7 +61,8 @@
 
     @Test
     public void testType() {
-        AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, AnnotatedBean1.class, "urn:foo");
+        AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, AnnotatedBean1.class, "urn:foo",
+                                                       new TypeCreationOptions());
 
         Iterator elements = info.getElements();
         assertTrue(elements.hasNext());
@@ -171,7 +173,8 @@
 
     @Test
     public void testGetSetRequired() throws Exception {
-        BeanType type = new BeanType(new AnnotatedTypeInfo(tm, BadBean.class, "urn:foo"));
+        BeanType type = new BeanType(new AnnotatedTypeInfo(tm, BadBean.class, "urn:foo",
+                                                           new TypeCreationOptions()));
         type.setSchemaType(new QName("urn:foo", "BadBean"));
 
         assertFalse(type.getTypeInfo().getElements().hasNext());

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/JaxbTypeTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/JaxbTypeTest.java?rev=657376&r1=657375&r2=657376&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/JaxbTypeTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/JaxbTypeTest.java
Sat May 17 08:31:09 2008
@@ -27,6 +27,7 @@
 import org.apache.cxf.aegis.AbstractAegisTest;
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeCreationOptions;
 import org.apache.cxf.aegis.type.TypeMapping;
 import org.apache.cxf.aegis.type.XMLTypeCreator;
 import org.apache.cxf.aegis.type.basic.BeanType;
@@ -60,7 +61,8 @@
 
     @Test
     public void testType() {
-        AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, JaxbBean1.class, "urn:foo");
+        AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, JaxbBean1.class, "urn:foo",
+                                                       new TypeCreationOptions());
 
         Iterator elements = info.getElements();
         assertTrue(elements.hasNext());
@@ -171,7 +173,8 @@
 
     @Test
     public void testGetSetRequired() throws Exception {
-        BeanType type = new BeanType(new AnnotatedTypeInfo(tm, BadBean.class, "urn:foo"));
+        BeanType type = new BeanType(new AnnotatedTypeInfo(tm, BadBean.class, "urn:foo",
+                                                           new TypeCreationOptions()));
         type.setSchemaType(new QName("urn:foo", "BadBean"));
 
         assertFalse(type.getTypeInfo().getElements().hasNext());

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTypeTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTypeTest.java?rev=657376&r1=657375&r2=657376&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTypeTest.java
(original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/XFireTypeTest.java
Sat May 17 08:31:09 2008
@@ -27,6 +27,7 @@
 import org.apache.cxf.aegis.AbstractAegisTest;
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
 import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeCreationOptions;
 import org.apache.cxf.aegis.type.TypeMapping;
 import org.apache.cxf.aegis.type.XMLTypeCreator;
 import org.apache.cxf.aegis.type.basic.BeanType;
@@ -60,7 +61,8 @@
 
     @Test
     public void testType() {
-        AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, XFireBean1.class, "urn:foo");
+        AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, XFireBean1.class, "urn:foo",
+                                                       new TypeCreationOptions());
 
         Iterator elements = info.getElements();
         assertTrue(elements.hasNext());
@@ -171,7 +173,8 @@
 
     @Test
     public void testGetSetRequired() throws Exception {
-        BeanType type = new BeanType(new AnnotatedTypeInfo(tm, BadBean.class, "urn:foo"));
+        BeanType type = new BeanType(new AnnotatedTypeInfo(tm, BadBean.class, "urn:foo",
+                                                           new TypeCreationOptions()));
         type.setSchemaType(new QName("urn:foo", "BadBean"));
 
         assertFalse(type.getTypeInfo().getElements().hasNext());



Mime
View raw message