├── .gitignore
├── src
└── test
│ ├── resources
│ ├── feeders
│ │ ├── search.csv
│ │ ├── toungzip.json.gz
│ │ ├── tounzip.json.zip
│ │ ├── searchToFilter.csv
│ │ └── dzejson.json
│ ├── otherFiles
│ │ └── dummy.pdf
│ ├── logback-test.xml
│ └── gatling.conf
│ └── java
│ ├── pl
│ └── gemiusz
│ │ ├── Case0012DenySomeResourcesSimulation.java
│ │ ├── Case0002PDFdownloadSimulation.java
│ │ ├── Case0004StatusCodeSimulation.java
│ │ ├── Case0019WhenStatusCode400ThenFailSimulation.java
│ │ ├── Case0014Loop5times1RPSand3sPauseSimulation.java
│ │ ├── Case0005UUIDfeederSimulation.java
│ │ ├── Case0020ExitBlockOnFailSimulation.java
│ │ ├── Case0025JSONfeederRandomSimulation.java
│ │ ├── Case0026ResponseHeaderRegexSimulation.java
│ │ ├── Case0007AsyncReqSimulation.java
│ │ ├── Case0003UnzipJsonForFeederSimulation.java
│ │ ├── Case0015UUIDfeederTwoRecordsAtTheSameTimeSimulation.java
│ │ ├── Case0011ProxyCommandLineParametersSimulation.java
│ │ ├── Case0027FilterFeederAndForeverLoopSameRecordByVU.java
│ │ ├── Case0009SessionValuesSimulation.java
│ │ ├── Case0023foreachFromUUIDfeederFiveRecordsAtTheSameTimeSimulation.java
│ │ ├── Case0013RequestBeforeSimulation.java
│ │ ├── Case0006CommandLineParametersSimulation.java
│ │ ├── Case0001JMESPathSimulation.java
│ │ ├── Case0021CheckResourcesResponseTimeSimulation.java
│ │ ├── Case0010JsonEditVariableSimulation.java
│ │ ├── Case0018GetTokenWhenStatus401Simulation.java
│ │ ├── Case0016ScenarioDurationSimulation.java
│ │ ├── Case0024IterationLoopCondition.java
│ │ ├── Case0022SetOrRefreshTokenSimulation.java
│ │ ├── Case0008AsyncReqResourcesSimulation.java
│ │ └── Case0017ForeachAfterForeachSimulation.java
│ └── computerdatabase
│ ├── BasicSimulation.java
│ ├── advanced
│ ├── AdvancedSimulationStep04.java
│ ├── AdvancedSimulationStep02.java
│ ├── AdvancedSimulationStep01.java
│ ├── AdvancedSimulationStep05.java
│ └── AdvancedSimulationStep03.java
│ └── ComputerDatabaseSimulation.java
├── go.mod
├── .github
├── dependabot.yml
└── workflows
│ ├── gatling_test_all_mine_after_pull_request.yml
│ └── gatling_test_all_mine_after_push.yml
├── .mvn
└── wrapper
│ └── maven-wrapper.properties
├── pom.xml
├── mvnw.cmd
├── README.md
└── mvnw
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /.idea
3 |
--------------------------------------------------------------------------------
/src/test/resources/feeders/search.csv:
--------------------------------------------------------------------------------
1 | searchCriterion,searchComputerName
2 | Macbook,MacBook Pro
3 | eee,ASUS Eee PC 1005PE
4 |
--------------------------------------------------------------------------------
/src/test/resources/otherFiles/dummy.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gemiusz/gatling-examples-maven-java/HEAD/src/test/resources/otherFiles/dummy.pdf
--------------------------------------------------------------------------------
/src/test/resources/feeders/toungzip.json.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gemiusz/gatling-examples-maven-java/HEAD/src/test/resources/feeders/toungzip.json.gz
--------------------------------------------------------------------------------
/src/test/resources/feeders/tounzip.json.zip:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/gemiusz/gatling-examples-maven-java/HEAD/src/test/resources/feeders/tounzip.json.zip
--------------------------------------------------------------------------------
/go.mod:
--------------------------------------------------------------------------------
1 | module github.com/gemiusz/gatling-examples-maven-java
2 |
3 | go 1.20
4 |
5 | require (
6 | github.com/gatling/gatling v3.14.3+incompatible // indirect
7 | )
8 |
--------------------------------------------------------------------------------
/src/test/resources/feeders/searchToFilter.csv:
--------------------------------------------------------------------------------
1 | searchCriterion,searchComputerName
2 | Macbook,MacBook Pro_1
3 | eee,ASUS Eee PC 1005PE_1
4 | Macbook,MacBook Pro_2
5 | eee,ASUS Eee PC 1005PE_2
6 | Macbook,MacBook Pro_3
7 | eee,ASUS Eee PC 1005PE_3
8 |
--------------------------------------------------------------------------------
/.github/dependabot.yml:
--------------------------------------------------------------------------------
1 | version: 2
2 | updates:
3 | - package-ecosystem: "maven"
4 | directory: "/"
5 | schedule:
6 | interval: "daily"
7 | - package-ecosystem: "github-actions"
8 | # Workflow files stored in the
9 | # default location of `.github/workflows`
10 | directory: "/"
11 | schedule:
12 | interval: "daily"
13 |
--------------------------------------------------------------------------------
/src/test/resources/feeders/dzejson.json:
--------------------------------------------------------------------------------
1 | [
2 | {
3 | "username": "UserA",
4 | "agendaID": "AgendaA_ID",
5 | "patients": [
6 | {
7 | "patientID": "PatientAX_ID",
8 | "patientID64": "PatientAX_ID64"
9 | },
10 | {
11 | "patientID": "PatientAY_ID",
12 | "patientID64": "PatientAY_ID64"
13 | }
14 | ]
15 | },
16 | {
17 | "username": "UserB",
18 | "agendaID": "AgendaB_ID",
19 | "patients": [
20 | {
21 | "patientID": "PatientBX_ID",
22 | "patientID64": "PatientBX_ID64"
23 | },
24 | {
25 | "patientID": "PatientBY_ID",
26 | "patientID64": "PatientBY_ID64"
27 | }
28 | ]
29 | }
30 | ]
--------------------------------------------------------------------------------
/.github/workflows/gatling_test_all_mine_after_pull_request.yml:
--------------------------------------------------------------------------------
1 | name: gatling:test
2 |
3 | on:
4 | pull_request:
5 | branches: [ "master" ]
6 |
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - name: CheckOut
12 | uses: actions/checkout@v4
13 | - name: Set up JDK 21
14 | uses: actions/setup-java@v4
15 | with:
16 | java-version: '21'
17 | distribution: 'temurin'
18 | cache: maven
19 | - name: Run Gatling with Maven
20 | run: mvn clean gatling:test -Dgatling.runMultipleSimulations -Dgatling.includes=pl.gemiusz.* -Dgatling.excludes=pl.gemiusz.Case0019WhenStatusCode400ThenFailSimulation
21 |
--------------------------------------------------------------------------------
/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | %d{HH:mm:ss.SSS} [%-5level] %logger{15} - %msg%n%rEx
7 |
8 | false
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
--------------------------------------------------------------------------------
/.github/workflows/gatling_test_all_mine_after_push.yml:
--------------------------------------------------------------------------------
1 | name: gatling:test
2 |
3 | on:
4 | push:
5 | branches: [ "master" ]
6 |
7 | jobs:
8 | build:
9 | runs-on: ubuntu-latest
10 | steps:
11 | - name: CheckOut
12 | uses: actions/checkout@v4
13 | - name: Set up JDK 21
14 | uses: actions/setup-java@v4
15 | with:
16 | java-version: '21'
17 | distribution: 'temurin'
18 | cache: maven
19 | - name: Run Gatling with Maven
20 | run: mvn clean gatling:test -Dgatling.runMultipleSimulations -Dgatling.includes=pl.gemiusz.* -Dgatling.excludes=pl.gemiusz.Case0019WhenStatusCode400ThenFailSimulation
21 | - name: Maven Dependency Tree Dependency Submission
22 | uses: advanced-security/maven-dependency-submission-action@v5.0.0
23 | with:
24 | ignore-maven-wrapper: true
25 |
--------------------------------------------------------------------------------
/.mvn/wrapper/maven-wrapper.properties:
--------------------------------------------------------------------------------
1 | # Licensed to the Apache Software Foundation (ASF) under one
2 | # or more contributor license agreements. See the NOTICE file
3 | # distributed with this work for additional information
4 | # regarding copyright ownership. The ASF licenses this file
5 | # to you under the Apache License, Version 2.0 (the
6 | # "License"); you may not use this file except in compliance
7 | # with the License. You may obtain a copy of the License at
8 | #
9 | # http://www.apache.org/licenses/LICENSE-2.0
10 | #
11 | # Unless required by applicable law or agreed to in writing,
12 | # software distributed under the License is distributed on an
13 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14 | # KIND, either express or implied. See the License for the
15 | # specific language governing permissions and limitations
16 | # under the License.
17 | wrapperVersion=3.3.2
18 | distributionType=only-script
19 | distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.9.8/apache-maven-3.9.8-bin.zip
20 |
--------------------------------------------------------------------------------
/src/test/java/pl/gemiusz/Case0012DenySomeResourcesSimulation.java:
--------------------------------------------------------------------------------
1 | package pl.gemiusz;
2 |
3 | import io.gatling.javaapi.core.ScenarioBuilder;
4 | import io.gatling.javaapi.core.Simulation;
5 | import io.gatling.javaapi.http.HttpProtocolBuilder;
6 |
7 | import static io.gatling.javaapi.core.CoreDsl.*;
8 | import static io.gatling.javaapi.http.HttpDsl.http;
9 |
10 | public class Case0012DenySomeResourcesSimulation extends Simulation {
11 |
12 | HttpProtocolBuilder httpProtocol =
13 | http
14 | .baseUrl("https://github.com")
15 | .inferHtmlResources(
16 | DenyList(
17 | ".*github\\.githubassets\\.com.*",
18 | ".*avatars\\.githubusercontent\\.com\\/facebook.*"));
19 |
20 | ScenarioBuilder scn =
21 | scenario("GeMi_DenySomeResourcesSimulation")
22 | .exec(
23 | http("GeMi_DenySomeResourcesSimulation_get")
24 | .get("/")
25 | );
26 |
27 | {
28 | setUp(scn.injectOpen(atOnceUsers(1)).protocols(httpProtocol));
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/test/java/pl/gemiusz/Case0002PDFdownloadSimulation.java:
--------------------------------------------------------------------------------
1 | package pl.gemiusz;
2 |
3 | import io.gatling.javaapi.core.ScenarioBuilder;
4 | import io.gatling.javaapi.core.Simulation;
5 | import io.gatling.javaapi.http.HttpProtocolBuilder;
6 |
7 | import static io.gatling.javaapi.core.CoreDsl.*;
8 | import static io.gatling.javaapi.http.HttpDsl.http;
9 |
10 | public class Case0002PDFdownloadSimulation extends Simulation {
11 |
12 | // https://www.w3.org/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf
13 | HttpProtocolBuilder httpProtocol =
14 | http
15 | .baseUrl("https://www.w3.org");
16 |
17 | ScenarioBuilder scn =
18 | scenario("GeMi_PDFdownloadSimulation")
19 | .exec(
20 | http("GeMi_PDFdownloadSimulation_get")
21 | .get("/WAI/ER/tests/xhtml/testfiles/resources/pdf/dummy.pdf")
22 | .check(bodyBytes().is(RawFileBody("otherFiles/dummy.pdf")))
23 | .check(bodyLength().is(13264))
24 | );
25 |
26 | {
27 | setUp(scn.injectOpen(atOnceUsers(1)).protocols(httpProtocol));
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/test/java/pl/gemiusz/Case0004StatusCodeSimulation.java:
--------------------------------------------------------------------------------
1 | package pl.gemiusz;
2 |
3 | import io.gatling.javaapi.core.ScenarioBuilder;
4 | import io.gatling.javaapi.core.Simulation;
5 | import io.gatling.javaapi.http.HttpProtocolBuilder;
6 |
7 | import static io.gatling.javaapi.core.CoreDsl.atOnceUsers;
8 | import static io.gatling.javaapi.core.CoreDsl.scenario;
9 | import static io.gatling.javaapi.http.HttpDsl.http;
10 | import static io.gatling.javaapi.http.HttpDsl.status;
11 |
12 | public class Case0004StatusCodeSimulation extends Simulation {
13 |
14 | HttpProtocolBuilder httpProtocol =
15 | http
16 | .baseUrl("https://postman-echo.com");
17 |
18 | ScenarioBuilder scn =
19 | scenario("GeMi_StatusCodeSimulation")
20 | .exec(
21 | http("GeMi_StatusCodeSimulation_get")
22 | .get("/status/414")
23 | .check(status().is(414).saveAs("GeMi_Status_Code"))
24 | ).exec(session -> {
25 | System.out.println("GeMi_Status_Code: " + session.get("GeMi_Status_Code").toString());
26 | return session;
27 | });
28 |
29 | {
30 | setUp(scn.injectOpen(atOnceUsers(1)).protocols(httpProtocol));
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/pl/gemiusz/Case0019WhenStatusCode400ThenFailSimulation.java:
--------------------------------------------------------------------------------
1 | package pl.gemiusz;
2 |
3 | import io.gatling.javaapi.core.ScenarioBuilder;
4 | import io.gatling.javaapi.core.Simulation;
5 | import io.gatling.javaapi.http.HttpProtocolBuilder;
6 |
7 | import static io.gatling.javaapi.core.CoreDsl.*;
8 | import static io.gatling.javaapi.http.HttpDsl.http;
9 | import static io.gatling.javaapi.http.HttpDsl.status;
10 |
11 | /**
12 | * HOW TO RUN:
13 | * mvnw gatling:test -Dgatling.simulationClass=pl.gemiusz.Case0019WhenStatusCode400ThenFailSimulation
14 | */
15 | public class Case0019WhenStatusCode400ThenFailSimulation extends Simulation {
16 |
17 | HttpProtocolBuilder httpProtocol =
18 | http
19 | .baseUrl("https://postman-echo.com");
20 |
21 | ScenarioBuilder scn =
22 | scenario("GeMi_WhenStatusCode400ThenFailSimulation")
23 | .exec(
24 | http("GeMi_WhenStatusCode400ThenFailSimulation_get")
25 | .get("/status/400")
26 | .check(status().not(400))
27 | );
28 |
29 | {
30 | setUp(scn.injectOpen(atOnceUsers(1)).protocols(httpProtocol))
31 | .assertions(
32 | global().failedRequests().count().is(0L)
33 | );
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/test/java/pl/gemiusz/Case0014Loop5times1RPSand3sPauseSimulation.java:
--------------------------------------------------------------------------------
1 | package pl.gemiusz;
2 |
3 | import io.gatling.javaapi.core.OpenInjectionStep;
4 | import io.gatling.javaapi.core.ScenarioBuilder;
5 | import io.gatling.javaapi.core.Simulation;
6 | import io.gatling.javaapi.http.HttpProtocolBuilder;
7 |
8 | import java.time.Duration;
9 | import java.util.stream.Stream;
10 |
11 | import static io.gatling.javaapi.core.CoreDsl.*;
12 | import static io.gatling.javaapi.http.HttpDsl.http;
13 | import static io.gatling.javaapi.http.HttpDsl.status;
14 |
15 | public class Case0014Loop5times1RPSand3sPauseSimulation extends Simulation {
16 |
17 | HttpProtocolBuilder httpProtocol =
18 | http
19 | .baseUrl("https://postman-echo.com");
20 |
21 | ScenarioBuilder scn =
22 | scenario("GeMi_Loop5times1RPSand3sPauseSimulation")
23 | .exec(
24 | http("GeMi_Loop5times1RPSand3sPauseSimulation_get")
25 | .get("/status/200")
26 | .check(status().is(200).saveAs("GeMi_Status_Code"))
27 | );
28 |
29 | {
30 | setUp(scn.injectOpen(
31 | Stream.generate(
32 | () -> new OpenInjectionStep[]{
33 | atOnceUsers(1),
34 | nothingFor(Duration.ofSeconds(3))
35 | }
36 | ).limit(5).flatMap(Stream::of).toArray(OpenInjectionStep[]::new)
37 | )
38 | .protocols(httpProtocol));
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/src/test/java/pl/gemiusz/Case0005UUIDfeederSimulation.java:
--------------------------------------------------------------------------------
1 | package pl.gemiusz;
2 |
3 | import io.gatling.javaapi.core.ScenarioBuilder;
4 | import io.gatling.javaapi.core.Simulation;
5 | import io.gatling.javaapi.http.HttpProtocolBuilder;
6 |
7 | import java.util.Collections;
8 | import java.util.Iterator;
9 | import java.util.Map;
10 | import java.util.UUID;
11 | import java.util.function.Supplier;
12 | import java.util.stream.Stream;
13 |
14 | import static io.gatling.javaapi.core.CoreDsl.*;
15 | import static io.gatling.javaapi.http.HttpDsl.http;
16 |
17 | public class Case0005UUIDfeederSimulation extends Simulation {
18 |
19 | HttpProtocolBuilder httpProtocol =
20 | http
21 | .baseUrl("https://postman-echo.com");
22 |
23 | Iterator