[jboss-svn-commits] JBoss Common SVN: r2926 - in jbossxb/trunk/src: main/java/org/jboss/xb/builder and 8 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Wed Oct 15 14:44:53 EDT 2008
Author: alex.loubyansky at jboss.com
Date: 2008-10-15 14:44:53 -0400 (Wed, 15 Oct 2008)
New Revision: 2926
Added:
jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AnyAttributeBinding.java
jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AnyAttributeHandler.java
jbossxb/trunk/src/main/java/org/jboss/xb/builder/runtime/AnyAttributePropertyHandler.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/support/
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/support/AnyAttributes.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/test/
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/test/AnyAttributeUnitTestCase.java
jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/anyattribute/
jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/anyattribute/test/
jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/anyattribute/test/AnyAttribute.xml
Modified:
jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributesHandler.java
jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/TypeBinding.java
jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
Log:
JBXB-160
Added: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AnyAttributeBinding.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AnyAttributeBinding.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AnyAttributeBinding.java 2008-10-15 18:44:53 UTC (rev 2926)
@@ -0,0 +1,106 @@
+/*
+ * 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.xb.binding.sunday.unmarshalling;
+
+import org.jboss.xb.binding.metadata.PropertyMetaData;
+import org.jboss.xb.binding.sunday.marshalling.AttributeMarshaller;
+import org.jboss.xb.binding.sunday.marshalling.DefaultAttributeMarshaller;
+
+/**
+ * A AnyAttributeBinding.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnyAttributeBinding
+{
+ private final SchemaBinding schema;
+ private AnyAttributeHandler handler;
+ private AttributeMarshaller marshaller = DefaultAttributeMarshaller.INSTANCE;
+ private PropertyMetaData propertyMetaData;
+ private ValueAdapter valueAdapter;
+ protected Boolean normalizeSpace;
+
+ public AnyAttributeBinding(SchemaBinding schema, AnyAttributeHandler handler)
+ {
+ super();
+ this.schema = schema;
+ this.handler = handler;
+ }
+
+ public AnyAttributeHandler getHandler()
+ {
+ return handler;
+ }
+
+ public void setHandler(AnyAttributeHandler handler)
+ {
+ this.handler = handler;
+ }
+
+ public AttributeMarshaller getMarshaller()
+ {
+ return marshaller;
+ }
+
+ public void setMarshaller(AttributeMarshaller marshaller)
+ {
+ this.marshaller = marshaller;
+ }
+
+ public PropertyMetaData getPropertyMetaData()
+ {
+ return propertyMetaData;
+ }
+
+ public void setPropertyMetaData(PropertyMetaData propertyMetaData)
+ {
+ this.propertyMetaData = propertyMetaData;
+ }
+
+ public ValueAdapter getValueAdapter()
+ {
+ return valueAdapter;
+ }
+
+ public void setValueAdapter(ValueAdapter valueAdapter)
+ {
+ this.valueAdapter = valueAdapter;
+ }
+
+ public boolean isNormalizeSpace()
+ {
+ if(normalizeSpace != null)
+ return normalizeSpace.booleanValue();
+ return schema == null ? true : schema.isNormalizeSpace();
+ }
+
+ public void setNormalizeSpace(Boolean normalizeSpace)
+ {
+ this.normalizeSpace = normalizeSpace;
+ }
+
+ public SchemaBinding getSchema()
+ {
+ return schema;
+ }
+}
Property changes on: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AnyAttributeBinding.java
___________________________________________________________________
Name: svn:executable
+ *
Added: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AnyAttributeHandler.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AnyAttributeHandler.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AnyAttributeHandler.java 2008-10-15 18:44:53 UTC (rev 2926)
@@ -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.xb.binding.sunday.unmarshalling;
+
+import javax.xml.namespace.NamespaceContext;
+import javax.xml.namespace.QName;
+
+/**
+ * A AnyAttributeHandler.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public abstract class AnyAttributeHandler
+{
+ public Object unmarshal(QName elemName, QName attrName, AnyAttributeBinding binding, NamespaceContext nsCtx, String value)
+ {
+ if(value != null && binding.isNormalizeSpace())
+ value = value.trim();
+ return value;
+ }
+
+ public abstract void attribute(QName elemName, QName attrName, AnyAttributeBinding binding, Object owner, Object value);
+}
Property changes on: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AnyAttributeHandler.java
___________________________________________________________________
Name: svn:executable
+ *
Modified: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributesHandler.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributesHandler.java 2008-09-17 15:35:46 UTC (rev 2925)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/AttributesHandler.java 2008-10-15 18:44:53 UTC (rev 2926)
@@ -50,18 +50,28 @@
Object value = handler.unmarshal(elementName, qName, binding, nsCtx, attrs.getValue(i));
handler.attribute(elementName, qName, binding, o, value);
}
- else if(!Constants.NS_XML_SCHEMA_INSTANCE.equals(qName.getNamespaceURI()))
+ else
{
- SchemaBinding schemaBinding = type.getSchemaBinding();
- if(schemaBinding != null && schemaBinding.isStrictSchema())
+ AnyAttributeBinding anyAttribute = type.getAnyAttribute();
+ if(anyAttribute != null)
{
- throw new JBossXBRuntimeException(
- "Attribute is not bound: element owner " + elementName + ", attribute " + qName
- );
+ AnyAttributeHandler handler = anyAttribute.getHandler();
+ Object value = handler.unmarshal(elementName, qName, anyAttribute, nsCtx, attrs.getValue(i));
+ handler.attribute(elementName, qName, anyAttribute, o, value);
}
- else if(log.isTraceEnabled())
+ else if(!Constants.NS_XML_SCHEMA_INSTANCE.equals(qName.getNamespaceURI()))
{
- log.trace("Attribute is not bound: element owner " + elementName + ", attribute " + qName);
+ SchemaBinding schemaBinding = type.getSchemaBinding();
+ if(schemaBinding != null && schemaBinding.isStrictSchema())
+ {
+ throw new JBossXBRuntimeException(
+ "Attribute is not bound: element owner " + elementName + ", attribute " + qName
+ );
+ }
+ else if(log.isTraceEnabled())
+ {
+ log.trace("Attribute is not bound: element owner " + elementName + ", attribute " + qName);
+ }
}
}
}
Modified: jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/TypeBinding.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/TypeBinding.java 2008-09-17 15:35:46 UTC (rev 2925)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/binding/sunday/unmarshalling/TypeBinding.java 2008-10-15 18:44:53 UTC (rev 2926)
@@ -53,6 +53,7 @@
protected QName qName;
/** Map<QName, AttributeBinding> */
private Map<QName, AttributeBinding> attrs = Collections.emptyMap();
+ private AnyAttributeBinding anyAttribute;
private ParticleHandler handler;//todo default handler is now in SundayContentHandler.
private CharactersHandler charactersHandler;
private ClassMetaData classMetaData;
@@ -692,6 +693,16 @@
this.ignoreEmptyString = value;
}
+ public AnyAttributeBinding getAnyAttribute()
+ {
+ return anyAttribute;
+ }
+
+ public void setAnyAttribute(AnyAttributeBinding anyAttribute)
+ {
+ this.anyAttribute = anyAttribute;
+ }
+
public String toString()
{
return super.toString() + "[" + qName + "]";
Modified: jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java 2008-09-17 15:35:46 UTC (rev 2925)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java 2008-10-15 18:44:53 UTC (rev 2926)
@@ -37,6 +37,7 @@
import javax.xml.XMLConstants;
import javax.xml.bind.annotation.XmlAccessOrder;
import javax.xml.bind.annotation.XmlAccessorOrder;
+import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAnyElement;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
@@ -92,6 +93,7 @@
import org.jboss.xb.binding.JBossXBRuntimeException;
import org.jboss.xb.binding.SimpleTypeBindings;
import org.jboss.xb.binding.sunday.unmarshalling.AllBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.AnyAttributeBinding;
import org.jboss.xb.binding.sunday.unmarshalling.AttributeBinding;
import org.jboss.xb.binding.sunday.unmarshalling.AttributeHandler;
import org.jboss.xb.binding.sunday.unmarshalling.CharactersHandler;
@@ -108,6 +110,7 @@
import org.jboss.xb.binding.sunday.unmarshalling.ValueAdapter;
import org.jboss.xb.binding.sunday.unmarshalling.WildcardBinding;
import org.jboss.xb.builder.runtime.AbstractPropertyHandler;
+import org.jboss.xb.builder.runtime.AnyAttributePropertyHandler;
import org.jboss.xb.builder.runtime.ArraySequenceBinding;
import org.jboss.xb.builder.runtime.BeanHandler;
import org.jboss.xb.builder.runtime.BuilderParticleHandler;
@@ -825,6 +828,7 @@
if (properties != null && properties.isEmpty() == false)
{
boolean seenXmlAnyElement = false;
+ PropertyInfo seenXmlAnyAttribute = null;
for (PropertyInfo property : properties)
{
push(typeInfo, property.getName());
@@ -894,6 +898,25 @@
log.trace("Bound attribute " + qName + " type=" + beanInfo.getName() + " property=" + property.getName() + " propertyType=" + attributeTypeInfo + ", normalizeSpace=" + attribute.isNormalizeSpace());
}
+ // Is this any attribute
+ XmlAnyAttribute xmlAnyAttribute = property.getUnderlyingAnnotation(XmlAnyAttribute.class);
+ if (xmlAnyAttribute != null)
+ {
+ if (seenXmlAnyAttribute != null)
+ throw new RuntimeException("@XmlAnyAttribute seen on two properties: " + property.getName() + " and " + seenXmlAnyAttribute.getName());
+ seenXmlAnyAttribute = property;
+
+ AnyAttributePropertyHandler anyHandler = new AnyAttributePropertyHandler(property, property.getType());
+ AnyAttributeBinding anyAttribute = new AnyAttributeBinding(schemaBinding, anyHandler);
+ typeBinding.setAnyAttribute(anyAttribute);
+
+ JBossXmlPreserveWhitespace preserveSpace = property.getUnderlyingAnnotation(JBossXmlPreserveWhitespace.class);
+ if(preserveSpace != null)
+ anyAttribute.setNormalizeSpace(preserveSpace.preserve() ? false : true);
+ if (trace)
+ log.trace("Bound any attribute type=" + beanInfo.getName() + " property=" + property.getName() + ", normalizeSpace=" + anyAttribute.isNormalizeSpace());
+ }
+
// Are we determining the property order?
if (determinePropertyOrder)
{
Added: jbossxb/trunk/src/main/java/org/jboss/xb/builder/runtime/AnyAttributePropertyHandler.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/builder/runtime/AnyAttributePropertyHandler.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/builder/runtime/AnyAttributePropertyHandler.java 2008-10-15 18:44:53 UTC (rev 2926)
@@ -0,0 +1,144 @@
+/*
+ * 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.xb.builder.runtime;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.logging.Logger;
+import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.xb.binding.sunday.unmarshalling.AnyAttributeBinding;
+import org.jboss.xb.binding.sunday.unmarshalling.AnyAttributeHandler;
+import org.jboss.xb.binding.sunday.unmarshalling.ValueAdapter;
+import org.jboss.xb.spi.BeanAdapter;
+
+/**
+ * A AnyAttributePropertyHandler.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnyAttributePropertyHandler extends AnyAttributeHandler
+{
+ /** The log */
+ protected final Logger log = Logger.getLogger(getClass());
+
+ /** Whether trace is enabled */
+ protected boolean trace = log.isTraceEnabled();
+
+ /** The property info */
+ private PropertyInfo propertyInfo;
+
+ /** The property type */
+ private TypeInfo propertyType;
+
+ public AnyAttributePropertyHandler(PropertyInfo propertyInfo, TypeInfo propertyType)
+ {
+ if (propertyInfo == null)
+ throw new IllegalArgumentException("Null propertyInfo");
+ if (propertyType == null)
+ throw new IllegalArgumentException("Null propertyType");
+
+ if(!propertyType.isMap())
+ throw new IllegalStateException("Current implementation expects property bound to anyAttribute to be of type Map<QName, Object>." +
+ " Property name is " + propertyInfo.getName() + ", property type is " + propertyType.getName());
+
+ this.propertyInfo = propertyInfo;
+ }
+
+ /**
+ * Get the property info
+ *
+ * @return the property info
+ */
+ public PropertyInfo getPropertyInfo()
+ {
+ return propertyInfo;
+ }
+
+ public void doHandle(Object parent, Object child, QName qName)
+ {
+ if (trace)
+ log.trace("QName " + qName + " handle " + BuilderUtil.toDebugString(child) + " to " + BuilderUtil.toDebugString(parent) + " property=" + propertyInfo.getName());
+
+ try
+ {
+ handle(propertyInfo, propertyType, parent, child, qName);
+ }
+ catch (RuntimeException e)
+ {
+ throw e;
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("QName " + qName + "error setting property " + propertyInfo.getName() + " with value " + BuilderUtil.toDebugString(child) + " to " + BuilderUtil.toDebugString(parent));
+ }
+ }
+
+ @Override
+ public void attribute(QName elemName, QName attrName, AnyAttributeBinding binding, Object owner, Object value)
+ {
+ ValueAdapter valueAdapter = binding.getValueAdapter();
+ if (valueAdapter != null)
+ value = valueAdapter.cast(value, null);
+
+ BeanAdapter parent = (BeanAdapter) owner;
+ doHandle(parent, value, attrName);
+ }
+
+ public void handle(PropertyInfo propertyInfo, TypeInfo propertyType, Object parent, Object child, QName name)
+ {
+ BeanAdapter beanAdapter = (BeanAdapter) parent;
+
+ Map<QName, Object> map = null;
+ try
+ {
+ if (propertyInfo.getGetter() != null)
+ map = (Map<QName, Object>) beanAdapter.get(propertyInfo);
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error getting map for property " + propertyInfo.getName()
+ + " bound to any attribute from " + BuilderUtil.toDebugString(parent), t);
+ }
+
+ // No map so create one
+ if (map == null)
+ {
+ map = new HashMap<QName, Object>();
+ try
+ {
+ beanAdapter.set(propertyInfo, map);
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException("Error setting map property " + propertyInfo.getName()
+ + " bound to any attribute for " + BuilderUtil.toDebugString(parent) + " with value " + BuilderUtil.toDebugString(map), t);
+ }
+ }
+
+ map.put(name, child);
+ }
+}
Property changes on: jbossxb/trunk/src/main/java/org/jboss/xb/builder/runtime/AnyAttributePropertyHandler.java
___________________________________________________________________
Name: svn:executable
+ *
Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/support/AnyAttributes.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/support/AnyAttributes.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/support/AnyAttributes.java 2008-10-15 18:44:53 UTC (rev 2926)
@@ -0,0 +1,63 @@
+/*
+ * 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.xb.builder.object.anyattribute.support;
+
+import java.util.Map;
+
+import javax.xml.bind.annotation.XmlAnyAttribute;
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.namespace.QName;
+
+/**
+ * A AnyAttributes.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnyAttributes
+{
+ private Map<QName,Object> anyAttributes;
+
+ private String staticAttribute;
+
+ @XmlAnyAttribute
+ public void setAnyAttributes(Map<QName,Object> anyAttributes)
+ {
+ this.anyAttributes = anyAttributes;
+ }
+
+ public Map<QName,Object> getAnyAttributes()
+ {
+ return this.anyAttributes;
+ }
+
+ @XmlAttribute
+ public void setStaticAttribute(String staticAttribute)
+ {
+ this.staticAttribute = staticAttribute;
+ }
+
+ public String getStaticAttribute()
+ {
+ return this.staticAttribute;
+ }
+}
Property changes on: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/support/AnyAttributes.java
___________________________________________________________________
Name: svn:executable
+ *
Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/test/AnyAttributeUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/test/AnyAttributeUnitTestCase.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/test/AnyAttributeUnitTestCase.java 2008-10-15 18:44:53 UTC (rev 2926)
@@ -0,0 +1,58 @@
+/*
+ * 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.xb.builder.object.anyattribute.test;
+
+import java.util.Map;
+
+import javax.xml.namespace.QName;
+
+import org.jboss.test.xb.builder.AbstractBuilderTest;
+import org.jboss.test.xb.builder.object.anyattribute.support.AnyAttributes;
+
+
+/**
+ * A AnyAttributeUnitTestCase.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class AnyAttributeUnitTestCase extends AbstractBuilderTest
+{
+ public AnyAttributeUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testUnmarshal() throws Exception
+ {
+ AnyAttributes result = unmarshalObject(AnyAttributes.class);
+ assertEquals("static", result.getStaticAttribute());
+ Map<QName, Object> anyAttributes = result.getAnyAttributes();
+ assertNotNull(anyAttributes);
+ assertEquals(2, anyAttributes.size());
+
+ Object value = anyAttributes.get(new QName("attr1"));
+ assertEquals("value1", value);
+ value = anyAttributes.get(new QName("attr2"));
+ assertEquals("value2", value);
+ }
+}
Property changes on: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/anyattribute/test/AnyAttributeUnitTestCase.java
___________________________________________________________________
Name: svn:executable
+ *
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/anyattribute/test/AnyAttribute.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/anyattribute/test/AnyAttribute.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/anyattribute/test/AnyAttribute.xml 2008-10-15 18:44:53 UTC (rev 2926)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<any-attributes
+ static-attribute="static"
+ attr1="value1"
+ attr2="value2"
+/>
Property changes on: jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/anyattribute/test/AnyAttribute.xml
___________________________________________________________________
Name: svn:executable
+ *
More information about the jboss-svn-commits
mailing list