[jboss-svn-commits] JBoss Common SVN: r2900 - in jbossxb/trunk/src/test: resources/org/jboss/test/xml and 1 other directory.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Fri Aug 15 05:43:38 EDT 2008
Author: alex.loubyansky at jboss.com
Date: 2008-08-15 05:43:37 -0400 (Fri, 15 Aug 2008)
New Revision: 2900
Added:
jbossxb/trunk/src/test/java/org/jboss/test/xml/ListValueUnitTestCase.java
jbossxb/trunk/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xml
jbossxb/trunk/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xsd
Modified:
jbossxb/trunk/src/test/java/org/jboss/test/xml/RepeatableTermsUnitTestCase.java
Log:
a test for non default ctor with arguments that are repeatable particles
Added: jbossxb/trunk/src/test/java/org/jboss/test/xml/ListValueUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/ListValueUnitTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/ListValueUnitTestCase.java 2008-08-15 09:43:37 UTC (rev 2900)
@@ -0,0 +1,114 @@
+/*
+ * 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.List;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlRootElement;
+import javax.xml.bind.annotation.XmlValue;
+
+import org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+import org.jboss.xb.builder.JBossXBBuilder;
+
+/**
+ * A ListValueUnitTestCase.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class ListValueUnitTestCase extends AbstractJBossXBTest
+{
+ public ListValueUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testCtor() throws Exception
+ {
+ System.out.println(getName());
+
+ //SchemaBinding schema = JBossXBBuilder.build(Root.class);
+ //Object o = unmarshal("ListValueUnitTestCase_" + getName() + ".xml", schema);
+ Object o = unmarshal();
+ assertNotNull(o);
+ assertTrue(o instanceof Root);
+ Root root = (Root) o;
+ assertEquals("attr", root.getAttr());
+ int[] ints = root.getInts();
+ assertNotNull(ints);
+ assertEquals(2, ints.length);
+ assertEquals(1, ints[0]);
+ assertEquals(2, ints[1]);
+ List<String> strs = root.getStrs();
+ assertNotNull(strs);
+ assertEquals(2, strs.size());
+ assertEquals("item1", strs.get(0));
+ assertEquals("item2", strs.get(1));
+ }
+
+ public static class Root
+ {
+ private String attr;
+ private int[] ints;
+ private List<String> strs;
+
+
+ public Root(String attr, List<String> items, int[] ints)
+ {
+ this.attr = attr;
+ this.ints = ints;
+ this.strs = items;
+ }
+
+ public String getAttr()
+ {
+ return attr;
+ }
+
+ public void setAttr(String attr)
+ {
+ this.attr = attr;
+ }
+
+ public int[] getInts()
+ {
+ return ints;
+ }
+
+ public void setInts(int[] ints)
+ {
+ this.ints = ints;
+ }
+
+ public List<String> getStrs()
+ {
+ return strs;
+ }
+
+ public void setStrs(List<String> items)
+ {
+ this.strs = items;
+ }
+ }
+}
Modified: jbossxb/trunk/src/test/java/org/jboss/test/xml/RepeatableTermsUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xml/RepeatableTermsUnitTestCase.java 2008-08-14 12:58:39 UTC (rev 2899)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xml/RepeatableTermsUnitTestCase.java 2008-08-15 09:43:37 UTC (rev 2900)
@@ -25,6 +25,7 @@
import java.util.List;
import org.jboss.test.xml.repeatableterms.AbstractProduct;
+import org.jboss.test.xml.repeatableterms.Product;
import org.jboss.test.xml.repeatableterms.ProductArray;
import junit.framework.TestSuite;
@@ -116,6 +117,15 @@
List<AbstractProduct> products = arr.getProduct();
assertNotNull(products);
assertEquals(3, products.size());
+
+ int i = 0;
+ while(i < products.size())
+ {
+ Product product = (Product) products.get(i++);
+ assertNotNull(product);
+ assertEquals("product" + i, product.getName());
+ assertEquals(i, product.getPrice());
+ }
}
// Inner
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xml 2008-08-15 09:43:37 UTC (rev 2900)
@@ -0,0 +1,6 @@
+<root attr="attr">
+ <str>item1</str>
+ <str>item2</str>
+ <int>1</int>
+ <int>2</int>
+</root>
\ No newline at end of file
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xsd
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xsd (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xsd 2008-08-15 09:43:37 UTC (rev 2900)
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
+ targetNamespace=""
+ xmlns=""
+ xmlns:jbxb="http://www.jboss.org/xml/ns/jbxb"
+ elementFormDefault="qualified"
+ attributeFormDefault="unqualified"
+ version="1.0">
+
+ <xsd:element name="root">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:class impl="org.jboss.test.xml.ListValueUnitTestCase$Root"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="str" type="xsd:string" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="strs"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ <xsd:element name="int" type="xsd:int" maxOccurs="unbounded">
+ <xsd:annotation>
+ <xsd:appinfo>
+ <jbxb:property name="ints"/>
+ </xsd:appinfo>
+ </xsd:annotation>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="attr" type="xsd:string"></xsd:attribute>
+ </xsd:complexType>
+ </xsd:element>
+</xsd:schema>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list