1   /*
2    * $Id: XmlObjectTransformersUTF8TestCase.java 9594 2007-11-05 11:15:16Z holger $
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.MuleManager;
14  import org.mule.tck.AbstractTransformerTestCase;
15  import org.mule.umo.transformer.UMOTransformer;
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      protected void doSetUp() throws Exception
37      {
38          super.doSetUp();
39  
40          MuleManager.getConfiguration().setEncoding("UTF-8");
41      }
42  
43      public UMOTransformer getTransformer() throws Exception
44      {
45          return new XmlToObject();
46      }
47  
48      public UMOTransformer getRoundTripTransformer() throws Exception
49      {
50          // no round tripping because ObjectToXml transforms to String, and not byte[]
51          return null;
52      }
53  
54      public Object getTestData()
55      {
56          return testXml;
57      }
58  
59      public Object getResultData()
60      {
61          return TEST_STRING;
62      }
63  }