1
2
3
4
5
6
7 package org.mule.transport.ftp;
8
9 import static org.junit.Assert.assertEquals;
10 import static org.junit.Assert.assertNotNull;
11 import org.mule.api.MuleMessage;
12 import org.mule.module.client.MuleClient;
13 import org.mule.util.FileUtils;
14
15 import java.io.File;
16
17 import org.junit.Ignore;
18 import org.junit.Test;
19
20 public class FtpEncodingFunctionalTestCase extends AbstractFtpServerTestCase
21 {
22
23 private static final String TEST_MESSAGE_EUC_JP_ENCODED = "\u3053";
24 private static final int FIVE_SECONDS_TIMEOUT = 5000;
25 private static final String ENCODING = "EUC-JP";
26
27 private File testDataFile;
28
29 @Override
30 protected String getConfigResources()
31 {
32 return "ftp-encoding-functional-config.xml";
33 }
34
35 @Test
36 @Ignore("MULE-6926: Flaky Test")
37 public void testReadingFileWithEucJpEncodingGetsTheRightText() throws Exception
38 {
39 File tmpDir = new File(FTP_SERVER_BASE_DIR);
40 testDataFile = createDataFile(tmpDir, ENCODING, TEST_MESSAGE_EUC_JP_ENCODED);
41
42 MuleClient client = new MuleClient(muleContext);
43 MuleMessage message = client.request("vm://receive", FIVE_SECONDS_TIMEOUT);
44
45 assertNotNull(message);
46 assertEquals(ENCODING, message.getEncoding());
47 assertEquals(TEST_MESSAGE_EUC_JP_ENCODED, message.getPayloadAsString());
48 }
49
50 private File createDataFile(File folder, String encoding, final String testMessage) throws Exception
51 {
52 File target = File.createTempFile("mule-file-test-", ".txt", folder);
53 target.deleteOnExit();
54 FileUtils.writeStringToFile(target, testMessage, encoding);
55
56 return target;
57 }
58
59 @Override
60 protected void doTearDown() throws Exception
61 {
62 super.doTearDown();
63 FileUtils.deleteTree(testDataFile);
64 }
65 }