You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2006/10/25 07:05:18 UTC
svn commit: r467564 [1/2] - in
/webservices/axis2/branches/java/1_1/modules/adb-codegen:
src/org/apache/axis2/schema/ src/org/apache/axis2/schema/template/
src/org/apache/axis2/schema/writer/ test-resources/testsuite/
test/org/apache/axis2/schema/tests...
Author: dims
Date: Tue Oct 24 22:05:17 2006
New Revision: 467564
URL: http://svn.apache.org/viewvc?view=rev&rev=467564
Log:
Fix for AXIS2-1490 - ADB Testsuite
Added:
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AnyElementsTest.java
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/OuterElementsTest.java
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/XsdAnyElementsTest.java
Modified:
webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
webservices/axis2/branches/java/1_1/modules/adb-codegen/test-resources/testsuite/complete.xsd
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AbstractTest.java
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/CustomElementsTest.java
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/IntElementsTest.java
webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/StringElementsTest.java
Modified: webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java?view=diff&rev=467564&r1=467563&r2=467564
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java (original)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/BeanWriterMetaInfoHolder.java Tue Oct 24 22:05:17 2006
@@ -42,8 +42,8 @@
protected boolean restriction = false;
private String extensionClassName = "";
private String restrictionClassName = "";
- private QName extensionBaseType = null;
- private QName restrictionBaseType = null;
+ private QName extensionBaseType = null;
+ private QName restrictionBaseType = null;
protected Map elementToSchemaQNameMap = new LinkedHashMap();
protected Map elementToJavaClassMap = new LinkedHashMap();
protected Map specialTypeFlagMap = new LinkedHashMap();
@@ -52,7 +52,7 @@
protected Map qNameOrderMap = new LinkedHashMap();
protected QName ownQname = null;
protected String ownClassName = null;
-
+
protected long lengthFacet = -1;
protected long maxLengthFacet = -1;
protected long minLengthFacet = -1;
@@ -63,7 +63,7 @@
protected String maxInclusiveFacet = null;
protected String minInclusiveFacet = null;
- protected List nillableQNameList = new ArrayList();
+ protected List nillableQNameList = new ArrayList();
//the parent metainfo holder, useful in handling extensions and
//restrictions
@@ -156,7 +156,6 @@
}
-
/**
* Sets the extension status.
*
@@ -169,7 +168,7 @@
public String getRestrictionClassName() {
return restrictionClassName;
}
-
+
/**
* Sets the restriction base class name. Valid only when the isRestriction
* returns true.
@@ -179,7 +178,7 @@
public void setRestrictionClassName(String restrictionClassName) {
this.restrictionClassName = restrictionClassName;
}
-
+
/**
* Gets the restriction status.
*
@@ -188,7 +187,7 @@
public boolean isRestriction() {
return restriction;
}
-
+
/**
* Sets the restriction status.
*
@@ -197,7 +196,7 @@
public void setRestriction(boolean restriction) {
this.restriction = restriction;
}
-
+
/**
* Sets the extension basetype.
*
@@ -206,7 +205,7 @@
public void setExtensionBaseType(QName extensionBaseType) {
this.extensionBaseType = extensionBaseType;
}
-
+
/**
* Checks if it is a extension base type.
*
@@ -215,7 +214,7 @@
public boolean isExtensionBaseType(QName extensionBaseType) {
return (this.extensionBaseType == extensionBaseType);
}
-
+
/**
* Sets the restriction basetype.
*
@@ -224,7 +223,7 @@
public void setRestrictionBaseType(QName restrictionBaseType) {
this.restrictionBaseType = restrictionBaseType;
}
-
+
/**
* Checks if it is a restriction base type.
*
@@ -233,7 +232,7 @@
public boolean isRestrictionBaseType(QName restrictionBaseType) {
return (this.restrictionBaseType == restrictionBaseType);
}
-
+
/**
* Gets the ordered status.
*
@@ -244,7 +243,7 @@
}
/**
- * Sets the ordered flag.
+ * Sets the ordered flag.
*
* @param ordered
*/
@@ -264,7 +263,8 @@
}
- /** Registers a Qname as nillable
+ /**
+ * Registers a Qname as nillable
* The qName better be of an element
*
* @param qName
@@ -277,6 +277,7 @@
/**
* Returns whether a QName is nillable or not
+ *
* @param eltQName
*/
public boolean isNillable(QName eltQName) {
@@ -327,10 +328,27 @@
public boolean getAttributeStatusForQName(QName qName) {
Integer state = (Integer) specialTypeFlagMap.get(qName);
- return state != null && getStatus(state.intValue(),SchemaConstants.ATTRIBUTE_TYPE);
+ return state != null && getStatus(state.intValue(), SchemaConstants.ATTRIBUTE_TYPE);
}
/**
+ * checks the element corresponds to the qName type is xsd:anyType
+ *
+ * @param qName
+ * @return is element corresponds to qName has xsd:anyType
+ */
+
+ public boolean getDefaultStatusForQName(QName qName) {
+ boolean isDefault = false;
+ QName schemaTypeQName = (QName) this.elementToSchemaQNameMap.get(qName);
+ if (schemaTypeQName != null) {
+ isDefault = schemaTypeQName.equals(SchemaConstants.XSD_ANYTYPE);
+ }
+ return isDefault;
+ }
+
+
+ /**
* Gets whether a given QName represents a anyType
*
* @param qName
@@ -338,7 +356,7 @@
*/
public boolean getAnyStatusForQName(QName qName) {
Integer state = (Integer) specialTypeFlagMap.get(qName);
- return state != null && getStatus(state.intValue(),SchemaConstants.ANY_TYPE);
+ return state != null && getStatus(state.intValue(), SchemaConstants.ANY_TYPE);
}
/**
@@ -384,22 +402,22 @@
* @return Returns boolean.
*/
public boolean getAnyAttributeStatusForQName(QName qName) {
- return getArrayStatusForQName(qName) &&
- getAnyStatusForQName(qName);
+ return getArrayStatusForQName(qName) &&
+ getAnyStatusForQName(qName);
}
/**
* Gets whether a given QName has the optional attribute status.
- *
+ *
* @param qName QName of attribute
* @return Returns <code>true</code> if attribute has optional status
*/
public boolean getOptionalAttributeStatusForQName(QName qName) {
Integer state = (Integer) specialTypeFlagMap.get(qName);
return state != null && getStatus(state.intValue(),
- SchemaConstants.OPTIONAL_TYPE);
+ SchemaConstants.OPTIONAL_TYPE);
}
-
+
/**
* Clears the whole set of tables.
*/
@@ -507,28 +525,30 @@
//add them explicitly to the end of this list
QName[] allNames = getQNameArray();
for (int i = 0; i < allNames.length; i++) {
- if(getAttributeStatusForQName(allNames[i])){
+ if (getAttributeStatusForQName(allNames[i])) {
returnQNames.add(allNames[i]);
}
}
- return (QName[])returnQNames.toArray(new QName[returnQNames.size()]);
+ return (QName[]) returnQNames.toArray(new QName[returnQNames.size()]);
}
/**
- * Finds the starting count for the addition of new items to the order
+ * Finds the starting count for the addition of new items to the order
+ *
* @return the starting number for the sequence
*/
- public int getOrderStartPoint(){
+ public int getOrderStartPoint() {
return qNameOrderMap.size();
}
/**
* Creates link to th
+ *
* @param metaInfo
*/
- public void setAsParent(BeanWriterMetaInfoHolder metaInfo){
+ public void setAsParent(BeanWriterMetaInfoHolder metaInfo) {
parent = metaInfo;
}
@@ -536,196 +556,197 @@
* Adds a another status to a particular Qname.
* A Qname can be associated with multiple status flags
* and they all will be preserved
+ *
* @param type
* @param mask
*/
- public void addtStatus(QName type,int mask){
+ public void addtStatus(QName type, int mask) {
Object obj = this.specialTypeFlagMap.get(type);
- if (obj!=null){
- int preValue = ((Integer)obj).intValue();
+ if (obj != null) {
+ int preValue = ((Integer) obj).intValue();
this.specialTypeFlagMap.put(type, new Integer((preValue | mask)));
- }else{
+ } else {
this.specialTypeFlagMap.put(type, new Integer(mask));
}
}
- private boolean getStatus(int storedStatus,int mask){
+ private boolean getStatus(int storedStatus, int mask) {
//when the mask is anded with the status then we should get
//the mask it self!
- return (mask==(mask & storedStatus));
+ return (mask == (mask & storedStatus));
}
-
+
/**
* Sets the length facet.
*
* @param lengthFacet
*/
public void setLengthFacet(long lengthFacet) {
- this.lengthFacet = lengthFacet;
+ this.lengthFacet = lengthFacet;
}
-
+
/**
* Gets the length facet.
*
* @return Returns length facet.
*/
public long getLengthFacet() {
- return this.lengthFacet;
+ return this.lengthFacet;
}
-
+
/**
* Sets the maxExclusive.
*
* @param maxExclusiveFacet
*/
public void setMaxExclusiveFacet(String maxExclusiveFacet) {
- this.maxExclusiveFacet = maxExclusiveFacet;
+ this.maxExclusiveFacet = maxExclusiveFacet;
}
-
+
/**
* Gets the maxExclusive.
*
* @return Returns the maxExclusive.
*/
public String getMaxExclusiveFacet() {
- return this.maxExclusiveFacet;
+ return this.maxExclusiveFacet;
}
-
+
/**
* Sets the minExclusive.
*
* @param minExclusiveFacet
*/
public void setMinExclusiveFacet(String minExclusiveFacet) {
- this.minExclusiveFacet = minExclusiveFacet;
+ this.minExclusiveFacet = minExclusiveFacet;
}
-
+
/**
* Gets the minExclusive.
*
* @return Returns the minExclusive.
*/
public String getMinExclusiveFacet() {
- return this.minExclusiveFacet;
+ return this.minExclusiveFacet;
}
-
+
/**
* Sets the maxInclusive.
*
* @param maxInclusiveFacet
*/
public void setMaxInclusiveFacet(String maxInclusiveFacet) {
- this.maxInclusiveFacet = maxInclusiveFacet;
+ this.maxInclusiveFacet = maxInclusiveFacet;
}
-
+
/**
* Gets the maxInclusive.
*
* @return Returns the maxInclusive.
*/
public String getMaxInclusiveFacet() {
- return this.maxInclusiveFacet;
+ return this.maxInclusiveFacet;
}
-
+
/**
* Sets the minInclusive.
*
* @param minInclusiveFacet
*/
public void setMinInclusiveFacet(String minInclusiveFacet) {
- this.minInclusiveFacet = minInclusiveFacet;
+ this.minInclusiveFacet = minInclusiveFacet;
}
-
+
/**
* Gets the minInclusive.
*
* @return Returns the minInclusive.
*/
public String getMinInclusiveFacet() {
- return this.minInclusiveFacet;
+ return this.minInclusiveFacet;
}
-
+
/**
* Sets the maxLength.
*
* @param maxLengthFacet
*/
public void setMaxLengthFacet(long maxLengthFacet) {
- this.maxLengthFacet = maxLengthFacet;
+ this.maxLengthFacet = maxLengthFacet;
}
-
+
/**
* Gets the maxLength.
*
* @return Returns maxLength.
*/
public long getMaxLengthFacet() {
- return this.maxLengthFacet;
+ return this.maxLengthFacet;
}
-
+
/**
* Sets the minLength.
*
* @param minLengthFacet
*/
public void setMinLengthFacet(long minLengthFacet) {
- this.minLengthFacet = minLengthFacet;
+ this.minLengthFacet = minLengthFacet;
}
-
+
/**
* Gets the minLength.
*
* @return Returns minLength.
*/
public long getMinLengthFacet() {
- return this.minLengthFacet;
+ return this.minLengthFacet;
}
-
+
/**
* Sets the enumeration.
*
* @param enumFacet
*/
public void setEnumFacet(ArrayList enumFacet) {
- this.enumFacet = enumFacet;
+ this.enumFacet = enumFacet;
}
-
+
/**
* Adds the enumeration.
*
* @param enumFacet
*/
public void addEnumFacet(String enumFacet) {
- this.enumFacet.add(enumFacet);
+ this.enumFacet.add(enumFacet);
}
-
+
/**
* Gets the enumeration.
*
* @return Returns enumeration.
*/
public List getEnumFacet() {
- return this.enumFacet;
+ return this.enumFacet;
}
-
+
/**
* Sets the pattern.
*
* @param patternFacet
*/
public void setPatternFacet(String patternFacet) {
- this.patternFacet = patternFacet;
+ this.patternFacet = patternFacet;
}
-
+
/**
* Gets the pattern.
*
* @return Returns pattern.
*/
public String getPatternFacet() {
- return this.patternFacet;
+ return this.patternFacet;
}
}
Modified: webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl?view=diff&rev=467564&r1=467563&r2=467564
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl (original)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/template/ADBBeanTemplate.xsl Tue Oct 24 22:05:17 2006
@@ -750,7 +750,27 @@
if (<xsl:value-of select="$varName"/>!=null){
for (int i = 0;i < <xsl:value-of select="$varName"/>.length;i++){
if (<xsl:value-of select="$varName"/>[i] != null){
- <xsl:value-of select="$varName"/>[i].serialize(xmlWriter);
+ // write null attribute
+ java.lang.String namespace2 = "<xsl:value-of select="$namespace"/>";
+ if (! namespace2.equals("")) {
+ java.lang.String prefix2 = xmlWriter.getPrefix(namespace2);
+
+ if (prefix2 == null) {
+ prefix2 = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
+
+ xmlWriter.writeStartElement(prefix2,"<xsl:value-of select="$propertyName"/>", namespace2);
+ xmlWriter.writeNamespace(prefix2, namespace2);
+ xmlWriter.setPrefix(prefix2, namespace2);
+
+ } else {
+ xmlWriter.writeStartElement(namespace2,"<xsl:value-of select="$propertyName"/>");
+ }
+
+ } else {
+ xmlWriter.writeStartElement("<xsl:value-of select="$propertyName"/>");
+ }
+ <xsl:value-of select="$varName"/>[i].serialize(xmlWriter);
+ xmlWriter.writeEndElement();
} else {
<xsl:choose>
<xsl:when test="@nillable">
@@ -825,7 +845,27 @@
<xsl:when test="@default and not(@array)">
<!-- Note - Assumed to be OMElement-->
if (<xsl:value-of select="$varName"/>!=null){
+ // write null attribute
+ java.lang.String namespace2 = "<xsl:value-of select="$namespace"/>";
+ if (! namespace2.equals("")) {
+ java.lang.String prefix2 = xmlWriter.getPrefix(namespace2);
+
+ if (prefix2 == null) {
+ prefix2 = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
+
+ xmlWriter.writeStartElement(prefix2,"<xsl:value-of select="$propertyName"/>", namespace2);
+ xmlWriter.writeNamespace(prefix2, namespace2);
+ xmlWriter.setPrefix(prefix2, namespace2);
+
+ } else {
+ xmlWriter.writeStartElement(namespace2,"<xsl:value-of select="$propertyName"/>");
+ }
+
+ } else {
+ xmlWriter.writeStartElement("<xsl:value-of select="$propertyName"/>");
+ }
<xsl:value-of select="$varName"/>.serialize(xmlWriter);
+ xmlWriter.writeEndElement();
} else {
<xsl:choose>
<xsl:when test="@nillable">
@@ -1188,36 +1228,43 @@
}
<xsl:if test="not($primitive)">
if (<xsl:value-of select="$varName"/>==null){
- // write the nil attribute
- writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ <xsl:choose>
+ <xsl:when test="$nillable">
+ // write the nil attribute
+ writeAttribute("xsi","http://www.w3.org/2001/XMLSchema-instance","nil","true",xmlWriter);
+ </xsl:when>
+ <xsl:otherwise>
+ throw new RuntimeException("testValue cannot be null !!");
+ </xsl:otherwise>
+ </xsl:choose>
}else{
- <xsl:choose>
- <xsl:when test="$propertyType='javax.xml.namespace.QName'">
- java.lang.String prefix ="";
- java.lang.String namespaceURI =<xsl:value-of select="$varName"/>.getNamespaceURI();
- if(namespaceURI !=null){
- prefix = <xsl:value-of select="$varName"/>.getPrefix();
- if (prefix == null) {
- prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
- }
- xmlWriter.writeNamespace(prefix,namespaceURI );
- xmlWriter.writeCharacters(prefix + ":"+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
- } else {
+ <xsl:choose>
+ <xsl:when test="$propertyType='javax.xml.namespace.QName'">
+ java.lang.String prefix ="";
+ java.lang.String namespaceURI =<xsl:value-of select="$varName"/>.getNamespaceURI();
+ if(namespaceURI !=null){
+ prefix = <xsl:value-of select="$varName"/>.getPrefix();
+ if (prefix == null) {
+ prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix();
+ }
+ xmlWriter.writeNamespace(prefix,namespaceURI );
+ xmlWriter.writeCharacters(prefix + ":"+ org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
+ } else {
+ xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
+ }
+ </xsl:when>
+ <xsl:when test="$propertyType='org.apache.axiom.om.OMElement'">
+ <xsl:value-of select="$varName"/>.serialize(xmlWriter);
+ </xsl:when>
+ <xsl:otherwise>
xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
- }
- </xsl:when>
- <xsl:when test="$propertyType='org.apache.axiom.om.OMElement'">
- <xsl:value-of select="$varName"/>.serialize(xmlWriter);
- </xsl:when>
- <xsl:otherwise>
- xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
- </xsl:otherwise>
- </xsl:choose>
+ </xsl:otherwise>
+ </xsl:choose>
}
</xsl:if>
- <xsl:if test="$primitive">
- xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
- </xsl:if>
+ <xsl:if test="$primitive">
+ xmlWriter.writeCharacters(org.apache.axis2.databinding.utils.ConverterUtil.convertToString(<xsl:value-of select="$varName"/>));
+ </xsl:if>
xmlWriter.writeEndElement();
</xsl:otherwise>
</xsl:choose>
@@ -1291,7 +1338,6 @@
parentQName,factory,dataSource);
</xsl:when>
<xsl:otherwise>
- //ignore the QName passed in - we send only OUR QName!
return new org.apache.axiom.om.impl.llom.OMSourcedElementImpl(
MY_QNAME,factory,dataSource);
</xsl:otherwise>
@@ -1605,7 +1651,15 @@
// Skip the element and report the null value. It cannot have subelements.
while (!reader.isEndElement())
reader.next();
- return null;
+ <xsl:choose>
+ <xsl:when test="@type or @anon">
+ return null;
+ </xsl:when>
+ <xsl:otherwise>
+ return object;
+ </xsl:otherwise>
+ </xsl:choose>
+
}
</xsl:if>
<xsl:if test="$isType or $anon">
@@ -1820,30 +1874,71 @@
<!-- End of Array handling of ADB classes -->
<!--Let's handle xs:any here-->
- <xsl:when test="$shortTypeName='OMElement'">
+ <xsl:when test="@any">
boolean <xsl:value-of select="$loopBoolName"/>=false;
while (!<xsl:value-of select="$loopBoolName"/>){
event = reader.getEventType();
if (javax.xml.stream.XMLStreamConstants.START_ELEMENT == event){
- <!-- if-block that handles nillable -->
- <xsl:if test="@nillable">
- if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
- <xsl:value-of select="$listName"/>.add(null);
- }else{
- </xsl:if>
-
// We need to wrap the reader so that it produces a fake START_DOCUEMENT event
org.apache.axis2.databinding.utils.NamedStaxOMBuilder <xsl:value-of select="$builderName"/>
= new org.apache.axis2.databinding.utils.NamedStaxOMBuilder(
new org.apache.axis2.util.StreamWrapper(reader), reader.getName());
<xsl:value-of select="$listName"/>.add(<xsl:value-of select="$builderName"/>.getOMElement());
+ reader.next();
+ if (reader.isEndElement()) {
+ // we have two countinuos end elements
+ loopDone1 = true;
+ }
+
+ }else if (javax.xml.stream.XMLStreamConstants.END_DOCUMENT == event){
+ <xsl:value-of select="$loopBoolName"/> = true;
+ }else{
+ reader.next();
+ }
+
+ }
+
+ object.set<xsl:value-of select="$javaName"/>((<xsl:value-of select="$propertyType"/>)
+ org.apache.axis2.databinding.utils.ConverterUtil.convertToArray(
+ <xsl:value-of select="$basePropertyType"/>.class,<xsl:value-of select="$listName"/>));
+ </xsl:when>
+
+ <!-- End of Array handling of ADB classes -->
+ <xsl:when test="@default">
+
+ boolean <xsl:value-of select="$loopBoolName"/>=false;
+ javax.xml.namespace.QName <xsl:value-of select="$startQname"/> = new javax.xml.namespace.QName(
+ "<xsl:value-of select="$namespace"/>",
+ "<xsl:value-of select="$propertyName"/>");
+
+ while (!<xsl:value-of select="$loopBoolName"/>){
+ event = reader.getEventType();
+ if (javax.xml.stream.XMLStreamConstants.START_ELEMENT == event
+ && <xsl:value-of select="$startQname"/>.equals(reader.getName())){
+
+ <!-- if-block that handles nillable -->
+ <xsl:if test="@nillable">
+ if ("true".equals(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","nil"))){
+ <xsl:value-of select="$listName"/>.add(null);
+ reader.next();
+ }else{
+ </xsl:if>
+ // we parse it as an omElement
+ // We need to wrap the reader so that it produces a fake START_DOCUEMENT event
+ // this is needed by the builder classes
+ org.apache.axis2.databinding.utils.NamedStaxOMBuilder <xsl:value-of select="$builderName"/> =
+ new org.apache.axis2.databinding.utils.NamedStaxOMBuilder(
+ new org.apache.axis2.util.StreamWrapper(reader),<xsl:value-of select="$startQname"/>);
+ <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$builderName"/>.getOMElement().getFirstElement());
<xsl:if test="@nillable">}</xsl:if>
- } else if (javax.xml.stream.XMLStreamConstants.START_ELEMENT == event){
+ } else if (javax.xml.stream.XMLStreamConstants.START_ELEMENT == event &&
+ !<xsl:value-of select="$startQname"/>.equals(reader.getName())){
<xsl:value-of select="$loopBoolName"/> = true;
- }else if (javax.xml.stream.XMLStreamConstants.END_ELEMENT == event){
+ }else if (javax.xml.stream.XMLStreamConstants.END_ELEMENT == event &&
+ !<xsl:value-of select="$startQname"/>.equals(reader.getName())){
<xsl:value-of select="$loopBoolName"/> = true;
}else if (javax.xml.stream.XMLStreamConstants.END_DOCUMENT == event){
<xsl:value-of select="$loopBoolName"/> = true;
@@ -1856,8 +1951,8 @@
object.set<xsl:value-of select="$javaName"/>((<xsl:value-of select="$propertyType"/>)
org.apache.axis2.databinding.utils.ConverterUtil.convertToArray(
<xsl:value-of select="$basePropertyType"/>.class,<xsl:value-of select="$listName"/>));
- </xsl:when>
+ </xsl:when>
<xsl:otherwise>
<xsl:choose>
@@ -1884,7 +1979,7 @@
= new org.apache.axis2.databinding.utils.NamedStaxOMBuilder(
new org.apache.axis2.util.StreamWrapper(reader), <xsl:value-of select="$startQname"/>);
- <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$builderName"/>.getOMElement());
+ <xsl:value-of select="$listName"/>.add(<xsl:value-of select="$builderName"/>.getOMElement().getFirstElement());
<xsl:if test="@nillable">}</xsl:if>
} else if (javax.xml.stream.XMLStreamConstants.START_ELEMENT == event &&
!<xsl:value-of select="$startQname"/>.equals(reader.getName())){
@@ -2008,7 +2103,7 @@
org.apache.axis2.databinding.utils.NamedStaxOMBuilder <xsl:value-of select="$builderName"/> =
new org.apache.axis2.databinding.utils.NamedStaxOMBuilder(
new org.apache.axis2.util.StreamWrapper(reader),<xsl:value-of select="$startQname"/>);
- object.set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$builderName"/>.getOMElement());
+ object.set<xsl:value-of select="$javaName"/>(<xsl:value-of select="$builderName"/>.getOMElement().getFirstElement());
<xsl:if test="$isType or $anon"> <!-- This is a subelement property to be consumed -->
reader.next();
</xsl:if>
Modified: webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java?view=diff&rev=467564&r1=467563&r2=467564
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java (original)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/src/org/apache/axis2/schema/writer/JavaBeanWriter.java Tue Oct 24 22:05:17 2006
@@ -23,6 +23,7 @@
import java.io.*;
import java.util.*;
+
/*
* Copyright 2004,2005 The Apache Software Foundation.
*
@@ -583,7 +584,7 @@
XSLTUtils.addAttribute(model, "primitive", "yes", property);
}
// add an attribute that says the type is default
- if (isDefault(javaClassNameForElement)) {
+ if (metainf.getDefaultStatusForQName(name)) {
XSLTUtils.addAttribute(model, "default", "yes", property);
}
Modified: webservices/axis2/branches/java/1_1/modules/adb-codegen/test-resources/testsuite/complete.xsd
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/test-resources/testsuite/complete.xsd?view=diff&rev=467564&r1=467563&r2=467564
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/test-resources/testsuite/complete.xsd (original)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/test-resources/testsuite/complete.xsd Tue Oct 24 22:05:17 2006
@@ -241,91 +241,64 @@
</element>
- <!-- generating elemens for any types -->
- <element name="testOM1">
- <complexType>
- <sequence>
- <element name="testValue" minOccurs="0" nillable="true" maxOccurs="unbounded"
- type="xsd:anyType"/>
- </sequence>
- </complexType>
- </element>
- <element name="testOM2">
- <complexType>
- <sequence>
- <element name="testValue" minOccurs="0" nillable="true" type="xsd:anyType"/>
- </sequence>
- </complexType>
- </element>
- <element name="testOM3">
- <complexType>
- <sequence>
- <element name="testValue" minOccurs="0" maxOccurs="unbounded" type="xsd:anyType"/>
- </sequence>
- </complexType>
- </element>
- <element name="testOM4">
- <complexType>
- <sequence>
- <element name="testValue" minOccurs="0" type="xsd:anyType"/>
- </sequence>
- </complexType>
- </element>
- <element name="testOM5">
+ <!-- generating elemens for any elements -->
+ <element name="testAny1">
<complexType>
<sequence>
- <element name="testValue" nillable="true" maxOccurs="unbounded" type="xsd:anyType"/>
+ <any minOccurs="0" maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
- <element name="testOM6">
+ <element name="testAny2">
<complexType>
<sequence>
- <element name="testValue" nillable="true" type="xsd:anyType"/>
+ <any minOccurs="0"/>
</sequence>
</complexType>
</element>
- <element name="testOM7">
+ <element name="testAny3">
<complexType>
<sequence>
- <element name="testValue" maxOccurs="unbounded" type="xsd:anyType"/>
+ <any maxOccurs="unbounded"/>
</sequence>
</complexType>
</element>
- <element name="testOM8">
+ <element name="testAny4">
<complexType>
<sequence>
- <element name="testValue" type="xsd:anyType"/>
+ <any/>
</sequence>
</complexType>
</element>
- <!-- generating elemens for any elements -->
- <element name="testAny1">
- <complexType>
- <sequence>
- <any minOccurs="0" maxOccurs="unbounded"/>
- </sequence>
- </complexType>
- </element>
- <element name="testAny2">
- <complexType>
- <sequence>
- <any minOccurs="0"/>
- </sequence>
- </complexType>
- </element>
- <element name="testAny3">
+ <!-- test string variables -->
+ <element name="OuterTestString1" type="xsd:string" nillable="true"/>
+ <element name="OuterTestString2" type="xsd:string"/>
+
+ <!-- test primitive variables -->
+ <element name="OuterTestInt1" type="xsd:int" nillable="true"/>
+ <element name="OuterTestInt2" type="xsd:int"/>
+
+ <!-- test xsd:any variables -->
+ <element name="OuterTestAnyType1" type="xsd:anyType" nillable="true"/>
+ <element name="OuterTestAnyType2" type="xsd:anyType"/>
+
+ <!-- test xsd:any variables -->
+ <element name="OuterTestBookInformation1" type="tns:BookInformation" nillable="true"/>
+ <element name="OuterTestBookInformation2" type="tns:BookInformation"/>
+
+ <!-- complext elements -->
+ <element name="OuterTestComplex1" nillable="true">
<complexType>
<sequence>
- <any maxOccurs="unbounded"/>
+ <element name="testValue" type="xsd:string"/>
</sequence>
</complexType>
</element>
- <element name="testAny4">
+ <element name="OuterTestComplex2">
<complexType>
<sequence>
- <any/>
+ <element name="testValue" type="xsd:string"/>
</sequence>
</complexType>
</element>
Modified: webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AbstractTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AbstractTest.java?view=diff&rev=467564&r1=467563&r2=467564
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AbstractTest.java (original)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AbstractTest.java Tue Oct 24 22:05:17 2006
@@ -71,6 +71,8 @@
} else {
if (object instanceof BookInformation){
isContain = isBookInformationObjectsEquals((BookInformation)objectArray[i],(BookInformation)object);
+ } else if (object instanceof OMElement){
+ isContain = isOMElementsEqual((OMElement)objectArray[i],(OMElement)object);
} else {
isContain = objectArray[i].equals(object);
}
Added: webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AnyElementsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AnyElementsTest.java?view=auto&rev=467564
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AnyElementsTest.java (added)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/AnyElementsTest.java Tue Oct 24 22:05:17 2006
@@ -0,0 +1,167 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.schema.testsuite;
+
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.util.StAXUtils;
+import services.echo.types.TestAny1;
+import services.echo.types.TestAny2;
+import services.echo.types.TestAny3;
+import services.echo.types.TestAny4;
+
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+
+
+public class AnyElementsTest extends AbstractTest {
+
+ public static final int MIN_EQUALS_ZERO = 0;
+ public static final int MIN_EQUALS_ONE = 1;
+
+ public void testAnyArray() {
+ OMElement[] returnObject;
+ try {
+ returnObject = testAnyArray(null, MIN_EQUALS_ZERO);
+ assertTrue(assertArrayEqual(returnObject, null));
+ returnObject = testAnyArray(new OMElement[]{null}, MIN_EQUALS_ZERO);
+ assertTrue(assertArrayEqual(returnObject, null));
+ returnObject = testAnyArray(new OMElement[]{getOMElement()}, MIN_EQUALS_ZERO);
+ assertTrue(assertArrayEqual(returnObject, new OMElement[]{getOMElement()}));
+ returnObject = testAnyArray(new OMElement[]{getOMElement(), getOMElement()}, MIN_EQUALS_ZERO);
+ assertTrue(assertArrayEqual(returnObject, new OMElement[]{getOMElement(), getOMElement()}));
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail();
+ }
+
+ try {
+ returnObject = testAnyArray(null, MIN_EQUALS_ONE);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testAnyArray(new OMElement[]{null}, MIN_EQUALS_ONE);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testAnyArray(new OMElement[]{getOMElement(), getOMElement()}, MIN_EQUALS_ONE);
+ assertTrue(assertArrayEqual(returnObject, new OMElement[]{getOMElement(), getOMElement()}));
+ } catch (Exception e) {
+ fail();
+ }
+
+
+ }
+
+ private OMElement[] testAnyArray(OMElement[] innerObject, int type) throws Exception {
+ OMElement omElement;
+ String omElementString;
+ OMElement[] returnObject = null;
+
+ switch (type) {
+ case MIN_EQUALS_ZERO : {
+ TestAny1 testAny = new TestAny1();
+ testAny.setExtraElement(innerObject);
+ omElement = testAny.getOMElement(TestAny1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestAny1.Factory.parse(xmlReader).getExtraElement();
+ break;
+ }
+ case MIN_EQUALS_ONE : {
+ TestAny3 testAny = new TestAny3();
+ testAny.setExtraElement(innerObject);
+ omElement = testAny.getOMElement(TestAny3.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestAny3.Factory.parse(xmlReader).getExtraElement();
+ break;
+ }
+ }
+ return returnObject;
+ }
+
+ public void testAny() {
+ OMElement returnObject;
+ try {
+ returnObject = testAny(null, MIN_EQUALS_ZERO);
+ assertTrue(isOMElementsEqual(returnObject, null));
+ returnObject = testAny(getOMElement(), MIN_EQUALS_ZERO);
+ assertTrue(isOMElementsEqual(returnObject, getOMElement()));
+
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ returnObject = testAny(null, MIN_EQUALS_ONE);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testAny(getOMElement(), MIN_EQUALS_ONE);
+ assertTrue(isOMElementsEqual(returnObject, getOMElement()));
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ private OMElement testAny(OMElement innerObject, int type) throws Exception {
+ OMElement omElement;
+ OMElement returnObject = null;
+ String omElementString;
+
+ switch (type) {
+ case MIN_EQUALS_ZERO : {
+ TestAny2 testAny = new TestAny2();
+ testAny.setExtraElement(innerObject);
+ omElement = testAny.getOMElement(TestAny2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestAny2.Factory.parse(xmlReader).getExtraElement();
+ break;
+ }
+ case MIN_EQUALS_ONE : {
+ TestAny4 testAny = new TestAny4();
+ testAny.setExtraElement(innerObject);
+ omElement = testAny.getOMElement(TestAny4.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestAny4.Factory.parse(xmlReader).getExtraElement();
+ break;
+ }
+ }
+ return returnObject;
+ }
+
+
+}
Modified: webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/CustomElementsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/CustomElementsTest.java?view=diff&rev=467564&r1=467563&r2=467564
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/CustomElementsTest.java (original)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/CustomElementsTest.java Tue Oct 24 22:05:17 2006
@@ -17,6 +17,7 @@
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.util.StAXUtils;
import services.echo.types.*;
import javax.xml.stream.XMLInputFactory;
@@ -37,39 +38,40 @@
System.out.println("minOccurs = 0 and nillable true");
try {
returnObject = testCustomArray(null, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
- assertTrue(assertArrayEqual(returnObject,new BookInformation[]{null}));
+ assertTrue(assertArrayEqual(returnObject, new BookInformation[]{null}));
returnObject = testCustomArray(new BookInformation[]{null}, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
- assertTrue(assertArrayEqual(returnObject,new BookInformation[]{null}));
+ assertTrue(assertArrayEqual(returnObject, new BookInformation[]{null}));
returnObject = testCustomArray(new BookInformation[]{getBookInformation()}, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
- assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation()}));
+ assertTrue(assertArrayEqual(returnObject, new BookInformation[]{getBookInformation()}));
returnObject = testCustomArray(new BookInformation[]{getBookInformation(), null}, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
- assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation(), null}));
+ assertTrue(assertArrayEqual(returnObject, new BookInformation[]{getBookInformation(), null}));
} catch (Exception e) {
fail();
}
System.out.println("minOccurs = 0 and nillable false");
try {
returnObject = testCustomArray(null, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
- assertTrue(assertArrayEqual(returnObject,null));
+ assertTrue(assertArrayEqual(returnObject, null));
returnObject = testCustomArray(new BookInformation[]{null}, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
- assertTrue(assertArrayEqual(returnObject,null));
+ assertTrue(assertArrayEqual(returnObject, null));
returnObject = testCustomArray(new BookInformation[]{getBookInformation()}, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
- assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation()}));
+ assertTrue(assertArrayEqual(returnObject, new BookInformation[]{getBookInformation()}));
returnObject = testCustomArray(new BookInformation[]{getBookInformation(), null}, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
- assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation()}));
+ assertTrue(assertArrayEqual(returnObject, new BookInformation[]{getBookInformation()}));
} catch (Exception e) {
+ e.printStackTrace();
fail();
}
System.out.println("minOccurs = 1 and nillable true");
try {
returnObject = testCustomArray(null, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
- assertTrue(assertArrayEqual(returnObject,new BookInformation[]{null}));
+ assertTrue(assertArrayEqual(returnObject, new BookInformation[]{null}));
returnObject = testCustomArray(new BookInformation[]{null}, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
- assertTrue(assertArrayEqual(returnObject,new BookInformation[]{null}));
+ assertTrue(assertArrayEqual(returnObject, new BookInformation[]{null}));
returnObject = testCustomArray(new BookInformation[]{getBookInformation()}, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
- assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation()}));
+ assertTrue(assertArrayEqual(returnObject, new BookInformation[]{getBookInformation()}));
returnObject = testCustomArray(new BookInformation[]{getBookInformation(), null}, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
- assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation(), null}));
+ assertTrue(assertArrayEqual(returnObject, new BookInformation[]{getBookInformation(), null}));
} catch (Exception e) {
fail();
}
@@ -98,7 +100,7 @@
try {
returnObject = testCustomArray(new BookInformation[]{getBookInformation()}, MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
- assertTrue(assertArrayEqual(returnObject,new BookInformation[]{getBookInformation()}));
+ assertTrue(assertArrayEqual(returnObject, new BookInformation[]{getBookInformation()}));
} catch (Exception e) {
fail();
}
@@ -106,48 +108,57 @@
}
- private BookInformation[] testCustomArray(BookInformation[] innerElement, int type) throws Exception{
+ private BookInformation[] testCustomArray(BookInformation[] innerElement, int type) throws Exception {
OMElement omElement;
BookInformation[] returnObject = null;
+ String omElementString;
switch (type) {
case MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST : {
TestBookInformation1 testBookInformation = new TestBookInformation1();
testBookInformation.setTestValue(innerElement);
omElement = testBookInformation.getOMElement(TestBookInformation1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestBookInformation1.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestBookInformation1.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST : {
TestBookInformation3 testBookInformation = new TestBookInformation3();
testBookInformation.setTestValue(innerElement);
omElement = testBookInformation.getOMElement(TestBookInformation3.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestBookInformation3.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestBookInformation3.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ONE_NILLABLE_TRUE_TEST : {
TestBookInformation5 testBookInformation = new TestBookInformation5();
testBookInformation.setTestValue(innerElement);
omElement = testBookInformation.getOMElement(TestBookInformation5.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestBookInformation5.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestBookInformation5.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ONE_NILLABLE_FALSE_TEST : {
TestBookInformation7 testBookInformation = new TestBookInformation7();
testBookInformation.setTestValue(innerElement);
omElement = testBookInformation.getOMElement(TestBookInformation7.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestBookInformation7.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestBookInformation7.Factory.parse(xmlReader).getTestValue();
break;
}
}
- return returnObject;
+ return returnObject;
}
public void testCustom() {
@@ -155,27 +166,27 @@
System.out.println("minOccurs = 0 and nillable true");
try {
returnObject = testCustom(null, MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
- assertTrue(isBookInformationObjectsEquals(returnObject,null));
+ assertTrue(isBookInformationObjectsEquals(returnObject, null));
returnObject = testCustom(getBookInformation(), MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST);
- assertTrue(isBookInformationObjectsEquals(returnObject,getBookInformation()));
+ assertTrue(isBookInformationObjectsEquals(returnObject, getBookInformation()));
} catch (Exception e) {
fail();
}
System.out.println("minOccurs = 0 and nillable false");
try {
returnObject = testCustom(null, MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
- assertTrue(isBookInformationObjectsEquals(returnObject,null));
+ assertTrue(isBookInformationObjectsEquals(returnObject, null));
returnObject = testCustom(getBookInformation(), MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST);
- assertTrue(isBookInformationObjectsEquals(returnObject,getBookInformation()));
+ assertTrue(isBookInformationObjectsEquals(returnObject, getBookInformation()));
} catch (Exception e) {
fail();
}
System.out.println("minOccurs = 1 and nillable true");
try {
returnObject = testCustom(null, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
- assertTrue(isBookInformationObjectsEquals(returnObject,null));
+ assertTrue(isBookInformationObjectsEquals(returnObject, null));
returnObject = testCustom(getBookInformation(), MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
- assertTrue(isBookInformationObjectsEquals(returnObject,getBookInformation()));
+ assertTrue(isBookInformationObjectsEquals(returnObject, getBookInformation()));
} catch (Exception e) {
fail();
}
@@ -189,7 +200,7 @@
try {
returnObject = testCustom(getBookInformation(), MIN_EQUALS_ONE_NILLABLE_FALSE_TEST);
- assertTrue(isBookInformationObjectsEquals(returnObject,getBookInformation()));
+ assertTrue(isBookInformationObjectsEquals(returnObject, getBookInformation()));
} catch (Exception e) {
fail();
}
@@ -199,41 +210,50 @@
private BookInformation testCustom(BookInformation innerElement, int type) throws Exception {
OMElement omElement;
BookInformation returnObject = null;
+ String omElementString;
switch (type) {
case MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST : {
TestBookInformation2 testBookInformation = new TestBookInformation2();
testBookInformation.setTestValue(innerElement);
omElement = testBookInformation.getOMElement(TestBookInformation2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestBookInformation2.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestBookInformation2.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST : {
TestBookInformation4 testBookInformation = new TestBookInformation4();
testBookInformation.setTestValue(innerElement);
omElement = testBookInformation.getOMElement(TestBookInformation4.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestBookInformation4.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestBookInformation4.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ONE_NILLABLE_TRUE_TEST : {
TestBookInformation6 testBookInformation = new TestBookInformation6();
testBookInformation.setTestValue(innerElement);
omElement = testBookInformation.getOMElement(TestBookInformation6.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestBookInformation6.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestBookInformation6.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ONE_NILLABLE_FALSE_TEST : {
TestBookInformation8 testBookInformation = new TestBookInformation8();
testBookInformation.setTestValue(innerElement);
omElement = testBookInformation.getOMElement(TestBookInformation8.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestBookInformation8.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestBookInformation8.Factory.parse(xmlReader).getTestValue();
break;
}
}
Modified: webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/IntElementsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/IntElementsTest.java?view=diff&rev=467564&r1=467563&r2=467564
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/IntElementsTest.java (original)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/IntElementsTest.java Tue Oct 24 22:05:17 2006
@@ -17,10 +17,9 @@
import org.apache.axiom.om.OMAbstractFactory;
import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.util.StAXUtils;
import services.echo.types.*;
-import services.echo.*;
-import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLStreamReader;
import java.io.ByteArrayInputStream;
import java.util.Arrays;
@@ -60,6 +59,7 @@
returnObject = testIntArray(new int[]{5}, MIN_EQUALS_ONE_NILLABLE_TRUE_TEST);
assertTrue(Arrays.equals(returnObject, new int[]{5}));
} catch (Exception e) {
+ e.printStackTrace();
fail();
}
@@ -81,41 +81,50 @@
private int[] testIntArray(int[] innerElement, int type) throws Exception {
OMElement omElement;
int[] returnObject = null;
+ String omElementString;
switch (type) {
case MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST : {
TestInt1 testInt = new TestInt1();
testInt.setTestValue(innerElement);
omElement = testInt.getOMElement(TestInt1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestInt1.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestInt1.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST : {
TestInt3 testInt = new TestInt3();
testInt.setTestValue(innerElement);
omElement = testInt.getOMElement(TestInt3.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestInt3.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestInt3.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ONE_NILLABLE_TRUE_TEST : {
TestInt5 testInt = new TestInt5();
testInt.setTestValue(innerElement);
omElement = testInt.getOMElement(TestInt5.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestInt5.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestInt5.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ONE_NILLABLE_FALSE_TEST : {
TestInt7 testInt = new TestInt7();
testInt.setTestValue(innerElement);
omElement = testInt.getOMElement(TestInt7.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnObject = TestInt7.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = TestInt7.Factory.parse(xmlReader).getTestValue();
break;
}
}
@@ -138,42 +147,51 @@
public int testInt(int innerElement, int type) throws Exception {
OMElement omElement;
int returnInt = 0;
+ String omElementString;
switch (type) {
case MIN_EQUALS_ZERO_NILLABLE_TRUE_TEST : {
TestInt2 testInt = new TestInt2();
testInt.setTestValue(innerElement);
omElement = testInt.getOMElement(TestInt2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnInt = TestInt2.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnInt = TestInt2.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ZERO_NILLABLE_FALSE_TEST : {
TestInt4 testInt = new TestInt4();
testInt.setTestValue(innerElement);
omElement = testInt.getOMElement(TestInt4.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnInt = TestInt4.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnInt = TestInt4.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ONE_NILLABLE_TRUE_TEST : {
TestInt6 testInt = new TestInt6();
testInt.setTestValue(innerElement);
omElement = testInt.getOMElement(TestInt6.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnInt = TestInt6.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnInt = TestInt6.Factory.parse(xmlReader).getTestValue();
break;
}
case MIN_EQUALS_ONE_NILLABLE_FALSE_TEST : {
TestInt8 testInt = new TestInt8();
testInt.setTestValue(innerElement);
omElement = testInt.getOMElement(TestInt8.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
- System.out.println("OMElement ==> " + omElement);
- XMLStreamReader reader = XMLInputFactory.newInstance().createXMLStreamReader(new ByteArrayInputStream(omElement.toString().getBytes()));
- returnInt = TestInt6.Factory.parse(reader).getTestValue();
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnInt = TestInt6.Factory.parse(xmlReader).getTestValue();
break;
}
}
Added: webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/OuterElementsTest.java
URL: http://svn.apache.org/viewvc/webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/OuterElementsTest.java?view=auto&rev=467564
==============================================================================
--- webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/OuterElementsTest.java (added)
+++ webservices/axis2/branches/java/1_1/modules/adb-codegen/test/org/apache/axis2/schema/testsuite/OuterElementsTest.java Tue Oct 24 22:05:17 2006
@@ -0,0 +1,253 @@
+/*
+ * Copyright 2004,2005 The Apache Software Foundation.
+ *
+ * Licensed 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.axis2.schema.testsuite;
+
+import org.apache.axiom.om.OMAbstractFactory;
+import org.apache.axiom.om.OMElement;
+import org.apache.axiom.om.util.StAXUtils;
+import services.echo.types.*;
+
+import javax.xml.stream.XMLStreamReader;
+import java.io.ByteArrayInputStream;
+
+public class OuterElementsTest extends AbstractTest {
+
+ public static final int NILLABLE_TRUE = 0;
+ public static final int NILLABLE_FALSE = 1;
+
+ public void testString() {
+ String returnString;
+ try {
+ returnString = testString(null, NILLABLE_TRUE);
+ assertEquals(returnString, null);
+ returnString = testString("Test String", NILLABLE_TRUE);
+ assertEquals(returnString, "Test String");
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ returnString = testString(null, NILLABLE_FALSE);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnString = testString("Test String", NILLABLE_FALSE);
+ assertEquals(returnString, "Test String");
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ private String testString(String innerElement, int type) throws Exception {
+ OMElement omElement;
+ String returnString = null;
+ String omElementString;
+
+ switch (type) {
+ case NILLABLE_TRUE : {
+ OuterTestString1 outerTestString = new OuterTestString1();
+ outerTestString.setOuterTestString1(innerElement);
+ omElement = outerTestString.getOMElement(OuterTestString1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnString = OuterTestString1.Factory.parse(xmlReader).getOuterTestString1();
+ break;
+ }
+
+ case NILLABLE_FALSE : {
+ OuterTestString2 outerTestString = new OuterTestString2();
+ outerTestString.setOuterTestString2(innerElement);
+ omElement = outerTestString.getOMElement(OuterTestString2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnString = OuterTestString2.Factory.parse(xmlReader).getOuterTestString2();
+ break;
+
+ }
+ }
+ return returnString;
+ }
+
+ public void testInt() {
+ int returnInt;
+ try {
+ returnInt = testInt(5, NILLABLE_TRUE);
+ assertEquals(returnInt, 5);
+ returnInt = testInt(5, NILLABLE_FALSE);
+ assertEquals(returnInt, 5);
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ private int testInt(int innerElement, int type) throws Exception {
+ OMElement omElement;
+ int returnInt = 0;
+ String omElementString;
+ switch (type) {
+ case NILLABLE_TRUE : {
+ OuterTestInt1 outerTestInt = new OuterTestInt1();
+ outerTestInt.setOuterTestInt1(innerElement);
+ omElement = outerTestInt.getOMElement(OuterTestInt1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnInt = OuterTestInt1.Factory.parse(xmlReader).getOuterTestInt1();
+ break;
+ }
+ case NILLABLE_FALSE : {
+ OuterTestInt2 outerTestInt = new OuterTestInt2();
+ outerTestInt.setOuterTestInt2(innerElement);
+ omElement = outerTestInt.getOMElement(OuterTestInt2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnInt = OuterTestInt2.Factory.parse(xmlReader).getOuterTestInt2();
+ break;
+ }
+ }
+ return returnInt;
+ }
+
+ public void testAnyType() {
+ OMElement returnObject;
+ try {
+ returnObject = testAnyType(null, NILLABLE_TRUE);
+ assertTrue(isOMElementsEqual(returnObject, null));
+ returnObject = testAnyType(getOMElement(), NILLABLE_TRUE);
+ assertTrue(isOMElementsEqual(returnObject, getOMElement()));
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ returnObject = testAnyType(null, NILLABLE_FALSE);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testAnyType(getOMElement(), NILLABLE_FALSE);
+ assertTrue(isOMElementsEqual(returnObject, getOMElement()));
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ private OMElement testAnyType(OMElement innerElement, int type) throws Exception {
+ OMElement omElement;
+ OMElement returnString = null;
+ String omElementString;
+
+ switch (type) {
+ case NILLABLE_TRUE : {
+ OuterTestAnyType1 outerTestAnyType = new OuterTestAnyType1();
+ outerTestAnyType.setOuterTestAnyType1(innerElement);
+ omElement = outerTestAnyType.getOMElement(OuterTestAnyType1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnString = OuterTestAnyType1.Factory.parse(xmlReader).getOuterTestAnyType1();
+ break;
+ }
+
+ case NILLABLE_FALSE : {
+ OuterTestAnyType2 outerTestAnyType = new OuterTestAnyType2();
+ outerTestAnyType.setOuterTestAnyType2(innerElement);
+ omElement = outerTestAnyType.getOMElement(OuterTestAnyType2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnString = OuterTestAnyType2.Factory.parse(xmlReader).getOuterTestAnyType2();
+ break;
+ }
+ }
+ return returnString;
+ }
+
+ public void testBookInformation() {
+ BookInformation returnObject;
+ try {
+ returnObject = testBookInformation(null, NILLABLE_TRUE);
+ assertTrue(isBookInformationObjectsEquals(returnObject, null));
+ returnObject = testBookInformation(getBookInformation(), NILLABLE_TRUE);
+ assertTrue(isBookInformationObjectsEquals(returnObject, getBookInformation()));
+ } catch (Exception e) {
+ fail();
+ }
+
+ try {
+ returnObject = testBookInformation(null, NILLABLE_FALSE);
+ fail();
+ } catch (Exception e) {
+ assertTrue(true);
+ }
+
+ try {
+ returnObject = testBookInformation(getBookInformation(), NILLABLE_FALSE);
+ assertTrue(isBookInformationObjectsEquals(returnObject, getBookInformation()));
+ } catch (Exception e) {
+ fail();
+ }
+ }
+
+ private BookInformation testBookInformation(BookInformation innerElement, int type) throws Exception {
+ OMElement omElement;
+ BookInformation returnObject = null;
+ String omElementString;
+
+ switch (type) {
+ case NILLABLE_TRUE : {
+ OuterTestBookInformation1 outerTestBookInformation = new OuterTestBookInformation1();
+ outerTestBookInformation.setOuterTestBookInformation1(innerElement);
+ omElement = outerTestBookInformation.getOMElement(OuterTestBookInformation1.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = OuterTestBookInformation1.Factory.parse(xmlReader).getOuterTestBookInformation1();
+ break;
+ }
+
+ case NILLABLE_FALSE : {
+ OuterTestBookInformation2 outerTestBookInformation = new OuterTestBookInformation2();
+ outerTestBookInformation.setOuterTestBookInformation2(innerElement);
+ omElement = outerTestBookInformation.getOMElement(OuterTestBookInformation2.MY_QNAME, OMAbstractFactory.getSOAP12Factory());
+ omElementString = omElement.toStringWithConsume();
+ System.out.println("OMElement ==> " + omElementString);
+ XMLStreamReader xmlReader =
+ StAXUtils.createXMLStreamReader(new ByteArrayInputStream(omElementString.getBytes()));
+ returnObject = OuterTestBookInformation2.Factory.parse(xmlReader).getOuterTestBookInformation2();
+ break;
+ }
+ }
+ return returnObject;
+ }
+
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org