Author: manaRH
Date: 2009-08-13 01:57:03 -0400 (Thu, 13 Aug 2009)
New Revision: 11372
Modified:
branches/enterprise/JBPAPP_5_0/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java
branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/RemotingTest.java
Log:
JBPAPP-2406 - RemotingTest fixed for MapWrapper
Modified:
branches/enterprise/JBPAPP_5_0/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java
===================================================================
---
branches/enterprise/JBPAPP_5_0/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java 2009-08-13
00:46:47 UTC (rev 11371)
+++
branches/enterprise/JBPAPP_5_0/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java 2009-08-13
05:57:03 UTC (rev 11372)
@@ -53,6 +53,11 @@
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;
@@ -113,7 +118,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_5_0/src/test/unit/org/jboss/seam/test/unit/RemotingTest.java
===================================================================
---
branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/RemotingTest.java 2009-08-13
00:46:47 UTC (rev 11371)
+++
branches/enterprise/JBPAPP_5_0/src/test/unit/org/jboss/seam/test/unit/RemotingTest.java 2009-08-13
05:57:03 UTC (rev 11372)
@@ -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;
@@ -21,6 +22,7 @@
import java.util.Collection;
import java.util.Date;
import java.util.HashMap;
+import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Queue;
@@ -51,6 +53,7 @@
import org.jboss.seam.remoting.wrapper.StringWrapper;
import org.jboss.seam.remoting.wrapper.WrapperFactory;
import org.testng.annotations.Test;
+import org.w3c.dom.Node;
import org.jboss.seam.remoting.InterfaceGenerator;
import java.math.BigInteger;
import java.math.BigDecimal;
@@ -599,12 +602,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();
+ // ensure when we marshal/unmarshal the values in the map remain the same
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);
Show replies by date