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