1   /*
2    * $Id: XStreamFactoryTestCase.java 7976 2007-08-21 14:26:13Z dirk.olmes $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSource, Inc.  All rights reserved.  http://www.mulesource.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
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  }