diff --git a/testing-modules/gatling-java/src/test/java/org/baeldung/EmployeeRegistrationSimulation.java b/testing-modules/gatling-java/src/test/java/org/baeldung/EmployeeRegistrationSimulation.java index de59273bbd5c..6b2de8ec925f 100644 --- a/testing-modules/gatling-java/src/test/java/org/baeldung/EmployeeRegistrationSimulation.java +++ b/testing-modules/gatling-java/src/test/java/org/baeldung/EmployeeRegistrationSimulation.java @@ -27,14 +27,11 @@ public class EmployeeRegistrationSimulation extends Simulation { private static final HttpProtocolBuilder HTTP_PROTOCOL_BUILDER = setupProtocolForSimulation(); - private static final Iterator> FEED_DATA = setupTestFeedData(); - private static final ScenarioBuilder POST_SCENARIO_BUILDER = buildPostScenario(); - public EmployeeRegistrationSimulation() { - setUp(POST_SCENARIO_BUILDER.injectOpen(postEndpointInjectionProfile()) + setUp(buildPostScenario().injectOpen(postEndpointInjectionProfile()) .protocols(HTTP_PROTOCOL_BUILDER)).assertions(global().responseTime() .max() .lte(10000), global().successfulRequests() diff --git a/testing-modules/gatling/README.md b/testing-modules/gatling/README.md index b99fafce15fb..7ac8eeeffa8e 100644 --- a/testing-modules/gatling/README.md +++ b/testing-modules/gatling/README.md @@ -4,3 +4,5 @@ ### Running a simualtion - To run a simulation use "simulation" profile, command - `mvn install -Psimulation -Dgib.enabled=false` +- To run the default scenario, use `mvn install gatling:test` +- To run specific simulation, use the parameter to specify the class: `mvn install gatling:test -Dgatling.simulation.class=org.baeldung.RecordedSimulation` diff --git a/testing-modules/gatling/pom.xml b/testing-modules/gatling/pom.xml index 66a48ce105f0..bbbe58824487 100644 --- a/testing-modules/gatling/pom.xml +++ b/testing-modules/gatling/pom.xml @@ -14,47 +14,43 @@ 1.0.0-SNAPSHOT - - - - io.gatling - gatling-app - ${gatling.version} - - - io.gatling - gatling-recorder - ${gatling.version} - - - io.gatling.highcharts - gatling-charts-highcharts - ${gatling.version} - - - org.scala-lang - scala3-library_3 - ${scala.version} - - - - io.gatling.highcharts gatling-charts-highcharts + ${gatling.version} io.gatling gatling-app + ${gatling.version} io.gatling gatling-recorder + ${gatling.version} + + + org.springframework.boot + spring-boot-starter-web + ${spring.version} + + + ch.qos.logback + logback-classic + ${logback.version} + runtime + + + ch.qos.logback + logback-core + ${logback.version} + runtime org.scala-lang scala3-library_3 + ${scala.version} @@ -98,9 +94,14 @@ gatling-maven-plugin ${gatling-maven-plugin.version} - org.baeldung.RecordedSimulation + ${gatling.simulation.class} + + org.springframework.boot + spring-boot-maven-plugin + ${spring.version} + @@ -109,6 +110,9 @@ 3.10.5 4.8.1 4.8.1 + 3.3.4 + 1.5.11 + org.baeldung.RecordedSimulation \ No newline at end of file diff --git a/testing-modules/gatling/src/main/java/org/baeldung/testableservice/TestableApplication.java b/testing-modules/gatling/src/main/java/org/baeldung/testableservice/TestableApplication.java new file mode 100644 index 000000000000..b0dbdc89054b --- /dev/null +++ b/testing-modules/gatling/src/main/java/org/baeldung/testableservice/TestableApplication.java @@ -0,0 +1,12 @@ +package org.baeldung.testableservice; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class TestableApplication { + + public static void main(String[] args) { + SpringApplication.run(TestableApplication.class, args); + } +} diff --git a/testing-modules/gatling/src/main/java/org/baeldung/testableservice/controllers/HealthController.java b/testing-modules/gatling/src/main/java/org/baeldung/testableservice/controllers/HealthController.java new file mode 100644 index 000000000000..4fa5d40041b8 --- /dev/null +++ b/testing-modules/gatling/src/main/java/org/baeldung/testableservice/controllers/HealthController.java @@ -0,0 +1,18 @@ +package org.baeldung.testableservice.controllers; + +import static org.springframework.http.ResponseEntity.ok; + +import org.springframework.http.ResponseEntity; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; + +@RestController +@RequestMapping("/health") +public class HealthController { + + @GetMapping("/status") + public ResponseEntity health() { + return ok("OK!!"); + } +}