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