cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bimargul...@apache.org
Subject svn commit: r730858 [2/2] - in /cxf/trunk: api/src/main/java/org/apache/cxf/service/model/ common/common/src/main/java/org/apache/cxf/common/xmlschema/ common/common/src/main/java/org/apache/cxf/helpers/ rt/databinding/aegis/ rt/databinding/aegis/src/m...
Date Fri, 02 Jan 2009 22:43:29 GMT
Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java?rev=730858&r1=730857&r2=730858&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/collection/MapType.java Fri Jan  2 14:43:28 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.cxf.common.util.SOAPConstants;
-import org.jdom.Attribute;
-import org.jdom.Element;
+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;
 
 public class MapType extends Type {
     private Type keyType;
@@ -176,49 +176,43 @@
     }
 
     @Override
-    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);
+    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);
 
         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);
 
-        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);
+        createElement(evSequence, getKeyName(), kType);
+        createElement(evSequence, getValueName(), vType);
     }
 
     /**
      * Creates a element in a sequence for the key type and the value type.
      */
-    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"));
+    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);
     }
 
     @Override

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java?rev=730858&r1=730857&r2=730858&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java Fri Jan  2 14:43:28 2009
@@ -25,6 +25,7 @@
 import java.util.List;
 import java.util.Set;
 import java.util.StringTokenizer;
+
 import javax.xml.namespace.QName;
 
 import org.apache.commons.logging.Log;
@@ -39,7 +40,7 @@
 import org.apache.cxf.aegis.xml.MessageWriter;
 import org.apache.cxf.binding.soap.Soap11;
 import org.apache.cxf.helpers.CastUtils;
-import org.jdom.Element;
+import org.apache.ws.commons.schema.XmlSchema;
 
 import static org.apache.cxf.aegis.type.encoded.SoapEncodingUtil.readAttributeValue;
 
@@ -333,7 +334,7 @@
      * Throws UnsupportedOperationException
      */
     @Override
-    public void writeSchema(Element root) {
+    public void writeSchema(XmlSchema root) {
         throw new UnsupportedOperationException();
     }
 

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

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java?rev=730858&r1=730857&r2=730858&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/java5/EnumType.java Fri Jan  2 14:43:28 2009
@@ -23,10 +23,12 @@
 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.util.SOAPConstants;
-import org.jdom.Attribute;
-import org.jdom.Element;
-import org.jdom.Namespace;
+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;
 
 public class EnumType extends Type {
     @SuppressWarnings("unchecked")
@@ -53,23 +55,23 @@
     }
 
     @Override
-    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);
+    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);
 
         Object[] constants = getTypeClass().getEnumConstants();
 
+        XmlSchemaObjectCollection facets = restriction.getFacets();
         for (Object constant : constants) {
-            Element enumeration = new Element("enumeration", xsd);
-            enumeration.setAttribute(new Attribute("value", ((Enum)constant).name()));
-            restriction.addContent(enumeration);
+            XmlSchemaEnumerationFacet f = new XmlSchemaEnumerationFacet();
+            f.setValue(((Enum)constant).name());
+            facets.add(f);
         }
     }
 

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java?rev=730858&r1=730857&r2=730858&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/mtom/AbstractXOPType.java Fri Jan  2 14:43:28 2009
@@ -21,23 +21,25 @@
 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.common.util.SOAPConstants;
+import org.apache.cxf.helpers.DOMUtils;
 import org.apache.cxf.message.Attachment;
