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.transformer.simple;
8   
9   import org.mule.api.transformer.Transformer;
10  import org.mule.transformer.AbstractTransformerTestCase;
11  
12  import java.util.Arrays;
13  
14  public class StringByteArrayTransformersTestCase extends AbstractTransformerTestCase
15  {
16  
17      public Transformer getTransformer() throws Exception
18      {
19          return new ObjectToByteArray();
20      }
21  
22      public Transformer getRoundTripTransformer() throws Exception
23      {
24          return new ByteArrayToObject();
25      }
26  
27      public Object getTestData()
28      {
29          return "Test";
30      }
31  
32      public Object getResultData()
33      {
34          return "Test".getBytes();
35      }
36  
37      @Override
38      public boolean compareResults(Object src, Object result)
39      {
40          if (src == null && result == null)
41          {
42              return true;
43          }
44          if (src == null || result == null)
45          {
46              return false;
47          }
48          return Arrays.equals((byte[]) src, (byte[]) result);
49      }
50  
51      @Override
52      public boolean compareRoundtripResults(Object src, Object result)
53      {
54          if (src == null && result == null)
55          {
56              return true;
57          }
58          if (src == null || result == null)
59          {
60              return false;
61          }
62          return src.equals(result);
63      }
64  }