[jboss-svn-commits] JBoss Common SVN: r2700 - in jbossxb/trunk/src: main/java/org/jboss/xb/builder and 4 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Tue Jan 15 09:32:50 EST 2008
Author: alex.loubyansky at jboss.com
Date: 2008-01-15 09:32:49 -0500 (Tue, 15 Jan 2008)
New Revision: 2700
Added:
jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlMapKey.java
jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlMapValue.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/EntryTypeKeyAttributeValueEntry.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/EntryTypeKeyAttributeValueEntryContent.java
jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntry_testEntryTypeKeyAttributeValueEntry.xml
jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntry_testEntryTypeKeyAttributeValueEntryContent.xml
Modified:
jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
jbossxb/trunk/src/main/java/org/jboss/xb/builder/runtime/MapPropertyHandler.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/Root.java
jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntryUnitTestCase.java
Log:
support for @JBossXmlMapEntry.type() and entry as a value
Added: jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlMapKey.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlMapKey.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlMapKey.java 2008-01-15 14:32:49 UTC (rev 2700)
@@ -0,0 +1,46 @@
+/*
+ * 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.xb.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * A JBossXmlMapKey. Specifies which property in the entry class
+ * represents the entry's key.
+ * There must be only one property in the entry class annotated with
+ * JBossXmlMapKey.
+ *
+ * Note: this annotation doesn't bind Java element to XML schema construct
+ * directly but just signifies which property should be used as the map
+ * entry's key property. The standard JAXB/JBossXB annotations
+ * should be used for binding the property to the XML schema construct.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD, ElementType.FIELD})
+public @interface JBossXmlMapKey {}
Added: jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlMapValue.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlMapValue.java (rev 0)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/annotations/JBossXmlMapValue.java 2008-01-15 14:32:49 UTC (rev 2700)
@@ -0,0 +1,47 @@
+/*
+ * 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.xb.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+
+/**
+ * A JBossXmlMapValue. Specifies which property in the entry class
+ * represents the entry's value.
+ * If none of the properties in the entry class is annotated with
+ * JBossXmlMapValue then an instance of the entry class
+ * is considered the value.
+ *
+ * Note: this annotation doesn't bind Java element to XML schema construct
+ * directly but just signifies which property should be used as the map
+ * entry's value property. The standard JAXB/JBossXB annotations
+ * should be used for binding the property to the XML schema construct.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+ at Retention(RetentionPolicy.RUNTIME)
+ at Target({ElementType.METHOD, ElementType.FIELD})
+public @interface JBossXmlMapValue {}
Modified: jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java 2008-01-14 20:05:16 UTC (rev 2699)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/builder/JBossXBNoSchemaBuilder.java 2008-01-15 14:32:49 UTC (rev 2700)
@@ -1687,6 +1687,7 @@
}
else if (propertyType.isMap() && ((ClassInfo) propertyType).getUnderlyingAnnotation(XmlType.class) == null)
{
+ JBossXmlMapEntry entryElement = property.getUnderlyingAnnotation(JBossXmlMapEntry.class);
JBossXmlMapKeyElement keyElement = property.getUnderlyingAnnotation(JBossXmlMapKeyElement.class);
JBossXmlMapKeyAttribute keyAttribute = property.getUnderlyingAnnotation(JBossXmlMapKeyAttribute.class);
@@ -1694,7 +1695,6 @@
{
// further assuming the map is bound
- JBossXmlMapEntry entryElement = property.getUnderlyingAnnotation(JBossXmlMapEntry.class);
JBossXmlMapValueElement valueElement = property.getUnderlyingAnnotation(JBossXmlMapValueElement.class);
JBossXmlMapValueAttribute valueAttribute = property.getUnderlyingAnnotation(JBossXmlMapValueAttribute.class);
@@ -1722,8 +1722,7 @@
entryType.setSchemaBinding(schemaBinding);
entryType.setHandler(entryHandler);
- entryTypeInfo = JBossXBBuilder.configuration.getTypeInfo(DefaultMapEntry.class);
-
+ entryTypeInfo = JBossXBBuilder.configuration.getTypeInfo(DefaultMapEntry.class);
ElementBinding entryElementBinding = createElementBinding(entryTypeInfo, entryType, entryName, false);
ParticleBinding entryParticle = new ParticleBinding(entryElementBinding, 0, -1, true);
targetGroup.addParticle(entryParticle);
@@ -1753,7 +1752,7 @@
valueBinding.setRequired(true);
entryType.addAttribute(valueBinding);
- propertyHandler = new MapPropertyHandler(property, localPropertyType);
+ propertyHandler = new MapPropertyHandler(JBossXBBuilder.configuration, property, localPropertyType);
}
else if(valueElement == null)
{
@@ -1808,8 +1807,26 @@
// TODO: need to verify correct binding before proceeding
isMap = true;
- propertyHandler = new MapPropertyHandler(property, localPropertyType);
+ propertyHandler = new MapPropertyHandler(JBossXBBuilder.configuration, property, localPropertyType);
}
+ else if(entryElement != null && !JBossXmlMapEntry.DEFAULT.class.equals(entryElement.type()))
+ {
+ if(!JBossXmlConstants.DEFAULT.equals(entryElement.name()))
+ {
+ String ns = entryElement.namespace();
+ if(JBossXmlConstants.DEFAULT.equals(ns))
+ ns = propertyQName.getNamespaceURI();
+ propertyQName = new QName(ns, entryElement.name());
+ }
+
+ TypeInfo entryTypeBinding = JBossXBBuilder.configuration.getTypeInfo(entryElement.type());
+ ElementBinding entryElementBinding = createElementBinding(entryTypeBinding, propertyQName.getLocalPart(), false);
+ ParticleBinding entryParticle = new ParticleBinding(entryElementBinding, 0, -1, true);
+ targetGroup.addParticle(entryParticle);
+
+ propertyHandler = new MapPropertyHandler(JBossXBBuilder.configuration, property, localPropertyType);
+ isMap = true;
+ }
else
{
// no or incorrect binding
Modified: jbossxb/trunk/src/main/java/org/jboss/xb/builder/runtime/MapPropertyHandler.java
===================================================================
--- jbossxb/trunk/src/main/java/org/jboss/xb/builder/runtime/MapPropertyHandler.java 2008-01-14 20:05:16 UTC (rev 2699)
+++ jbossxb/trunk/src/main/java/org/jboss/xb/builder/runtime/MapPropertyHandler.java 2008-01-15 14:32:49 UTC (rev 2700)
@@ -27,10 +27,15 @@
import javax.xml.namespace.QName;
+import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.beans.info.spi.PropertyInfo;
+import org.jboss.config.spi.Configuration;
import org.jboss.reflect.spi.ClassInfo;
import org.jboss.reflect.spi.ConstructorInfo;
import org.jboss.reflect.spi.TypeInfo;
+import org.jboss.xb.annotations.JBossXmlMapEntry;
+import org.jboss.xb.annotations.JBossXmlMapKey;
+import org.jboss.xb.annotations.JBossXmlMapValue;
import org.jboss.xb.spi.BeanAdapter;
/**
@@ -42,7 +47,7 @@
public class MapPropertyHandler extends AbstractPropertyHandler
{
private final MapFactory mapFactory;
-
+ private final MapPutAdapter mapPutAdapter;
/**
* Create a new MapPropertyHandler.
*
@@ -50,14 +55,14 @@
* @param propertyType the property type
* @throws IllegalArgumentException for a null qName or property
*/
- public MapPropertyHandler(PropertyInfo propertyInfo, TypeInfo propertyType)
+ public MapPropertyHandler(Configuration config, PropertyInfo propertyInfo, TypeInfo propertyType)
{
super(propertyInfo, propertyType);
ClassInfo classInfo = (ClassInfo) propertyType;
if (Modifier.isAbstract(classInfo.getModifiers()))
{
- mapFactory = new HashMapFactory();
+ mapFactory = HashMapFactory.INSTANCE;
}
else
{
@@ -82,6 +87,15 @@
}
mapFactory = new CtorMapFactory(constructor);
}
+
+ JBossXmlMapEntry entry = propertyInfo.getUnderlyingAnnotation(JBossXmlMapEntry.class);
+ if(entry != null && !JBossXmlMapEntry.DEFAULT.class.equals(entry.type()))
+ {
+ BeanInfo entryBean = config.getBeanInfo(entry.type());
+ mapPutAdapter = new CustomMapEntryPutAdapter(entryBean);
+ }
+ else
+ mapPutAdapter = DefaultMapEntryPutAdapter.INSTANCE;
}
@Override
@@ -122,23 +136,88 @@
throw new RuntimeException("QName " + qName + " error setting map property " + propertyInfo.getName() + " for " + BuilderUtil.toDebugString(parent) + " with value " + BuilderUtil.toDebugString(m), t);
}
}
-
- if(!(child instanceof DefaultMapEntry))
- throw new IllegalStateException("Only the DefaultMapEntry is supported at the moment: " + child);
-
- DefaultMapEntry entry = (DefaultMapEntry) child;
- // Now add
try
{
- m.put(entry.getKey(), entry.getValue());
+ mapPutAdapter.put(m, child);
}
- catch (Exception e)
+ catch (Throwable e)
{
throw new RuntimeException("QName " + qName + " error adding " + BuilderUtil.toDebugString(child) + " to map " + BuilderUtil.toDebugString(m), e);
}
}
+ private static interface MapPutAdapter
+ {
+ void put(Map<Object,Object> map, Object entry) throws Throwable;
+ }
+
+ private static class CustomMapEntryPutAdapter implements MapPutAdapter
+ {
+ private final PropertyInfo keyProp;
+ private final PropertyInfo valueProp;
+
+ CustomMapEntryPutAdapter(BeanInfo entryBean)
+ {
+ PropertyInfo keyProp = null;
+ PropertyInfo valueProp = null;
+ for(PropertyInfo prop : entryBean.getProperties())
+ {
+ JBossXmlMapKey key = prop.getUnderlyingAnnotation(JBossXmlMapKey.class);
+ if(key != null)
+ {
+ if(keyProp != null)
+ throw new IllegalStateException(
+ "Found two properties in entry type " + entryBean.getName() +
+ " annotated with @JBossXmlMapKey: " +
+ keyProp.getName() + " and " + prop.getName());
+ keyProp = prop;
+ }
+
+ JBossXmlMapValue value = prop.getUnderlyingAnnotation(JBossXmlMapValue.class);
+ if(value != null)
+ {
+ if(valueProp != null)
+ throw new IllegalStateException(
+ "Found two properties in entry type " + entryBean.getName() +
+ " annotated with @JBossXmlMapValue: " +
+ valueProp.getName() + " and " + prop.getName());
+ valueProp = prop;
+ }
+ }
+
+ if(keyProp == null)
+ throw new IllegalStateException(
+ "Entry type " + entryBean.getName() +
+ " doesn't have any property annotated with @JBossXmlMapKey.");
+
+ this.keyProp = keyProp;
+ this.valueProp = valueProp;
+ }
+
+ public void put(Map<Object, Object> map, Object entry) throws Throwable
+ {
+ Object key = keyProp.get(entry);
+ Object value = entry;
+ if(valueProp != null)
+ value = valueProp.get(entry);
+ map.put(key, value);
+ }
+ }
+
+ private static class DefaultMapEntryPutAdapter implements MapPutAdapter
+ {
+ static final MapPutAdapter INSTANCE = new DefaultMapEntryPutAdapter();
+
+ public void put(Map<Object, Object> map, Object entry)
+ {
+ if(!(entry instanceof DefaultMapEntry))
+ throw new IllegalStateException("Expected DefaultMapEntry but got " + entry);
+ DefaultMapEntry defEntry = (DefaultMapEntry) entry;
+ map.put(defEntry.getKey(), defEntry.getValue());
+ }
+ }
+
private static interface MapFactory
{
Map<Object, Object> createMap() throws Throwable;
@@ -146,6 +225,8 @@
private static class HashMapFactory implements MapFactory
{
+ static final MapFactory INSTANCE = new HashMapFactory();
+
@SuppressWarnings("unchecked")
public Map<Object, Object> createMap()
{
Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/EntryTypeKeyAttributeValueEntry.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/EntryTypeKeyAttributeValueEntry.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/EntryTypeKeyAttributeValueEntry.java 2008-01-15 14:32:49 UTC (rev 2700)
@@ -0,0 +1,76 @@
+/*
+ * 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.jbossxmlmapentry.support;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlElement;
+
+import org.jboss.xb.annotations.JBossXmlMapKey;
+
+
+/**
+ * A EntryTypeKeyAttributeValueEntry.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class EntryTypeKeyAttributeValueEntry
+{
+ private String key;
+ private String valueAttribute;
+ private Integer valueElement;
+
+
+ @JBossXmlMapKey
+ @XmlAttribute
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey(String key)
+ {
+ this.key = key;
+ }
+
+ @XmlAttribute(name="attr")
+ public String getValueAttribute()
+ {
+ return valueAttribute;
+ }
+
+ public void setValueAttribute(String valueAttribute)
+ {
+ this.valueAttribute = valueAttribute;
+ }
+
+ @XmlElement(name="value")
+ public Integer getValueElement()
+ {
+ return valueElement;
+ }
+
+ public void setValueElement(Integer valueElement)
+ {
+ this.valueElement = valueElement;
+ }
+}
Added: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/EntryTypeKeyAttributeValueEntryContent.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/EntryTypeKeyAttributeValueEntryContent.java (rev 0)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/EntryTypeKeyAttributeValueEntryContent.java 2008-01-15 14:32:49 UTC (rev 2700)
@@ -0,0 +1,65 @@
+/*
+ * 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.jbossxmlmapentry.support;
+
+import javax.xml.bind.annotation.XmlAttribute;
+import javax.xml.bind.annotation.XmlValue;
+
+import org.jboss.xb.annotations.JBossXmlMapKey;
+import org.jboss.xb.annotations.JBossXmlMapValue;
+
+
+/**
+ * A EntryTypeKeyAttributeValueEntryContent.
+ *
+ * @author <a href="alex at jboss.com">Alexey Loubyansky</a>
+ * @version $Revision: 1.1 $
+ */
+public class EntryTypeKeyAttributeValueEntryContent
+{
+ private String key;
+ private Integer value;
+
+ @JBossXmlMapKey
+ @XmlAttribute
+ public String getKey()
+ {
+ return key;
+ }
+
+ public void setKey(String key)
+ {
+ this.key = key;
+ }
+
+ @JBossXmlMapValue
+ @XmlValue
+ public Integer getValue()
+ {
+ return value;
+ }
+
+ public void setValue(Integer value)
+ {
+ this.value = value;
+ }
+}
Modified: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/Root.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/Root.java 2008-01-14 20:05:16 UTC (rev 2699)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/support/Root.java 2008-01-15 14:32:49 UTC (rev 2700)
@@ -42,6 +42,7 @@
public class Root
{
private Map<String, Integer> stringToInteger;
+ private Map<String, EntryTypeKeyAttributeValueEntry> entryTypeMap;
@JBossXmlMapKeyElement(name = "key")
@JBossXmlMapValueElement(name = "value")
@@ -92,4 +93,26 @@
{
this.stringToInteger = value;
}
+
+ @JBossXmlMapEntry(name = "entry-type-key-attr-value-entry-content", type=EntryTypeKeyAttributeValueEntryContent.class)
+ public Map<String, Integer> getEntryTypeKeyAttributeValueEntryContent()
+ {
+ return this.stringToInteger;
+ }
+
+ public void setEntryTypeKeyAttributeValueEntryContent(Map<String, Integer> value)
+ {
+ this.stringToInteger = value;
+ }
+
+ @JBossXmlMapEntry(name = "entry-type-key-attr-value-entry", type=EntryTypeKeyAttributeValueEntry.class)
+ public Map<String, EntryTypeKeyAttributeValueEntry> getEntryTypeKeyAttributeValueEntry()
+ {
+ return this.entryTypeMap;
+ }
+
+ public void setEntryTypeKeyAttributeValueEntry(Map<String, EntryTypeKeyAttributeValueEntry> value)
+ {
+ this.entryTypeMap = value;
+ }
}
Modified: jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntryUnitTestCase.java
===================================================================
--- jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntryUnitTestCase.java 2008-01-14 20:05:16 UTC (rev 2699)
+++ jbossxb/trunk/src/test/java/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntryUnitTestCase.java 2008-01-15 14:32:49 UTC (rev 2700)
@@ -24,6 +24,7 @@
import java.util.Map;
import org.jboss.test.xb.builder.AbstractBuilderTest;
+import org.jboss.test.xb.builder.object.jbossxmlmapentry.support.EntryTypeKeyAttributeValueEntry;
import org.jboss.test.xb.builder.object.jbossxmlmapentry.support.Root;
@@ -65,6 +66,38 @@
assertMap(root.getKeyAttributeValueEntryContent());
}
+ public void testEntryTypeKeyAttributeValueEntryContent() throws Exception
+ {
+ Root root = unmarshalObject(Root.class);
+ assertMap(root.getEntryTypeKeyAttributeValueEntryContent());
+ }
+
+ public void testEntryTypeKeyAttributeValueEntry() throws Exception
+ {
+ Root root = unmarshalObject(Root.class);
+ Map<String, EntryTypeKeyAttributeValueEntry> map = root.getEntryTypeKeyAttributeValueEntry();
+ assertNotNull(map);
+ assertEquals(3, map.size());
+
+ EntryTypeKeyAttributeValueEntry entry = map.get("key1");
+ assertNotNull(entry);
+ assertEquals("key1", entry.getKey());
+ assertEquals("attr1", entry.getValueAttribute());
+ assertEquals(new Integer(1), entry.getValueElement());
+
+ entry = map.get("key2");
+ assertNotNull(entry);
+ assertEquals("key2", entry.getKey());
+ assertEquals("attr2", entry.getValueAttribute());
+ assertEquals(new Integer(22), entry.getValueElement());
+
+ entry = map.get("key3");
+ assertNotNull(entry);
+ assertEquals("key3", entry.getKey());
+ assertEquals("attr3", entry.getValueAttribute());
+ assertEquals(new Integer(333), entry.getValueElement());
+ }
+
private void assertMap(Map<String, Integer> map)
{
assertNotNull(map);
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntry_testEntryTypeKeyAttributeValueEntry.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntry_testEntryTypeKeyAttributeValueEntry.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntry_testEntryTypeKeyAttributeValueEntry.xml 2008-01-15 14:32:49 UTC (rev 2700)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<root>
+ <entry-type-key-attr-value-entry key="key1" attr="attr1">
+ <value>1</value>
+ </entry-type-key-attr-value-entry>
+ <entry-type-key-attr-value-entry key="key2" attr="attr2">
+ <value>22</value>
+ </entry-type-key-attr-value-entry>
+ <entry-type-key-attr-value-entry key="key3" attr="attr3">
+ <value>333</value>
+ </entry-type-key-attr-value-entry>
+</root>
Added: jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntry_testEntryTypeKeyAttributeValueEntryContent.xml
===================================================================
--- jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntry_testEntryTypeKeyAttributeValueEntryContent.xml (rev 0)
+++ jbossxb/trunk/src/test/resources/org/jboss/test/xb/builder/object/jbossxmlmapentry/test/JBossXmlMapEntry_testEntryTypeKeyAttributeValueEntryContent.xml 2008-01-15 14:32:49 UTC (rev 2700)
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<root>
+ <entry-type-key-attr-value-entry-content key="key1">1</entry-type-key-attr-value-entry-content>
+ <entry-type-key-attr-value-entry-content key="key2">22</entry-type-key-attr-value-entry-content>
+ <entry-type-key-attr-value-entry-content key="key3">333</entry-type-key-attr-value-entry-content>
+</root>
More information about the jboss-svn-commits
mailing list