Forum Discussion

alibaba82's avatar
alibaba82
Super Contributor
17 years ago

Trimming empty spaces in assertions.

Hello Ole,
I have a assertion of type content where the expected value is specified in a database datasource filed.

The problem is that the database is the return a value but has some whitespaces. For example the resonse returns 'abcd' whereas in the database it is 'abcd  '.

How can i create an content assertion such that it will ignore the whitespaces.

i guess something like
${DataSource#Name}.ignorewhitespace

THanks

ALi

7 Replies

  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Ali,

    hmm.. can you show the entire XPath expression for the assertion?

    regards!

    /Ole
    eviware.com
  • alibaba82's avatar
    alibaba82
    Super Contributor
    declare namespace ns1='http://services.tvguide.com/v2.5/common/types';
    declare namespace ns2='http://services.tvguide.com/v2.5/listings';
    //ns2:GetServicesResponse/ns2:GetServicesResult/ns2:Service/ns1:Name/text()


    Expected Result
    ${DataSource#Name}

    If I can specify in the assertion to ignore leading and trailing whitespaces or if you can tell you to do that in the SQL query which is specified in the datasource. I think both will achieve the same purpose.

    Ali
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi Ali,

    I'm not sure on the SQL syntax but it should be possible, something like TRIM( columnName) in the select clause.

    What if you changed the assertion to be as follows:

    declare namespace ns1='http://services.tvguide.com/v2.5/common/types';
    declare namespace ns2='http://services.tvguide.com/v2.5/listings';
    //ns2:GetServicesResponse/ns2:GetServicesResult/ns2:Service/ns1:Name/text() = normalize-space( '${DataSource#Name}' )

    Expected Result
    true

    ?

    regards!

    /Ole
    eviware.com
  • omatzura's avatar
    omatzura
    Super Contributor
    Good!

    This does have some drawbacks though.. we'll add a trim option to the expected value field in a coming version..

    regards!

    /Ole
    eviware.com
  • omatzura's avatar
    omatzura
    Super Contributor
    Hi,

    2.0.3 will have both optional trimming and "entitizing" for all datasource values, so that should fix this issue for you.

    regards!

    /Ole
    eviware.com