soi-toolkit / soi-toolkit-mule

SOI Toolkit and Mule ESB
Apache License 2.0
6 stars 1 forks source link

Don't use MiscUtil.readFileAsString in integration tests #297

Open hdahl opened 9 years ago

hdahl commented 9 years ago

Original issue 297 created by soi-toolkit on 2012-09-11T13:55:31.000Z:

This mainly applies for integrations that uses SFTP on inbound endpoints. It could apply to other integrations as well.

Using MiscUtil.readFileAsString requires two unnecessary conversions that involves encoding (file -> convert -> String -> convert -> file). If the content of the file is read into a bytearray instead there is no need for any conversion that takes encoding into account.

Currently there is a bug in mule sftp connector that has to be worked around due to the encoding dependent conversion:

http://www.mulesoft.org/jira/browse/MULE-6055

So use:

byte [] input = IOUtils.toByteArray(new FileInputStream(inputFile));

instead of

String input = MiscUtil.readFileAsString(inputFile);

Where IOUtils is from commons-io (org.apache.commons.io.IOUtils)

I think that both methods readFileAsString can be dropped since they are available in IOUtils.

hdahl commented 9 years ago

Comment #1 originally posted by soi-toolkit on 2013-06-12T08:28:18.000Z:

<empty>

hdahl commented 9 years ago

Comment #2 originally posted by soi-toolkit on 2013-06-12T08:29:08.000Z:

Related to issue 297 and issue 341.