[jboss-dev-forums] [JBoss XML Binding Development] New message: "Re: Regression moving to JBossXB 2.0.2.Beta5"

Alexey Loubyansky do-not-reply at jboss.com
Thu Mar 18 04:05:36 EDT 2010


JBoss development,

A new message was posted in the thread "Regression moving to JBossXB 2.0.2.Beta5":

http://community.jboss.org/message/532704#532704

Author  : Alexey Loubyansky
Profile : http://community.jboss.org/people/alex.loubyansky@jboss.com

Message:
--------------------------------------------------------------
Strangely, the following test passes
 
public class XsiNilUnitTestCase extends AbstractJBossXBTest
{
   private static String XSD =
      "<xsd:schema xmlns:xsd='http://www.w3.org/2001/XMLSchema'" +
      "  xmlns='http://www.w3.org/2001/XMLSchema'" +
      "  xmlns:jbxb='" + Constants.NS_JBXB + "'>" +
      "<xsd:element name='root'  nillable='true'>" +
      "  <xsd:complexType>" +
      "    <annotation>" +
      "      <appinfo>" +
      "        <jbxb:class impl='" + Root.class.getName() + "'/>" +
      "      </appinfo>" +
      "    </annotation>" +
      "  </xsd:complexType>" +
      "</xsd:element>" +
      "</xsd:schema>";
   
   private static String XML_NIL_1 = "<root xsi:nil='1' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'/>";
   private static String XML_NIL_0 = "<root xsi:nil='0' xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'/>";
   private static String XML = "<root/>";
   
   public XsiNilUnitTestCase(String name)
   {
      super(name);
   }
 
   public void testUnmarshalling() throws Exception
   {
      SchemaBinding schema = XsdBinder.bind(new StringReader(XSD), null);
      ElementBinding rootBinding = schema.getElement(new QName("root"));
      assertNotNull(rootBinding);
      assertTrue(rootBinding.isNillable());
      
      Root root = (Root) UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(new StringReader(XML), schema);
      assertNotNull(root);
      root = (Root) UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(new StringReader(XML_NIL_1), schema);
      assertNull(root);
      root = (Root) UnmarshallerFactory.newInstance().newUnmarshaller().unmarshal(new StringReader(XML_NIL_0), schema);
      assertNotNull(root);
   }
   
   public static class Root
   {
   }
}

--------------------------------------------------------------

To reply to this message visit the message page: http://community.jboss.org/message/532704#532704




More information about the jboss-dev-forums mailing list