View Javadoc

1   /*
2    * $Id: GZipTransformerRawBytesTestCase.java 22377 2011-07-11 12:41:42Z dirk.olmes $
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.transformer.compression;
12  
13  import org.mule.api.lifecycle.InitialisationException;
14  import org.mule.api.transformer.Transformer;
15  
16  import java.io.UnsupportedEncodingException;
17  
18  import static org.junit.Assert.fail;
19  
20  public class GZipTransformerRawBytesTestCase extends GZipTransformerTestCase
21  {
22  
23      @Override
24      public Object getResultData()
25      {
26          try
27          {
28              return strat.compressByteArray((byte[]) this.getTestData());
29          }
30          catch (Exception e)
31          {
32              fail(e.getMessage());
33              return null;
34          }
35      }
36  
37      @Override
38      public Object getTestData()
39      {
40          try
41          {
42              return ((String) super.getTestData()).getBytes("UTF8");
43          }
44          catch (UnsupportedEncodingException uex)
45          {
46              fail(uex.getMessage());
47              return null;
48          }
49      }
50  
51      @Override
52      public Transformer getRoundTripTransformer()
53      {
54          GZipUncompressTransformer transformer = new GZipUncompressTransformer();
55          transformer.setMuleContext(muleContext);
56  
57          try
58          {
59              transformer.initialise();
60          }
61          catch (InitialisationException e)
62          {
63              fail(e.getMessage());
64          }
65  
66          return transformer;
67      }
68  
69      @Override
70      public void doTestBadReturnType(Transformer tran, Object src) throws Exception
71      {
72          /*
73           * Disabled, otherwise the test for invalid return types would fail. The
74           * "invalid" class that is configured as returnType by the test harness would
75           * actually be a valid return type for our roundTripTransformer.
76           */
77      }
78  
79  }