[jboss-svn-commits] JBoss Common SVN: r2902 - in jbossxb/branches/1_0/src: test/java/org/jboss/test/xml and 2 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Aug 19 08:36:20 EDT 2008


Author: alex.loubyansky at jboss.com
Date: 2008-08-19 08:36:19 -0400 (Tue, 19 Aug 2008)
New Revision: 2902

Added:
   jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/ListValueUnitTestCase.java
   jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/
   jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/AbstractProduct.java
   jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/Product.java
   jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/ProductArray.java
   jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xml
   jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xsd
   jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testPolymorphicArray.xml
   jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testPolymorphicArray.xsd
Modified:
   jbossxb/branches/1_0/src/main/java/org/jboss/xb/binding/group/ValueList.java
   jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/RepeatableTermsUnitTestCase.java
Log:
JBXB-116

Modified: jbossxb/branches/1_0/src/main/java/org/jboss/xb/binding/group/ValueList.java
===================================================================
--- jbossxb/branches/1_0/src/main/java/org/jboss/xb/binding/group/ValueList.java	2008-08-18 12:35:33 UTC (rev 2901)
+++ jbossxb/branches/1_0/src/main/java/org/jboss/xb/binding/group/ValueList.java	2008-08-19 12:36:19 UTC (rev 2902)
@@ -114,7 +114,7 @@
    void addRepeatableTermValue(QName qName, ParticleBinding binding, Object handler, Object value, ParticleBinding parentParticle)
    {
       NonRequiredValue last = (NonRequiredValue) (nonRequiredValues.isEmpty() ? null : nonRequiredValues.get(nonRequiredValues.size() - 1));
-      if (last == null || last.binding != binding)
+      if (last == null /*|| last.binding != binding*/)
       {
          Collection col;
          PropertyMetaData propMetaData = binding.getTerm().getPropertyMetaData();

Added: jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/ListValueUnitTestCase.java
===================================================================
--- jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/ListValueUnitTestCase.java	                        (rev 0)
+++ jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/ListValueUnitTestCase.java	2008-08-19 12:36:19 UTC (rev 2902)
@@ -0,0 +1,104 @@
+/*
+ * 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 org.jboss.xb.binding.sunday.unmarshalling.SchemaBinding;
+
+/**
+ * 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
+   {
+      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 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 strs;
+      
+      
+      public Root(String attr, List 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 getStrs()
+      {
+         return strs;
+      }
+      
+      public void setStrs(List items)
+      {
+         this.strs = items;
+      }
+   }
+}

Modified: jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/RepeatableTermsUnitTestCase.java
===================================================================
--- jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/RepeatableTermsUnitTestCase.java	2008-08-18 12:35:33 UTC (rev 2901)
+++ jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/RepeatableTermsUnitTestCase.java	2008-08-19 12:36:19 UTC (rev 2902)
@@ -22,6 +22,10 @@
 package org.jboss.test.xml;
 
 import java.util.Arrays;
+import java.util.List;
+ 
+import org.jboss.test.xml.repeatableterms.Product;
+import org.jboss.test.xml.repeatableterms.ProductArray;
 
 /**
  * @author <a href="mailto:alex at jboss.org">Alexey Loubyansky</a>
@@ -96,6 +100,26 @@
       assertEquals("item2", top.item2);
    }
 
+   public void testPolymorphicArray() throws Exception
+   {
+      Object o = unmarshal();
+      assertNotNull(o);
+      assertTrue(o instanceof ProductArray);
+      ProductArray arr = (ProductArray) o;
+      List 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
 
    public static final class Top

Added: jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/AbstractProduct.java
===================================================================
--- jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/AbstractProduct.java	                        (rev 0)
+++ jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/AbstractProduct.java	2008-08-19 12:36:19 UTC (rev 2902)
@@ -0,0 +1,43 @@
+/*
+ * 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.repeatableterms;
+
+/**
+ * A BasicProduct.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AbstractProduct
+{
+   private String name;
+   
+   public String getName()
+   {
+      return name;
+   }
+   
+   public void setName(String name)
+   {
+      this.name = name;
+   }
+}

Added: jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/Product.java
===================================================================
--- jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/Product.java	                        (rev 0)
+++ jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/Product.java	2008-08-19 12:36:19 UTC (rev 2902)
@@ -0,0 +1,43 @@
+/*
+ * 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.repeatableterms;
+
+/**
+ * A Product.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class Product extends AbstractProduct
+{
+   private int price;
+   
+   public int getPrice()
+   {
+      return price;
+   }
+   
+   public void setPrice(int price)
+   {
+      this.price = price;
+   }
+}

Added: jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/ProductArray.java
===================================================================
--- jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/ProductArray.java	                        (rev 0)
+++ jbossxb/branches/1_0/src/test/java/org/jboss/test/xml/repeatableterms/ProductArray.java	2008-08-19 12:36:19 UTC (rev 2902)
@@ -0,0 +1,45 @@
+/*
+ * 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.repeatableterms;
+
+import java.util.List;
+
+/**
+ * A ProductArray.
+ * 
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class ProductArray
+{
+   private List product;
+   
+   public List getProduct()
+   {
+      return product;
+   }
+   
+   public void setProduct(List products)
+   {
+      this.product = products;
+   }
+}

Added: jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xml
===================================================================
--- jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xml	                        (rev 0)
+++ jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xml	2008-08-19 12:36:19 UTC (rev 2902)
@@ -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/branches/1_0/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xsd
===================================================================
--- jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xsd	                        (rev 0)
+++ jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/ListValueUnitTestCase_testCtor.xsd	2008-08-19 12:36:19 UTC (rev 2902)
@@ -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

Added: jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testPolymorphicArray.xml
===================================================================
--- jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testPolymorphicArray.xml	                        (rev 0)
+++ jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testPolymorphicArray.xml	2008-08-19 12:36:19 UTC (rev 2902)
@@ -0,0 +1,16 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<product-array xmlns='http://www.jboss.org/test/xml/repeatableterms' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>
+  <product xsi:type='Product'>
+    <name>product1</name>
+    <price>1</price>
+  </product>
+  <product xsi:type='Product'>
+    <name>product2</name>
+    <price>2</price>
+  </product>
+  <product xsi:type='Product'>
+    <name>product3</name>
+    <price>3</price>
+  </product>
+</product-array>

Added: jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testPolymorphicArray.xsd
===================================================================
--- jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testPolymorphicArray.xsd	                        (rev 0)
+++ jbossxb/branches/1_0/src/test/resources/org/jboss/test/xml/RepeatableTermsUnitTestCase_testPolymorphicArray.xsd	2008-08-19 12:36:19 UTC (rev 2902)
@@ -0,0 +1,47 @@
+<?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="product-array">
+      <xsd:annotation>
+         <xsd:appinfo>
+            <jbxb:class impl="org.jboss.test.xml.repeatableterms.ProductArray"/>
+         </xsd:appinfo>
+      </xsd:annotation>
+      <xsd:complexType>
+         <xsd:sequence>
+            <xsd:element name="product" type="AbstractProduct" maxOccurs="unbounded"/>
+         </xsd:sequence>
+      </xsd:complexType>
+   </xsd:element>
+   <xsd:complexType name='AbstractProduct'>
+     <xsd:annotation>
+       <xsd:appinfo>
+          <jbxb:class impl="org.jboss.test.xml.repeatableterms.AbstractProduct"/>
+       </xsd:appinfo>
+     </xsd:annotation>
+     <xsd:sequence>
+        <xsd:element name='name' nillable='true' type='xsd:string'/>
+     </xsd:sequence>
+   </xsd:complexType>
+   <xsd:complexType name='Product'>
+    <xsd:annotation>
+       <xsd:appinfo>
+          <jbxb:class impl="org.jboss.test.xml.repeatableterms.Product"/>
+       </xsd:appinfo>
+    </xsd:annotation>
+    <xsd:complexContent>
+     <xsd:extension base='AbstractProduct'>
+      <xsd:sequence>
+       <xsd:element name='price' type='xsd:int'/>
+      </xsd:sequence>
+     </xsd:extension>
+    </xsd:complexContent>
+   </xsd:complexType>
+</xsd:schema>




More information about the jboss-svn-commits mailing list