Skip to content

Commit

Permalink
Use loadtest4j 0.10.0 (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
themasterchef authored Jun 8, 2018
1 parent e626e83 commit 366d38d
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 3 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<dependency>
<groupId>com.github.loadtest4j</groupId>
<artifactId>loadtest4j</artifactId>
<version>0.9.0</version>
<version>0.10.0</version>
</dependency>
<dependency>
<groupId>io.gatling</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,13 @@ package com.github.loadtest4j.drivers.gatling {
val headers = scalaMap(request.getHeaders)
val method = request.getMethod
val path = request.getPath
val queryParams = scalaMap(request.getQueryParams)

http("loadtest4j request")
.httpRequest(method, path)
.headers(headers)
.body(stringBody(request.getBody))
.queryParamMap(queryParams)
}

private def stringBody(str: String): Body = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,16 @@ import scala.collection.JavaConverters

object DriverRequests {
def get(path: String): DriverRequest = {
new DriverRequest("", Collections.emptyMap(), "GET", path)
new DriverRequest("", Collections.emptyMap(), "GET", path, Collections.emptyMap())
}

def getWithQueryParams(path: String, queryParams: Map[String, String]): DriverRequest = {
val javaQueryParams = JavaConverters.mapAsJavaMap(queryParams)
new DriverRequest("", Collections.emptyMap(), "GET", path, javaQueryParams)
}

def post(path: String, body: String, headers: Map[String, String]): DriverRequest = {
val javaHeaders = JavaConverters.mapAsJavaMap(headers)
new DriverRequest(body, javaHeaders, "POST", path)
new DriverRequest(body, javaHeaders, "POST", path, Collections.emptyMap())
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,23 @@ class GatlingTest {
verifyHttp(httpServer).atLeast(1, method(Method.GET), uri("/"))
}

@Test
def testRunWithQueryString(): Unit = {
// Given
val driver = sut()
// And
whenHttp(httpServer).`match`(get("/")).`then`(status(HttpStatus.NOT_FOUND_404))
// And
whenHttp(httpServer).`match`(get("/"), parameter("foo", "bar")).`then`(status(HttpStatus.OK_200))

// When
val result = driver.run(Collections.singletonList(DriverRequests.getWithQueryParams("/", Map("foo" -> "bar"))))

// Then
assertEquals(0, result.getKo)
assertGreaterThanOrEqualTo(1, result.getOk)
}

@Test
def testRunWithElaborateRequest(): Unit = {
// Given
Expand Down

0 comments on commit 366d38d

Please sign in to comment.