1
2
3
4
5
6
7
8
9
10
11 package org.mule.transformers.xml;
12
13 import org.mule.tck.AbstractMuleTestCase;
14 import org.mule.util.StringUtils;
15
16 import com.thoughtworks.xstream.XStream;
17
18 import java.util.Map;
19
20 import edu.emory.mathcs.backport.java.util.concurrent.ConcurrentHashMap;
21
22 public class XStreamFactoryTestCase extends AbstractMuleTestCase
23 {
24
25 public void testConcurrentHashMapConverter()
26 throws ClassNotFoundException, IllegalAccessException, InstantiationException
27 {
28 ConcurrentHashMap map = new ConcurrentHashMap();
29 map.put("foo", "bar");
30
31 XStream xstream = new XStreamFactory().getInstance();
32 String mapXML = xstream.toXML(map);
33 assertNotNull(mapXML);
34 assertTrue(StringUtils.isNotEmpty(mapXML));
35
36 Object newMap = xstream.fromXML(mapXML);
37 assertNotNull(newMap);
38 assertTrue(newMap instanceof ConcurrentHashMap);
39 assertEquals(1, ((Map)newMap).size());
40 assertEquals("bar", ((Map)newMap).get("foo"));
41 }
42
43 }