[Jboss-cvs] JBossAS SVN: r56250 - in trunk/testsuite/src: main/org/jboss/test/xml resources/org/jboss/test/xml
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Fri Aug 25 05:33:06 EDT 2006
Author: alex.loubyansky at jboss.com
Date: 2006-08-25 05:33:00 -0400 (Fri, 25 Aug 2006)
New Revision: 56250
Added:
trunk/testsuite/src/main/org/jboss/test/xml/RepeatableTermsUnitTestCase.java
trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase.xml
trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase.xsd
Log:
testcase for repeatable modelgroups
Added: trunk/testsuite/src/main/org/jboss/test/xml/RepeatableTermsUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/xml/RepeatableTermsUnitTestCase.java 2006-08-25 08:59:56 UTC (rev 56249)
+++ trunk/testsuite/src/main/org/jboss/test/xml/RepeatableTermsUnitTestCase.java 2006-08-25 09:33:00 UTC (rev 56250)
@@ -0,0 +1,216 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2005, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.test.xml;
+
+import java.util.Arrays;
+import org.jboss.xb.binding.sunday.unmarshalling.XsdBinder;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBindingResolver;
+import org.jboss.xb.binding.Unmarshaller;
+import org.jboss.xb.binding.UnmarshallerFactory;
+
+/**
+ * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
+ * @version <tt>$Revision: $</tt>
+ */
+public class RepeatableTermsUnitTestCase
+ extends AbstractJBossXBTest
+{
+ public RepeatableTermsUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ protected void configureLogging()
+ {
+ //enableTrace("org.jboss.xb.binding.sunday");
+ //enableTrace("org.jboss.xb.binding.sunday.unmarshalling.SequenceBinding");
+ //enableTrace("org.jboss.xb.binding.sunday.unmarshalling.ChoiceBinding");
+ }
+
+ public void testUnmarshal() throws Exception
+ {
+ String testXsd = findXML(rootName + ".xsd");
+ SchemaBinding schema = XsdBinder.bind(testXsd, (SchemaBindingResolver)null);
+ schema.setIgnoreUnresolvedFieldOrClass(false);
+
+ Unmarshaller unmarshaller = UnmarshallerFactory.newInstance().newUnmarshaller();
+ Object o = unmarshaller.unmarshal(findXML(rootName + ".xml"), schema);
+
+ assertNotNull(o);
+ assertTrue(o instanceof Top);
+ Top top = (Top)o;
+
+ assertNotNull(top.item);
+ assertEquals(3, top.item.length);
+ assertEquals(new String[]{"item1", "item2", "item3"}, top.item);
+
+ assertNotNull(top.sequence);
+ //assertEquals(5, top.sequence.length);
+ assertEquals(
+ new Sequence[]
+ {
+ new Sequence("sequenceChoice1_1", null),
+ new Sequence(null, "sequenceChoice2_1"),
+ new Sequence("sequenceChoice1_2", null),
+ new Sequence("sequenceChoice1_3", null),
+ new Sequence(null, "sequenceChoice2_2")
+ },
+ top.sequence
+ );
+
+ assertNotNull(top.choice);
+ assertEquals(3, top.choice.length);
+ assertEquals(
+ new Choice[]
+ {
+ new Choice(new String[]{"choiceChoice1_1", "choiceChoice1_2"}, null),
+ new Choice(null, new String[]{"choiceChoice2_1", "choiceChoice2_2"}),
+ new Choice(new String[]{"choiceChoice1_3", "choiceChoice1_4"}, null),
+ },
+ top.choice
+ );
+ }
+
+ // Inner
+
+ public static final class Top
+ {
+ public String[] item;
+ public Sequence[] sequence;
+ public Choice[] choice;
+
+ public String toString()
+ {
+ return "[top item=" + (item == null ? null : Arrays.asList(item)) +
+ " sequence=" + (sequence == null ? null : Arrays.asList(sequence)) +
+ " choice=" + (choice == null ? null : Arrays.asList(choice)) + "]";
+ }
+ }
+
+ public static final class Sequence
+ {
+ public String sequenceChoice1;
+ public String sequenceChoice2;
+
+ public Sequence()
+ {
+ }
+
+ public Sequence(String sequenceChoice1, String sequenceChoice2)
+ {
+ this.sequenceChoice1 = sequenceChoice1;
+ this.sequenceChoice2 = sequenceChoice2;
+ }
+
+ public String toString()
+ {
+ return "[" + sequenceChoice1 + " " + sequenceChoice2 + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Sequence))
+ {
+ return false;
+ }
+
+ final Sequence sequence = (Sequence)o;
+
+ if(sequenceChoice1 != null ? !sequenceChoice1.equals(sequence.sequenceChoice1) : sequence.sequenceChoice1 != null)
+ {
+ return false;
+ }
+ if(sequenceChoice2 != null ? !sequenceChoice2.equals(sequence.sequenceChoice2) : sequence.sequenceChoice2 != null)
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ int result;
+ result = (sequenceChoice1 != null ? sequenceChoice1.hashCode() : 0);
+ result = 29 * result + (sequenceChoice2 != null ? sequenceChoice2.hashCode() : 0);
+ return result;
+ }
+ }
+
+ public static final class Choice
+ {
+ public String[] choiceChoice1;
+ public String[] choiceChoice2;
+
+ public Choice()
+ {
+ }
+
+ public Choice(String[] choiceChoice1, String[] choiceChoice2)
+ {
+ this.choiceChoice1 = choiceChoice1;
+ this.choiceChoice2 = choiceChoice2;
+ }
+
+ public String toString()
+ {
+ return "[" +
+ (choiceChoice1 == null ? null : Arrays.asList(choiceChoice1)) +
+ " " + (choiceChoice2 == null ? null : Arrays.asList(choiceChoice2)) + "]";
+ }
+
+ public boolean equals(Object o)
+ {
+ if(this == o)
+ {
+ return true;
+ }
+ if(!(o instanceof Choice))
+ {
+ return false;
+ }
+
+ final Choice choice = (Choice)o;
+
+ if(!Arrays.equals(choiceChoice1, choice.choiceChoice1))
+ {
+ return false;
+ }
+ if(!Arrays.equals(choiceChoice2, choice.choiceChoice2))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ public int hashCode()
+ {
+ return 0;
+ }
+ }
+}
Added: trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase.xml
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase.xml 2006-08-25 08:59:56 UTC (rev 56249)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase.xml 2006-08-25 09:33:00 UTC (rev 56250)
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<top xmlns='http://www.jboss.org/test/xml/repeatableterms'>
+ <item>item1</item>
+ <item>item2</item>
+ <item>item3</item>
+
+ <sequenceChoice1>sequenceChoice1_1</sequenceChoice1>
+ <sequenceChoice2>sequenceChoice2_1</sequenceChoice2>
+ <sequenceChoice1>sequenceChoice1_2</sequenceChoice1>
+ <sequenceChoice1>sequenceChoice1_3</sequenceChoice1>
+ <sequenceChoice2>sequenceChoice2_2</sequenceChoice2>
+
+ <choiceChoice1>choiceChoice1_1</choiceChoice1>
+ <choiceChoice1>choiceChoice1_2</choiceChoice1>
+
+ <choiceChoice2>choiceChoice2_1</choiceChoice2>
+ <choiceChoice2>choiceChoice2_2</choiceChoice2>
+
+ <choiceChoice1>choiceChoice1_3</choiceChoice1>
+ <choiceChoice1>choiceChoice1_4</choiceChoice1>
+</top>
Added: trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase.xsd
===================================================================
--- trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase.xsd 2006-08-25 08:59:56 UTC (rev 56249)
+++ trunk/testsuite/src/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase.xsd 2006-08-25 09:33:00 UTC (rev 56250)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace="http://www.jboss.org/test/xml/repeatableterms"
+ xmlns="http://www.jboss.org/test/xml/repeatableterms"
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:element name="top">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.RepeatableTermsUnitTestCase$Top"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="item" type="xsd:string" maxOccurs="unbounded"/>
+ <xsd:sequence maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.RepeatableTermsUnitTestCase$Sequence"/>
+ <jbxb:property name="sequence"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:choice>
+ <xsd:element name="sequenceChoice1" type="xsd:string"/>
+ <xsd:element name="sequenceChoice2" type="xsd:string"/>
+ </xsd:choice>
+ </xsd:sequence>
+ <xsd:choice maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.RepeatableTermsUnitTestCase$Choice"/>
+ <jbxb:property name="choice"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:element name="choiceChoice1" type="xsd:string" maxOccurs="unbounded"/>
+ <xsd:element name="choiceChoice2" type="xsd:string" maxOccurs="unbounded"/>
+ </xsd:choice>
+ </xsd:sequence>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
More information about the jboss-cvs-commits
mailing list