1
2
3
4
5
6
7
8
9
10
11 package org.mule.providers.file.transformers;
12
13 import org.mule.tck.AbstractTransformerTestCase;
14 import org.mule.umo.transformer.TransformerException;
15 import org.mule.umo.transformer.UMOTransformer;
16 import org.mule.util.FileUtils;
17 import org.mule.util.SystemUtils;
18
19 import java.io.File;
20 import java.io.FileWriter;
21
22
23
24
25 public class FileToStringTestCase extends AbstractTransformerTestCase
26 {
27 FileToString _fts;
28 File _testData = null;
29 final String _resultData = "The dog is on the table, where's the dog?";
30
31
32
33
34
35
36 protected void doSetUp() throws Exception
37 {
38 super.doSetUp();
39 _testData = FileUtils.newFile(SystemUtils.JAVA_IO_TMPDIR, "FileToStringTestData");
40 FileWriter fw = new FileWriter(_testData);
41 fw.write(_resultData);
42 fw.close();
43 }
44
45
46
47
48
49
50 protected void doTearDown() throws Exception
51 {
52 assertTrue(_testData.delete());
53 super.doTearDown();
54 }
55
56
57
58
59
60
61 public Object getResultData()
62 {
63 return _resultData;
64 }
65
66
67
68
69
70
71 public UMOTransformer getRoundTripTransformer() throws Exception
72 {
73 return null;
74 }
75
76
77
78
79
80
81 public Object getTestData()
82 {
83 return _testData;
84 }
85
86
87
88
89
90
91 public UMOTransformer getTransformer() throws Exception
92 {
93 return new FileToString();
94 }
95
96
97
98
99 public void testTransformExcEnc() throws Exception
100 {
101 try
102 {
103 FileToString fts = (FileToString)getTransformer();
104 fts.doTransform(getTestData(), "NO-SUCH_ENCODING");
105 fail("Should fail when the specified encoding is not supported");
106 }
107 catch (TransformerException tfe)
108 {
109
110 }
111 }
112
113 }