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

PlainTextValidator does not ignore whitespaces #248

Closed
gucce opened this Issue Jun 2, 2017 · 0 comments

Comments

Projects
None yet
2 participants
@gucce
Contributor

gucce commented Jun 2, 2017

Problem

Update: Actually, setting citrus.plaintext.validation.ignore.whitespace=true in citrus.properties doesn't even work. I debugged PlainTextValidator and its private field ignoreWhitespace is set to false, see code.

The documentation on plaintext validation states that

You can disable this default behavior and ignore whitespaces characters like new lines with following system property:
citrus.plaintext.validation.ignore.whitespace=true

This is not true since the property exclusively ignores different line separators (LF vs CR LF) as implemented in #214. Other whitespace characters like tabs \t and space characters are still not ignored, see PlainTextValidator code:

private String normalizeWhitespace(String payload) {
    if (ignoreWhitespace) {
        return payload.replaceAll("\\r(\\n)?", "\n");
    }

    return payload;
}

Solution

It is very tricky to get comparison ignoring whitespaces right. I suggest using the hamcrast matcher IsEqualIgnoringWhiteSpace.

Quick fix: Change documentation to emphasize that the feature only ignores different kinds of line separators and change the name to something like ignoreDifferentLineSeparators.

@gucce gucce added the Type: Bug label Jun 2, 2017

@christophd christophd added the READY label Jun 13, 2017

@christophd christophd added this to the v2.7.2 milestone Jun 13, 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