cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r747871 [2/3] - in /cxf/branches/2.1.x-fixes: api/src/main/java/org/apache/cxf/wsdl/ rt/databinding/aegis/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/ rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/databinding/ rt/data...
Date Wed, 25 Feb 2009 17:54:36 GMT
Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/BeanTypeInfo.java Wed Feb 25 17:54:34 2009
@@ -399,12 +399,12 @@
         return mappedName2pdName.get(name);
     }
 
-    public List<QName> getAttributes() {
-        return attributes;
+    public Iterator<QName> getAttributes() {
+        return attributes.iterator();
     }
 
-    public List<QName> getElements() {
-        return elements;
+    public Iterator<QName> getElements() {
+        return elements.iterator();
     }
 
     public boolean isExtensibleElements() {

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/ObjectType.java Wed Feb 25 17:54:34 2009
@@ -35,10 +35,8 @@
 import org.apache.cxf.aegis.xml.MessageWriter;
 import org.apache.cxf.common.util.Base64Utility;
 import org.apache.cxf.common.util.SOAPConstants;
-import org.apache.cxf.common.xmlschema.XmlSchemaConstants;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaSimpleType;
-import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
+import org.jdom.Attribute;
+import org.jdom.Element;
 
 /**
  * Type for runtime inspection of types. Looks as the class to be written, and
@@ -280,15 +278,16 @@
     }
 
     @Override
-    public void writeSchema(XmlSchema root) {
+    public void writeSchema(Element root) {
         if (serializedWhenUnknown) {
-            XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root);
-            simple.setName("serializedJavaObject");
-            root.addType(simple);
-            root.getItems().add(simple);
-            XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();    
-            simple.setContent(restriction);
-            restriction.setBaseTypeName(XmlSchemaConstants.BASE64BINARY_QNAME);
+            Element simple = new Element("simpleType", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+            simple.setAttribute(new Attribute("name", "serializedJavaObject"));
+            root.addContent(simple);
+
+            Element restriction = new Element("restriction", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+            restriction.setAttribute(new Attribute("base", SOAPConstants.XSD_PREFIX + ":base64Binary"));
+
+            simple.addContent(restriction);
         }
     }
 }

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/basic/XMLBeanTypeInfo.java Wed Feb 25 17:54:34 2009
@@ -26,13 +26,11 @@
 
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Element;
-
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.cxf.aegis.DatabindingException;
 import org.apache.cxf.aegis.util.NamespaceHelper;
-import org.apache.cxf.helpers.DOMUtils;
+import org.jdom.Element;
 
 public class XMLBeanTypeInfo extends BeanTypeInfo {
     private static final Log LOG = LogFactory.getLog(XMLBeanTypeInfo.class);
@@ -52,7 +50,7 @@
     @Override
     protected boolean registerType(PropertyDescriptor desc) {
         Element e = getPropertyElement(desc.getName());
-        if (e != null && DOMUtils.getAttributeValueEmptyNull(e, "type") != null) {
+        if (e != null && e.getAttributeValue("type") != null) {
             return false;
         }
 
@@ -66,14 +64,14 @@
         QName mappedName = null;
 
         if (e != null) {
-            String ignore = DOMUtils.getAttributeValueEmptyNull(e, "ignore");
+            String ignore = e.getAttributeValue("ignore");
             if (ignore != null && ignore.equals("true")) {
                 return;
             }
 
             LOG.debug("Found mapping for property " + pd.getName());
 
-            style = DOMUtils.getAttributeValueEmptyNull(e, "style");
+            style = e.getAttributeValue("style");
         }
 
         if (style == null) {
@@ -93,7 +91,7 @@
         }
         
         if (e != null) {
-            mappedName = NamespaceHelper.createQName(e, DOMUtils.getAttributeValueEmptyNull(e, "mappedName"),
+            mappedName = NamespaceHelper.createQName(e, e.getAttributeValue("mappedName"),
                                                      namespace);
         }
 
@@ -102,19 +100,18 @@
         }
 
         if (e != null) {
-            QName mappedType = NamespaceHelper.createQName(e, 
-                                                           DOMUtils.getAttributeValueEmptyNull(e, "typeName"),
+            QName mappedType = NamespaceHelper.createQName(e, e.getAttributeValue("typeName"),
                                                            getDefaultNamespace());
             if (mappedType != null) {
                 mapTypeName(mappedName, mappedType);
             }
 
-            String nillableVal = DOMUtils.getAttributeValueEmptyNull(e, "nillable");
+            String nillableVal = e.getAttributeValue("nillable");
             if (nillableVal != null && nillableVal.length() > 0) {
                 ensurePropertyInfo(mappedName).setNillable(Boolean.valueOf(nillableVal).booleanValue());
             }
 
-            String minOccurs = DOMUtils.getAttributeValueEmptyNull(e, "minOccurs");
+            String minOccurs = e.getAttributeValue("minOccurs");
             if (minOccurs != null && minOccurs.length() > 0) {
                 ensurePropertyInfo(mappedName).setMinOccurs(Integer.parseInt(minOccurs));
             }
@@ -140,10 +137,10 @@
     private Element getPropertyElement(String name2) {
         for (Iterator itr = mappings.iterator(); itr.hasNext();) {
             Element mapping2 = (Element)itr.next();
-            List<Element> elements = DOMUtils.getChildrenWithName(mapping2, "", "property");
+            List elements = mapping2.getChildren("property");
             for (int i = 0; i < elements.size(); i++) {
                 Element e = (Element)elements.get(i);
-                String name = DOMUtils.getAttributeValueEmptyNull(e, "name");
+                String name = e.getAttributeValue("name");
 
                 if (name != null && name.equals(name2)) {
                     return e;

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java Wed Feb 25 17:54:34 2009
@@ -31,12 +31,12 @@
 import org.apache.cxf.aegis.DatabindingException;
 import org.apache.cxf.aegis.type.Type;
 import org.apache.cxf.aegis.type.TypeUtil;
+import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.apache.cxf.aegis.xml.MessageReader;
 import org.apache.cxf.aegis.xml.MessageWriter;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaComplexType;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.apache.cxf.common.util.SOAPConstants;
+import org.jdom.Attribute;
+import org.jdom.Element;
 
 public class MapType extends Type {
     private Type keyType;
@@ -176,43 +176,49 @@
     }
 
     @Override
-    public void writeSchema(XmlSchema root) {
-        XmlSchemaComplexType complex = new XmlSchemaComplexType(root);
-        complex.setName(getSchemaType().getLocalPart());
-        root.addType(complex);
-        root.getItems().add(complex);
-        XmlSchemaSequence sequence = new XmlSchemaSequence();
-        complex.setParticle(sequence);
+    public void writeSchema(Element root) {
+        Element complex = new Element("complexType", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+        complex.setAttribute(new Attribute("name", getSchemaType().getLocalPart()));
+        root.addContent(complex);
+
+        Element seq = new Element("sequence", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+        complex.addContent(seq);
 
         Type kType = getKeyType();
         Type vType = getValueType();
-        
-        XmlSchemaElement element = new XmlSchemaElement();
-        sequence.getItems().add(element);
-        element.setName(getEntryName().getLocalPart());
-        element.setMinOccurs(0);
-        element.setMaxOccurs(Long.MAX_VALUE);
-        
-        XmlSchemaComplexType evType = new XmlSchemaComplexType(root);
-        element.setType(evType);
-        
-        XmlSchemaSequence evSequence = new XmlSchemaSequence();
-        evType.setParticle(evSequence);
 
-        createElement(evSequence, getKeyName(), kType);
-        createElement(evSequence, getValueName(), vType);
+        Element element = new Element("element", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+        seq.addContent(element);
+
+        element.setAttribute(new Attribute("name", getEntryName().getLocalPart()));
+        element.setAttribute(new Attribute("minOccurs", "0"));
+        element.setAttribute(new Attribute("maxOccurs", "unbounded"));
+
+        Element evComplex = new Element("complexType", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+        element.addContent(evComplex);
+
+        Element evseq = new Element("sequence", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+        evComplex.addContent(evseq);
+
+        createElement(root, evseq, getKeyName(), kType);
+        createElement(root, evseq, getValueName(), vType);
     }
 
     /**
      * Creates a element in a sequence for the key type and the value type.
      */
-    private void createElement(XmlSchemaSequence seq, QName name, Type type) {
-        XmlSchemaElement element = new XmlSchemaElement();
-        seq.getItems().add(element);
-        element.setName(name.getLocalPart());
-        element.setSchemaTypeName(type.getSchemaType());
-        element.setMinOccurs(0);
-        element.setMaxOccurs(1);
+    private void createElement(Element root, Element seq, QName name, Type type) {
+        Element element = new Element("element", SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+        seq.addContent(element);
+
+        String prefix = NamespaceHelper.getUniquePrefix((Element)root, type.getSchemaType()
+            .getNamespaceURI());
+
+        element.setAttribute(new Attribute("name", name.getLocalPart()));
+        element.setAttribute(TypeUtil.createTypeAttribute(prefix, type, root));
+
+        element.setAttribute(new Attribute("minOccurs", "0"));
+        element.setAttribute(new Attribute("maxOccurs", "1"));
     }
 
     @Override

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfo.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfo.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfo.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfo.java Wed Feb 25 17:54:34 2009
@@ -24,8 +24,6 @@
 import java.util.Collections;
 import java.util.List;
 import java.util.StringTokenizer;
-
-import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.aegis.DatabindingException;
@@ -58,8 +56,7 @@
     }
 
     public ArrayTypeInfo(MessageReader reader, TypeMapping tm) {
-        this(reader.getXMLStreamReader().getNamespaceContext(),
-             readAttributeValue(reader, SOAP_ARRAY_TYPE), readAttributeValue(reader, SOAP_ARRAY_OFFSET));
+        this(readAttributeValue(reader, SOAP_ARRAY_TYPE), readAttributeValue(reader, SOAP_ARRAY_OFFSET));
 
         // if type is xsd:ur-type replace it with xsd:anyType
         String namespace = reader.getNamespaceForPrefix(typeName.getPrefix());
@@ -88,11 +85,11 @@
         }
     }
 
-    public ArrayTypeInfo(NamespaceContext namespaceContext, String arrayTypeValue) {
-        this(namespaceContext, arrayTypeValue, null);
+    public ArrayTypeInfo(String arrayTypeValue) {
+        this(arrayTypeValue, null);
     }
 
-    public ArrayTypeInfo(NamespaceContext namespaceContext, String arrayTypeValue, String offsetString) {
+    public ArrayTypeInfo(String arrayTypeValue, String offsetString) {
         if (arrayTypeValue == null) {
             throw new NullPointerException("arrayTypeValue is null");
         }
@@ -113,8 +110,7 @@
             throw new DatabindingException("Invalid ArrayType value " + arrayTypeValue);
         }
         if (tokens.get(1).equals(":")) {
-            typeName = 
-                new QName(namespaceContext.getNamespaceURI(tokens.get(0)), tokens.get(2), tokens.get(0));
+            typeName = new QName("", tokens.get(2), tokens.get(0));
             tokens = tokens.subList(3, tokens.size());
         } else {
             typeName = new QName("", tokens.get(0));
@@ -222,11 +218,6 @@
 
     public String toString() {
         StringBuilder string = new StringBuilder();
-        
-        // no prefix handed to us by someone else ...
-        if ("".equals(typeName.getPrefix()) && !"".equals(typeName.getNamespaceURI())) {
-            throw new RuntimeException("No prefix provided in QName for " + typeName.getNamespaceURI());
-        }
 
         // typeName: foo:bar
         if (typeName.getPrefix() != null && typeName.getPrefix().length() > 0) {

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java Wed Feb 25 17:54:34 2009
@@ -25,7 +25,6 @@
 import java.util.List;
 import java.util.Set;
 import java.util.StringTokenizer;
-
 import javax.xml.namespace.QName;
 
 import org.apache.commons.logging.Log;
@@ -40,7 +39,7 @@
 import org.apache.cxf.aegis.xml.MessageWriter;
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.helpers.CastUtils;
-import org.apache.ws.commons.schema.XmlSchema;
+import org.jdom.Element;
 
 import static org.apache.cxf.aegis.type.encoded.SoapEncodingUtil.readAttributeValue;
 
@@ -136,7 +135,7 @@
                 sparse = position != null;
             }
 
-            // nested element names can specify a type
+            // nested element names can specifiy a type
             Type compType = getTypeMapping().getType(creader.getName());
             if (compType == null) {
                 // use the type declared in the arrayType attribute
@@ -291,9 +290,6 @@
         // Root component's schema type
         QName rootType = getRootType();
         String prefix = writer.getPrefixForNamespace(rootType.getNamespaceURI(), rootType.getPrefix());
-        if (prefix == null) {
-            prefix = "";
-        }
         rootType = new QName(rootType.getNamespaceURI(), rootType.getLocalPart(), prefix);
 
 
@@ -301,9 +297,6 @@
         ArrayTypeInfo arrayTypeInfo = new ArrayTypeInfo(rootType,
                 getDimensions() - 1,
                 Array.getLength(values));
-        // ensure that the writer writes out this prefix...
-        writer.getPrefixForNamespace(arrayTypeInfo.getTypeName().getNamespaceURI(), 
-                                     arrayTypeInfo.getTypeName().getPrefix());
         arrayTypeInfo.writeAttribute(writer);
 
         // write each element
@@ -340,7 +333,7 @@
      * Throws UnsupportedOperationException
      */
     @Override
-    public void writeSchema(XmlSchema root) {
+    public void writeSchema(Element root) {
         throw new UnsupportedOperationException();
     }
 

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefType.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefType.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapRefType.java Wed Feb 25 17:54:34 2009
@@ -19,7 +19,6 @@
 package org.apache.cxf.aegis.type.encoded;
 
 import java.util.Set;
-
 import javax.xml.namespace.QName;
 
 import org.apache.cxf.aegis.Context;
@@ -28,7 +27,7 @@
 import org.apache.cxf.aegis.type.TypeMapping;
 import org.apache.cxf.aegis.xml.MessageReader;
 import org.apache.cxf.aegis.xml.MessageWriter;
-import org.apache.ws.commons.schema.XmlSchema;
+import org.jdom.Element;
 
 /**
  * SoapRefType reads and writes SoapRef objects.
@@ -78,9 +77,8 @@
         SoapEncodingUtil.writeRef(writer, refId);
     }
 
-    @Override
-    public void writeSchema(XmlSchema schema) {
-        baseType.writeSchema(schema);
+    public void writeSchema(Element root) {
+        baseType.writeSchema(root);
     }
 
     public TypeMapping getTypeMapping() {

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java Wed Feb 25 17:54:34 2009
@@ -23,12 +23,10 @@
 import org.apache.cxf.aegis.type.Type;
 import org.apache.cxf.aegis.xml.MessageReader;
 import org.apache.cxf.aegis.xml.MessageWriter;
-import org.apache.cxf.common.xmlschema.XmlSchemaConstants;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaEnumerationFacet;
-import org.apache.ws.commons.schema.XmlSchemaObjectCollection;
-import org.apache.ws.commons.schema.XmlSchemaSimpleType;
-import org.apache.ws.commons.schema.XmlSchemaSimpleTypeRestriction;
+import org.apache.cxf.common.util.SOAPConstants;
+import org.jdom.Attribute;
+import org.jdom.Element;
+import org.jdom.Namespace;
 
 public class EnumType extends Type {
     @SuppressWarnings("unchecked")
@@ -55,23 +53,23 @@
     }
 
     @Override
-    public void writeSchema(XmlSchema root) {
-        
-        XmlSchemaSimpleType simple = new XmlSchemaSimpleType(root);
-        simple.setName(getSchemaType().getLocalPart());
-        root.addType(simple);
-        root.getItems().add(simple);
-        XmlSchemaSimpleTypeRestriction restriction = new XmlSchemaSimpleTypeRestriction();
-        restriction.setBaseTypeName(XmlSchemaConstants.STRING_QNAME);
-        simple.setContent(restriction);
+    public void writeSchema(Element root) {
+        Namespace xsd = Namespace.getNamespace(SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+
+        Element simple = new Element("simpleType", xsd);
+        simple.setAttribute(new Attribute("name", getSchemaType().getLocalPart()));
+        root.addContent(simple);
+
+        Element restriction = new Element("restriction", xsd);
+        restriction.setAttribute(new Attribute("base", SOAPConstants.XSD_PREFIX + ":string"));
+        simple.addContent(restriction);
 
         Object[] constants = getTypeClass().getEnumConstants();
 
-        XmlSchemaObjectCollection facets = restriction.getFacets();
         for (Object constant : constants) {
-            XmlSchemaEnumerationFacet f = new XmlSchemaEnumerationFacet();
-            f.setValue(((Enum)constant).name());
-            facets.add(f);
+            Element enumeration = new Element("enumeration", xsd);
+            enumeration.setAttribute(new Attribute("value", ((Enum)constant).name()));
+            restriction.addContent(enumeration);
         }
     }
 

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java Wed Feb 25 17:54:34 2009
@@ -21,25 +21,23 @@
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collection;
-import java.util.HashMap;
-import java.util.Map;
 
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamReader;
 
-import org.w3c.dom.Attr;
-import org.w3c.dom.Node;
-
 import org.apache.cxf.aegis.Context;
 import org.apache.cxf.aegis.DatabindingException;
 import org.apache.cxf.aegis.type.Type;
 import org.apache.cxf.aegis.type.basic.Base64Type;
 import org.apache.cxf.aegis.xml.MessageReader;
 import org.apache.cxf.aegis.xml.MessageWriter;
-import org.apache.cxf.helpers.DOMUtils;
+import org.apache.cxf.common.util.SOAPConstants;
 import org.apache.cxf.message.Attachment;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.constants.Constants;
+import org.jaxen.JaxenException;
+import org.jaxen.jdom.JDOMXPath;
+import org.jdom.Attribute;
+import org.jdom.Element;
+import org.jdom.Namespace;
 
 /**
  * Base class for MtoM types.
@@ -53,6 +51,18 @@
     public static final QName XML_MIME_CONTENT_TYPE = new QName(XML_MIME_NS, "contentType");
     public static final QName XOP_HREF = new QName("href");
     public static final QName XML_MIME_BASE64 = new QName(XML_MIME_NS, "base64Binary", "xmime");
+    private static JDOMXPath importXmimeXpath;
+    
+    static {
+        try {
+            importXmimeXpath = new JDOMXPath("xsd:import[@namespace='"
+                                             + XML_MIME_NS
+                                             + "']");
+            importXmimeXpath.addNamespace(SOAPConstants.XSD_PREFIX, SOAPConstants.XSD);
+        } catch (JaxenException e) {
+            throw new RuntimeException(e);
+        }
+    }
     
     private String expectedContentTypes;
     // the base64 type knows how to deal with just plain base64 here, which is essentially always 
@@ -77,6 +87,10 @@
         }
     }
     
+    public static JDOMXPath getXmimeXpathImport() {
+        return importXmimeXpath;
+    }
+
     /**
      * This is called from base64Type when it recognizes an XOP attachment.
      * @param reader
@@ -194,13 +208,13 @@
     protected abstract byte[] getBytes(Object object);
 
     @Override
-    public void addToSchemaElement(XmlSchemaElement schemaElement) {
+    public void addToSchemaElement(Element schemaElement) {
         if (expectedContentTypes != null) {
-            Map<String, Node> extAttrMap = new HashMap<String, Node>();
-            Attr theAttr = DOMUtils.createDocument().createAttributeNS(XML_MIME_NS, "xmime");
-            theAttr.setNodeValue(expectedContentTypes);
-            extAttrMap.put("xmime", theAttr);
-            schemaElement.addMetaInfo(Constants.MetaDataConstants.EXTERNAL_ATTRIBUTES, extAttrMap);
+            Namespace ns = Namespace.getNamespace("xmime", XML_MIME_NS);
+            Attribute expectedContentTypeAttribute = new Attribute(XML_MIME_ATTR_LOCAL_NAME, 
+                                                                   expectedContentTypes,
+                                                                   ns);
+            schemaElement.setAttribute(expectedContentTypeAttribute);
         }
     }
     

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java Wed Feb 25 17:54:34 2009
@@ -20,6 +20,7 @@
 
 import java.net.MalformedURLException;
 import java.net.URL;
+import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
 
@@ -29,11 +30,10 @@
 import javax.xml.stream.XMLStreamReader;
 import javax.xml.stream.XMLStreamWriter;
 
-import org.w3c.dom.Element;
-
 import org.apache.cxf.aegis.DatabindingException;
-import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.helpers.JavaUtils;
+import org.jdom.Element;
+import org.jdom.Namespace;
 
 /**
  * Namespace utilities.
@@ -62,26 +62,60 @@
                 return "";
             }
             prefix = getUniquePrefix(element);
-            DOMUtils.addNamespacePrefix(element, namespaceURI, prefix);
+            element.addNamespaceDeclaration(Namespace.getNamespace(prefix, namespaceURI));
         }
         return prefix;
     }
 
     public static String getPrefix(Element element, String namespaceURI) {
-        return DOMUtils.getPrefixRecursive(element, namespaceURI);
+        if (element.getNamespaceURI().equals(namespaceURI)) {
+            return element.getNamespacePrefix();
+        }
+
+        List namespaces = element.getAdditionalNamespaces();
+
+        for (Iterator itr = namespaces.iterator(); itr.hasNext();) {
+            Namespace ns = (Namespace)itr.next();
+
+            if (ns.getURI().equals(namespaceURI)) {
+                return ns.getPrefix();
+            }
+        }
+
+        if (element.getParentElement() != null) {
+            return getPrefix(element.getParentElement(), namespaceURI);
+        } else {
+            return null;
+        }
     }
 
     public static void getPrefixes(Element element, String namespaceURI, List<String> prefixes) {
-        DOMUtils.getPrefixesRecursive(element, namespaceURI, prefixes);
+        if (element.getNamespaceURI().equals(namespaceURI)) {
+            prefixes.add(element.getNamespacePrefix());
+        }
+
+        List namespaces = element.getAdditionalNamespaces();
+
+        for (Iterator itr = namespaces.iterator(); itr.hasNext();) {
+            Namespace ns = (Namespace)itr.next();
+
+            if (ns.getURI().equals(namespaceURI)) {
+                prefixes.add(ns.getPrefix());
+            }
+        }
+
+        if (element.getParentElement() != null) {
+            getPrefixes(element.getParentElement(), namespaceURI, prefixes);
+        }
     }
 
-    public static String getUniquePrefix(Element el) {
+    private static String getUniquePrefix(Element el) {
         int n = 1;
 
         while (true) {
             String nsPrefix = "ns" + n;
 
-            if (DOMUtils.getNamespace(el, nsPrefix) == null) {
+            if (el.getNamespace(nsPrefix) == null) {
                 return nsPrefix;
             }
 
@@ -339,15 +373,17 @@
 
         String prefix = value.substring(0, index);
         String localName = value.substring(index + 1);
-        String jNS = DOMUtils.getNamespace(e, prefix);
+        Namespace jNS = e.getNamespace(prefix);
         if (jNS == null) {
             throw new DatabindingException("No namespace was found for prefix: " + prefix);
         }
         
-        if (jNS == null || localName == null) {
+        String ns = jNS.getURI();
+
+        if (ns == null || localName == null) {
             throw new DatabindingException("Invalid QName in mapping: " + value);
         }
 
-        return new QName(jNS, localName, prefix);
+        return new QName(ns, localName, prefix);
     }
 }

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMNamespaceContext.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMNamespaceContext.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMNamespaceContext.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMNamespaceContext.java Wed Feb 25 17:54:34 2009
@@ -24,6 +24,7 @@
 
 import javax.xml.namespace.NamespaceContext;
 
+import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.jdom.Element;
 import org.jdom.Namespace;
 
@@ -40,12 +41,12 @@
     }
 
     public String getPrefix(String uri) {
-        return rawGetPrefix(element, uri);
+        return NamespaceHelper.getPrefix(element, uri);
     }
 
     public Iterator<String> getPrefixes(String uri) {
         List<String> prefixes = new ArrayList<String>();
-        rawGetPrefixes(element, uri, prefixes);
+        NamespaceHelper.getPrefixes(element, uri, prefixes);
         return prefixes.iterator();
     }
 
@@ -56,46 +57,4 @@
     public void setElement(Element element) {
         this.element = element;
     }
-    
-    public static String rawGetPrefix(Element element, String namespaceURI) {
-        if (element.getNamespaceURI().equals(namespaceURI)) {
-            return element.getNamespacePrefix();
-        }
-
-        List namespaces = element.getAdditionalNamespaces();
-
-        for (Iterator itr = namespaces.iterator(); itr.hasNext();) {
-            Namespace ns = (Namespace)itr.next();
-
-            if (ns.getURI().equals(namespaceURI)) {
-                return ns.getPrefix();
-            }
-        }
-
-        if (element.getParentElement() != null) {
-            return rawGetPrefix(element.getParentElement(), namespaceURI);
-        } else {
-            return null;
-        }
-    }
-    
-    static void rawGetPrefixes(Element element, String namespaceURI, List<String> prefixes) {
-        if (element.getNamespaceURI().equals(namespaceURI)) {
-            prefixes.add(element.getNamespacePrefix());
-        }
-
-        List namespaces = element.getAdditionalNamespaces();
-
-        for (Iterator itr = namespaces.iterator(); itr.hasNext();) {
-            Namespace ns = (Namespace)itr.next();
-
-            if (ns.getURI().equals(namespaceURI)) {
-                prefixes.add(ns.getPrefix());
-            }
-        }
-
-        if (element.getParentElement() != null) {
-            rawGetPrefixes(element.getParentElement(), namespaceURI, prefixes);
-        }
-    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMStreamWriter.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMStreamWriter.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMStreamWriter.java Wed Feb 25 17:54:34 2009
@@ -26,6 +26,7 @@
 import javax.xml.stream.XMLStreamException;
 import javax.xml.stream.XMLStreamWriter;
 
+import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.jdom.Attribute;
 import org.jdom.CDATA;
 import org.jdom.Comment;
@@ -183,7 +184,7 @@
     }
 
     public String getPrefix(String uri) throws XMLStreamException {
-        return JDOMNamespaceContext.rawGetPrefix(currentNode, uri);
+        return NamespaceHelper.getPrefix(currentNode, uri);
     }
 
     public void setPrefix(String arg0, String arg1) throws XMLStreamException {

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/jdom/JDOMWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/jdom/JDOMWriter.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/jdom/JDOMWriter.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/jdom/JDOMWriter.java Wed Feb 25 17:54:34 2009
@@ -21,7 +21,7 @@
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamWriter;
 
-import org.apache.cxf.aegis.util.stax.JDOMNamespaceContext;
+import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.apache.cxf.aegis.xml.AbstractMessageWriter;
 import org.apache.cxf.aegis.xml.MessageWriter;
 import org.jdom.Attribute;
@@ -44,7 +44,7 @@
     }
 
     public void writeValue(Object value, String ns, String attr) {
-        String prefix = getUniquePrefix(element, ns);
+        String prefix = NamespaceHelper.getUniquePrefix(element, ns);
 
         element.setAttribute(new Attribute(attr, value.toString(), Namespace.getNamespace(prefix, ns)));
     }
@@ -54,7 +54,7 @@
     }
 
     public MessageWriter getElementWriter(String name, String namespace) {
-        String prefix = getUniquePrefix(element, namespace);
+        String prefix = NamespaceHelper.getUniquePrefix(element, namespace);
 
         Element child = new Element(name, Namespace.getNamespace(prefix, namespace));
         element.addContent(child);
@@ -67,17 +67,17 @@
     }
 
     public String getPrefixForNamespace(String namespace) {
-        return getUniquePrefix(element, namespace);
+        return NamespaceHelper.getUniquePrefix(element, namespace);
     }
 
     public XMLStreamWriter getXMLStreamWriter() {
-        throw new UnsupportedOperationException("Stream writing not supported from a W3CDOMWriter.");
+        throw new UnsupportedOperationException("Stream writing not supported from a JDOMWriter.");
     }
 
     public String getPrefixForNamespace(String namespace, String hint) {
         // todo: this goes for the option of ignoring the hint - we should
         // probably at least attempt to honour it
-        return getUniquePrefix(element, namespace);
+        return NamespaceHelper.getUniquePrefix(element, namespace);
     }
 
     public MessageWriter getAttributeWriter(String name) {
@@ -89,7 +89,7 @@
     public MessageWriter getAttributeWriter(String name, String namespace) {
         Attribute att;
         if (namespace != null && namespace.length() > 0) {
-            String prefix = getUniquePrefix(element, namespace);
+            String prefix = NamespaceHelper.getUniquePrefix(element, namespace);
             att = new Attribute(name, "", Namespace.getNamespace(prefix, namespace));
         } else {
             att = new Attribute(name, "");
@@ -105,32 +105,4 @@
 
     public void close() {
     }
-    
-    private static String getUniquePrefix(Element el) {
-        int n = 1;
-
-        while (true) {
-            String nsPrefix = "ns" + n;
-
-            if (el.getNamespace(nsPrefix) == null) {
-                return nsPrefix;
-            }
-
-            n++;
-        }
-    }
-    
-    private static String getUniquePrefix(Element element, String namespaceURI) {
-        String prefix = JDOMNamespaceContext.rawGetPrefix(element, namespaceURI);
-
-        // it is OK to have both namespace URI and prefix be empty. 
-        if (prefix == null) {
-            if ("".equals(namespaceURI)) {
-                return "";
-            }
-            prefix = getUniquePrefix(element);
-            element.addNamespaceDeclaration(Namespace.getNamespace(prefix, namespaceURI));
-        }
-        return prefix;
-    }
 }

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/stax/ElementWriter.java Wed Feb 25 17:54:34 2009
@@ -162,7 +162,6 @@
     public void close() {
         try {
             writer.writeEndElement();
-            writer.flush();
         } catch (XMLStreamException e) {
             throw new DatabindingException("Error writing document.", e);
         }
@@ -208,18 +207,13 @@
     public String getPrefixForNamespace(String ns, String hint) {
         try {
             String pfx = writer.getPrefix(ns);
-            String contextPfx = writer.getNamespaceContext().getPrefix(ns);
 
             if (pfx == null) {
                 String ns2 = writer.getNamespaceContext().getNamespaceURI(hint);
-                // if the hint is "" (the default) and the context does 
-                if (ns2 == null && !"".equals(hint)) { 
+                if (ns2 == null) {
                     pfx = hint;
-                } else if (ns.equals(ns2)) {
-                    // just because it's in the context, doesn't mean it has been written.
-                    pfx = hint;
-                } else if (contextPfx != null) {
-                    pfx = contextPfx;
+                } else if (ns2.equals(ns)) {
+                    return pfx;
                 } else {
                     pfx = NamespaceHelper.getUniquePrefix(writer);
                 }

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/AbstractAegisTest.java Wed Feb 25 17:54:34 2009
@@ -26,40 +26,27 @@
 import javax.wsdl.WSDLException;
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLWriter;
-import javax.xml.namespace.NamespaceContext;
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
-import javax.xml.transform.dom.DOMResult;
 
 import org.w3c.dom.Document;
-import org.w3c.dom.Element;
 import org.w3c.dom.Node;
+import org.w3c.dom.NodeList;
 
 import org.apache.cxf.Bus;
 import org.apache.cxf.BusException;
 import org.apache.cxf.BusFactory;
 import org.apache.cxf.aegis.databinding.AegisDatabinding;
-import org.apache.cxf.aegis.type.Type;
-import org.apache.cxf.aegis.xml.stax.ElementWriter;
 import org.apache.cxf.binding.BindingFactoryManager;
 import org.apache.cxf.binding.soap.SoapBindingConstants;
 import org.apache.cxf.binding.soap.SoapBindingFactory;
 import org.apache.cxf.binding.soap.SoapTransportFactory;
 import org.apache.cxf.bus.extension.ExtensionManagerBus;
-import org.apache.cxf.common.WSDLConstants;
 import org.apache.cxf.common.util.SOAPConstants;
-import org.apache.cxf.common.xmlschema.XmlSchemaConstants;
 import org.apache.cxf.endpoint.Server;
 import org.apache.cxf.endpoint.ServerRegistry;
 import org.apache.cxf.frontend.AbstractWSDLBasedEndpointFactory;
 import org.apache.cxf.frontend.ServerFactoryBean;
-import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.helpers.MapNamespaceContext;
-import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
-import org.apache.cxf.jaxws.support.JaxWsServiceFactoryBean;
 import org.apache.cxf.service.Service;
-import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.test.AbstractCXFTest;
 import org.apache.cxf.transport.ConduitInitiatorManager;
 import org.apache.cxf.transport.DestinationFactoryManager;
@@ -68,13 +55,13 @@
 import org.apache.cxf.wsdl11.ServiceWSDLBuilder;
 import org.apache.cxf.wsdl11.WSDLDefinitionBuilder;
 import org.apache.cxf.wsdl11.WSDLManagerImpl;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.utils.NamespaceMap;
+import org.jdom.Element;
+import org.jdom.output.DOMOutputter;
 import org.junit.Before;
 
 public abstract class AbstractAegisTest extends AbstractCXFTest {
     protected LocalTransportFactory localTransport;
-    private boolean enableJDOM;
+
 
     @Before
     public void setUp() throws Exception {
@@ -93,7 +80,7 @@
         dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/", soapDF);
         dfm.registerDestinationFactory(SoapBindingConstants.SOAP11_BINDING_ID, soapDF);
         dfm.registerDestinationFactory("http://cxf.apache.org/transports/local", soapDF);
-
+        
         localTransport = new LocalTransportFactory();
         dfm.registerDestinationFactory("http://schemas.xmlsoap.org/soap/http", localTransport);
         dfm.registerDestinationFactory("http://schemas.xmlsoap.org/wsdl/soap/http", localTransport);
@@ -105,13 +92,15 @@
         extension.registerConduitInitiator("http://schemas.xmlsoap.org/wsdl/soap/", localTransport);
         extension.registerConduitInitiator("http://schemas.xmlsoap.org/soap/http", localTransport);
         extension.registerConduitInitiator(SoapBindingConstants.SOAP11_BINDING_ID, localTransport);
-
+        
         bus.setExtension(new WSDLManagerImpl(), WSDLManager.class);
+        
 
         addNamespace("wsdl", SOAPConstants.WSDL11_NS);
         addNamespace("wsdlsoap", SOAPConstants.WSDL11_SOAP_NS);
         addNamespace("xsd", SOAPConstants.XSD);
 
+
     }
 
     @Override
@@ -120,108 +109,87 @@
         BusFactory.setDefaultBus(bus);
         return bus;
     }
-
+    
     protected Node invoke(String service, String message) throws Exception {
         return invoke("local://" + service, LocalTransportFactory.TRANSPORT_ID, message);
     }
-
+    
     public Server createService(Class serviceClass, QName name) {
         return createService(serviceClass, null, name);
     }
-
+    
     public Server createService(Class serviceClass, Object serviceBean, QName name) {
         return createService(serviceClass, serviceBean, serviceClass.getSimpleName(), name);
     }
-
+    
     protected Server createService(Class serviceClass, QName name, AegisDatabinding binding) {
         return createService(serviceClass, serviceClass.getSimpleName(), name, binding);
     }
 
-    protected Server createService(Class serviceClass, String address, QName name, AegisDatabinding binding) {
+    protected Server createService(Class serviceClass, 
+                                   String address, QName name, 
+                                    AegisDatabinding binding) {
         ServerFactoryBean sf = createServiceFactory(serviceClass, null, address, name, binding);
         return sf.create();
     }
-
+    
     protected Server createService(Class serviceClass, String address) {
         ServerFactoryBean sf = createServiceFactory(serviceClass, null, address, null, null);
         return sf.create();
     }
-
+    
     protected Server createService(Class serviceClass) {
-        ServerFactoryBean sf = createServiceFactory(serviceClass, null, serviceClass.getSimpleName(), null,
-                                                    null);
+        ServerFactoryBean sf = createServiceFactory(serviceClass, null, 
+                                                    serviceClass.getSimpleName(), null, null);
         return sf.create();
     }
-
-    protected Server createJaxwsService(Class serviceClass, Object serviceBean, String address, QName name) {
-        if (address == null) {
-            address = serviceClass.getSimpleName();
-        }
-        JaxWsServiceFactoryBean sf = new JaxWsServiceFactoryBean();
-        sf.setDataBinding(new AegisDatabinding());
-        JaxWsServerFactoryBean serverFactoryBean = new JaxWsServerFactoryBean();
-        serverFactoryBean.setServiceClass(serviceClass);
-        
-        if (serviceBean != null) {
-            serverFactoryBean.setServiceBean(serviceBean);
-        }
-
-        serverFactoryBean.setAddress("local://" + address);
-            
-        serverFactoryBean.setServiceFactory(sf);
-        if (name != null) {
-            serverFactoryBean.setEndpointName(name);
-        }
-        return serverFactoryBean.create();
-    }
-
-    public Server createService(Class serviceClass, Object serviceBean, String address, QName name) {
+    
+    public Server createService(Class serviceClass,
+                                Object serviceBean, 
+                                String address,
+                                QName name) {
         ServerFactoryBean sf = createServiceFactory(serviceClass, serviceBean, address, name, null);
         return sf.create();
     }
-
-    public Server createService(Class serviceClass, Object serviceBean, String address,
+    
+    public Server createService(Class serviceClass,
+                                Object serviceBean, 
+                                String address,
                                 AegisDatabinding binding) {
         ServerFactoryBean sf = createServiceFactory(serviceClass, serviceBean, address, null, binding);
         return sf.create();
     }
 
-    protected ServerFactoryBean createServiceFactory(Class serviceClass, Object serviceBean, String address,
-                                                     QName name, AegisDatabinding binding) {
+    protected ServerFactoryBean createServiceFactory(Class serviceClass, 
+                                                     Object serviceBean, 
+                                                     String address, 
+                                                     QName name,
+                                                     AegisDatabinding binding) {
         ServerFactoryBean sf = new ServerFactoryBean();
         sf.setServiceClass(serviceClass);
         if (serviceBean != null) {
             sf.setServiceBean(serviceBean);
-        }
+        }    
         sf.getServiceFactory().setServiceName(name);
         sf.setAddress("local://" + address);
         setupAegis(sf, binding);
         return sf;
     }
-
-    protected void setupAegis(AbstractWSDLBasedEndpointFactory sf) {
+    protected void setupAegis(AbstractWSDLBasedEndpointFactory sf) { 
         setupAegis(sf, null);
     }
-
     @SuppressWarnings("deprecation")
     protected void setupAegis(AbstractWSDLBasedEndpointFactory sf, AegisDatabinding binding) {
         if (binding == null) {
-            AegisContext context = new AegisContext();
-            if (enableJDOM) {
-                context.setEnableJDOMMappings(true);
-            }
             binding = new AegisDatabinding();
-            if (enableJDOM) { // this preserves pre-2.1 behavior.
-                binding.setAegisContext(context);
-            }
         }
-        sf.getServiceFactory().getServiceConfigurations()
-            .add(0, new org.apache.cxf.aegis.databinding.AegisServiceConfiguration());
+        sf.getServiceFactory().getServiceConfigurations().add(0, 
+            new org.apache.cxf.aegis.databinding.AegisServiceConfiguration());
         sf.getServiceFactory().setDataBinding(binding);
     }
 
     protected Collection<Document> getWSDLDocuments(String string) throws WSDLException {
-        WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
+        WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();        
 
         Collection<Document> docs = new ArrayList<Document>();
         Definition definition = getWSDLDefinition(string);
@@ -229,7 +197,7 @@
             return null;
         }
         docs.add(writer.getDocument(definition));
-
+        
         for (Import wsdlImport : WSDLDefinitionBuilder.getImports(definition)) {
             docs.add(writer.getDocument(wsdlImport.getDefinition()));
         }
@@ -246,9 +214,26 @@
             }
         }
         return null;
-
+        
+    }
+    
+    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 NodeList assertValid(String xpath, Element element) throws Exception {
+        org.w3c.dom.Document doc = new DOMOutputter().output(element.getDocument());
+        
+        return 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) {
@@ -257,76 +242,10 @@
         WSDLWriter writer = WSDLFactory.newInstance().newWSDLWriter();
         return writer.getDocument(definition);
     }
-
+    
     protected Context getContext() {
         AegisContext globalContext = new AegisContext();
         globalContext.initialize();
         return new Context(globalContext);
     }
-    
-    protected XmlSchema newXmlSchema(String targetNamespace) {
-        XmlSchema s = new XmlSchema();
-        s.setTargetNamespace(targetNamespace);
-        NamespaceMap xmlsNamespaceMap = new NamespaceMap();
-        s.setNamespaceContext(xmlsNamespaceMap);
-
-        // tns: is conventional, and besides we have unit tests that are hardcoded to it.
-        xmlsNamespaceMap.add(WSDLConstants.CONVENTIONAL_TNS_PREFIX, targetNamespace);
-        
-        // ditto for xsd: instead of just namespace= for the schema schema.
-        xmlsNamespaceMap.add("xsd", XmlSchemaConstants.XSD_NAMESPACE_URI);
-        return s;
-    }
-    
-    protected Element createElement(String namespace, String name) {
-        return createElement(namespace, name, null);
-    }
-
-    protected Element createElement(String namespace, String name, String namespacePrefix) {
-        Document doc = DOMUtils.createDocument();
-
-        Element element = doc.createElementNS(namespace, name);
-        if (namespacePrefix != null) {
-            element.setPrefix(namespacePrefix);
-            DOMUtils.addNamespacePrefix(element, namespace, namespacePrefix);
-        }
-
-        doc.appendChild(element);
-        return element;
-    }
-    
-    protected ElementWriter getElementWriter(Element element) {
-        return getElementWriter(element, new MapNamespaceContext());
-    }
-
-    protected ElementWriter getElementWriter(Element element, NamespaceContext namespaceContext) {
-        XMLStreamWriter writer = StaxUtils.createXMLStreamWriter(new DOMResult(element));
-        try {
-            writer.setNamespaceContext(namespaceContext);
-        } catch (XMLStreamException e) {
-            throw new RuntimeException(e);
-        }
-        return new ElementWriter(writer);
-    }
-
-    protected Element writeObjectToElement(Type type, Object bean) {
-        return writeObjectToElement(type, bean, getContext());
-    }
-
-    protected Element writeObjectToElement(Type type, Object bean, Context context) {
-        Element element = createElement("urn:Bean", "root", "b");
-        ElementWriter writer = getElementWriter(element, new MapNamespaceContext());
-        type.writeObject(bean, writer, getContext());
-        writer.close();
-        return element;
-    }
-
-    protected boolean isEnableJDOM() {
-        return enableJDOM;
-    }
-
-    protected void setEnableJDOM(boolean enableJDOM) {
-        this.enableJDOM = enableJDOM;
-    }
-    
 }

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomMappingTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomMappingTest.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomMappingTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomMappingTest.java Wed Feb 25 17:54:34 2009
@@ -27,8 +27,7 @@
 import org.apache.cxf.aegis.type.TypeMapping;
 import org.apache.cxf.aegis.type.basic.BeanType;
 import org.apache.cxf.aegis.type.basic.BeanTypeInfo;
-import org.apache.ws.commons.schema.XmlSchema;
-
+import org.jdom.Element;
 import org.junit.Test;
 
 /**
@@ -45,9 +44,8 @@
         TypeMapping mapping = context.getTypeMapping();
         // we are replacing the default mapping.
         mapping.register(beanType);
-        XmlSchema schema = newXmlSchema("http://util.java");
-        beanType.writeSchema(schema);
-        // well, test?
+        Element root = new Element("dummySchema");
+        beanType.writeSchema(root);
     }
 
 }

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/ParameterMappingTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/ParameterMappingTest.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/ParameterMappingTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/ParameterMappingTest.java Wed Feb 25 17:54:34 2009
@@ -40,7 +40,6 @@
     @Before 
     public void setUp() throws Exception {
         super.setUp();
-        setEnableJDOM(true); // there are JDOM types in here.
         createService(AddNumbers.class, "AddNumbers", null);
         createService(ArrayService.class, "ArrayService", null);
     }
@@ -71,7 +70,7 @@
         WSDLFactory.newInstance().newWSDLWriter().writeWSDL(def, sink);
         assertXPathEquals("/wsdl:definitions/wsdl:types/"
                     + "xsd:schema[@targetNamespace= 'http://services.aegis.cxf.apache.org']"
-                    + "/xsd:complexType[@name='ArrayOfString-2-50']" 
+                    + "/xsd:complexType[@name='ArrayOfString-50-2']" 
                     + "/xsd:sequence" 
                     + "/xsd:element[@name='string']/@minOccurs", "2", doc);
     }

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/integration/WrappedTest.java Wed Feb 25 17:54:34 2009
@@ -20,9 +20,7 @@
 
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Document;
 import org.w3c.dom.Node;
-import org.w3c.dom.NodeList;
 
 import org.apache.cxf.aegis.AbstractAegisTest;
 import org.apache.cxf.aegis.services.ArrayService;
@@ -41,12 +39,11 @@
     @Before 
     public void setUp() throws Exception {
         super.setUp();
-        setEnableJDOM(true);
         arrayService = new ArrayService();
         createService(BeanService.class, "BeanService");
         createService(ArrayService.class, arrayService, "Array", new QName("urn:Array", "Array"));
     }
-    
+
     @Test
     public void testBeanService() throws Exception {
         Node response = invoke("BeanService", "bean11.xml");
@@ -58,13 +55,6 @@
         assertValid("//sb:getSimpleBeanResponse/sb:return/beanz:howdy[text()=\"howdy\"]", response);
         assertValid("//sb:getSimpleBeanResponse/sb:return/beanz:bleh[text()=\"bleh\"]", response);
     }
-    
-    @Test
-    public void testArrayWsdl() throws Exception {
-        Document doc = getWSDLDocument("Array");
-        NodeList stuff = assertValid("//xsd:complexType[@name='ArrayOfString-2-50']", doc);
-        assertEquals(1, stuff.getLength());
-    }
 
     @Test
     public void testBeanServiceWSDL() throws Exception {
@@ -107,8 +97,7 @@
                         + "[@type=\"xsd:string\"]",
                     doc);
     }
-
-    @org.junit.Ignore // uses Jaxen.
+    
     @Test 
     public void testSubmitJDOMArray() throws Exception {
         
@@ -144,4 +133,66 @@
         assertEquals("after items", arrayService.getAfterValue());
     }
 
+    // public void testGetArray()
+    // throws Exception
+    // {
+    // Document response = invokeService("Array",
+    // "/org/codehaus/xfire/message/wrapped/GetStringArray11.xml");
+    //
+    // addNamespace("a", "urn:Array");
+    // addNamespace("sb", "http://test.java.xfire.codehaus.org");
+    // assertValid("//a:getStringArrayResponse", response);
+    // assertValid("//a:getStringArrayResponse/a:out/a:string", response);
+    // }
+    //    
+    // public void testArrayService()
+    // throws Exception
+    // {
+    // Document response = invokeService("Array",
+    // "/org/codehaus/xfire/message/wrapped/SubmitStringArray11.xml");
+    //
+    // addNamespace("a", "urn:Array");
+    // addNamespace("sb", "http://test.java.xfire.codehaus.org");
+    // assertValid("//a:SubmitStringArrayResponse", response);
+    // assertValid("//a:SubmitStringArrayResponse/a:out[text()='true']",
+    // response);
+    // }
+    //
+    // public void testArrayServiceNoWhitespace()
+    // throws Exception
+    // {
+    // Document response = invokeService("Array",
+    // "/org/codehaus/xfire/message/wrapped/SubmitStringArray11NoWS.xml");
+    //
+    // addNamespace("a", "urn:Array");
+    // addNamespace("sb", "http://test.java.xfire.codehaus.org");
+    // assertValid("//a:SubmitStringArrayResponse", response);
+    // assertValid("//a:SubmitStringArrayResponse/a:out[text()='true']",
+    // response);
+    // }
+    //
+    // public void testArrayServiceWSDL()
+    // throws Exception
+    // {
+    // Document doc = getWSDLDocument("Array");
+    //
+    // addNamespace("wsdl", WSDLWriter.WSDL11_NS);
+    // addNamespace("wsdlsoap", WSDLWriter.WSDL11_SOAP_NS);
+    // addNamespace("xsd", SoapConstants.XSD);
+    //
+    // assertValid("/wsdl:definitions/wsdl:types", doc);
+    // assertValid("/wsdl:definitions/wsdl:types/xsd:schema", doc);
+    // assertValid("/wsdl:definitions/wsdl:types/xsd:schema[@targetNamespace='urn:Array']",
+    // doc);
+    // assertValid("//xsd:schema[@targetNamespace='urn:Array']/xsd:element[@name='SubmitBeanArray']",
+    // doc);
+    // assertValid(
+    // "//xsd:element[@name='SubmitStringArray']/xsd:complexType/xsd:sequence/xsd:element"
+    //    + "[@name='array'][@type='tns:ArrayOfString']",
+    // doc);
+    // assertValid(
+    // "//xsd:element[@name='SubmitBeanArray']/xsd:complexType/xsd:sequence/xsd:element"
+    //  + "[@name='array'][@type='ns1:ArrayOfSimpleBean']",
+    // doc);
+    // }
 }

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.aegis.xml
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.aegis.xml?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.aegis.xml (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/services/ArrayService.aegis.xml Wed Feb 25 17:54:34 2009
@@ -20,7 +20,7 @@
 <mappings>
     <mapping name="ArrayService">
         <method name="submitStringArray">
-            <parameter index="0" minOccurs='2' maxOccurs='50' nillable='false' />
+            <parameter index="0" minOccurs='2' maxOccurs='50' />
         </method>
     </mapping>
 </mappings>

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/BeanTest.java Wed Feb 25 17:54:34 2009
@@ -24,10 +24,9 @@
 import java.util.Date;
 
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamReader;
 
-import org.w3c.dom.Document;
-import org.w3c.dom.Element;
+import org.w3c.dom.Attr;
+import org.w3c.dom.NodeList;
 
 import org.apache.cxf.aegis.AbstractAegisTest;
 import org.apache.cxf.aegis.AegisContext;
@@ -36,18 +35,14 @@
 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.util.jdom.StaxBuilder;
+import org.apache.cxf.aegis.xml.jdom.JDOMReader;
+import org.apache.cxf.aegis.xml.jdom.JDOMWriter;
 import org.apache.cxf.aegis.xml.stax.ElementReader;
 import org.apache.cxf.aegis.xml.stax.ElementWriter;
 import org.apache.cxf.common.util.SOAPConstants;
-import org.apache.cxf.common.xmlschema.XmlSchemaConstants;
-import org.apache.cxf.helpers.DOMUtils;
-import org.apache.cxf.staxutils.StaxUtils;
-import org.apache.ws.commons.schema.XmlSchema;
-import org.apache.ws.commons.schema.XmlSchemaAttribute;
-import org.apache.ws.commons.schema.XmlSchemaComplexType;
-import org.apache.ws.commons.schema.XmlSchemaElement;
-import org.apache.ws.commons.schema.XmlSchemaObject;
-import org.apache.ws.commons.schema.XmlSchemaSequence;
+import org.jdom.Document;
+import org.jdom.Element;
 import org.junit.Test;
 
 public class BeanTest extends AbstractAegisTest {
@@ -100,12 +95,14 @@
         bean.setBleh("bleh");
 
         // Test writing
-        Element element = writeObjectToElement(type, bean, getContext());
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), getContext());
 
         assertValid("/b:root/b:bleh[text()='bleh']", element);
         assertValid("/b:root/b:howdy[text()='howdy']", element);
     }
-
+    
     @Test
     public void testBeanWithXsiType() throws Exception {
         BeanType type = new BeanType();
@@ -124,7 +121,10 @@
 
         reader.getXMLStreamReader().close();
 
-        Element element = writeObjectToElement(type, bean, getContext());
+        // Test writing
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), getContext());
 
         assertValid("/b:root/b:bleh[text()='bleh']", element);
         assertValid("/b:root/b:howdy[text()='howdy']", element);
@@ -154,12 +154,15 @@
 
         reader.getXMLStreamReader().close();
 
-        Element element = writeObjectToElement(type, bean, getContext());
+        // Test writing
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), getContext());
 
         assertInvalid("/b:root/b:bleh", element);
         assertValid("/b:root/b:howdycustom[text()='howdy']", element);
     }
-    
+
     @Test
     public void testAttributeMap() throws Exception {
         BeanTypeInfo info = new BeanTypeInfo(SimpleBean.class, "urn:Bean");
@@ -181,30 +184,23 @@
         reader.getXMLStreamReader().close();
 
         // Test writing
-        Element element = writeObjectToElement(type, bean, getContext());
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), getContext());
+
         assertValid("/b:root[@b:bleh='bleh']", element);
         assertValid("/b:root[@b:howdy='howdy']", element);
-        
-        XmlSchema schema = newXmlSchema("urn:Bean");
+
+        Element types = new Element("types", "xsd", SOAPConstants.XSD);
+        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
         type.writeSchema(schema);
-        
-        XmlSchemaComplexType stype = (XmlSchemaComplexType)schema.getTypeByName("bean");
-        boolean howdy = false;
-        boolean bleh = false;
-        for (int x = 0; x < stype.getAttributes().getCount(); x++) {
-            XmlSchemaObject o = stype.getAttributes().getItem(x);
-            if (o instanceof XmlSchemaAttribute) {
-                XmlSchemaAttribute a = (XmlSchemaAttribute)o;
-                if ("howdy".equals(a.getName())) {
-                    howdy = true;
-                }
-                if ("bleh".equals(a.getName())) {
-                    bleh = true;
-                }
-            }
-        }
-        assertTrue(howdy);
-        assertTrue(bleh);
+
+        assertValid("//xsd:complexType[@name='bean']/xsd:attribute[@name='howdy']", schema);
+        assertValid("//xsd:complexType[@name='bean']/xsd:attribute[@name='bleh']", schema);
     }
 
     @Test
@@ -237,8 +233,9 @@
 
         bos.close();
         
-        Document doc = DOMUtils.readXml(new ByteArrayInputStream(bos.toByteArray()));
-        Element element = doc.getDocumentElement();
+        StaxBuilder builder = new StaxBuilder();
+        Document doc = builder.build(new ByteArrayInputStream(bos.toByteArray()));
+        Element element = doc.getRootElement();
 
         addNamespace("b2", "urn:Bean2");
         assertValid("/b:root[@b2:bleh='bleh']", element);
@@ -260,42 +257,23 @@
         SimpleBean bean = new SimpleBean();
 
         // Test writing
-        
-        Element element = writeObjectToElement(type, bean, getContext());
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), getContext());
 
         assertInvalid("/b:root[@b:howdy]", element);
         assertValid("/b:root/b:bleh[@xsi:nil='true']", element);
 
-        XmlSchema schema = newXmlSchema("urn:Bean");
+        Element types = new Element("types", "xsd", SOAPConstants.XSD);
+        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
         type.writeSchema(schema);
-        
-        XmlSchemaComplexType stype = (XmlSchemaComplexType)schema.getTypeByName("bean");
-        XmlSchemaSequence seq = (XmlSchemaSequence) stype.getParticle();
-        boolean howdy = false;
-        boolean bleh = false;
-
-        for (int x = 0; x < seq.getItems().getCount(); x++) {
-            XmlSchemaObject o = seq.getItems().getItem(x);
-            if (o instanceof XmlSchemaElement) {
-                XmlSchemaElement a = (XmlSchemaElement)o;
-                if ("bleh".equals(a.getName())) {
-                    bleh = true;
-                }
-            }
-        }
-
-        for (int x = 0; x < stype.getAttributes().getCount(); x++) {
-            XmlSchemaObject o = stype.getAttributes().getItem(x);
-            if (o instanceof XmlSchemaAttribute) {
-                XmlSchemaAttribute a = (XmlSchemaAttribute)o;
-                if ("howdy".equals(a.getName())) {
-                    howdy = true;
-                }
-            }
-        }
 
-        assertTrue(howdy);
-        assertTrue(bleh);
+        assertValid("//xsd:complexType[@name='bean']/xsd:attribute[@name='howdy']", schema);
+        assertValid("//xsd:complexType[@name='bean']/xsd:sequence/xsd:element[@name='bleh']", schema);
     }
     
     @Test
@@ -308,30 +286,22 @@
         type.setTypeMapping(mapping);
         type.setSchemaType(new QName("urn:Bean", "bean"));
 
-        XmlSchema schema = newXmlSchema("urn:Bean");
+        Element types = new Element("types", "xsd", SOAPConstants.XSD);
+        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
         type.writeSchema(schema);
-        
-        XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("bean");
-        XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
-        boolean int1ok = false;
-        boolean int2ok = false;
-        for (int x = 0; x < seq.getItems().getCount(); x++) {
-            XmlSchemaObject o = seq.getItems().getItem(x);
-            if (o instanceof XmlSchemaElement) {
-                XmlSchemaElement oe = (XmlSchemaElement) o;
-                if ("int1".equals(oe.getName())) {
-                    int1ok = true;
-                    assertTrue(oe.isNillable());
-                    assertEquals(0, oe.getMinOccurs());
-                } else if ("int2".equals(oe.getName())) {
-                    int2ok = true;
-                    assertEquals(0, oe.getMinOccurs());
-                    assertFalse(oe.isNillable());
-                }
-            }
-        }
-        assertTrue(int1ok);
-        assertTrue(int2ok);
+
+        assertValid("//xsd:complexType[@name='bean']/xsd:sequence/xsd:element[@name='int1']"
+                    + "[@nillable='true'][@minOccurs='0']",
+                    schema);
+        assertValid("//xsd:complexType[@name='bean']/xsd:sequence/xsd:element[@name='int2'][@minOccurs='0']",
+                    schema);
+        assertInvalid("//xsd:complexType[@name='bean']/xsd:sequence"
+                        + "/xsd:element[@name='int2'][@nillable='true']",
+                      schema);
     }
     @Test
     public void testNillableIntMinOccurs1() throws Exception {
@@ -348,24 +318,20 @@
         type.setTypeClass(IntBean.class);
         type.setTypeMapping(mapping);
 
-        XmlSchema schema = newXmlSchema("urn:Bean");
+        Element types = new Element("types", "xsd", SOAPConstants.XSD);
+        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
         type.writeSchema(schema);
-        
-        XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("IntBean");
-        XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
-        boolean int1ok = false;
-        for (int x = 0; x < seq.getItems().getCount(); x++) {
-            XmlSchemaObject o = seq.getItems().getItem(x);
-            if (o instanceof XmlSchemaElement) {
-                XmlSchemaElement oe = (XmlSchemaElement) o;
-                if ("int1".equals(oe.getName())) {
-                    int1ok = true;
-                    assertFalse(oe.isNillable());
-                    assertEquals(1, oe.getMinOccurs());
-                } 
-            }
-        }
-        assertTrue(int1ok);
+
+        assertValid("//xsd:complexType[@name='IntBean']/xsd:sequence/xsd:element[@name='int1']", schema);
+        assertInvalid(
+                      "//xsd:complexType[@name='IntBean']/xsd:sequence/xsd:element[@name='int1'][@minOccurs]",
+                      schema);
+        assertInvalid("//xsd:complexType[@name='IntBean']/xsd:sequence/xsd:element[@name='int1'][@nillable]",
+                      schema);
     }
     
     @Test
@@ -377,28 +343,25 @@
         BeanType type = (BeanType)mapping.getTypeCreator().createType(SimpleBean.class);
         type.setTypeClass(SimpleBean.class);
         type.setTypeMapping(mapping);
-        
-        XmlSchema schema = newXmlSchema("urn:Bean");
+
+        Element types = new Element("types", "xsd", SOAPConstants.XSD);
+        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
         type.writeSchema(schema);
-        
-        XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("SimpleBean");
-        XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
-        boolean charok = false;
-
-        for (int x = 0; x < seq.getItems().getCount(); x++) {
-            XmlSchemaObject o = seq.getItems().getItem(x);
-            if (o instanceof XmlSchemaElement) {
-                XmlSchemaElement oe = (XmlSchemaElement) o;
-                if ("character".equals(oe.getName())) {
-                    charok = true;
-                    assertNotNull(oe.getSchemaTypeName());
-                    assertTrue(oe.isNillable());
-                    assertEquals(CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME, 
-                                 oe.getSchemaTypeName());
-                }
-            }
-        }
-        assertTrue(charok);
+
+        NodeList typeAttrNode = 
+            assertValid("//xsd:complexType[@name='SimpleBean']/xsd:sequence/xsd:element[@name='character']"
+                       + "/@type", 
+                       schema); 
+        assertEquals(1, typeAttrNode.getLength());
+        Attr typeAttr = (Attr)typeAttrNode.item(0);
+        String typeQnameString = typeAttr.getValue();
+        String[] pieces = typeQnameString.split(":");
+        assertEquals(CharacterAsStringType.CHARACTER_AS_STRING_TYPE_QNAME.getLocalPart(),
+                     pieces[1]);
     }
     
     @Test
@@ -411,36 +374,42 @@
         type.setTypeClass(SimpleBean.class);
         type.setTypeMapping(mapping);
 
-        XmlSchema schema = newXmlSchema("urn:Bean");
+        Element types = new Element("types", "xsd", SOAPConstants.XSD);
+        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
+        types.addContent(schema);
+
+        new Document(types);
+
         type.writeSchema(schema);
+
+        NodeList typeAttrNode = 
+            assertValid("//xsd:complexType[@name='SimpleBean']/xsd:sequence/xsd:element[@name='littleByte']"
+                       + "/@type", 
+                       schema); 
+        assertEquals(1, typeAttrNode.getLength());
+        Attr typeAttr = (Attr)typeAttrNode.item(0);
+        String typeQnameString = typeAttr.getValue();
+        String[] pieces = typeQnameString.split(":");
+        assertEquals("xsd", pieces[0]);
+        assertEquals("byte", pieces[1]);
+        
+        typeAttrNode = 
+            assertValid("//xsd:complexType[@name='SimpleBean']/xsd:sequence/xsd:element[@name='bigByte']"
+                       + "/@type", 
+                       schema); 
+        assertEquals(1, typeAttrNode.getLength());
+        typeAttr = (Attr)typeAttrNode.item(0);
+        typeQnameString = typeAttr.getValue();
+        pieces = typeQnameString.split(":");
+        assertEquals("xsd", pieces[0]);
+        assertEquals("byte", pieces[1]);
         
-        XmlSchemaComplexType btype = (XmlSchemaComplexType)schema.getTypeByName("SimpleBean");
-        XmlSchemaSequence seq = (XmlSchemaSequence)btype.getParticle();
-        boolean littleByteOk = false;
-        boolean bigByteOk = false;
-
-        for (int x = 0; x < seq.getItems().getCount(); x++) {
-            XmlSchemaObject o = seq.getItems().getItem(x);
-            if (o instanceof XmlSchemaElement) {
-                XmlSchemaElement oe = (XmlSchemaElement) o;
-                if ("littleByte".equals(oe.getName())) {
-                    littleByteOk = true;
-                    assertNotNull(oe.getSchemaTypeName());
-                    assertEquals(XmlSchemaConstants.BYTE_QNAME, oe.getSchemaTypeName());
-                } else if ("bigByte".equals(oe.getName())) {
-                    bigByteOk = true;
-                    assertNotNull(oe.getSchemaTypeName());
-                    assertEquals(XmlSchemaConstants.BYTE_QNAME, oe.getSchemaTypeName());
-                }
-            }
-        }
-        assertTrue(littleByteOk);
-        assertTrue(bigByteOk);
-        
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
         SimpleBean bean = new SimpleBean();
         bean.setBigByte(new Byte((byte)0xfe));
         bean.setLittleByte((byte)0xfd);
-        Element element = writeObjectToElement(type, bean, getContext());
+        type.writeObject(bean, new JDOMWriter(element), getContext());
         Byte bb = new Byte((byte)0xfe);
         String bbs = bb.toString();
         assertValid("/b:root/bz:bigByte[text()='" + bbs + "']", element);
@@ -468,7 +437,9 @@
         DateBean bean = new DateBean();
 
         // Test writing
-        Element element = writeObjectToElement(type, bean, getContext());
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), getContext());
 
         // Make sure the date doesn't have an element. Its non nillable so it
         // just
@@ -492,7 +463,10 @@
         ExtendedBean bean = new ExtendedBean();
         bean.setHowdy("howdy");
 
-        Element element = writeObjectToElement(type, bean, getContext());
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), getContext());
+
         assertValid("/b:root/b:howdy[text()='howdy']", element);
     }
     @Test
@@ -514,7 +488,9 @@
         ByteBean bean = new ByteBean();
 
         // Test writing
-        Element element = writeObjectToElement(type, bean, getContext());
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
+        type.writeObject(bean, new JDOMWriter(element), getContext());
 
         // Make sure the date doesn't have an element. Its non nillable so it
         // just
@@ -523,8 +499,7 @@
         addNamespace("xsi", SOAPConstants.XSI_NS);
         assertValid("/b:root/b:data[@xsi:nil='true']", element);
 
-        XMLStreamReader sreader = StaxUtils.createXMLStreamReader(element);
-        bean = (ByteBean)type.readObject(new ElementReader(sreader), getContext());
+        bean = (ByteBean)type.readObject(new JDOMReader(element), getContext());
         assertNotNull(bean);
         assertNull(bean.getData());
     }
@@ -535,21 +510,21 @@
         type.setTypeMapping(mapping);
         type.setSchemaType(new QName("urn:foo", "BadBean"));
 
-        assertTrue(type.getTypeInfo().getElements().iterator().hasNext());
+        assertTrue(type.getTypeInfo().getElements().hasNext());
 
         type = new BeanType();
         type.setTypeClass(BadBean.class);
         type.setTypeMapping(mapping);
         type.setSchemaType(new QName("urn:foo", "BadBean"));
 
-        assertFalse(type.getTypeInfo().getElements().iterator().hasNext());
+        assertFalse(type.getTypeInfo().getElements().hasNext());
 
         type = new BeanType();
         type.setTypeClass(BadBean2.class);
         type.setTypeMapping(mapping);
         type.setSchemaType(new QName("urn:foo", "BadBean2"));
 
-        assertFalse(type.getTypeInfo().getElements().iterator().hasNext());
+        assertFalse(type.getTypeInfo().getElements().hasNext());
     }
 
     public static class DateBean {

Modified: cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/QualificationTest.java
URL: http://svn.apache.org/viewvc/cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/QualificationTest.java?rev=747871&r1=747870&r2=747871&view=diff
==============================================================================
--- cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/QualificationTest.java (original)
+++ cxf/branches/2.1.x-fixes/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/basic/QualificationTest.java Wed Feb 25 17:54:34 2009
@@ -20,8 +20,6 @@
 
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Element;
-
 import org.apache.cxf.aegis.AbstractAegisTest;
 import org.apache.cxf.aegis.AegisContext;
 import org.apache.cxf.aegis.Context;
@@ -30,8 +28,10 @@
 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 {
@@ -55,8 +55,10 @@
         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();
-        Element element = writeObjectToElement(type, bean, messageContext);
+        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);
@@ -77,8 +79,10 @@
         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();
-        Element element = writeObjectToElement(type, bean, messageContext);
+        type.writeObject(bean, new JDOMWriter(element), messageContext);
         assertValid("/b:root[@xyzzy:attrExplicitString]", element);
         assertXPathEquals("/b:root/@xyzzy:attrExplicitString", "attrExplicit", element);
         assertValid("/b:root[@pkg:attrPlainString]", element);
@@ -94,9 +98,10 @@
         type.setSchemaType(new QName("urn:Bean", "bean"));
 
         Context messageContext = new Context(context);
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
         XmlMappedAttributeBean bean = new XmlMappedAttributeBean();
-        
-        Element element = writeObjectToElement(type, bean, messageContext);
+        type.writeObject(bean, new JDOMWriter(element), messageContext);
         assertValid("/b:root[@attrXmlString]", element);
         assertXPathEquals("/b:root/@attrXmlString", "attrXml", element);
     }
@@ -115,9 +120,10 @@
         type.setSchemaType(new QName("urn:Bean", "bean"));
 
         Context messageContext = new Context(context);
+        Element element = new Element("root", "b", "urn:Bean");
+        new Document(element);
         XmlMappedAttributeBean bean = new XmlMappedAttributeBean();
-
-        Element element = writeObjectToElement(type, bean, messageContext);
+        type.writeObject(bean, new JDOMWriter(element), messageContext);
         assertValid("/b:root[@pkg:attrXmlString]", element);
         assertXPathEquals("/b:root/@pkg:attrXmlString", "attrXml", element);
     }



Mime
View raw message