|
17 | 17 | package com.akamai.edgegrid.signer.gatling |
18 | 18 |
|
19 | 19 | import com.akamai.edgegrid.signer.ahc.AsyncHttpClientEdgeGridSignatureCalculator |
| 20 | +import com.github.tomakehurst.wiremock.WireMockServer |
| 21 | +import com.github.tomakehurst.wiremock.client.WireMock._ |
| 22 | +import com.github.tomakehurst.wiremock.core.WireMockConfiguration |
20 | 23 | import io.gatling.core.Predef._ |
21 | 24 | import io.gatling.http.Predef._ |
22 | 25 |
|
23 | | -class EdgeGridSignerSimulation2 extends Simulation{ |
| 26 | +class EdgeGridSignerSimulation2 extends Simulation { |
24 | 27 |
|
25 | 28 | val httpConf = http |
26 | 29 |
|
| 30 | + val wireMockServer = new WireMockServer(WireMockConfiguration.wireMockConfig().port(testdata.SERVICE_MOCK_PORT)) |
| 31 | + |
27 | 32 | val testScenario = scenario("Test scenario") |
28 | 33 | .exec( |
29 | 34 | http("fakeRequest") |
30 | | - .get("https://" + testdata.testCredential.getHost + "/test") |
| 35 | + .get("http://" + testdata.testCredential.getHost + "/test") |
31 | 36 | .signatureCalculator(new AsyncHttpClientEdgeGridSignatureCalculator(testdata.testCredential)) |
32 | 37 | ) |
33 | 38 |
|
34 | | - setUp( |
35 | | - testScenario.inject(atOnceUsers(1)) |
36 | | - ).protocols(httpConf) |
| 39 | + before { |
| 40 | + wireMockServer.start() |
| 41 | + wireMockServer.stubFor(get(urlPathEqualTo("/test")) |
| 42 | + .withHeader("Authorization", matching(".*")) |
| 43 | + .withHeader("Host", equalTo(testdata.SERVICE_MOCK)) |
| 44 | + .willReturn(aResponse.withStatus(201) |
| 45 | + .withHeader("Content-Type", "text/xml") |
| 46 | + .withBody("<response>Some content</response>"))) |
| 47 | + } |
| 48 | + |
| 49 | + setUp(testScenario.inject(atOnceUsers(1))) |
| 50 | + .protocols(httpConf) |
| 51 | + .assertions( |
| 52 | + global.successfulRequests.percent.is(100) |
| 53 | + ) |
| 54 | + |
| 55 | + after { |
| 56 | + wireMockServer.stop() |
| 57 | + } |
| 58 | + |
37 | 59 |
|
38 | 60 | } |
0 commit comments