1
2
3
4
5
6
7
8
9
10
11 package org.mule.transformer;
12
13 import org.mule.api.transformer.Transformer;
14 import org.mule.api.transformer.TransformerException;
15 import org.mule.transport.NullPayload;
16
17 public class NullResultTestCase extends AbstractTransformerTestCase
18 {
19
20 private final NullResultTransformer transformer = new NullResultTransformer();
21
22 public Object getTestData()
23 {
24 return new Object();
25 }
26
27 public Object getResultData()
28 {
29 return NullPayload.getInstance();
30 }
31
32 public Transformer getTransformer() throws Exception
33 {
34 return transformer;
35 }
36
37 public Transformer getRoundTripTransformer() throws Exception
38 {
39 return null;
40 }
41
42 public void testNullNotExpected() throws Exception
43 {
44 transformer.setReturnClass(String.class);
45 try
46 {
47 testTransform();
48 fail("Transformer should have thrown an exception because the return class doesn't match the result.");
49 }
50 catch (TransformerException e)
51 {
52
53 }
54 }
55
56 public static final class NullResultTransformer extends AbstractTransformer
57 {
58 public NullResultTransformer()
59 {
60 super();
61 this.registerSourceType(Object.class);
62 this.setReturnClass(NullPayload.class);
63 }
64
65 public Object doTransform(Object src, String encoding) throws TransformerException
66 {
67 return null;
68 }
69 }
70
71 }