1   /*
2    * $Id: GZipTransformerTestCase.java 11337 2008-03-12 20:16:06Z dirk.olmes $
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.transformer.compression;
12  
13  import org.mule.api.lifecycle.InitialisationException;
14  import org.mule.api.transformer.Transformer;
15  import org.mule.transformer.AbstractTransformerTestCase;
16  import org.mule.util.compression.GZipCompression;
17  
18  import org.apache.commons.lang.SerializationUtils;
19  
20  public class GZipTransformerTestCase extends AbstractTransformerTestCase
21  {
22      protected static final String TEST_DATA = "the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog the quick brown fox jumped over the lazy dog";
23      protected GZipCompression strat;
24  
25      // @Override
26      protected void doSetUp() throws Exception
27      {
28          strat = new GZipCompression();
29      }
30  
31      public Object getResultData()
32      {
33          try
34          {
35              return strat.compressByteArray(SerializationUtils.serialize(TEST_DATA));
36          }
37          catch (Exception e)
38          {
39              fail(e.getMessage());
40              return null;
41          }
42      }
43  
44      public Object getTestData()
45      {
46          return TEST_DATA;
47      }
48  
49      public Transformer getTransformer()
50      {
51          return new GZipCompressTransformer();
52      }
53  
54      public Transformer getRoundTripTransformer()
55      {
56          GZipUncompressTransformer transformer = new GZipUncompressTransformer();
57          transformer.setReturnClass(String.class);
58  
59          try
60          {
61              transformer.initialise();
62          }
63          catch (InitialisationException e)
64          {
65              fail(e.getMessage());
66          }
67  
68          return transformer;
69      }
70  
71  }