[jboss-svn-commits] JBoss Common SVN: r2708 - in jbossxb/trunk/src: test/java/org/jboss/test/xb/builder/object/type/xmlanyelement and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Feb 12 05:56:33 EST 2008
Author: alex.loubyansky at jboss.com
Date: 2008-02-12 05:56:33 -0500 (Tue, 12 Feb 2008)
New Revision: 2708
Added:
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/support/XmlElementsAndXmlAnyElement.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/test/XmlElementsAndXmlAnyElementUnitTestCase.java
jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/type/xmlanyelement/test/XmlElementsAndXmlAnyElement.xml
Modified:
jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/ObjectTypeXmlAnyElementTestSuite.java
Log:
JBXB-120
Modified: jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java 2008-02-11 13:21:34 UTC (rev 2707)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java 2008-02-12 10:56:33 UTC (rev 2708)
@@ -39,6 +39,7 @@
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElementRefs;
import javax.xml.bind.annotation.XmlElementWrapper;
import javax.xml.bind.annotation.XmlElements;
import javax.xml.bind.annotation.XmlEnum;
@@ -807,6 +808,7 @@
}
// Is this the wildcard property?
+ boolean ignoreXmlAnyElement = false;
XmlAnyElement xmlAnyElement = property.getUnderlyingAnnotation(XmlAnyElement.class);
if (xmlAnyElement != null)
{
@@ -816,6 +818,11 @@
throw new RuntimeException("@XmlAnyElement seen on two properties: " + property.getName() + " and " + wildcardProperty.getName());
wildcardProperty = property;
seenXmlAnyElement = true;
+
+ // should we ignore it
+ if(property.getUnderlyingAnnotation(XmlElements.class) == null &&
+ property.getUnderlyingAnnotation(XmlElementRefs.class) == null)
+ ignoreXmlAnyElement = true;
}
else if (!seenXmlAnyElement && wildcardProperty == null && property.getType().getName().equals(org.w3c.dom.Element.class.getName()))
{
@@ -860,7 +867,7 @@
continue;
}
// Wildcard property
- if (xmlAnyElement != null)
+ if (ignoreXmlAnyElement)
{
if (trace)
log.trace("Ignore not element @XmlAnyElement for type=" + beanInfo.getName() + " property=" + property.getName());
Modified: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/ObjectTypeXmlAnyElementTestSuite.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/ObjectTypeXmlAnyElementTestSuite.java 2008-02-11 13:21:34 UTC (rev 2707)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/ObjectTypeXmlAnyElementTestSuite.java 2008-02-12 10:56:33 UTC (rev 2708)
@@ -27,10 +27,14 @@
import org.jboss.test.xb.builder.object.type.xmlanyelement.test.ArrayElementWildcardUnitTestCase;
import org.jboss.test.xb.builder.object.type.xmlanyelement.test.ArrayObjectWildcardUnitTestCase;
+import org.jboss.test.xb.builder.object.type.xmlanyelement.test.ElementPropertiesAndWildcardUnitTestCase;
import org.jboss.test.xb.builder.object.type.xmlanyelement.test.ElementWildcardUnitTestCase;
+import org.jboss.test.xb.builder.object.type.xmlanyelement.test.ElementWildcardWithCollectionPropertyUnitTestCase;
import org.jboss.test.xb.builder.object.type.xmlanyelement.test.ListElementWildcardUnitTestCase;
import org.jboss.test.xb.builder.object.type.xmlanyelement.test.ListObjectWildcardUnitTestCase;
+import org.jboss.test.xb.builder.object.type.xmlanyelement.test.NotAnnotatedElementWildcardUnitTestCase;
import org.jboss.test.xb.builder.object.type.xmlanyelement.test.SimpleObjectWildcardUnitTestCase;
+import org.jboss.test.xb.builder.object.type.xmlanyelement.test.XmlElementsAndXmlAnyElementUnitTestCase;
/**
* ObjectTypeXmlAnyElementTestSuite.
@@ -55,6 +59,10 @@
suite.addTest(ElementWildcardUnitTestCase.suite());
suite.addTest(ArrayElementWildcardUnitTestCase.suite());
suite.addTest(ListElementWildcardUnitTestCase.suite());
+ suite.addTest(ElementPropertiesAndWildcardUnitTestCase.suite());
+ suite.addTest(ElementWildcardWithCollectionPropertyUnitTestCase.suite());
+ suite.addTest(NotAnnotatedElementWildcardUnitTestCase.suite());
+ suite.addTest(XmlElementsAndXmlAnyElementUnitTestCase.suite());
return suite;
}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/support/XmlElementsAndXmlAnyElement.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/support/XmlElementsAndXmlAnyElement.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/support/XmlElementsAndXmlAnyElement.java 2008-02-12 10:56:33 UTC (rev 2708)
@@ -0,0 +1,57 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, 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.xb.builder.object.type.xmlanyelement.support;
+
+import java.util.List;
+
+import javax.xml.bind.annotation.XmlAnyElement;
+import javax.xml.bind.annotation.XmlElement;
+import javax.xml.bind.annotation.XmlElements;
+
+/**
+ * XmlElementsAndXmlAnyElement.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+// apprently if there is no propOrder the test fails
+//@XmlType(propOrder="list")
+public class XmlElementsAndXmlAnyElement
+{
+ private List<Object> list;
+
+ public List<Object> getList()
+ {
+ return list;
+ }
+
+ @XmlElements
+ ({
+ @XmlElement(name="a", type=Integer.class),
+ @XmlElement(name="b", type=String.class)
+ })
+ @XmlAnyElement
+ public void setList(List<Object> wildcard)
+ {
+ this.list = wildcard;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/test/XmlElementsAndXmlAnyElementUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/test/XmlElementsAndXmlAnyElementUnitTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/type/xmlanyelement/test/XmlElementsAndXmlAnyElementUnitTestCase.java 2008-02-12 10:56:33 UTC (rev 2708)
@@ -0,0 +1,60 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2006, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file 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.xb.builder.object.type.xmlanyelement.test;
+
+import java.util.List;
+
+import junit.framework.Test;
+
+import org.jboss.test.xb.builder.AbstractBuilderTest;
+import org.jboss.test.xb.builder.object.type.xmlanyelement.support.XmlElementsAndXmlAnyElement;
+
+
+/**
+ * A XmlElementsAndXmlAnyElementUnitTestCase.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class XmlElementsAndXmlAnyElementUnitTestCase extends AbstractBuilderTest
+{
+ public static Test suite()
+ {
+ return suite(XmlElementsAndXmlAnyElementUnitTestCase.class);
+ }
+
+ public XmlElementsAndXmlAnyElementUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testUnmarshalling() throws Exception
+ {
+ XmlElementsAndXmlAnyElement o = unmarshalObject(XmlElementsAndXmlAnyElement.class);
+ List<Object> list = o.getList();
+ assertNotNull(list);
+ assertEquals(3, list.size());
+ assertEquals(11, list.get(0));
+ assertEquals("22", list.get(1));
+ assertTrue(list.get(2) instanceof XmlElementsAndXmlAnyElement);
+ }
+}
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/type/xmlanyelement/test/XmlElementsAndXmlAnyElement.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/type/xmlanyelement/test/XmlElementsAndXmlAnyElement.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/type/xmlanyelement/test/XmlElementsAndXmlAnyElement.xml 2008-02-12 10:56:33 UTC (rev 2708)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<xml-elements-and-xml-any-element>
+ <a>11</a>
+ <b>22</b>
+ <xml-elements-and-xml-any-element/>
+</xml-elements-and-xml-any-element>
\ No newline at end of file
More information about the jboss-svn-commits
mailing list