View Javadoc
1   /*
2    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
3    * The software in this package is published under the terms of the CPAL v1.0
4    * license, a copy of which has been included with this distribution in the
5    * LICENSE.txt file.
6    */
7   package org.mule.transformers.xml.xstream;
8   
9   import org.mule.api.transformer.Transformer;
10  import org.mule.module.xml.transformer.XmlToObject;
11  import org.mule.transformer.AbstractTransformerTestCase;
12  import org.mule.util.ArrayUtils;
13  
14  import java.io.UnsupportedEncodingException;
15  
16  public class XmlObjectTransformersUTF8TestCase extends AbstractTransformerTestCase
17  {
18  
19      // this is "���b���d���f" in a Java source file encoding independent form.
20      private static final String TEST_STRING = "\u00E1b\u00E7d\u00E8f";
21  
22      private final byte[] testXml;
23  
24      public XmlObjectTransformersUTF8TestCase() throws UnsupportedEncodingException
25      {
26          super();
27  
28          testXml = ArrayUtils.addAll("<string>".getBytes("ASCII"), ArrayUtils.addAll(
29              TEST_STRING.getBytes("UTF-8"), "</string>".getBytes("ASCII")));
30      }
31  
32      public Transformer getTransformer() throws Exception
33      {
34          return createObject(XmlToObject.class);
35      }
36  
37      public Transformer getRoundTripTransformer() throws Exception
38      {
39          // no round tripping because ObjectToXml transforms to String, and not byte[]
40          return null;
41      }
42  
43      public Object getTestData()
44      {
45          return testXml;
46      }
47  
48      public Object getResultData()
49      {
50          return TEST_STRING;
51      }
52  }