-import org.jaxen.JaxenException;
-import org.jaxen.jdom.JDOMXPath;
-import org.jdom.Attribute;
-import org.jdom.Element;
-import org.jdom.Namespace;
+import org.apache.ws.commons.schema.XmlSchemaElement;
+import org.apache.ws.commons.schema.constants.Constants;
 
 /**
  * Base class for MtoM types.
@@ -51,18 +53,6 @@
     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 
@@ -87,10 +77,6 @@
         }
     }
     
-    public static JDOMXPath getXmimeXpathImport() {
-        return importXmimeXpath;
-    }
-
     /**
      * This is called from base64Type when it recognizes an XOP attachment.
      * @param reader
@@ -208,13 +194,13 @@
     protected abstract byte[] getBytes(Object object);
 
     @Override
-    public void addToSchemaElement(Element schemaElement) {
+    public void addToSchemaElement(XmlSchemaElement schemaElement) {
         if (expectedContentTypes != null) {
-            Namespace ns = Namespace.getNamespace("xmime", XML_MIME_NS);
-            Attribute expectedContentTypeAttribute = new Attribute(XML_MIME_ATTR_LOCAL_NAME, 
-                                                                   expectedContentTypes,
-                                                                   ns);
-            schemaElement.setAttribute(expectedContentTypeAttribute);
+            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);
         }
     }
     

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java?rev=730858&r1=730857&r2=730858&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/NamespaceHelper.java Fri Jan  2 14:43:28 2009
@@ -20,7 +20,6 @@
 
 import java.net.MalformedURLException;
 import java.net.URL;
-import java.util.Iterator;
 import java.util.List;
 import java.util.StringTokenizer;
 
@@ -30,10 +29,11 @@
 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,51 +62,17 @@
                 return "";
             }
             prefix = getUniquePrefix(element);
-            element.addNamespaceDeclaration(Namespace.getNamespace(prefix, namespaceURI));
+            DOMUtils.addNamespacePrefix(element, namespaceURI, prefix);
         }
         return prefix;
     }
 
     public static String getPrefix(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 getPrefix(element.getParentElement(), namespaceURI);
-        } else {
-            return null;
-        }
+        return DOMUtils.getPrefixRecursive(element, namespaceURI);
     }
 
     public static void getPrefixes(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) {
-            getPrefixes(element.getParentElement(), namespaceURI, prefixes);
-        }
+        DOMUtils.getPrefixesRecursive(element, namespaceURI, prefixes);
     }
 
     private static String getUniquePrefix(Element el) {
@@ -115,7 +81,7 @@
         while (true) {
             String nsPrefix = "ns" + n;
 
-            if (el.getNamespace(nsPrefix) == null) {
+            if (DOMUtils.getNamespace(el, nsPrefix) == null) {
                 return nsPrefix;
             }
 
@@ -373,17 +339,15 @@
 
         String prefix = value.substring(0, index);
         String localName = value.substring(index + 1);
-        Namespace jNS = e.getNamespace(prefix);
+        String jNS = DOMUtils.getNamespace(e, prefix);
         if (jNS == null) {
             throw new DatabindingException("No namespace was found for prefix: " + prefix);
         }
         
-        String ns = jNS.getURI();
-
-        if (ns == null || localName == null) {
+        if (jNS == null || localName == null) {
             throw new DatabindingException("Invalid QName in mapping: " + value);
         }
 
-        return new QName(ns, localName, prefix);
+        return new QName(jNS, localName, prefix);
     }
 }

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMNamespaceContext.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMNamespaceContext.java?rev=730858&r1=730857&r2=730858&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMNamespaceContext.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMNamespaceContext.java Fri Jan  2 14:43:28 2009
@@ -24,7 +24,6 @@
 
 import javax.xml.namespace.NamespaceContext;
 
-import org.apache.cxf.aegis.util.NamespaceHelper;
 import org.jdom.Element;
 import org.jdom.Namespace;
 
@@ -41,12 +40,12 @@
     }
 
     public String getPrefix(String uri) {
-        return NamespaceHelper.getPrefix(element, uri);
+        return rawGetPrefix(element, uri);
     }
 
     public Iterator<String> getPrefixes(String uri) {
         List<String> prefixes = new ArrayList<String>();
-        NamespaceHelper.getPrefixes(element, uri, prefixes);
+        rawGetPrefixes(element, uri, prefixes);
         return prefixes.iterator();
     }
 
@@ -57,4 +56,46 @@
     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/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMStreamWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMStreamWriter.java?rev=730858&r1=730857&r2=730858&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMStreamWriter.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/util/stax/JDOMStreamWriter.java Fri Jan  2 14:43:28 2009
@@ -26,7 +26,6 @@
 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;
@@ -184,7 +183,7 @@
     }
 
     public String getPrefix(String uri) throws XMLStreamException {
-        return NamespaceHelper.getPrefix(currentNode, uri);
+        return JDOMNamespaceContext.rawGetPrefix(currentNode, uri);
     }
 
     public void setPrefix(String arg0, String arg1) throws XMLStreamException {

Modified: cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/jdom/JDOMWriter.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/jdom/JDOMWriter.java?rev=730858&r1=730857&r2=730858&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/jdom/JDOMWriter.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/xml/jdom/JDOMWriter.java Fri Jan  2 14:43:28 2009
@@ -21,7 +21,7 @@
 import javax.xml.namespace.QName;
 import javax.xml.stream.XMLStreamWriter;
 
-import org.apache.cxf.aegis.util.NamespaceHelper;
+import org.apache.cxf.aegis.util.stax.JDOMNamespaceContext;
 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 = NamespaceHelper.getUniquePrefix(element, ns);
+        String prefix = 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 = NamespaceHelper.getUniquePrefix(element, namespace);
+        String prefix = getUniquePrefix(element, namespace);
 
         Element child = new Element(name, Namespace.getNamespace(prefix, namespace));
         element.addContent(child);
@@ -67,7 +67,7 @@
     }
 
     public String getPrefixForNamespace(String namespace) {
-        return NamespaceHelper.getUniquePrefix(element, namespace);
+        return getUniquePrefix(element, namespace);
     }
 
     public XMLStreamWriter getXMLStreamWriter() {
@@ -77,7 +77,7 @@
     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 NamespaceHelper.getUniquePrefix(element, namespace);
+        return 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 = NamespaceHelper.getUniquePrefix(element, namespace);
+            String prefix = getUniquePrefix(element, namespace);
             att = new Attribute(name, "", Namespace.getNamespace(prefix, namespace));
         } else {
             att = new Attribute(name, "");
@@ -105,4 +105,32 @@
 
     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/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomMappingTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomMappingTest.java?rev=730858&r1=730857&r2=730858&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomMappingTest.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/custom/CustomMappingTest.java Fri Jan  2 14:43:28 2009
@@ -27,7 +27,8 @@
 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.jdom.Element;
+import org.apache.ws.commons.schema.XmlSchema;
+
 import org.junit.Test;
 
 /**
@@ -44,8 +45,9 @@
         TypeMapping mapping = context.getTypeMapping();
         // we are replacing the default mapping.
         mapping.register(beanType);
-        Element root = new Element("dummySchema");
-        beanType.writeSchema(root);
+        XmlSchema schema = new XmlSchema();
+        beanType.writeSchema(schema);
+        // well, test?
     }
 
 }

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=730858&r1=730857&r2=730858&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 Fri Jan  2 14:43:28 2009
@@ -25,9 +25,6 @@
 
 import javax.xml.namespace.QName;
 
-import org.w3c.dom.Attr;
-import org.w3c.dom.NodeList;
-
 import org.apache.cxf.aegis.AbstractAegisTest;
 import org.apache.cxf.aegis.AegisContext;
 import org.apache.cxf.aegis.Context;
@@ -41,6 +38,13 @@
 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.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;
@@ -162,7 +166,7 @@
         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");
@@ -190,17 +194,27 @@
 
         assertValid("/b:root[@b:bleh='bleh']", element);
         assertValid("/b:root[@b:howdy='howdy']", element);
-
-        Element types = new Element("types", "xsd", SOAPConstants.XSD);
-        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
-        types.addContent(schema);
-
-        new Document(types);
-
+        
+        XmlSchema schema = new XmlSchema();
         type.writeSchema(schema);
-
-        assertValid("//xsd:complexType[@name='bean']/xsd:attribute[@name='howdy']", schema);
-        assertValid("//xsd:complexType[@name='bean']/xsd:attribute[@name='bleh']", 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);
     }
 
     @Test
@@ -264,16 +278,36 @@
         assertInvalid("/b:root[@b:howdy]", element);
         assertValid("/b:root/b:bleh[@xsi:nil='true']", element);
 
-        Element types = new Element("types", "xsd", SOAPConstants.XSD);
-        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
-        types.addContent(schema);
-
-        new Document(types);
-
+        XmlSchema schema = new XmlSchema();
         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;
+                }
+            }
+        }
 
-        assertValid("//xsd:complexType[@name='bean']/xsd:attribute[@name='howdy']", schema);
-        assertValid("//xsd:complexType[@name='bean']/xsd:sequence/xsd:element[@name='bleh']", schema);
+        assertTrue(howdy);
+        assertTrue(bleh);
     }
     
     @Test
@@ -286,22 +320,30 @@
         type.setTypeMapping(mapping);
         type.setSchemaType(new QName("urn:Bean", "bean"));
 
-        Element types = new Element("types", "xsd", SOAPConstants.XSD);
-        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
-        types.addContent(schema);
-
-        new Document(types);
-
+        XmlSchema schema = new XmlSchema();
         type.writeSchema(schema);
-
-        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);
+        
+        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);
     }
     @Test
     public void testNillableIntMinOccurs1() throws Exception {
@@ -318,20 +360,24 @@
         type.setTypeClass(IntBean.class);
         type.setTypeMapping(mapping);
 
-        Element types = new Element("types", "xsd", SOAPConstants.XSD);
-        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
-        types.addContent(schema);
-
-        new Document(types);
-
+        XmlSchema schema = new XmlSchema();
         type.writeSchema(schema);
-
-        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);
+        
+        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);
     }
     
     @Test
@@ -343,25 +389,28 @@
         BeanType type = (BeanType)mapping.getTypeCreator().createType(SimpleBean.class);
         type.setTypeClass(SimpleBean.class);
         type.setTypeMapping(mapping);
-
-        Element types = new Element("types", "xsd", SOAPConstants.XSD);
-        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
-        types.addContent(schema);
-
-        new Document(types);
-
+        
+        XmlSchema schema = new XmlSchema();
         type.writeSchema(schema);
-
-        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]);
+        
+        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);
     }
     
     @Test
@@ -374,35 +423,33 @@
         type.setTypeClass(SimpleBean.class);
         type.setTypeMapping(mapping);
 
-        Element types = new Element("types", "xsd", SOAPConstants.XSD);
-        Element schema = new Element("schema", "xsd", SOAPConstants.XSD);
-        types.addContent(schema);
-
-        new Document(types);
-
+        XmlSchema schema = new XmlSchema();
         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());
+                    assertTrue(oe.isNillable());
+                    assertEquals(XmlSchemaConstants.BYTE_QNAME, oe.getSchemaTypeName());
+                } else if ("bigByte".equals(oe.getName())) {
+                    bigByteOk = true;
+                    assertNotNull(oe.getSchemaTypeName());
+                    assertTrue(oe.isNillable());
+                    assertEquals(XmlSchemaConstants.BYTE_QNAME, oe.getSchemaTypeName());
+                }
+            }
+        }
+        assertTrue(littleByteOk);
+        assertTrue(bigByteOk);
         
         Element element = new Element("root", "b", "urn:Bean");
         new Document(element);
@@ -510,21 +557,21 @@
         type.setTypeMapping(mapping);
         type.setSchemaType(new QName("urn:foo", "BadBean"));
 
-        assertTrue(type.getTypeInfo().getElements().hasNext());
+        assertTrue(type.getTypeInfo().getElements().iterator().hasNext());
 
         type = new BeanType();
         type.setTypeClass(BadBean.class);
         type.setTypeMapping(mapping);
         type.setSchemaType(new QName("urn:foo", "BadBean"));
 
-        assertFalse(type.getTypeInfo().getElements().hasNext());
+        assertFalse(type.getTypeInfo().getElements().iterator().hasNext());
 
         type = new BeanType();
         type.setTypeClass(BadBean2.class);
         type.setTypeMapping(mapping);
         type.setSchemaType(new QName("urn:foo", "BadBean2"));
 
-        assertFalse(type.getTypeInfo().getElements().hasNext());
+        assertFalse(type.getTypeInfo().getElements().iterator().hasNext());
     }
 
     public static class DateBean {

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=730858&r1=730857&r2=730858&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 Fri Jan  2 14:43:28 2009
@@ -64,7 +64,7 @@
         AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, AnnotatedBean1.class, "urn:foo",
                                                        new TypeCreationOptions());
 
-        Iterator elements = info.getElements();
+        Iterator elements = info.getElements().iterator();
         assertTrue(elements.hasNext());
         QName element = (QName)elements.next();
         assertTrue(elements.hasNext());
@@ -91,7 +91,7 @@
             fail("Unexpected element name: " + element.getLocalPart());
         }
 
-        Iterator atts = info.getAttributes();
+        Iterator atts = info.getAttributes().iterator();
         assertTrue(atts.hasNext());
         atts.next();
         assertFalse(atts.hasNext());
@@ -104,9 +104,9 @@
     public void testAegisType() {
         BeanType type = (BeanType)tm.getTypeCreator().createType(AnnotatedBean3.class);
 
-        assertFalse(type.getTypeInfo().getAttributes().hasNext());
+        assertEquals(0, type.getTypeInfo().getAttributes().size());
 
-        Iterator itr = type.getTypeInfo().getElements();
+        Iterator itr = type.getTypeInfo().getElements().iterator();
         assertTrue(itr.hasNext());
         QName q = (QName)itr.next();
         assertEquals("attProp", q.getLocalPart());
@@ -124,7 +124,7 @@
     public void testNillableAndMinOccurs() {
         BeanType type = (BeanType)tm.getTypeCreator().createType(AnnotatedBean4.class);
         AnnotatedTypeInfo info = (AnnotatedTypeInfo)type.getTypeInfo();
-        Iterator elements = info.getElements();
+        Iterator elements = info.getElements().iterator();
         assertTrue(elements.hasNext());
         // nillable first
         QName element = (QName)elements.next();
@@ -177,7 +177,7 @@
                                                            new TypeCreationOptions()));
         type.setSchemaType(new QName("urn:foo", "BadBean"));
 
-        assertFalse(type.getTypeInfo().getElements().hasNext());
+        assertFalse(type.getTypeInfo().getElements().iterator().hasNext());
     }
 
     public static class BadBean {

Modified: cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/EnumTypeTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/EnumTypeTest.java?rev=730858&r1=730857&r2=730858&view=diff
==============================================================================
--- cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/EnumTypeTest.java (original)
+++ cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/java5/EnumTypeTest.java Fri Jan  2 14:43:28 2009
@@ -30,8 +30,10 @@
 import org.apache.cxf.aegis.xml.jdom.JDOMReader;
 import org.apache.cxf.aegis.xml.jdom.JDOMWriter;
 import org.apache.cxf.common.util.SOAPConstants;
+import org.apache.ws.commons.schema.XmlSchema;
+import org.apache.ws.commons.schema.XmlSchemaSerializer;
 import org.jdom.Element;
-import org.jdom.output.DOMOutputter;
+
 import org.junit.Before;
 import org.junit.Test;
 
@@ -118,12 +120,11 @@
         EnumType type = new EnumType();
         type.setTypeClass(smallEnum.class);
         type.setSchemaType(new QName("urn:test", "test"));
+        XmlSchema schema = new XmlSchema();
+        type.writeSchema(schema);
 
-        Element root = new Element("root");
-        org.jdom.Document wsdl = new org.jdom.Document(root);
-        type.writeSchema(root);
-
-        Document doc = new DOMOutputter().output(wsdl);
+        XmlSchemaSerializer ser = new XmlSchemaSerializer();
+        Document doc = ser.serializeSchema(schema, false)[0];
         addNamespace("xsd", SOAPConstants.XSD);
         assertValid("//xsd:simpleType[@name='test']/xsd:restriction[@base='xsd:string']", doc);
         assertValid("//xsd:restriction[@base='xsd:string']/xsd:enumeration[@value='VALUE1']", doc);

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=730858&r1=730857&r2=730858&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 Fri Jan  2 14:43:28 2009
@@ -64,7 +64,7 @@
         AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, JaxbBean1.class, "urn:foo",
                                                        new TypeCreationOptions());
 
-        Iterator elements = info.getElements();
+        Iterator elements = info.getElements().iterator();
         assertTrue(elements.hasNext());
         QName element = (QName)elements.next();
         assertTrue(elements.hasNext());
@@ -91,7 +91,7 @@
             fail("Unexpected element name: " + element.getLocalPart());
         }
 
-        Iterator atts = info.getAttributes();
+        Iterator atts = info.getAttributes().iterator();
         assertTrue(atts.hasNext());
         atts.next();
         assertFalse(atts.hasNext());
@@ -104,9 +104,9 @@
     public void testAegisType() {
         BeanType type = (BeanType)tm.getTypeCreator().createType(JaxbBean3.class);
 
-        assertFalse(type.getTypeInfo().getAttributes().hasNext());
+        assertEquals(0, type.getTypeInfo().getAttributes().size());
 
-        Iterator itr = type.getTypeInfo().getElements();
+        Iterator itr = type.getTypeInfo().getElements().iterator();
         assertTrue(itr.hasNext());
         QName q = (QName)itr.next();
         assertEquals("attProp", q.getLocalPart());
@@ -124,7 +124,7 @@
     public void testNillableAndMinOccurs() {
         BeanType type = (BeanType)tm.getTypeCreator().createType(JaxbBean4.class);
         AnnotatedTypeInfo info = (AnnotatedTypeInfo)type.getTypeInfo();
-        Iterator elements = info.getElements();
+        Iterator elements = info.getElements().iterator();
         assertTrue(elements.hasNext());
         // nillable first
         QName element = (QName)elements.next();
@@ -177,7 +177,7 @@
                                                            new TypeCreationOptions()));
         type.setSchemaType(new QName("urn:foo", "BadBean"));
 
-        assertFalse(type.getTypeInfo().getElements().hasNext());
+        assertEquals(0, type.getTypeInfo().getElements().size());
     }
 
     public static class BadBean {

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=730858&r1=730857&r2=730858&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 Fri Jan  2 14:43:28 2009
@@ -64,7 +64,7 @@
         AnnotatedTypeInfo info = new AnnotatedTypeInfo(tm, XFireBean1.class, "urn:foo",
                                                        new TypeCreationOptions());
 
-        Iterator elements = info.getElements();
+        Iterator elements = info.getElements().iterator();
         assertTrue(elements.hasNext());
         QName element = (QName)elements.next();
         assertTrue(elements.hasNext());
@@ -91,7 +91,7 @@
             fail("Unexpected element name: " + element.getLocalPart());
         }
 
-        Iterator atts = info.getAttributes();
+        Iterator atts = info.getAttributes().iterator();
         assertTrue(atts.hasNext());
         atts.next();
         assertFalse(atts.hasNext());
@@ -104,9 +104,9 @@
     public void testAegisType() {
         BeanType type = (BeanType)tm.getTypeCreator().createType(XFireBean3.class);
 
-        assertFalse(type.getTypeInfo().getAttributes().hasNext());
+        assertEquals(0, type.getTypeInfo().getAttributes().size());
 
-        Iterator itr = type.getTypeInfo().getElements();
+        Iterator itr = type.getTypeInfo().getElements().iterator();
         assertTrue(itr.hasNext());
         QName q = (QName)itr.next();
         assertEquals("attProp", q.getLocalPart());
@@ -124,7 +124,7 @@
     public void testNillableAndMinOccurs() {
         BeanType type = (BeanType)tm.getTypeCreator().createType(XFireBean4.class);
         AnnotatedTypeInfo info = (AnnotatedTypeInfo)type.getTypeInfo();
-        Iterator elements = info.getElements();
+        Iterator elements = info.getElements().iterator();
         assertTrue(elements.hasNext());
         // nillable first
         QName element = (QName)elements.next();
@@ -177,7 +177,7 @@
                                                            new TypeCreationOptions()));
         type.setSchemaType(new QName("urn:foo", "BadBean"));
 
-        assertFalse(type.getTypeInfo().getElements().hasNext());
+        assertEquals(0, type.getTypeInfo().getElements().size());
     }
 
     public static class BadBean {



Mime
View raw message