You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@xmlbeans.apache.org by ra...@apache.org on 2007/04/25 01:59:27 UTC
svn commit: r532146 - in /xmlbeans/trunk/test:
cases/xbean/misc/jira/xmlbeans_228.xsd src/common/Common.java
src/misc/detailed/JiraRegression201_250Test.java
Author: radup
Date: Tue Apr 24 16:59:26 2007
New Revision: 532146
URL: http://svn.apache.org/viewvc?view=rev&rev=532146
Log:
Contributed by Andreas Loew via Wing Yew Poon. Test case for JIRA XMLBEANS-228.
Added:
xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_228.xsd
Modified:
xmlbeans/trunk/test/src/common/Common.java
xmlbeans/trunk/test/src/misc/detailed/JiraRegression201_250Test.java
Added: xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_228.xsd
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_228.xsd?view=auto&rev=532146
==============================================================================
--- xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_228.xsd (added)
+++ xmlbeans/trunk/test/cases/xbean/misc/jira/xmlbeans_228.xsd Tue Apr 24 16:59:26 2007
@@ -0,0 +1,33 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
+ xmlns:sub="http://jira/xmlbeans_228/substitution"
+ targetNamespace="http://jira/xmlbeans_228/substitution"
+ elementFormDefault="qualified">
+ <xs:annotation>
+ <xs:documentation>
+ <xs:documentation>Wrong element order after substitution.</xs:documentation>
+ <creationdate>14.11.05 11:11</creationdate>
+ </xs:documentation>
+ </xs:annotation>
+ <xs:element name="Person">
+ <xs:complexType>
+ <xs:sequence>
+ <xs:element name="FirstName" type="xs:string"/>
+ <xs:element name="LastName" type="xs:string"/>
+ <xs:element ref="sub:Comment" minOccurs="0"/>
+ </xs:sequence>
+ </xs:complexType>
+ </xs:element>
+ <xs:element name="Comment" type="sub:CommentType"/>
+ <xs:complexType name="CommentType">
+ <xs:simpleContent>
+ <xs:extension base="xs:string"/>
+ </xs:simpleContent>
+ </xs:complexType>
+ <xs:element name="FirstCommentElement" type="sub:FirstCommentType" substitutionGroup="sub:Comment"/>
+ <xs:complexType name="FirstCommentType">
+ <xs:simpleContent>
+ <xs:extension base="sub:CommentType"/>
+ </xs:simpleContent>
+ </xs:complexType>
+</xs:schema>
Modified: xmlbeans/trunk/test/src/common/Common.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/common/Common.java?view=diff&rev=532146&r1=532145&r2=532146
==============================================================================
--- xmlbeans/trunk/test/src/common/Common.java (original)
+++ xmlbeans/trunk/test/src/common/Common.java Tue Apr 24 16:59:26 2007
@@ -30,6 +30,7 @@
*/
public class Common extends TestCase
{
+ public static final String NEWLINE = System.getProperty("line.separator");
public static final String P = File.separator;
public static String FWROOT = getRootFile();
Modified: xmlbeans/trunk/test/src/misc/detailed/JiraRegression201_250Test.java
URL: http://svn.apache.org/viewvc/xmlbeans/trunk/test/src/misc/detailed/JiraRegression201_250Test.java?view=diff&rev=532146&r1=532145&r2=532146
==============================================================================
--- xmlbeans/trunk/test/src/misc/detailed/JiraRegression201_250Test.java (original)
+++ xmlbeans/trunk/test/src/misc/detailed/JiraRegression201_250Test.java Tue Apr 24 16:59:26 2007
@@ -17,11 +17,17 @@
import misc.common.JiraTestBase;
import misc.detailed.jira208.FrogBreathDocument;
+import jira.xmlbeans228.substitution.PersonDocument;
+import jira.xmlbeans228.substitution.CommentType;
+import jira.xmlbeans228.substitution.FirstCommentType;
+import java.io.StringWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.Iterator;
+import javax.xml.namespace.QName;
+
import org.apache.xmlbeans.XmlOptions;
import org.apache.xmlbeans.XmlError;
@@ -78,4 +84,40 @@
assertTrue(valid2);
}
+ /*
+ * [XMLBEANS-228]:
+ * element order in sequence incorrect after calling substitute()
+ */
+ public void test_jira_xmlbeans228() throws Exception
+ {
+ PersonDocument personDocument = PersonDocument.Factory.newInstance();
+ PersonDocument.Person person = personDocument.addNewPerson();
+ CommentType commentType = person.addNewComment();
+ String ns = "http://jira/xmlbeans_228/substitution";
+ QName qName = new QName(ns, "FirstCommentElement");
+ Object resultObject = commentType.substitute(qName, FirstCommentType.type);
+ FirstCommentType firstCommentType = (FirstCommentType)resultObject;
+ firstCommentType.setStringValue("ThirdElement");
+ person.setComment(firstCommentType);
+
+ person.setFirstName("FirstElement");
+ person.setLastName("SecondElement");
+
+ XmlOptions opts = new XmlOptions().setSavePrettyPrint().setUseDefaultNamespace();
+ StringWriter out = new StringWriter();
+ personDocument.save(out, opts);
+
+ String exp =
+ "<Person xmlns=\"http://jira/xmlbeans_228/substitution\">" + NEWLINE +
+ " <FirstName>FirstElement</FirstName>" + NEWLINE +
+ " <LastName>SecondElement</LastName>" + NEWLINE +
+ " <FirstCommentElement>ThirdElement</FirstCommentElement>" + NEWLINE +
+ "</Person>";
+
+ assertEquals(exp, out.toString());
+ if (!personDocument.validate())
+ {
+ fail("Wrong element order!");
+ }
+ }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@xmlbeans.apache.org
For additional commands, e-mail: commits-help@xmlbeans.apache.org