New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Charset cannot be set per file for resources #247

Closed
gucce opened this Issue May 29, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@gucce
Contributor

gucce commented May 29, 2017

Problem

Loading files via the ` tag does not support setting the charset to use for reading the file. This is problematic if we want to use several files with a charset different than the default Citrus charset.

Solution

Support a charset attribute in the resource tag like this:

<resource file="classpath:iso_datei.txt" charset="ISO-8859-1"/>
<resource file="classpath:utf8_datei.txt" charset="UTF-8"/>

The corresponding readToString function already exists in the FileUtils class, see code.

@gucce

This comment has been minimized.

Contributor

gucce commented May 29, 2017

Note: as a workaround you can use a Groovy script to load the file contents with the correct charset into a Citrus variable (here inputFileAsString):

<groovy>
    String fileAsString = this.getClass().getResource('/path/to/file').getText('ISO-8859-1')
    context.setVariable('inputFileAsString', fileAsString)
</groovy>

...

<send endpoint="...">
    <message>
        <data>
            ${inputFileAsString}
        </data>
    </message>
</send>

@christophd christophd added this to the v2.7.2 milestone May 31, 2017

@christophd christophd added the READY label May 31, 2017

@christophd christophd added IN PROGRESS and removed READY labels Jun 28, 2017

@christophd christophd self-assigned this Jun 28, 2017

@christophd christophd removed the IN PROGRESS label Jun 28, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment