syedhu
syedhu

Reputation: 11

I am getting error: value exec is not a member of io.gatling.http.request.builder.HttpRequestBuilder

This is the code of ser.scala

val uploadTn =
           exec(http("Upload numbers")
        .post(Constants.url + Constants.tnservice + "/numbers")
          .headers(Constants.maplAuthorizedHeaders_multipart)
          .bodyPart(RawFileBodyPart("file", "BUpload.csv"))
          .check(status.is(201))
            .**exec**(session => {
              println(session)
              session
            }))

Here in this code I get an error because I used the exec for 2nd time

The code of simulation.scala

class TNServiceSimulation extends Simulation {
    val scn = scenario("Test Auth Service ")
        .feed(randomTN)
        .exec(AuthService.getAccessToken)
        .pause(1)
        .exec(TnService.SearchTasks)
        .pause(1)
        .exec(TnService.uploadTn)
        .pause(1)
        .exec(session => {
          try {
            Class.forName(Constants.driver)
            var connection = DriverManager.getConnection(Constants.url_db, Constants.username, Constants.password)
            val statement = connection.createStatement
            val rs = statement.executeQuery("delete from TNINVENTORY.TNRPOOL where fnn=(0345678912)")
            connection.close
          } catch {
            case e: Exception => e.printStackTrace
          }
          session.set("test", "test")
        })
      setUp(
        scn.inject(atOnceUsers(Constants.numberOfUsers)).protocols(Constants.httpProtocol)
      )

The error is only for the ser.sala file and the simualtion file has not error.

Upvotes: 1

Views: 5404

Answers (1)

notdryft
notdryft

Reputation: 188

Execs must be chained together and it cannot it otherwise. In this case, you need to add a ) at the end of the line with the check:

.check(status.is(201)))
                      ^

Upvotes: 2

Related Questions