cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r604317 [1/2] - in /incubator/cxf/trunk/rt/databinding/aegis/src: main/java/org/apache/cxf/aegis/type/encoded/ test/java/org/apache/cxf/aegis/type/encoded/
Date Fri, 14 Dec 2007 22:34:00 GMT
Author: dkulp
Date: Fri Dec 14 14:33:57 2007
New Revision: 604317

URL: http://svn.apache.org/viewvc?rev=604317&view=rev
Log:
[CXF-1299] Patch for SOAP:Encoded arrays from Dain applied.   Thanks!


Added:
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfo.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfoTest.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/SoapArrayTypeTest.java   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType1.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType2.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayArrayOfArrays1.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid1.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid2.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid3.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid4.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid5.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid6.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid7.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid8.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid9.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayPartiallyTransmitted.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arraySimple.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arraySparse1.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arraySparse2.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arraySparse3.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arraySquare.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayStructs.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayUrType1.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayUrType2.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/example-messages.xml   (with props)
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/temp.xml   (with props)
Modified:
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapEncodingUtil.java
    incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java
    incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfo.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfo.java?rev=604317&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfo.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfo.java Fri Dec 14 14:33:57 2007
@@ -0,0 +1,247 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.StringTokenizer;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.common.util.SOAPConstants;
+import org.apache.cxf.helpers.CastUtils;
+
+import static org.apache.cxf.aegis.type.encoded.SoapEncodingUtil.readAttributeValue;
+
+public class ArrayTypeInfo {
+    private static final String SOAP_ENCODING_NS_1_1 = Soap11.getInstance().getSoapEncodingStyle();
+    private static final QName SOAP_ARRAY_TYPE = new QName(SOAP_ENCODING_NS_1_1, "arrayType");
+    private static final QName SOAP_ARRAY_OFFSET = new QName(SOAP_ENCODING_NS_1_1, "offset");
+
+    private Type type;
+    private QName typeName;
+    private int ranks;
+    private final List<Integer> dimensions = new ArrayList<Integer>();
+    private int offset;
+
+    public ArrayTypeInfo(QName typeName, int ranks, Integer... dimensions) {
+        this.typeName = typeName;
+        this.ranks = ranks;
+        this.dimensions.addAll(Arrays.asList(dimensions));
+    }
+
+    public ArrayTypeInfo(MessageReader reader, TypeMapping tm) {
+        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());
+        if (namespace != null) {
+            if (SOAPConstants.XSD.equals(namespace) && "ur-type".equals(typeName.getLocalPart())) {
+                typeName = new QName(namespace, "anyType", typeName.getPrefix());
+            } else {
+                typeName = new QName(namespace, typeName.getLocalPart(), typeName.getPrefix());
+            }
+        }
+        
+        if (tm != null) {
+            type = tm.getType(typeName);
+
+            if (ranks > 0) {
+                Class componentType = type.getTypeClass();
+                for (int i = 1; i < ranks + dimensions.size(); i++) {
+                    componentType = Array.newInstance(componentType, 0).getClass();
+                }
+
+                SoapArrayType arrayType = new SoapArrayType();
+                arrayType.setTypeClass(componentType);
+                arrayType.setTypeMapping(type.getTypeMapping());
+                type = arrayType;
+            }
+        }
+    }
+
+    public ArrayTypeInfo(String arrayTypeValue) {
+        this(arrayTypeValue, null);
+    }
+
+    public ArrayTypeInfo(String arrayTypeValue, String offsetString) {
+        if (arrayTypeValue == null) {
+            throw new NullPointerException("arrayTypeValue is null");
+        }
+
+        // arrayTypeValue = atype , asize ;
+        // atype          = QName , [ rank ] ;
+        // rank           = "[" , { "," } , "]" ;
+        // asize          = "[" , length , { ","  length} , "]" ;
+        // length         = DIGIT , { DIGIT } ;
+        //
+        // x:foo[,,,][1,2,3,4]
+
+        StringTokenizer tokenizer = new StringTokenizer(arrayTypeValue, "[],:", true);
+        List<String> tokens = CastUtils.cast(Collections.list(tokenizer));
+
+        // ArrayType QName
+        if (tokens.size() < 3) {
+            throw new DatabindingException("Invalid ArrayType value " + arrayTypeValue);
+        }
+        if (tokens.get(1).equals(":")) {
+            typeName = new QName("", tokens.get(2), tokens.get(0));
+            tokens = tokens.subList(3, tokens.size());
+        } else {
+            typeName = new QName("", tokens.get(0));
+            tokens = tokens.subList(1, tokens.size());
+        }
+
+        if (!tokens.get(0).equals("[")) {
+            throw new DatabindingException("Invalid ArrayType value " + arrayTypeValue);
+        }
+
+        // Rank: [,,,,]
+        boolean hasRank = tokens.subList(1, tokens.size()).contains("[");
+        if (hasRank) {
+            // there are atleast [] there is one rank
+            ranks = 1;
+            for (String token : tokens.subList(1, tokens.size())) {
+                if ("]".equals(token)) {
+                    if (tokens.size() < ranks + 1) {
+                        throw new DatabindingException("Invalid ArrayType value " + arrayTypeValue);
+                    }
+                    tokens = tokens.subList(ranks + 1, tokens.size());
+                    break;
+                } else if (",".equals(token)) {
+                    ranks++;
+                } else {
+                    throw new DatabindingException("Invalid ArrayType value " + arrayTypeValue);
+                }
+            }
+        }
+
+        // Dimensions [1,2,3,4]
+        for (int i = 1; i < tokens.size(); i = i + 2) {
+            String dimension = tokens.get(i);
+            if ("]".equals(dimension)) {
+                if (i + 1 != tokens.size()) {
+                    throw new DatabindingException("Invalid ArrayType value " + arrayTypeValue);
+                }
+                break;
+            }
+
+            int value;
+            try {
+                value = Integer.parseInt(dimension);
+            } catch (NumberFormatException e) {
+                throw new DatabindingException("Invalid ArrayType value " + arrayTypeValue);
+            }
+            if (value < 1) {
+                throw new DatabindingException("Invalid ArrayType value " + arrayTypeValue);
+            }
+            dimensions.add(value);
+
+            // verify next token is a ',' or ']'
+            String next = tokens.get(i + 1);
+            if (!",".equals(next) && !"]".equals(next)) {
+                throw new DatabindingException("Invalid ArrayType value " + arrayTypeValue);
+            }
+        }
+
+        if (dimensions.isEmpty()) {
+            throw new DatabindingException("Invalid ArrayType value " + arrayTypeValue);
+        }
+
+        if (offsetString != null) {
+            // offset = "[" , length , "]" ;
+            tokens = CastUtils.cast(Collections.list(new StringTokenizer(offsetString, "[]", true)));
+            if (tokens.size() != 3 || !"[".equals(tokens.get(0)) || !"]".equals(tokens.get(2))) {
+                throw new DatabindingException("Invalid Array offset value " + offsetString);
+            }
+            try {
+                offset = Integer.parseInt(tokens.get(1));
+            } catch (NumberFormatException e) {
+                throw new DatabindingException("Invalid Array offset value " + offsetString);
+            }
+        }
+    }
+
+    public QName getTypeName() {
+        return typeName;
+    }
+
+    public Type getType() {
+        return type;
+    }
+
+    public int getRanks() {
+        return ranks;
+    }
+
+    public List<Integer> getDimensions() {
+        return dimensions;
+    }
+
+    public int getTotalDimensions() {
+        return ranks + dimensions.size();
+    }
+
+    public int getOffset() {
+        return offset;
+    }
+
+    public void writeAttribute(MessageWriter writer) {
+        String value = toString();
+        SoapEncodingUtil.writeAttribute(writer, SOAP_ARRAY_TYPE, value);
+    }
+
+    public String toString() {
+        StringBuilder string = new StringBuilder();
+
+        // typeName: foo:bar
+        if (typeName.getPrefix() != null && typeName.getPrefix().length() > 0) {
+            string.append(typeName.getPrefix()).append(":");
+        }
+        string.append(typeName.getLocalPart());
+
+        // ranks: [,,,,]
+        if (ranks > 0) {
+            string.append("[");
+            for (int i = 1; i < ranks; i++) {
+                string.append(",");
+            }
+            string.append("]");
+        }
+
+        // dimensions: [2,3,4]
+        string.append("[");
+        string.append(dimensions.get(0));
+        for (int dimension : dimensions.subList(1, dimensions.size())) {
+            string.append(",").append(dimension);
+
+        }
+        string.append("]");
+
+        return string.toString();
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfo.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfo.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java?rev=604317&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java Fri Dec 14 14:33:57 2007
@@ -0,0 +1,444 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.StringTokenizer;
+import javax.xml.namespace.QName;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+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.TypeMapping;
+import org.apache.cxf.aegis.type.TypeUtil;
+import org.apache.cxf.aegis.type.basic.BeanType;
+import org.apache.cxf.aegis.xml.MessageReader;
+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 static org.apache.cxf.aegis.type.encoded.SoapEncodingUtil.readAttributeValue;
+
+public class SoapArrayType extends Type {
+    private static final Log LOG = LogFactory.getLog(SoapArrayType.class);
+    private static final String SOAP_ENCODING_NS_1_1 = Soap11.getInstance().getSoapEncodingStyle();
+    private static final QName SOAP_ARRAY_POSITION = new QName(SOAP_ENCODING_NS_1_1, "position");
+
+    private QName componentName;
+
+    @Override
+    public Object readObject(MessageReader reader, Context context) throws DatabindingException {
+        try {
+            // get the encoded array type info
+            TypeMapping tm = context.getTypeMapping();
+            if (tm == null) {
+                tm = getTypeMapping();
+            }
+            ArrayTypeInfo arrayTypeInfo = new ArrayTypeInfo(reader, tm);
+
+            // verify arrayType dimensions are the same as this type class's array dimensions
+            if (getDimensions() != arrayTypeInfo.getTotalDimensions()) {
+                throw new DatabindingException("In " + getSchemaType() + " expected array with "
+                        + getDimensions() + " dimensions, but arrayType has "
+                        + arrayTypeInfo.getTotalDimensions() + " dimensions: "
+                        + arrayTypeInfo.toString());
+            }
+
+            // calculate max size
+            int maxSize = 1;
+            for (int dimension : arrayTypeInfo.getDimensions()) {
+                maxSize *= dimension;
+            }
+
+            // verify offset doesn't exceed maximum size
+            if (arrayTypeInfo.getOffset() >= maxSize) {
+                throw new DatabindingException("The array offset " + arrayTypeInfo.getOffset() + " in "
+                        + getSchemaType() + " exceeds the expecte size of " + maxSize);
+            }
+
+            // read the values
+            List<Object> values = readCollection(reader,
+                    context,
+                    arrayTypeInfo,
+                    maxSize - arrayTypeInfo.getOffset());
+
+            // if it is a partially transmitted array offset the array values
+            if (arrayTypeInfo.getOffset() > 0) {
+                List<Object> list = new ArrayList<Object>(values.size() + arrayTypeInfo.getOffset());
+                list.addAll(Collections.nCopies(arrayTypeInfo.getOffset(), null));
+                list.addAll(values);
+                values = list;
+            }
+
+            // check bounds
+            if (values.size() > maxSize) {
+                throw new DatabindingException("The number of elements " + values.size() + " in "
+                        + getSchemaType() + " exceeds the expecte size of " + maxSize);
+            }
+            if (values.size() < maxSize) {
+                values.addAll(Collections.nCopies(maxSize - values.size(), null));
+                // todo is this an error?
+                // throw new DatabindingException("The number of elements in " + getSchemaType() +
+                //         " is less then the expected size of " + expectedSize);
+            }
+            if (values.size() != maxSize) {
+                throw new IllegalStateException("Internal error: Expected values collection to contain "
+                        + maxSize + " elements but it contains " + values.size() + " elements");
+            }
+
+            // create the array
+            return makeArray(values, arrayTypeInfo.getDimensions(), getTypeClass().getComponentType());
+        } catch (IllegalArgumentException e) {
+            throw new DatabindingException("Illegal argument.", e);
+        }
+    }
+
+    protected List<Object> readCollection(MessageReader reader,
+            Context context,
+            ArrayTypeInfo arrayTypeInfo,
+            int maxSize) throws DatabindingException {
+
+        List<Object> values = new ArrayList<Object>();
+
+        Boolean sparse = null;
+        while (reader.hasMoreElementReaders()) {
+            MessageReader creader = reader.getNextElementReader();
+
+            // if the first element contains a position attribute, this is a sparse array
+            // and all subsequent elements must contain the position attribute
+            String position = readAttributeValue(creader, SOAP_ARRAY_POSITION);
+            if (sparse == null) {
+                sparse = position != null;
+            }
+
+            // nested element names can specifiy a type
+            Type compType = getTypeMapping().getType(creader.getName());
+            if (compType == null) {
+                // use the type declared in the arrayType attribute
+                compType = arrayTypeInfo.getType();
+            }
+            // check for an xsi:type override
+            compType = TypeUtil.getReadType(creader.getXMLStreamReader(), context, compType);
+
+            // wrap type with soap ref to handle hrefs
+            compType = new SoapRefType(compType);
+
+            // read the value
+            Object value;
+            if (creader.isXsiNil()) {
+                value = null;
+                creader.readToEnd();
+            } else {
+                value = compType.readObject(creader, context);
+            }
+
+            // add the value
+            if (!sparse) {
+                if (values.size() + 1 > maxSize) {
+                    throw new DatabindingException("The number of elements in " + getSchemaType()
+                            + " exceeds the maximum size of " + maxSize);
+                }
+                values.add(value);
+            } else {
+                int valuesPosition = readValuesPosition(position, arrayTypeInfo.getDimensions());
+                if (valuesPosition > maxSize) {
+                    throw new DatabindingException("Array position " + valuesPosition + " in "
+                            + getSchemaType() + " exceeds the maximum size of " + maxSize);
+                }
+                if (values.size() <= valuesPosition) {
+                    values.addAll(Collections.nCopies(valuesPosition - values.size() + 1, null));
+                }
+                Object oldValue = values.set(valuesPosition, value);
+                if (oldValue != null) {
+                    throw new DatabindingException("Array position " + valuesPosition + " in "
+                            + getSchemaType() + " is already assigned to value " + oldValue);
+                }
+            }
+        }
+
+        return values;
+    }
+
+    private int readValuesPosition(String positionString, List<Integer> dimensions) {
+        if (positionString == null) {
+            throw new DatabindingException("Sparse array entry does not contain a position attribute");
+        }
+
+        try {
+            // position = "[" , length , { "," , lenght } , "]" ;
+            List<String> tokens = CastUtils.cast(Collections.list(new StringTokenizer(positionString,
+                    "[],",
+                    true)));
+            if (tokens.size() == 2 + dimensions.size() + dimensions.size() - 1 && tokens.get(0).equals("[")
+                    && tokens.get(tokens.size() - 1).equals("]")) {
+
+                // strip off leading [ and trailing ]
+                tokens = tokens.subList(1, tokens.size() - 1);
+
+                // return the product of the values
+                int[] index = new int[dimensions.size()];
+                for (int i = 0; i < index.length; i++) {
+                    int tokenId = i * 2;
+
+                    index[i] = Integer.parseInt(tokens.get(tokenId));
+
+                    if (tokenId + 1 < tokens.size() && !tokens.get(tokenId + 1).equals(",")) {
+                        throw new IllegalStateException(
+                                "Expected a comma but got " + tokens.get(tokenId + 1));
+                    }
+                }
+
+                // determine the real position withing the flattened square array
+                int valuePosition = 0;
+                int multiplier = 1;
+                for (int i = index.length - 1; i >= 0; i--) {
+                    int position = index[i];
+                    valuePosition += position * multiplier;
+                    multiplier *= dimensions.get(i);
+                }
+
+                return valuePosition;
+            }
+        } catch (Exception ignored) {
+            // exception is thrown below
+        }
+
+        // failed print the expected format
+        StringBuilder expectedFormat = new StringBuilder();
+        expectedFormat.append("[x");
+        for (int i = 1; i < dimensions.size(); i++) {
+            expectedFormat.append(",x");
+        }
+        expectedFormat.append("]");
+        throw new DatabindingException("Expected sparse array position value in format " + expectedFormat
+                + ", but was " + positionString);
+    }
+
+    protected Object makeArray(List values, List<Integer> dimensions, Class componentType) {
+
+        // if this is an array of arrays, recurse into this function
+        // for each nested array
+        if (componentType.isArray() && dimensions.size() > 1) {
+            // square array
+            int chunkSize = 1;
+            for (Integer dimension : dimensions.subList(1, dimensions.size())) {
+                chunkSize *= dimension;
+            }
+            Object[] array = (Object[]) Array.newInstance(componentType, dimensions.get(0));
+            for (int i = 0; i < array.length; i++) {
+                List chunk = values.subList(i * chunkSize, (i + 1) * chunkSize);
+                Object value = makeArray(chunk,
+                        dimensions.subList(1, dimensions.size()),
+                        componentType.getComponentType());
+                Array.set(array, i, value);
+            }
+            return array;
+        }
+
+        // build the array
+        Object array = Array.newInstance(componentType, dimensions.get(0));
+        for (int i = 0; i < values.size(); i++) {
+            Object value = values.get(i);
+            if (value != null) {
+                SoapRef soapRef = (SoapRef) value;
+                soapRef.setAction(new SetArrayAction(array, i));
+            }
+        }
+        return array;
+    }
+
+    @Override
+    public void writeObject(Object values,
+            MessageWriter writer,
+            Context context) throws DatabindingException {
+        
+        if (values == null) {
+            return;
+        }
+
+        // ComponentType
+        Type type = getComponentType();
+        if (type == null) {
+            throw new DatabindingException("Couldn't find type for " + type.getTypeClass() + ".");
+        }
+
+        // Root component's schema type
+        QName rootType = getRootType();
+        String prefix = writer.getPrefixForNamespace(rootType.getNamespaceURI(), rootType.getPrefix());
+        rootType = new QName(rootType.getNamespaceURI(), rootType.getLocalPart(), prefix);
+
+
+        // write the soap arrayType attribute
+        ArrayTypeInfo arrayTypeInfo = new ArrayTypeInfo(rootType,
+                getDimensions() - 1,
+                Array.getLength(values));
+        arrayTypeInfo.writeAttribute(writer);
+
+        // write each element
+        for (int i = 0; i < Array.getLength(values); i++) {
+            writeValue(Array.get(values, i), writer, context, type);
+        }
+    }
+
+    protected void writeValue(Object value,
+            MessageWriter writer,
+            Context context,
+            Type type) throws DatabindingException {
+
+        type = TypeUtil.getWriteType(context, value, type);
+
+        MessageWriter cwriter = writer.getElementWriter(type.getSchemaType().getLocalPart(), "");
+
+        if (value == null && type.isNillable()) {
+            // null
+            cwriter.writeXsiNil();
+        } else if (type instanceof BeanType || type instanceof SoapArrayType) {
+            // write refs to complex type
+            String refId = MarshalRegistry.get(context).getInstanceId(value);
+            SoapEncodingUtil.writeRef(cwriter, refId);
+        } else {
+            // write simple types inline
+            type.writeObject(value, cwriter, context);
+        }
+
+        cwriter.close();
+    }
+
+    /**
+     * Throws UnsupportedOperationException
+     */
+    @Override
+    public void writeSchema(Element root) {
+        throw new UnsupportedOperationException();
+    }
+
+    /**
+     * We need to write a complex type schema for Beans, so return true.
+     *
+     * @see org.apache.cxf.aegis.type.Type#isComplex()
+     */
+    @Override
+    public boolean isComplex() {
+        return true;
+    }
+
+    /**
+     * Gets the QName of the component type of this array.
+     * @return the QName of the component type of this array
+     */
+    public QName getComponentName() {
+        return componentName;
+    }
+
+    /**
+     * Sets the QName of the component type of this array.
+     * @param componentName the QName of the component type of this array
+     */
+    public void setComponentName(QName componentName) {
+        this.componentName = componentName;
+    }
+
+    @Override
+    public Set<Type> getDependencies() {
+        Set<Type> deps = new HashSet<Type>();
+
+        deps.add(getComponentType());
+
+        return deps;
+    }
+
+    /**
+     * Get the <code>Type</code> of the elements in the array.  This is only used for writing an array.
+     * When reading the type is solely determined by the required arrayType soap attribute.
+     */
+    public Type getComponentType() {
+        Class compType = getTypeClass().getComponentType();
+
+        Type type;
+        if (componentName == null) {
+            type = getTypeMapping().getType(compType);
+        } else {
+            type = getTypeMapping().getType(componentName);
+
+            // We couldn't find the type the user specified. One is created
+            // below instead.
+            if (type == null) {
+                LOG.debug("Couldn't find array component type " + componentName + ". Creating one instead.");
+            }
+        }
+
+        if (type == null) {
+            type = getTypeMapping().getTypeCreator().createType(compType);
+            getTypeMapping().register(type);
+        }
+
+        return type;
+    }
+
+    /**
+     * Gets the QName of the root component type of this array.  This will be a non-array type such as
+     * a simple xsd type.
+     * @return the QName of the root component type of this array
+     */
+    protected QName getRootType() {
+        Type componentType = getComponentType();
+        if (componentType instanceof SoapArrayType) {
+            SoapArrayType arrayType = (SoapArrayType) componentType;
+            return arrayType.getRootType();
+        }
+        return componentType.getSchemaType();
+    }
+
+    /**
+     * Gets the number of array dimensions in the class for this type.
+     * @return the number of array dimensions
+     */
+    private int getDimensions() {
+        int dimensions = 0;
+        for (Class type = getTypeClass(); type.isArray(); type = type.getComponentType()) {
+            dimensions++;
+        }
+        return dimensions;
+    }
+
+    /**
+     * Sets an array entry when the soap ref is resolved
+     */
+    private static class SetArrayAction implements SoapRef.Action {
+        private final Object array;
+        private final int index;
+
+        public SetArrayAction(Object array, int index) {
+            this.array = array;
+            this.index = index;
+        }
+
+        public void onSet(SoapRef ref) {
+            Array.set(array, index, ref.get());
+        }
+    }
+}

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapArrayType.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapEncodingUtil.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapEncodingUtil.java?rev=604317&r1=604316&r2=604317&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapEncodingUtil.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/SoapEncodingUtil.java Fri Dec 14 14:33:57 2007
@@ -28,10 +28,10 @@
  * Utilitiy methods for SOAP reading and writing encoded mesages.
  */
 public final class SoapEncodingUtil {
-    private static final String SOAP_ENCODING_NS = Soap12.getInstance().getSoapEncodingStyle();
-    private static final QName SOAP_ENCODING_ID_1_2 = new QName(SOAP_ENCODING_NS, "id");
+    private static final String SOAP_ENCODING_NS_1_2 = Soap12.getInstance().getSoapEncodingStyle();
+    private static final QName SOAP_ENCODING_ID_1_2 = new QName(SOAP_ENCODING_NS_1_2, "id");
     private static final QName SOAP_ENCODING_ID_1_1 = new QName("id");
-    private static final QName SOAP_ENCODING_REF_1_2 = new QName(SOAP_ENCODING_NS, "ref");
+    private static final QName SOAP_ENCODING_REF_1_2 = new QName(SOAP_ENCODING_NS_1_2, "ref");
     private static final QName SOAP_ENCODING_REF_1_1 = new QName("href");
 
     private SoapEncodingUtil() {
@@ -44,9 +44,6 @@
      * @return the id or null of neither attribute was present
      */
     public static String readId(MessageReader reader) {
-        if (reader == null) {
-            throw new NullPointerException("reader is null");
-        }
         String id = readAttributeValue(reader, SOAP_ENCODING_ID_1_2);
         if (id == null) {
             id = readAttributeValue(reader, SOAP_ENCODING_ID_1_1);
@@ -61,9 +58,6 @@
      * @param id the id to write; must not be null
      */
     public static void writeId(MessageWriter writer, String id) {
-        if (writer == null) {
-            throw new NullPointerException("writer is null");
-        }
         if (id == null) {
             throw new NullPointerException("id is null");
         }
@@ -77,9 +71,6 @@
      * @return the reference id or null of neither attribute was present
      */
     public static String readRef(MessageReader reader) {
-        if (reader == null) {
-            throw new NullPointerException("reader is null");
-        }
         String ref = readAttributeValue(reader, SOAP_ENCODING_REF_1_2);
         if (ref == null) {
             ref = readAttributeValue(reader, SOAP_ENCODING_REF_1_1);
@@ -94,29 +85,41 @@
      * @param refId the reference id to write; must not be null
      */
     public static void writeRef(MessageWriter writer, String refId) {
-        if (writer == null) {
-            throw new NullPointerException("writer is null");
-        }
         if (refId == null) {
             throw new NullPointerException("refId is null");
         }
         writeAttribute(writer, SOAP_ENCODING_REF_1_1, refId);
     }
 
-    private static String readAttributeValue(MessageReader reader, QName name) {
+    public static String readAttributeValue(MessageReader reader, QName name) {
+        if (reader == null) {
+            throw new NullPointerException("reader is null");
+        }
+        if (name == null) {
+            throw new NullPointerException("name is null");
+        }
         MessageReader attributeReader = reader.getAttributeReader(name);
         if (attributeReader != null) {
-            String id = attributeReader.getValue();
-            if (id != null) {
-                return id;
+            String value = attributeReader.getValue();
+            if (value != null) {
+                return value;
             }
         }
         return null;
     }
 
-    private static void writeAttribute(MessageWriter writer, QName name, String refId) {
+    public static void writeAttribute(MessageWriter writer, QName name, String value) {
+        if (writer == null) {
+            throw new NullPointerException("writer is null");
+        }
+        if (name == null) {
+            throw new NullPointerException("name is null");
+        }
+        if (value == null) {
+            throw new NullPointerException("value is null");
+        }
         MessageWriter attributeWriter = writer.getAttributeWriter(name);
-        attributeWriter.writeValue(refId);
+        attributeWriter.writeValue(value);
         attributeWriter.close();
     }
 }

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java?rev=604317&r1=604316&r2=604317&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/main/java/org/apache/cxf/aegis/type/encoded/StructType.java Fri Dec 14 14:33:57 2007
@@ -119,8 +119,7 @@
 
         MessageWriter cwriter = writer.getElementWriter(name);
 
-        // todo check if the property value is a simple Java type instead of looking or a BeanType
-        if (type instanceof BeanType) {
+        if (type instanceof BeanType || type instanceof SoapArrayType) {
             String refId = MarshalRegistry.get(context).getInstanceId(value);
             SoapEncodingUtil.writeRef(cwriter, refId);
         } else {

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java?rev=604317&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/AbstractEncodedTest.java Fri Dec 14 14:33:57 2007
@@ -0,0 +1,189 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import java.io.ByteArrayInputStream;
+import java.util.List;
+import java.util.Map;
+import javax.xml.stream.XMLStreamException;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.DatabindingException;
+import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.apache.cxf.aegis.xml.MessageReader;
+import org.apache.cxf.aegis.xml.MessageWriter;
+import org.apache.cxf.aegis.xml.jdom.JDOMWriter;
+import org.apache.cxf.aegis.xml.stax.ElementReader;
+import org.apache.cxf.binding.soap.Soap11;
+import org.apache.cxf.common.util.SOAPConstants;
+import org.jdom.Document;
+import org.jdom.Element;
+import org.jdom.Namespace;
+import org.jdom.output.Format;
+import org.jdom.output.XMLOutputter;
+import org.junit.Before;
+
+public abstract class AbstractEncodedTest extends AbstractAegisTest {
+    protected TypeMapping mapping;
+    protected TrailingBlocks trailingBlocks;
+
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+
+        addNamespace("b", "urn:Bean");
+        addNamespace("a", "urn:anotherns");
+        addNamespace("xsi", SOAPConstants.XSI_NS);
+        addNamespace("soapenc", Soap11.getInstance().getSoapEncodingStyle());
+
+        DefaultTypeMappingRegistry reg = new DefaultTypeMappingRegistry(true);
+        mapping = reg.createTypeMapping(Soap11.getInstance().getSoapEncodingStyle(), true);
+
+        // serialization root type
+        trailingBlocks = new TrailingBlocks();
+    }
+
+    public <T> T readWriteReadRef(String file, Class<T> typeClass) throws XMLStreamException {
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        Type type = mapping.getType(typeClass);
+        assertNotNull("no type found for " + typeClass.getName());
+
+        // read file
+        ElementReader reader = new ElementReader(getClass().getResourceAsStream(file));
+        T value = typeClass.cast(type.readObject(reader, context));
+        reader.getXMLStreamReader().close();
+
+        // write value to element
+        Element element = writeRef(value);
+
+        // reread value from element
+        value = typeClass.cast(readRef(element));
+
+        return value;
+    }
+
+    public Object readRef(String file) throws XMLStreamException {
+        ElementReader root = new ElementReader(getClass().getResourceAsStream(file));
+        return readRef(root);
+    }
+
+    public Object readRef(Element element) throws XMLStreamException {
+        XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
+        String xml = xmlOutputter.outputString(element);
+        ElementReader root = new ElementReader(new ByteArrayInputStream(xml.getBytes()));
+        return readRef(root);
+    }
+
+    public Object readRef(ElementReader root) throws XMLStreamException {
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        // get Type based on the element qname
+        MessageReader reader = root.getNextElementReader();
+        Type type = this.mapping.getType(reader.getName());
+        assertNotNull("type is null", type);
+
+        // read ref
+        SoapRefType soapRefType = new SoapRefType(type);
+        SoapRef ref = (SoapRef) soapRefType.readObject(reader, context);
+        reader.readToEnd();
+
+        // read the trailing blocks (referenced objects)
+        List<Object> roots = trailingBlocks.readBlocks(root, context);
+        assertNotNull(roots);
+
+        // close the input stream
+        root.getXMLStreamReader().close();
+
+        // return the ref
+        return ref.get();
+    }
+
+    public Element writeRef(Object instance) {
+        Type type = mapping.getType(instance.getClass());
+        assertNotNull("no type found for " + instance.getClass().getName());
+
+        // create the document
+        Element element = new Element("root", "b", "urn:Bean");
+        for (Map.Entry<String, String> entry : getNamespaces().entrySet()) {
+            element.addNamespaceDeclaration(Namespace.getNamespace(entry.getKey(), entry.getValue()));
+        }
+        new Document(element);
+        JDOMWriter rootWriter = new JDOMWriter(element);
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        // get Type based on the object instance
+        assertNotNull("type is null", type);
+
+        // write the ref
+        SoapRefType soapRefType = new SoapRefType(type);
+        MessageWriter cwriter = rootWriter.getElementWriter(soapRefType.getSchemaType());
+        soapRefType.writeObject(instance, cwriter, context);
+        cwriter.close();
+
+        // write the trailing blocks (referenced objects)
+        trailingBlocks.writeBlocks(rootWriter, context);
+
+        // log xml for debugging
+        // XMLOutputter xmlOutputter = new XMLOutputter(Format.getPrettyFormat());
+        // System.out.println(xmlOutputter.outputString(element)) ;
+
+        return element;
+    }
+
+    public void verifyInvalid(String resourceName, Class<?> expectedType) throws XMLStreamException {
+        Type type = mapping.getType(expectedType);
+        assertNotNull("type is null", type);
+
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        ElementReader reader = new ElementReader(getClass().getResourceAsStream(resourceName));
+        try {
+            type.readObject(reader, context);
+            fail("expected DatabindingException");
+        } catch (DatabindingException expected) {
+            // expected
+        } finally {
+            reader.getXMLStreamReader().close();
+        }
+    }
+
+    public static void validateShippingAddress(Address address) {
+        assertNotNull(address);
+        assertEquals("1234 Riverside Drive", address.getStreet());
+        assertEquals("Gainesville", address.getCity());
+        assertEquals("FL", address.getState());
+        assertEquals("30506", address.getZip());
+    }
+
+    public static void validateBillingAddress(Address billing) {
+        assertNotNull("billing is null", billing);
+        assertEquals("1234 Fake Street", billing.getStreet());
+        assertEquals("Las Vegas", billing.getCity());
+        assertEquals("NV", billing.getState());
+        assertEquals("89102", billing.getZip());
+    }
+}

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

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

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfoTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfoTest.java?rev=604317&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfoTest.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/ArrayTypeInfoTest.java Fri Dec 14 14:33:57 2007
@@ -0,0 +1,136 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import java.io.ByteArrayInputStream;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.aegis.AbstractAegisTest;
+import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
+import org.apache.cxf.aegis.type.TypeMapping;
+import org.apache.cxf.aegis.type.basic.BeanTypeInfo;
+import org.apache.cxf.aegis.xml.stax.ElementReader;
+import org.apache.cxf.common.util.SOAPConstants;
+import org.junit.Test;
+
+public class ArrayTypeInfoTest extends AbstractAegisTest {
+    private TypeMapping mapping;
+    private StructType addressType;
+
+    public void setUp() throws Exception {
+        super.setUp();
+
+        addNamespace("b", "urn:Bean");
+        addNamespace("a", "urn:anotherns");
+        addNamespace("xsi", SOAPConstants.XSI_NS);
+
+        DefaultTypeMappingRegistry reg = new DefaultTypeMappingRegistry(true);
+        mapping = reg.createTypeMapping(true);
+
+        // address type
+        BeanTypeInfo addressInfo = new BeanTypeInfo(Address.class, "urn:Bean");
+        addressInfo.setTypeMapping(mapping);
+
+        addressType = new StructType(addressInfo);
+        addressType.setTypeClass(Address.class);
+        addressType.setSchemaType(new QName("urn:Bean", "addr"));
+        mapping.register(addressType);
+    }
+
+    @Test
+    public void testArrayTypeInfo() throws Exception {
+        assertEquals(new ArrayTypeInfo(new QName("", "addr"), 0, 4), "addr[4]");
+        assertEquals(new ArrayTypeInfo(new QName("urn:Bean", "addr", "b"), 0, 4), "b:addr[4]");
+        assertEquals(new ArrayTypeInfo(new QName("urn:Bean", "addr", "b"), 0, 4, 8, 9), "b:addr[4,8,9]");
+        assertEquals(new ArrayTypeInfo(new QName("urn:Bean", "addr", "b"), 0, 4), "b:addr[4]");
+        assertEquals(new ArrayTypeInfo(new QName("urn:Bean", "addr", "b"), 1, 4), "b:addr[][4]");
+        assertEquals(new ArrayTypeInfo(new QName("urn:Bean", "addr", "b"), 2, 4), "b:addr[,][4]");
+        assertEquals(new ArrayTypeInfo(new QName("urn:Bean", "addr", "b"), 4, 4), "b:addr[,,,][4]");
+        assertEquals(new ArrayTypeInfo(new QName("urn:Bean", "addr", "b"), 4, 4, 8, 9), "b:addr[,,,][4,8,9]");
+        assertInvalid("x");
+        assertInvalid("b:addr");
+        assertInvalid(":addr[4]");
+        assertInvalid("b:a:ddress[4]");
+        assertInvalid("b:addr[0]");
+        assertInvalid("b:addr[a]");
+        assertInvalid("b:addr[4,0]");
+        assertInvalid("b:addr[4,a]");
+        assertInvalid("b:addr[4,0,5]");
+        assertInvalid("b:addr[4,a,5]");
+        assertInvalid("b:addr[]");
+        assertInvalid("b:addr[,]");
+        assertInvalid("b:addr[,][]");
+        assertInvalid("b:addr],][4]");
+        assertInvalid("b:addr[,[[4]");
+        assertInvalid("b:addr[,]]4]");
+        assertInvalid("b:addr[,][4[");
+        assertInvalid("b:addr[,][]4]");
+        assertInvalid("b:addr[,][][4]");
+        assertInvalid("b:addr[,][][4[");
+        assertInvalid("b:addr[,][][4]end");
+    }
+
+    public void assertEquals(ArrayTypeInfo expected, String actualString) throws Exception {
+        ArrayTypeInfo actual = new ArrayTypeInfo(actualString);
+
+        // only compare local part because prefix is only resolved when using the MessageReader constructor
+        assertEquals(expected.getRanks(), actual.getRanks());
+        assertEquals(expected.getDimensions(), actual.getDimensions());
+        if (expected.getType() != null) {
+            assertEquals(expected.getTypeName().getLocalPart(), actual.getTypeName().getLocalPart());
+            if (expected.getRanks() == 0) {
+                assertSame(addressType, actual.getType());
+            } else {
+                assertTrue("actual.getType() should be an instance of SoapArrayType, but is "
+                        + actual.getType().getClass().getName(), actual.getType() instanceof SoapArrayType);
+            }
+        }
+        assertEquals(expected.toString(), actual.toString());
+
+        String xml = "<b:array xmlns:b=\"urn:Bean\"\n"
+                + "    xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\"\n"
+                + "    xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\"\n"
+                + "    xmlns:soapenc=\"http://schemas.xmlsoap.org/soap/encoding/\"\n"
+                + "    soapenc:arrayType=\"" + actualString + "\"/>";
+
+        ElementReader reader = new ElementReader(new ByteArrayInputStream(xml.getBytes()));
+        actual = new ArrayTypeInfo(reader, mapping);
+        assertEquals(expected.getRanks(), actual.getRanks());
+        assertEquals(expected.getDimensions(), actual.getDimensions());
+        if (expected.getType() != null) {
+            assertEquals(expected.getTypeName(), actual.getTypeName());
+            if (expected.getRanks() == 0) {
+                assertSame(addressType, actual.getType());
+            } else {
+                assertTrue("actual.getType() should be an instance of SoapArrayType, but is "
+                        + actual.getType().getClass().getName(), actual.getType() instanceof SoapArrayType);
+            }
+        }
+        assertEquals(expected.toString(), actual.toString());
+    }
+
+    public void assertInvalid(String actualString) {
+        try {
+            new ArrayTypeInfo(actualString);
+            fail("Expected a DatabindingException from invalid arrayType " + actualString);
+        } catch (Exception expected) {
+            // expected
+        }
+    }
+}
\ No newline at end of file

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

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

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/SoapArrayTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/SoapArrayTypeTest.java?rev=604317&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/SoapArrayTypeTest.java (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/SoapArrayTypeTest.java Fri Dec 14 14:33:57 2007
@@ -0,0 +1,331 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.aegis.type.encoded;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.aegis.Context;
+import org.apache.cxf.aegis.type.Type;
+import org.apache.cxf.aegis.type.basic.BeanTypeInfo;
+import org.apache.cxf.aegis.xml.stax.ElementReader;
+import org.junit.Test;
+
+public class SoapArrayTypeTest extends AbstractEncodedTest {
+    private static final String[][][] ARRAY_2_3_4 = new String[][][] {
+        new String[][]{
+            new String[]{"row1 col1 dep1", "row1 col1 dep2", "row1 col1 dep3", "row1 col1 dep4"},
+            new String[]{"row1 col2 dep1", "row1 col2 dep2", "row1 col2 dep3", "row1 col2 dep4"},
+            new String[]{"row1 col3 dep1", "row1 col3 dep2", "row1 col3 dep3", "row1 col3 dep4"},
+        },
+        new String[][]{
+            new String[]{"row2 col1 dep1", "row2 col1 dep2", "row2 col1 dep3", "row2 col1 dep4"},
+            new String[]{"row2 col2 dep1", "row2 col2 dep2", "row2 col2 dep3", "row2 col2 dep4"},
+            new String[]{"row2 col3 dep1", "row2 col3 dep2", "row2 col3 dep3", "row2 col3 dep4"},
+        },
+    };
+
+    public void setUp() throws Exception {
+        super.setUp();
+
+        // address type
+        BeanTypeInfo addressInfo = new BeanTypeInfo(Address.class, "urn:Bean");
+        addressInfo.setTypeMapping(mapping);
+
+        StructType addressType = new StructType(addressInfo);
+        addressType.setTypeClass(Address.class);
+        addressType.setSchemaType(new QName("urn:Bean", "address"));
+        mapping.register(addressType);
+
+        // purchase order type
+        BeanTypeInfo poInfo = new BeanTypeInfo(PurchaseOrder.class, "urn:Bean");
+        poInfo.setTypeMapping(mapping);
+
+        StructType purchaseOrderType = new StructType(poInfo);
+        purchaseOrderType.setTypeClass(PurchaseOrder.class);
+        purchaseOrderType.setTypeMapping(mapping);
+        purchaseOrderType.setSchemaType(new QName("urn:Bean", "po"));
+        mapping.register(purchaseOrderType);
+
+        // String[][][]
+        SoapArrayType arrayOfString =
+                createArrayType(String[].class, new QName("urn:Bean", "SOAPArrayOfString"));
+        mapping.register(arrayOfString);
+        SoapArrayType arrayOfArrayOfString =
+                createArrayType(String[][].class, new QName("urn:Bean", "SOAPArrayOfArrayOfString"));
+        mapping.register(arrayOfArrayOfString);
+        SoapArrayType arrayOfArrayOfArrayOfString =
+                createArrayType(String[][][].class, new QName("urn:Bean", "SOAPArrayOfArrayOfArrayOfString"));
+        mapping.register(arrayOfArrayOfArrayOfString);
+
+        // int[][]
+        SoapArrayType arrayOfInt =
+                createArrayType(int[].class, new QName("urn:Bean", "SOAPArrayOfInt"));
+        mapping.register(arrayOfInt);
+        SoapArrayType arrayOfArrayOfInt =
+                createArrayType(int[][].class, new QName("urn:Bean", "SOAPArrayOfArrayOfInt"));
+        mapping.register(arrayOfArrayOfInt);
+
+        // Object[]
+        SoapArrayType arrayOfAddress =
+                createArrayType(Address[].class, new QName("urn:Bean", "SOAPArrayOfAddress"));
+        mapping.register(arrayOfAddress);
+        SoapArrayType arrayOfAny =
+                createArrayType(Object[].class, new QName("urn:Bean", "SOAPArrayOfAny"));
+        mapping.register(arrayOfAny);
+    }
+
+    @Test
+    public void testSimpleArray() throws Exception {
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        // xsd:int[2]
+        ElementReader reader = new ElementReader(getClass().getResourceAsStream("arraySimple.xml"));
+        int[] numbers = (int[]) createArrayType(int[].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        assertArrayEquals(new int[]{3, 4}, numbers);
+
+        // round trip tests
+        numbers = readWriteReadRef("arraySimple.xml", int[].class);
+        assertArrayEquals(new int[]{3, 4}, numbers);
+    }
+
+    @Test
+    public void testUrTypeArray() throws Exception {
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        // ur-type[4] nested elements have xsi:type
+        ElementReader reader = new ElementReader(getClass().getResourceAsStream("arrayUrType1.xml"));
+        Object[] objects = (Object[]) createArrayType(Object[].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        assertArrayEquals(new Object[]{42, (float)42.42, "Forty Two"}, objects);
+
+        // ur-type[4] nested element name have a global schema type
+        reader = new ElementReader(getClass().getResourceAsStream("arrayUrType2.xml"));
+        objects = (Object[]) createArrayType(Object[].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        assertArrayEquals(new Object[]{42, (float)42.42, "Forty Two"}, objects);
+
+        // round trip tests
+        objects = readWriteReadRef("arrayUrType1.xml", Object[].class);
+        assertArrayEquals(new Object[]{42, (float)42.42, "Forty Two"}, objects);
+        objects = readWriteReadRef("arrayUrType2.xml", Object[].class);
+        assertArrayEquals(new Object[]{42, (float)42.42, "Forty Two"}, objects);
+    }
+
+    @Test
+    public void testAnyTypeArray() throws Exception {
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        // ur-type[4] nested elements have xsi:type
+        ElementReader reader = new ElementReader(getClass().getResourceAsStream("arrayAnyType1.xml"));
+        Object[] objects = (Object[]) createArrayType(Object[].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        assertArrayEquals(new Object[]{42, (float)42.42, "Forty Two"}, objects);
+
+        // ur-type[4] nested element name have a global schema type
+        reader = new ElementReader(getClass().getResourceAsStream("arrayAnyType2.xml"));
+        objects = (Object[]) createArrayType(Object[].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        assertArrayEquals(new Object[]{42, (float)42.42, "Forty Two"}, objects);
+
+        // round trip tests
+        objects = readWriteReadRef("arrayAnyType1.xml", Object[].class);
+        assertArrayEquals(new Object[]{42, (float)42.42, "Forty Two"}, objects);
+        objects = readWriteReadRef("arrayAnyType2.xml", Object[].class);
+        assertArrayEquals(new Object[]{42, (float)42.42, "Forty Two"}, objects);
+    }
+
+    @Test
+    public void testStructArray() throws Exception {
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        // b:address[2]
+        ElementReader reader = new ElementReader(getClass().getResourceAsStream("arrayStructs.xml"));
+        Address[] addresses = (Address[]) createArrayType(Address[].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        StructTypeTest.validateShippingAddress(addresses[0]);
+        StructTypeTest.validateBillingAddress(addresses[1]);
+
+        // round trip tests
+        addresses = readWriteReadRef("arrayStructs.xml", Address[].class);
+        StructTypeTest.validateShippingAddress(addresses[0]);
+        StructTypeTest.validateBillingAddress(addresses[1]);
+    }
+
+    @Test
+    public void testSquareArray() throws Exception {
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        // xsd:string[2,3,4]
+        ElementReader reader = new ElementReader(getClass().getResourceAsStream("arraySquare.xml"));
+        String[][][] strings = (String[][][]) createArrayType(String[][][].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        assertArrayEquals(ARRAY_2_3_4, strings);
+
+        // round trip tests
+        strings = readWriteReadRef("arraySquare.xml", String[][][].class);
+        assertArrayEquals(ARRAY_2_3_4, strings);
+    }
+
+    @Test
+    public void testArrayOfArrays() throws Exception {
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        // xsd:string[,][2]
+        ElementReader reader = new ElementReader(getClass().getResourceAsStream("arrayArrayOfArrays1.xml"));
+        String[][][] strings = (String[][][]) createArrayType(String[][][].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        assertArrayEquals(ARRAY_2_3_4, strings);
+
+        // round trip tests
+        strings = readWriteReadRef("arrayArrayOfArrays1.xml", String[][][].class);
+        assertArrayEquals(ARRAY_2_3_4, strings);
+    }
+
+    @Test
+    public void testPartiallyTransmitted() throws Exception {
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        // xsd:int[5] offset="[2]"
+        ElementReader reader = new ElementReader(
+                getClass().getResourceAsStream("arrayPartiallyTransmitted.xml"));
+        int[] numbers = (int[]) createArrayType(int[].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        assertArrayEquals(new int[]{0, 0, 3, 4, 0}, numbers);
+
+        // round trip tests
+        numbers = readWriteReadRef("arrayPartiallyTransmitted.xml", int[].class);
+        assertArrayEquals(new int[]{0, 0, 3, 4, 0}, numbers);
+    }
+
+    @Test
+    public void testSparseArray() throws Exception {
+        Context context = new Context();
+        context.setTypeMapping(mapping);
+
+        // xsd:string[2,3,4]
+        ElementReader reader = new ElementReader(getClass().getResourceAsStream("arraySparse1.xml"));
+        String[][][] strings = (String[][][]) createArrayType(String[][][].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        verifySparseArray(strings);
+
+        // xsd:string[,][4] -> xsd:string[3,4]
+        reader = new ElementReader(getClass().getResourceAsStream("arraySparse2.xml"));
+        strings = (String[][][]) createArrayType(String[][][].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        verifySparseArray(strings);
+
+        // xsd:string[,][4] -> xsd:string[][3] -> xsd:string[4]
+        reader = new ElementReader(getClass().getResourceAsStream("arraySparse3.xml"));
+        strings = (String[][][]) createArrayType(String[][][].class).readObject(reader, context);
+        reader.getXMLStreamReader().close();
+        verifySparseArray(strings);
+
+        // round trip tests
+        strings = readWriteReadRef("arraySparse1.xml", String[][][].class);
+        verifySparseArray(strings);
+        strings = readWriteReadRef("arraySparse2.xml", String[][][].class);
+        verifySparseArray(strings);
+        strings = readWriteReadRef("arraySparse3.xml", String[][][].class);
+        verifySparseArray(strings);
+    }
+
+    @Test
+    public void testInvalidArray() throws Exception {
+        // to many elements
+        verifyInvalid("arrayInvalid1.xml", int[].class);
+        // position out of bounds
+        verifyInvalid("arrayInvalid2.xml", int[].class);
+        // array dimensions mismatch
+        verifyInvalid("arrayInvalid3.xml", int[].class);
+        verifyInvalid("arrayInvalid4.xml", int[][].class);
+        // array offset to large
+        verifyInvalid("arrayInvalid5.xml", int[].class);
+        verifyInvalid("arrayInvalid6.xml", int[].class);
+        // duplicate entry in sparse array
+        verifyInvalid("arrayInvalid7.xml", String[][][].class);
+        // position doesn't have enough positions
+        verifyInvalid("arrayInvalid8.xml", String[][][].class);
+        // position has too many positions
+        verifyInvalid("arrayInvalid9.xml", String[][][].class);
+    }
+
+    private void verifySparseArray(String[][][] strings) {
+        assertEquals("row1 col1 dep1", strings[0][0][0]);
+        strings[0][0][0] = null;
+        assertEquals("row2 col1 dep1", strings[1][0][0]);
+        strings[1][0][0] = null;
+        assertEquals("row1 col2 dep1", strings[0][1][0]);
+        strings[0][1][0] = null;
+        assertEquals("row1 col1 dep2", strings[0][0][1]);
+        strings[0][0][1] = null;
+
+        assertEquals("row1 col3 dep1", strings[0][2][0]);
+        strings[0][2][0] = null;
+        assertEquals("row1 col1 dep4", strings[0][0][3]);
+        strings[0][0][3] = null;
+
+        assertEquals("row2 col3 dep4", strings[1][2][3]);
+        strings[1][2][3] = null;
+
+        assertEquals("row2 col3 dep2", strings[1][2][1]);
+        strings[1][2][1] = null;
+        assertEquals("row1 col2 dep3", strings[0][1][2]);
+        strings[0][1][2] = null;
+
+        assertEquals(2, strings.length);
+        for (int i = 0; i < strings.length; i++) {
+            if (strings[i] != null) {
+                assertEquals(3, strings[i].length);
+                for (int j = 0; j < strings[i].length; j++) {
+                    if (strings[i][j] != null) {
+                        assertEquals(4, strings[i][j].length);
+                        for (int k = 0; k < strings[i][j].length; k++) {
+                            assertNull("strings[" + i + "][" + j + "][" + k + "] is not null", 
+                                    strings[i][j][k]);
+                        }
+                    }
+                }
+            }
+        }
+    }
+
+    private SoapArrayType createArrayType(Class<?> typeClass) {
+        return createArrayType(typeClass, new QName("urn:Bean", "stuff"));
+    }
+
+    private SoapArrayType createArrayType(Class<?> typeClass, QName schemaType) {
+        Type type = mapping.getType(typeClass);
+        if (type != null) {
+            return (SoapArrayType) type;
+        }
+        SoapArrayType arrayType = new SoapArrayType();
+        arrayType.setTypeClass(typeClass);
+        arrayType.setTypeMapping(mapping);
+        arrayType.setSchemaType(schemaType);
+        return arrayType;
+    }
+}
\ No newline at end of file

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

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

Modified: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java?rev=604317&r1=604316&r2=604317&view=diff
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java (original)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/StructTypeTest.java Fri Dec 14 14:33:57 2007
@@ -18,23 +18,14 @@
  */
 package org.apache.cxf.aegis.type.encoded;
 
-import java.util.List;
 import java.util.Map;
 import java.util.TreeMap;
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
 
-import org.apache.cxf.aegis.AbstractAegisTest;
 import org.apache.cxf.aegis.Context;
-import org.apache.cxf.aegis.type.DefaultTypeMappingRegistry;
-import org.apache.cxf.aegis.type.Type;
-import org.apache.cxf.aegis.type.TypeMapping;
 import org.apache.cxf.aegis.type.basic.BeanTypeInfo;
-import org.apache.cxf.aegis.xml.MessageReader;
-import org.apache.cxf.aegis.xml.MessageWriter;
 import org.apache.cxf.aegis.xml.jdom.JDOMWriter;
 import org.apache.cxf.aegis.xml.stax.ElementReader;
-import org.apache.cxf.common.util.SOAPConstants;
 import org.apache.cxf.helpers.CastUtils;
 import org.jdom.Attribute;
 import org.jdom.Content;
@@ -43,22 +34,13 @@
 import org.jdom.output.XMLOutputter;
 import org.junit.Test;
 
-public class StructTypeTest extends AbstractAegisTest {
-    private TypeMapping mapping;
+public class StructTypeTest extends AbstractEncodedTest {
     private StructType addressType;
     private StructType purchaseOrderType;
-    private TrailingBlocks trailingBlocks;
 
     public void setUp() throws Exception {
         super.setUp();
 
-        addNamespace("b", "urn:Bean");
-        addNamespace("a", "urn:anotherns");
-        addNamespace("xsi", SOAPConstants.XSI_NS);
-
-        DefaultTypeMappingRegistry reg = new DefaultTypeMappingRegistry(true);
-        mapping = reg.createTypeMapping(true);
-
         // address type
         BeanTypeInfo addressInfo = new BeanTypeInfo(Address.class, "urn:Bean");
         addressInfo.setTypeMapping(mapping);
@@ -77,11 +59,6 @@
         purchaseOrderType.setTypeMapping(mapping);
         purchaseOrderType.setSchemaType(new QName("urn:Bean", "po"));
         mapping.register(purchaseOrderType);
-
-        // serialization root type
-        trailingBlocks = new TrailingBlocks();
-//        trailingBlocks.setTypeMapping(mapping);
-
     }
 
     @Test
@@ -89,13 +66,13 @@
         // Test reading
         ElementReader reader = new ElementReader(getClass().getResourceAsStream("struct1.xml"));
         Address address = (Address) addressType.readObject(reader, new Context());
-        validateAddress(address);
+        validateShippingAddress(address);
         reader.getXMLStreamReader().close();
 
         // Test reading - no namespace on nested elements
         reader = new ElementReader(getClass().getResourceAsStream("struct2.xml"));
         address = (Address) addressType.readObject(reader, new Context());
-        validateAddress(address);
+        validateShippingAddress(address);
         reader.getXMLStreamReader().close();
 
         // Test writing
@@ -146,64 +123,7 @@
         validatePurchaseOrder(element);
     }
 
-    private Object readRef(String file) throws XMLStreamException {
-        Context context = new Context();
-        context.setTypeMapping(mapping);
-        ElementReader root = new ElementReader(getClass().getResourceAsStream(file));
-
-        // get Type based on the element qname
-        MessageReader reader = root.getNextElementReader();
-        Type type = this.mapping.getType(reader.getName());
-        assertNotNull("type is null", type);
-
-        // read ref
-        SoapRefType soapRefType = new SoapRefType(type);
-        SoapRef ref = (SoapRef) soapRefType.readObject(reader, context);
-        reader.readToEnd();
-
-        // read the trailing blocks (referenced objects)
-        List<Object> roots = trailingBlocks.readBlocks(root, context);
-        assertNotNull(roots);
-
-        // close the input stream
-        root.getXMLStreamReader().close();
-
-        // return the ref
-        return ref.get();
-    }
-
-    private Element writeRef(Object instance) {
-        // create the document
-        Element element = new Element("root", "b", "urn:Bean");
-        new Document(element);
-        JDOMWriter rootWriter = new JDOMWriter(element);
-        Context context = new Context();
-        context.setTypeMapping(mapping);
-
-        // get Type based on the object instance
-        Type type = this.mapping.getType(instance.getClass());
-        assertNotNull("type is null", type);
-
-        // write the ref
-        SoapRefType soapRefType = new SoapRefType(type);
-        MessageWriter cwriter = rootWriter.getElementWriter(soapRefType.getSchemaType());
-        soapRefType.writeObject(instance, cwriter, context);
-        cwriter.close();
-
-        // write the trailing blocks (referenced objects)
-        trailingBlocks.writeBlocks(rootWriter, context);
-        return element;
-    }
-
-    private void validateAddress(Address address) {
-        assertNotNull(address);
-        assertEquals("1234 Riverside Drive", address.getStreet());
-        assertEquals("Gainesville", address.getCity());
-        assertEquals("FL", address.getState());
-        assertEquals("30506", address.getZip());
-    }
-
-    private void validateShippingAddress(Element shipping) {
+    public static void validateShippingAddress(Element shipping) {
         assertNotNull("shipping is null", shipping);
         assertChildEquals("1234 Riverside Drive", shipping, "street");
         assertChildEquals("Gainesville", shipping, "city");
@@ -211,7 +131,7 @@
         assertChildEquals("30506", shipping, "zip");
     }
 
-    private void validateBillingAddress(Element billing) {
+    public static void validateBillingAddress(Element billing) {
         assertNotNull("billing is null", billing);
         assertChildEquals("1234 Fake Street", billing, "street");
         assertChildEquals("Las Vegas", billing, "city");
@@ -270,7 +190,7 @@
         return refElement;
     }
 
-    private void assertChildEquals(String expected, Element element, String childName) {
+    private static void assertChildEquals(String expected, Element element, String childName) {
         assertEquals(expected, element.getChild(childName).getText());
     }
 

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType1.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType1.xml?rev=604317&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType1.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType1.xml Fri Dec 14 14:33:57 2007
@@ -0,0 +1,31 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<b:numbers
+    xmlns:b="urn:Bean"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+    soapenc:arrayType="xsd:anyType[3]">
+
+  <thing xsi:type="xsd:int">42</thing>
+  <thing xsi:type="xsd:float">42.42</thing>
+  <thing xsi:type="xsd:string">
+    Forty Two
+  </thing>
+</b:numbers>

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType1.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType1.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType2.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType2.xml?rev=604317&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType2.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType2.xml Fri Dec 14 14:33:57 2007
@@ -0,0 +1,31 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<b:numbers
+    xmlns:b="urn:Bean"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+    soapenc:arrayType="xsd:anyType[3]">
+
+  <soapenc:int>42</soapenc:int>
+  <soapenc:decimal>42.42</soapenc:decimal>
+  <xsd:string>
+    Forty Two
+  </xsd:string>
+</b:numbers>

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType2.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType2.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayAnyType2.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayArrayOfArrays1.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayArrayOfArrays1.xml?rev=604317&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayArrayOfArrays1.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayArrayOfArrays1.xml Fri Dec 14 14:33:57 2007
@@ -0,0 +1,59 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<strings
+    xmlns:b="urn:Bean"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+    soapenc:arrayType="xsd:string[,][2]">
+
+  <arrayOfArrays soapenc:arrayType="xsd:string[3,4]">
+    <item>row1 col1 dep1</item>
+    <item>row1 col1 dep2</item>
+    <item>row1 col1 dep3</item>
+    <item>row1 col1 dep4</item>
+
+    <item>row1 col2 dep1</item>
+    <item>row1 col2 dep2</item>
+    <item>row1 col2 dep3</item>
+    <item>row1 col2 dep4</item>
+
+    <item>row1 col3 dep1</item>
+    <item>row1 col3 dep2</item>
+    <item>row1 col3 dep3</item>
+    <item>row1 col3 dep4</item>
+  </arrayOfArrays>
+
+  <arrayOfArrays soapenc:arrayType="xsd:string[3,4]">
+    <item>row2 col1 dep1</item>
+    <item>row2 col1 dep2</item>
+    <item>row2 col1 dep3</item>
+    <item>row2 col1 dep4</item>
+
+    <item>row2 col2 dep1</item>
+    <item>row2 col2 dep2</item>
+    <item>row2 col2 dep3</item>
+    <item>row2 col2 dep4</item>
+
+    <item>row2 col3 dep1</item>
+    <item>row2 col3 dep2</item>
+    <item>row2 col3 dep3</item>
+    <item>row2 col3 dep4</item>
+  </arrayOfArrays>
+</strings>

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayArrayOfArrays1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayArrayOfArrays1.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayArrayOfArrays1.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid1.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid1.xml?rev=604317&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid1.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid1.xml Fri Dec 14 14:33:57 2007
@@ -0,0 +1,29 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<b:numbers
+    xmlns:b="urn:Bean"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+    soapenc:arrayType="xsd:int[2]">
+
+  <number>3</number>
+  <number>4</number>
+  <number>42</number>
+</b:numbers>

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid1.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid1.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid1.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid2.xml
URL: http://svn.apache.org/viewvc/incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid2.xml?rev=604317&view=auto
==============================================================================
--- incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid2.xml (added)
+++ incubator/cxf/trunk/rt/databinding/aegis/src/test/java/org/apache/cxf/aegis/type/encoded/arrayInvalid2.xml Fri Dec 14 14:33:57 2007
@@ -0,0 +1,27 @@
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements. See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership. The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied. See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<b:numbers
+    xmlns:b="urn:Bean"
+    xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+    xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
+    soapenc:arrayType="xsd:int[2]">
+
+  <number soapenc:position="[3]">3</number>
+</b:numbers>



Mime
View raw message