[seam-commits] Seam SVN: r11641 - in branches/enterprise/JBPAPP_4_3_FP01/src: test/unit/org/jboss/seam/test/unit and 1 other directory.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Nov 18 18:46:18 EST 2009


Author: manaRH
Date: 2009-11-18 18:46:18 -0500 (Wed, 18 Nov 2009)
New Revision: 11641

Modified:
   branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java
   branches/enterprise/JBPAPP_4_3_FP01/src/test/unit/org/jboss/seam/test/unit/RemotingTest.java
Log:
JBPAPP-3118

Modified: branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java	2009-11-18 23:17:00 UTC (rev 11640)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/remoting/org/jboss/seam/remoting/wrapper/MapWrapper.java	2009-11-18 23:46:18 UTC (rev 11641)
@@ -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_3_FP01/src/test/unit/org/jboss/seam/test/unit/RemotingTest.java
===================================================================
--- branches/enterprise/JBPAPP_4_3_FP01/src/test/unit/org/jboss/seam/test/unit/RemotingTest.java	2009-11-18 23:17:00 UTC (rev 11640)
+++ branches/enterprise/JBPAPP_4_3_FP01/src/test/unit/org/jboss/seam/test/unit/RemotingTest.java	2009-11-18 23:46:18 UTC (rev 11641)
@@ -8,12 +8,15 @@
 
 import static org.testng.Assert.assertEquals;
 
+import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
 import java.io.OutputStream;
 import java.io.StringReader;
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.Type;
+import java.math.BigDecimal;
+import java.math.BigInteger;
 import java.net.URLEncoder;
 import java.util.ArrayList;
 import java.util.Arrays;
@@ -36,6 +39,7 @@
 import org.jboss.seam.mock.MockServletContext;
 import org.jboss.seam.remoting.Call;
 import org.jboss.seam.remoting.CallContext;
+import org.jboss.seam.remoting.InterfaceGenerator;
 import org.jboss.seam.remoting.MarshalUtils;
 import org.jboss.seam.remoting.client.ParserUtils;
 import org.jboss.seam.remoting.wrapper.BagWrapper;
@@ -51,9 +55,6 @@
 import org.jboss.seam.remoting.wrapper.StringWrapper;
 import org.jboss.seam.remoting.wrapper.WrapperFactory;
 import org.testng.annotations.Test;
-import org.jboss.seam.remoting.InterfaceGenerator;
-import java.math.BigInteger;
-import java.math.BigDecimal;
 
 /**
  * Unit tests for Seam Remoting
@@ -599,13 +600,25 @@
       {
       }
 
-      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);
       assert ConversionScore.exact == wrapper.conversionScore(HashMap.class);



More information about the seam-commits mailing list