Skip to content

Instantly share code, notes, and snippets.

@ivanursul
Created January 3, 2015 14:52
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivanursul/32c4d07f9170ee8aae12 to your computer and use it in GitHub Desktop.
Save ivanursul/32c4d07f9170ee8aae12 to your computer and use it in GitHub Desktop.
package org.lnu.is.integration.person
import java.util.UUID
import scala.concurrent.duration.DurationInt
import io.gatling.core.Predef.checkBuilder2Check
import io.gatling.core.Predef.findCheckBuilder2ValidatorCheckBuilder
import io.gatling.core.Predef.scenario
import io.gatling.core.Predef.stringToExpression
import io.gatling.core.Predef.validatorCheckBuilder2CheckBuilder
import io.gatling.core.Predef.value2Expression
import io.gatling.core.Predef.value2Success
import io.gatling.http.Predef.ELFileBody
import io.gatling.http.Predef.http
import io.gatling.http.Predef.jsonPath
import io.gatling.http.Predef.status
import io.gatling.http.request.builder.AbstractHttpRequestBuilder.toActionBuilder
object PersonIntegrationTest {
val scn = scenario("Manage Persons")
.exec(session => {
session
.set("idnum", UUID.randomUUID())
.set("other_value_example", "value")
})
.exec(http("Post Person")
.post("/persons")
.header("Content-Type", "application/json")
.body(ELFileBody("data/person/post.json"))
.asJSON
.check(status.is(201))
.check(jsonPath("$.id").find.saveAs("identifier")))
.pause(500 milliseconds, 2 seconds)
.exec(
http("Get Person")
.get("/persons/${identifier}")
.check(status.is(200)))
.exec(
http("Update Person")
.put("/persons/${identifier}")
.header("Content-Type", "application/json")
.body(ELFileBody("data/person/put.json"))
.asJSON
.check(status.is(200)))
.exec(
http("Get Person")
.get("/persons/${identifier}")
.check(status.is(200))
.check(jsonPath("$.name").find.is("name1")))
.exec(http("Delete Person")
.delete("/persons/${identifier}")
.check(status.is(204))
)
.exec(http("Get Person")
.get("/persons/${identifier}")
.check(status.is(404))
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment