scalagatlingscala-gatling

Gatling: check binary response not empty


I'm doing some tests with Gatling using Scala. I'm trying to check whether a response body that is returned is not empty.

I'm doing it like this:

def getImages: ChainBuilder = feed(credentials)
     .exec(http("Get Image")
     .get(GET_MY_URI)
     .queryParam("guid", "${branch}")
     .queryParam("t", "0.458654")
     .check(status.is(200))
     .check(bodyString.transform(_.size > 1).is(true)))

But it's not working. I get:

java.nio.charset.MalformedInputException: Input length = 1

Does somebody know how to achieve what I'm trying?


Solution

  • Replace

    .check(bodyString.transform(_.size > 1).is(true))) 
    

    with

    .check(bodyBytes.exists)
    

    All the DSL is explained here: https://gatling.io/docs/current/cheat-sheet/ (link is dead, wayback machine version: https://web.archive.org/web/20170915100135/http://gatling.io/docs/current/cheat-sheet/)