View Javadoc

1   /*
2    * $Id: FileEncodingFunctionalTestCase.java 22491 2011-07-21 10:04:30Z claude.mamo $
3    * --------------------------------------------------------------------------------------
4    * Copyright (c) MuleSoft, Inc.  All rights reserved.  http://www.mulesoft.com
5    *
6    * The software in this package is published under the terms of the CPAL v1.0
7    * license, a copy of which has been included with this distribution in the
8    * LICENSE.txt file.
9    */
10  
11  package org.mule.transport.file;
12  
13  import static org.junit.Assert.assertEquals;
14  import static org.junit.Assert.assertNotNull;
15  
16  import org.mule.api.MuleMessage;
17  import org.mule.module.client.MuleClient;
18  
19  import java.util.Arrays;
20  import java.util.Collection;
21  
22  import org.junit.Test;
23  import org.junit.runners.Parameterized.Parameters;
24  
25  public class FileEncodingFunctionalTestCase extends AbstractFileFunctionalTestCase
26  {    
27      private static final String TEST_MESSAGE_EUC_JP_ENCODED = "\u3053";
28      private static final int FIVE_SECONDS_TIMEOUT = 5000;
29      private static final String ENCODING = "EUC-JP";
30  
31      public FileEncodingFunctionalTestCase(ConfigVariant variant, String configResources)
32      {
33          super(variant, configResources);    
34      }
35      
36      @Parameters
37      public static Collection<Object[]> parameters()
38      {
39          return Arrays.asList(new Object[][]{
40              {ConfigVariant.SERVICE, "file-encoding-test-service.xml"},
41              {ConfigVariant.FLOW, "file-encoding-test-flow.xml"}
42          });
43      }      
44  
45      @Test
46      public void testReadingFileWithEucJpEncodingGetsTheRightText() throws Exception
47      {
48          tmpDir = createFolder(".mule/mule-file-test-EUC-JP");
49          createDataFile(tmpDir, TEST_MESSAGE_EUC_JP_ENCODED, ENCODING);
50  
51          MuleClient client = new MuleClient(muleContext);
52          MuleMessage message = client.request("vm://receive", FIVE_SECONDS_TIMEOUT);
53  
54          assertNotNull(message);
55          assertEquals(ENCODING, message.getEncoding());
56          assertEquals(TEST_MESSAGE_EUC_JP_ENCODED, message.getPayloadAsString());
57      }
58  }