Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEAT: Replace SUT in java scripting intro #55

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -15,29 +15,33 @@
*/

//#full-example
package computerdatabase;
package example;

import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.*;

import io.gatling.javaapi.core.*;
import io.gatling.javaapi.http.*;

public class ComputerDatabaseSimulation extends Simulation {
public class BasicSimulation extends Simulation {

// Define HTTP configuration
// Reference: https://docs.gatling.io/reference/script/protocols/http/protocol/
HttpProtocolBuilder httpProtocol =
http.baseUrl("https://computer-database.gatling.io")
.acceptHeader("application/json")
.contentTypeHeader("application/json");
http.baseUrl("https://api-ecomm.gatling.io")
.acceptHeader("application/json")
.userAgentHeader(
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/119.0");

ScenarioBuilder myFirstScenario = scenario("My First Scenario")
.exec(http("Request 1")
.get("/computers/"));
// Define scenario
// Reference: https://docs.gatling.io/reference/script/core/scenario/
ScenarioBuilder scenario =
scenario("Scenario").exec(http("Session").get("/session"));

// Define injection profile and execute the test
// Reference: https://docs.gatling.io/reference/script/core/injection/
{
setUp(
myFirstScenario.injectOpen(constantUsersPerSec(2).during(60))
).protocols(httpProtocol);
setUp(scenario.injectOpen(constantUsersPerSec(2).during(60))).protocols(httpProtocol);
}
}
//#full-example
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

//#setup-the-file
package computerdatabase;
package example;

import static io.gatling.javaapi.core.CoreDsl.*;
import static io.gatling.javaapi.http.HttpDsl.*;
Expand All @@ -25,9 +25,9 @@
//#setup-the-file

class ScriptingIntro1SampleJava {
//#extend-the-simulation-class
public class ComputerDatabaseSimulation extends Simulation {
//#extend-the-simulation-class
public class BasicSimulation extends Simulation {

}
//#extend-the-simulation-class
}
//#extend-the-simulation-class
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,16 @@
import io.gatling.javaapi.http.*;

class ScriptingIntro2SampleJava {
//#define-the-protocol-class
public class ComputerDatabaseSimulation extends Simulation {
//#define-the-protocol-class
public class BasicSimulation extends Simulation {

// Add the HttpProtocolBuilder:
HttpProtocolBuilder httpProtocol =
http.baseUrl("https://computer-database.gatling.io")
// set the "accept" header to a value suited for the expected response
.acceptHeader("text/html");
}
//#define-the-protocol-class
// Define HTTP configuration
// Reference: https://docs.gatling.io/reference/script/protocols/http/protocol/
HttpProtocolBuilder httpProtocol =
http.baseUrl("https://api-ecomm.gatling.io")
.acceptHeader("application/json")
.userAgentHeader(
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/119.0");
}
//#define-the-protocol-class
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,21 @@
import io.gatling.javaapi.http.*;

class ScriptingIntro3SampleJava {
//#write-the-scenario
public class ComputerDatabaseSimulation extends Simulation {
//#write-the-scenario
public class BasicSimulation extends Simulation {

HttpProtocolBuilder httpProtocol =
http.baseUrl("https://computer-database.gatling.io")
// set the "accept" header to a value suited for the expected response
.acceptHeader("text/html");
// Define HTTP configuration
// Reference: https://docs.gatling.io/reference/script/protocols/http/protocol/
HttpProtocolBuilder httpProtocol =
http.baseUrl("https://api-ecomm.gatling.io")
.acceptHeader("application/json")
.userAgentHeader(
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/119.0");

// Add the ScenarioBuilder:
ScenarioBuilder myScenario = scenario("My Scenario")
.exec(http("Request 1").get("/computers/"));
// Define scenario
// Reference: https://docs.gatling.io/reference/script/core/scenario/
ScenarioBuilder scenario =
scenario("Scenario").exec(http("Session").get("/session"));
}
//#write-the-scenario
//#write-the-scenario
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,27 @@
import io.gatling.javaapi.http.*;

class ScriptingIntro4SampleJava {
//#define-the-injection-profile
public class ComputerDatabaseSimulation extends Simulation {
//#define-the-injection-profile
public class BasicSimulation extends Simulation {

HttpProtocolBuilder httpProtocol =
http.baseUrl("https://computer-database.gatling.io")
// set the "accept" header to a value suited for the expected response
.acceptHeader("text/html");
// Define HTTP configuration
// Reference: https://docs.gatling.io/reference/script/protocols/http/protocol/
HttpProtocolBuilder httpProtocol =
http.baseUrl("https://api-ecomm.gatling.io")
.acceptHeader("application/json")
.userAgentHeader(
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:109.0) Gecko/20100101 Firefox/119.0");

ScenarioBuilder myScenario = scenario("My Scenario")
.exec(
http("Request 1").get("/computers/")
);
// Define scenario
// Reference: https://docs.gatling.io/reference/script/core/scenario/
ScenarioBuilder scenario =
scenario("Scenario").exec(http("Session").get("/session"));

// Add the setUp block:
{
setUp(
myScenario.injectOpen(constantUsersPerSec(2).during(60))
).protocols(httpProtocol);
}
// Define injection profile and execute the test
// Reference: https://docs.gatling.io/reference/script/core/injection/
{
setUp(scenario.injectOpen(constantUsersPerSec(2).during(60))).protocols(httpProtocol);
}
//#define-the-injection-profile
}
//#define-the-injection-profile
}
Loading