So I'm creating a proper test in CompositeValueFactoryUnitTestCase, and there is a
descrepency with how the value TypeInfo is being obtained vs what is seen in
CompositeMetaTypeFactoryUnitTestCase. There, the type is obtained from the
field.getGenericType():
| /**
| * JBMICROCONT-238, Map<String,?> should map to a
MapCompositeMetaType(MetaValue<?>)
| * @throws Exception
| */
| public void testMapWithStringKeyComposite() throws Exception
| {
| Field field = getClass().getField("compositeSignature");
| Type mapSignature = field.getGenericType();
| CompositeMetaType result = assertInstanceOf(resolve(mapSignature),
CompositeMetaType.class);
| MapCompositeMetaType expected = new
MapCompositeMetaType(SimpleMetaType.STRING);
|
| testComposite(expected, result);
|
| Map<String, MetaValue> itemValues = new HashMap<String,
MetaValue>();
| itemValues.put("key1", SimpleValueSupport.wrap("value1"));
| itemValues.put("key2", SimpleValueSupport.wrap("value2"));
| itemValues.put("key3", SimpleValueSupport.wrap("value3"));
| MapCompositeValueSupport mapValue = new MapCompositeValueSupport(itemValues,
expected);
| assertEquals(SimpleValueSupport.wrap("value1"),
mapValue.get("key1"));
| assertEquals(SimpleValueSupport.wrap("value2"),
mapValue.get("key2"));
| assertEquals(SimpleValueSupport.wrap("value3"),
mapValue.get("key3"));
| }
|
In the CompositeValueFactoryUnitTestCase case, the type has to be obtained from
Configuration.getTypeInfo(value.getClass()), whcih relies on WeakTypeCache.get(Type).
Somewhere along the lines the parameterized info on the HashMap is being lost, so the
MetaType is not MapCompositeMetaType.
I guess this goes back to why the type test cannot be written as:
| public void testMapWithStringKeyComposite() throws Exception
| {
| Map<String,String> map = new HashMap<String,String>();
| CompositeMetaType result = assertInstanceOf(resolve(map.getClass()),
CompositeMetaType.class);
| MapCompositeMetaType expected = new
MapCompositeMetaType(SimpleMetaType.STRING);
| ...
|
This fails because the parameter types on the map are lost.
View the original post :
http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4134641#...
Reply to the post :
http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&a...