View Javadoc

1   /*
2    * $Id: XmlObjectTransformersUTF8TestCase.java 20321 2010-11-24 15:21:24Z dfeist $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.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.xstream;
12  
13  import org.mule.api.transformer.Transformer;
14  import org.mule.module.xml.transformer.XmlToObject;
15  import org.mule.transformer.AbstractTransformerTestCase;
16  import org.mule.util.ArrayUtils;
17  
18  import java.io.UnsupportedEncodingException;
19  
20  public class XmlObjectTransformersUTF8TestCase extends AbstractTransformerTestCase
21  {
22  
23      // this is "���b���d���f" in a Java source file encoding independent form.
24      private static final String TEST_STRING = "\u00E1b\u00E7d\u00E8f";
25  
26      private final byte[] testXml;
27  
28      public XmlObjectTransformersUTF8TestCase() throws UnsupportedEncodingException
29      {
30          super();
31  
32          testXml = ArrayUtils.addAll("<string>".getBytes("ASCII"), ArrayUtils.addAll(
33              TEST_STRING.getBytes("UTF-8"), "</string>".getBytes("ASCII")));
34      }
35  
36      public Transformer getTransformer() throws Exception
37      {
38          return createObject(XmlToObject.class);
39      }
40  
41      public Transformer getRoundTripTransformer() throws Exception
42      {
43          // no round tripping because ObjectToXml transforms to String, and not byte[]
44          return null;
45      }
46  
47      public Object getTestData()
48      {
49          return testXml;
50      }
51  
52      public Object getResultData()
53      {
54          return TEST_STRING;
55      }
56  }