1
2
3
4
5
6
7
8
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
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 }