Author: manaRH
Date: 2009-11-30 09:23:32 -0500 (Mon, 30 Nov 2009)
New Revision: 11704
Modified:
branches/enterprise/JBPAPP_4_2_CP01/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java
branches/enterprise/JBPAPP_4_2_CP01/src/test/misc/org/jboss/seam/test/RemotingTest.java
Log:
JBPAPP-3176
Modified:
branches/enterprise/JBPAPP_4_2_CP01/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java
===================================================================
---
branches/enterprise/JBPAPP_4_2_CP01/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java 2009-11-30
03:55:25 UTC (rev 11703)
+++
branches/enterprise/JBPAPP_4_2_CP01/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java 2009-11-30
14:23:32 UTC (rev 11704)
@@ -54,6 +54,12 @@
public Object convert(Type type)
throws ConversionException
{
+
+ if (context == null)
+ {
+ throw new IllegalStateException("No call context has been set");
+ }
+
Class typeClass = null;
Type keyType = null;
Type valueType = null;
@@ -108,9 +114,8 @@
Element keyElement = (Element) e.element("k").elementIterator().next();
Element valueElement = (Element)
e.element("v").elementIterator().next();
- ((Map) value).put(
- context.createWrapperFromElement(keyElement).convert(keyType),
- context.createWrapperFromElement(valueElement).convert(valueType));
+ ((Map) value).put(context.createWrapperFromElement(keyElement).convert(keyType),
+ context.createWrapperFromElement(valueElement).convert(valueType));
}
return value;
Modified:
branches/enterprise/JBPAPP_4_2_CP01/src/test/misc/org/jboss/seam/test/RemotingTest.java
===================================================================
---
branches/enterprise/JBPAPP_4_2_CP01/src/test/misc/org/jboss/seam/test/RemotingTest.java 2009-11-30
03:55:25 UTC (rev 11703)
+++
branches/enterprise/JBPAPP_4_2_CP01/src/test/misc/org/jboss/seam/test/RemotingTest.java 2009-11-30
14:23:32 UTC (rev 11704)
@@ -8,6 +8,7 @@
import static org.testng.Assert.assertEquals;
+import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.OutputStream;
@@ -597,13 +598,24 @@
{
}
- byte[] expected =
("<map><element><k><str>foo</str></k><v><str>aaaaa</str></v></element>"
- +
"<element><k><str>bar</str></k><v><str>zzzzz</str></v></element></map>")
- .getBytes();
ByteArrayOutputStream out = new ByteArrayOutputStream();
wrapper.marshal(out);
- assertEquals(expected, out.toByteArray());
-
+
+ SAXReader xmlReader = new SAXReader();
+ Document doc = xmlReader.read( new ByteArrayInputStream(out.toByteArray()) );
+
+ Element root = doc.getRootElement();
+
+ MapWrapper other = new MapWrapper();
+ other.setCallContext(new CallContext());
+ other.setElement(root);
+
+ Map otherMap = (Map) other.convert(Map.class);
+ for (Object key : otherMap.keySet())
+ {
+ assert otherMap.get(key).equals(m.get(key));
+ }
+
// test conversionScore() method
assert ConversionScore.exact == wrapper.conversionScore(Map.class);
assert ConversionScore.exact == wrapper.conversionScore(HashMap.class);
Show replies by date