├── .gitignore
├── LICENSE
├── README.md
├── help_images
└── load_tests_L.png
├── pom.xml
└── src
└── test
├── java
└── org
│ └── jsmart
│ └── zerocode
│ ├── restapimockserver
│ └── RunMeFirstMockApiServer.java
│ ├── runner
│ └── DbParameterizedLoadRunner.java
│ ├── samples
│ ├── load
│ │ ├── LoadTestSuite.java
│ │ ├── parallelget
│ │ │ └── LoadGetTest.java
│ │ ├── parallelmulti
│ │ │ └── LoadMultipleGetPostPutTest.java
│ │ ├── parallelparametized
│ │ │ └── LoadDbParameterizedGetTest.java
│ │ ├── parallelpost
│ │ │ └── LoadPostTest.java
│ │ ├── samplejunit
│ │ │ ├── LoadExistingJUnitRestTest.java
│ │ │ └── LoadExistingJUnitTest.java
│ │ └── samplemore
│ │ │ ├── JunitParallelMultiScenarioTest.java
│ │ │ ├── JunitParallelSingleScenarioLoadTest.java
│ │ │ └── LoadMultipleGroupAnnotationTest.java
│ ├── loadgradually
│ │ ├── LoadGraduallyTestSuite.java
│ │ └── get
│ │ │ ├── LoadGet1Per1SecTest.java
│ │ │ ├── LoadGet1Per5SecTest.java
│ │ │ └── LoadGet5Per1SecTest.java
│ └── tests
│ │ ├── get
│ │ └── GetScreeningServiceTest.java
│ │ ├── getparamids
│ │ └── GetByDbNextIdTest.java
│ │ ├── junit
│ │ ├── JunitExistingRestTest.java
│ │ └── JunitExistingTest.java
│ │ ├── post
│ │ └── PostCorpLoanServiceTest.java
│ │ └── put
│ │ └── PutCorpLoanServiceTest.java
│ ├── samplesjunit5
│ ├── jupiter
│ │ ├── JUnit5MoreTest.java
│ │ ├── JUnit5Test.java
│ │ └── extension
│ │ │ ├── ExtensionA.java
│ │ │ └── ExtensionB.java
│ └── loadjupiter
│ │ ├── ParallelLoadTestSuite.java
│ │ ├── commonload
│ │ └── JUnit5LoadCommonLoadTest.java
│ │ ├── differentload
│ │ └── JUnit5LoadDifferentLoadTest.java
│ │ └── simpleload
│ │ └── JUnit5LoadTest.java
│ └── utils
│ └── DbIdPicker.java
└── resources
├── corploan_server_host.properties
├── load_generation.properties
├── load_generation_1per1sec.properties
├── load_generation_1per5sec.properties
├── load_generation_5per1sec.properties
├── load_tests
├── get
│ ├── get_details_by_id.json
│ └── get_screening_details_by_custid.json
├── get_with_database_ids
│ └── get_details_by_next_db_custid.json
├── post
│ └── create_post_and_get_new_loan.json
└── put
│ └── amend_put_and_get_existing_loan.json
├── localhost_stubs
└── localhost_REST_fake_end_points_stubs.json
└── screening_service_host.properties
/.gitignore:
--------------------------------------------------------------------------------
1 | # Compiled class file
2 | *.class
3 |
4 | # Log file
5 | *.log
6 |
7 | # BlueJ files
8 | *.ctxt
9 |
10 | # Mobile Tools for Java (J2ME)
11 | .mtj.tmp/
12 |
13 | # Package Files #
14 | *.jar
15 | *.war
16 | *.nar
17 | *.ear
18 | *.zip
19 | *.tar.gz
20 | *.rar
21 |
22 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
23 | hs_err_pid*
24 |
25 |
26 | #copied from older project
27 | # Compiled class file
28 | *.class
29 |
30 | # Log file
31 | *.log
32 |
33 | # BlueJ files
34 | *.ctxt
35 |
36 | # Mobile Tools for Java (J2ME)
37 | .mtj.tmp/
38 |
39 | # Package Files #
40 | *.jar
41 | *.war
42 | *.ear
43 | *.zip
44 | *.tar.gz
45 | *.rar
46 |
47 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
48 | hs_err_pid*
49 |
50 | *iml
51 | *.idea
52 | /target
53 | .DS_Store
54 |
55 | package.properties
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2018 JAPPS
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | ## Table of Contents
2 | * [Introduction and Quick Overview](https://github.com/authorjapps/zerocode/wiki/Load-or-Performance-Testing-(IDE-based)#in-essence-the-performance-testing-is-all-about-)
3 | * [Performance testing (Testing load and stress)](#performance-testing-testing-load-and-stress)
4 | * [Using - JUnit5 Jupiter](#maven-dependencies---junit5-jupiter-tests)
5 | * [Using - JUnit4](#maven-dependencies---junit4)
6 | * [One user-journey parallel load](#single-scenario-parallel-load)
7 | * [Combining single user-journeys(GET, POST, PUT etc)](#combining-single-loadsget-post-put-etc)
8 | * [Multi scenario parallel load](#multi-scenario-parallel-load)
9 | * [Grouping the multiload tests(Optional)](#optionallygrouping-the-multiload-tests)
10 | * [Load with gradually increasing or decreasing](#load-with-gradually-increasing-or-decreasing)
11 | * [Maven library used](#maven-library-used)
12 | * [Disbaling long-running HTML reports]()
13 |
14 | # Performance testing (Testing load and stress)
15 |
16 | Sample Performance Tests - Banking (Using [JUnit](https://github.com/junit-team/junit4) and [Zerocode](https://github.com/authorjapps/zerocode) test framework)
17 |
18 | #### Maven dependencies - JUnit5 Jupiter Tests
19 | ```xml
20 |
21 | org.jsmart
22 | zerocode-tdd-jupiter
23 | 1.3.23
24 |
25 | ```
26 | Then follow this [WikiPage](https://github.com/authorjapps/zerocode/wiki/JUnit5-Jupiter-Parallel-Load-Extension).
27 |
28 | For **JUnit4** parallel-run or load testing, follow the samples in the below sections.
29 |
30 | #### Maven dependencies - JUnit4
31 | ```xml
32 |
33 | org.jsmart
34 | zerocode-tdd
35 | 1.3.23
36 |
37 | ```
38 |
39 | 
40 |
41 | Single scenario parallel load
42 | ===
43 | See this `GET` load test in the repo e.g.
44 | ```java
45 | @LoadWith("load_generation.properties")
46 | @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
47 | @RunWith(ZeroCodeLoadRunner.class)
48 | public class LoadGetTest {
49 |
50 | }
51 | ```
52 | Where, the `load_generation.properties` has the below load e.g.
53 | (100 requests in 100secs i.e. each request in 1 sec gap, looping twice, meaning 200 parallel requests)
54 | ```properties
55 | number.of.threads=100
56 | ramp.up.period.in.seconds=100
57 | loop.count=2
58 | ```
59 |
60 | It generates load for the below GET scenario:
61 | ```
62 | @TargetEnv("screening_service_host.properties")
63 | @RunWith(ZeroCodeUnitRunner.class)
64 | public class GetScreeningServiceTest {
65 |
66 | @Test
67 | @JsonTestCase("load_tests/get/get_screening_details_by_custid.json")
68 | public void testGetScreeningLocalAndGlobal() throws Exception {
69 | }
70 | }
71 | ```
72 |
73 | Where the `get_screening_details_by_custid.json` with payload and assertions/validations :
74 | ```
75 | {
76 | "scenarioName": "Screening API- Get Screening by customerId test",
77 | "steps": [
78 | {
79 | "name": "get_screening_details",
80 | "url": "/api/v1/screening/cust-ids/SINGAHV3033",
81 | "method": "GET",
82 | "request": {
83 | },
84 | "verify": {
85 | "status": 200,
86 | "body": {
87 | "id" : "SINGAHV3033",
88 | "localScreeningStatus" : "Green",
89 | "globalScreeningStatus" : "Red"
90 | }
91 | }
92 | }
93 |
94 | ]
95 | }
96 | ```
97 | + [Download](https://github.com/authorjapps/performance-tests/archive/master.zip) or [browse](https://github.com/authorjapps/performance-tests) in the repo
98 |
99 | Combining single loads(GET, POST, PUT etc)
100 | ===
101 | See the suite test firing different loads with single scenario each
102 | e.g.
103 | sample test-class: `org.jsmart.zerocode.samples.load.LoadTestSuite`
104 |
105 | ```java
106 | @Suite.SuiteClasses({
107 |
108 | LoadGetTest.class,
109 | LoadPostTest.class,
110 | LoadMultipleGetPostPutTest.class
111 |
112 | })
113 | @RunWith(Suite.class)
114 | public class LoadTestSuite {
115 |
116 | }
117 | ```
118 | + [Download](https://github.com/authorjapps/performance-tests/archive/master.zip) or [browse](https://github.com/authorjapps/performance-tests) in the repo
119 |
120 | Multi scenario parallel load
121 | ===
122 | See the test-class `org.jsmart.zerocode.samples.load.parallelmulti.LoadMultipleGetPostPutTest`
123 | ```java
124 | /**
125 | * What's new in ZeroCodeMultiLoadRunner.class ?
126 | * ---------------------------------------------
127 | * While running with "ZeroCodeMultiLoadRunner.class", each test mapping here is equivalent to one user,
128 | * that means there are 3 concurrent users below invoking their respective user operations as:
129 | * User-1) POST,GET
130 | * User-2) PUT,GET
131 | * User-3) GET
132 | * User-N) so on
133 | *
134 | * Note :
135 | * ------
136 | * All 3 users are running in parallel which resembles the production like scenario where each user
137 | * doing different jobs.
138 | *
139 | * You can keep feeding/adding as many tests by using @TestMapping(TestClassName.class, "testMethodName")
140 | *
141 | * Please make sure you set "number.of.threads" >= "number of test mappings(= 3 here)" giving chance for
142 | * each scenario to get executed at least once.
143 | *
144 | */
145 | @LoadWith("load_generation.properties")
146 | @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
147 | @TestMapping(testClass = PostCorpLoanServiceTest.class, testMethod = "testPostNewLoan_crudOperations")
148 | @TestMapping(testClass = PutCorpLoanServiceTest.class, testMethod = "testPutAmendExistingLoan")
149 | @RunWith(ZeroCodeMultiLoadRunner.class)
150 | public class LoadMultipleGetPostPutTest {
151 |
152 | }
153 | ```
154 | + [Download](https://github.com/authorjapps/performance-tests/archive/master.zip) or [browse](https://github.com/authorjapps/performance-tests) in the repo
155 |
156 | #### (Optionally)Grouping the multiload tests
157 | You can(optionally) group the `@TestMapping`s as below for better readability and pretty looking too.
158 | ```java
159 | @LoadWith("load_generation.properties")
160 | @TestMappings({
161 | @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal"),
162 | @TestMapping(testClass = PostCorpLoanServiceTest.class, testMethod = "testPostNewLoan_crudOperations"),
163 | @TestMapping(testClass = PutCorpLoanServiceTest.class, testMethod = "testPutAmendExistingLoan")
164 | })
165 | @RunWith(ZeroCodeMultiLoadRunner.class)
166 | public class LoadMultipleGroupAnnotationTest {
167 | }
168 | ```
169 | + [Download](https://github.com/authorjapps/performance-tests/archive/master.zip) or [browse](https://github.com/authorjapps/performance-tests) in the repo
170 |
171 | Load with gradually increasing or decreasing
172 | ===
173 |
174 | See the test-class `org.jsmart.zerocode.samples.loadgradually.LoadGraduallyTestSuite`
175 | ```java
176 | @Suite.SuiteClasses({
177 |
178 | LoadGet1Per5SecTest.class, // <-- Less load (5 sec gap)
179 | LoadGet1Per1SecTest.class, // <-- Bit more load (1 sec gap)
180 | LoadGet5Per1SecTest.class // <-- Heavy load (0.2 sec gap)
181 |
182 | })
183 | @RunWith(Suite.class)
184 | public class LoadGraduallyTestSuite {
185 |
186 | }
187 | ```
188 | + [Download](https://github.com/authorjapps/performance-tests/archive/master.zip) this project to run using your local IDE
189 |
190 | Maven library used
191 | ===
192 | + Latest release (includes Kafka testing):
193 | ```
194 |
195 | org.jsmart
196 | zerocode-tdd
197 | 1.3.x
198 |
199 | ```
200 | + Visit here for the latest in [Maven Central](https://mvnrepository.com/artifact/org.jsmart/zerocode-tdd)
201 | + Or check here at [zerocode maven-and-ci](https://github.com/authorjapps/zerocode/blob/master/README.md#maven-and-ci-)
202 | + Visit here for the earlier releases [Maven Central](https://mvnrepository.com/artifact/org.jsmart/zerocode-rest-bdd)
203 |
204 | Disabling long-running HTML Reports
205 | ===
206 |
207 | The Interactive-Html-Report generation is enabled by default. For load testing this report may not be quite useful as we are mostly interested in load statistics which we can get from the CSV reports. Also the HTML interactive reports particularly takes bit longer to generate during load testing.
208 |
209 | To disable this report generation please use the following flag in the host properties file annotated with `@TargetEnv("app_host_sit.properties")`.
210 |
211 | ```properties
212 | interactive.html.report.disabled=true
213 | ```
214 |
215 |
--------------------------------------------------------------------------------
/help_images/load_tests_L.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/authorjapps/performance-tests/8d587694227391b96ed01ad0c0238ddd95ce1a62/help_images/load_tests_L.png
--------------------------------------------------------------------------------
/pom.xml:
--------------------------------------------------------------------------------
1 |
2 |
5 |
6 | 4.0.0
7 |
8 | org.jsmart
9 | corp-bank-performance-tests
10 | 0.0.1-SNAPSHOT
11 |
12 | jar
13 | Corp Bank Performance Tests
14 | Performance testing(load and stress) of systems APIs
15 |
16 |
17 | 1.3.23
18 | 4.12
19 | 1.8
20 | 3.0.0
21 | 1.1.8
22 |
23 |
24 |
25 |
26 | junit
27 | junit
28 | ${junit.version}
29 | compile
30 |
31 |
32 | org.jsmart
33 | zerocode-tdd
34 | ${zerocode-tdd.version}
35 |
36 |
37 | org.jsmart
38 | zerocode-tdd-jupiter
39 | ${zerocode-tdd.version}
40 |
41 |
46 |
47 | org.jsmart
48 | micro-simulator
49 | ${micro-simulator.version}
50 | test
51 |
52 |
53 |
54 |
55 |
56 |
57 | org.apache.maven.plugins
58 | maven-compiler-plugin
59 |
60 | ${java.version}
61 | ${java.version}
62 |
63 |
64 |
65 | org.apache.maven.plugins
66 | maven-surefire-plugin
67 | 3.0.0-M3
68 |
69 |
70 |
80 | org.jsmart.zerocode.samples.load.LoadTestSuite.class
81 | org.jsmart.zerocode.samplesjunit5.loadjupiter.simpleload.JUnit5LoadTest
82 |
83 |
84 |
85 |
86 | org.apache.maven.plugins
87 | maven-source-plugin
88 | ${plugin.source.version}
89 |
90 |
91 | attach-sources
92 |
93 | jar
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/restapimockserver/RunMeFirstMockApiServer.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.restapimockserver;
2 |
3 | import org.jsmart.simulator.annotations.ApiRepo;
4 | import org.jsmart.simulator.impl.JsonBasedSimulator;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | /*
9 | * Created by Siddha on 27/04/2015.
10 | *
11 | * Are you done with the web server ? To stop this REST server, simply press Ctrl+c or Stop button on your IDE
12 | *
13 | */
14 | @ApiRepo("localhost_stubs")
15 | public class RunMeFirstMockApiServer extends JsonBasedSimulator {
16 | private static final Logger logger = LoggerFactory.getLogger(RunMeFirstMockApiServer.class);
17 |
18 | public static final int PORT = 8088;
19 |
20 | public RunMeFirstMockApiServer(int port) {
21 | super(port);
22 | }
23 |
24 | public static void main(String[] args) {
25 | logger.info("\n----------- REST Helper web-service starting...--------------");
26 | new RunMeFirstMockApiServer(PORT).start();
27 | logger.info("\n### REST Helper web-service started.");
28 |
29 | System.out.println("\n------ Done? To stop this REST server, simply press Ctrl+c or Stop button on your IDE -------");
30 |
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/runner/DbParameterizedLoadRunner.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.runner;
2 |
3 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner;
4 | import org.jsmart.zerocode.utils.DbIdPicker;
5 | import org.junit.runners.model.InitializationError;
6 | import org.slf4j.Logger;
7 | import org.slf4j.LoggerFactory;
8 |
9 | import static java.util.Arrays.asList;
10 |
11 | /**
12 | * This runner loads the "ids" from the DB and then, fires the parallel tests
13 | * Issue : https://github.com/authorjapps/zerocode/issues/233
14 | *
15 | * Note-
16 | * This is only for suggestion.
17 | * But feel free to bring up your own flavour of this runner
18 | */
19 | public class DbParameterizedLoadRunner extends ZeroCodeLoadRunner {
20 | private static final Logger LOGGER = LoggerFactory.getLogger(DbParameterizedLoadRunner.class);
21 |
22 | public DbParameterizedLoadRunner(Class> testClass) throws InitializationError {
23 | super(testClass);
24 | fetchDbIds();
25 | }
26 |
27 | private void fetchDbIds() {
28 | String fetchIdsSql = "select ID from CUSTOMER where SALARY < 60000";
29 | LOGGER.info("\nFetching all IDs from the DB......................................\n\n" + fetchIdsSql);
30 |
31 | // -------------------------------------------------
32 | // Connect to your DB via JDBC and execute your SQL
33 | // here and assign the IDs into a list e.g. "ids".
34 | //
35 | // Assume the below IDs (CUST-100, ... ) are from DB
36 | // -------------------------------------------------
37 |
38 | DbIdPicker.ids = asList( "SINGAHV3033", "SINGAHV3034");
39 | LOGGER.info("\n......................................done.\n\n");
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/load/LoadTestSuite.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.load;
2 |
3 | import org.jsmart.zerocode.samples.load.parallelget.LoadGetTest;
4 | import org.jsmart.zerocode.samples.load.parallelmulti.LoadMultipleGetPostPutTest;
5 | import org.jsmart.zerocode.samples.load.parallelpost.LoadPostTest;
6 | import org.jsmart.zerocode.samples.load.samplejunit.LoadExistingJUnitRestTest;
7 | import org.jsmart.zerocode.samples.load.samplejunit.LoadExistingJUnitTest;
8 | import org.junit.runner.RunWith;
9 | import org.junit.runners.Suite;
10 |
11 | @Suite.SuiteClasses({
12 | LoadGetTest.class,
13 | LoadPostTest.class,
14 | LoadMultipleGetPostPutTest.class,
15 | LoadExistingJUnitTest.class,
16 | LoadExistingJUnitRestTest.class
17 | })
18 | @RunWith(Suite.class)
19 | public class LoadTestSuite {
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/load/parallelget/LoadGetTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.load.parallelget;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner;
6 | import org.jsmart.zerocode.samples.tests.get.GetScreeningServiceTest;
7 | import org.junit.runner.RunWith;
8 |
9 | @LoadWith("load_generation.properties")
10 | @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
11 | @RunWith(ZeroCodeLoadRunner.class)
12 | public class LoadGetTest {
13 |
14 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/load/parallelmulti/LoadMultipleGetPostPutTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.load.parallelmulti;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeMultiLoadRunner;
6 | import org.jsmart.zerocode.samples.tests.get.GetScreeningServiceTest;
7 | import org.jsmart.zerocode.samples.tests.post.PostCorpLoanServiceTest;
8 | import org.jsmart.zerocode.samples.tests.put.PutCorpLoanServiceTest;
9 | import org.junit.runner.RunWith;
10 |
11 | /**
12 | * What's new in ZeroCodeMultiLoadRunner.class ?
13 | * ---------------------------------------------
14 | * While running with "ZeroCodeMultiLoadRunner.class", each test mapping here is equivalent to one user,
15 | * that means there are 3 concurrent users below invoking their respective user operations as:
16 | * User-1) POST,GET
17 | * User-2) PUT,GET
18 | * User-3) GET
19 | * User-N) so on
20 | *
21 | * Note :
22 | * ------
23 | * All 3 users are running in parallel which resembles the production like scenario where each user
24 | * doing different jobs.
25 | *
26 | * You can keep feeding/adding as many tests by using @TestMapping(TestClassName.class, "testMethodName")
27 | *
28 | * Please make sure you set "number.of.threads" >= "number of test mappings(= 3 here)" giving chance for
29 | * each scenario to get executed at least once.
30 | *
31 | * See (optionally) how to group the tests ?
32 | * -----------------------------------------
33 | * For pretty looking or better readability:
34 | * org.jsmart.zerocode.samples.load.samplemore.LoadMultipleGroupAnnotationTest
35 | *
36 | */
37 | @LoadWith("load_generation.properties")
38 | @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
39 | @TestMapping(testClass = PostCorpLoanServiceTest.class, testMethod = "testPostNewLoan_crudOperations")
40 | @TestMapping(testClass = PutCorpLoanServiceTest.class, testMethod = "testPutAmendExistingLoan")
41 | @RunWith(ZeroCodeMultiLoadRunner.class)
42 | public class LoadMultipleGetPostPutTest {
43 |
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/load/parallelparametized/LoadDbParameterizedGetTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.load.parallelparametized;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.runner.DbParameterizedLoadRunner;
6 | import org.jsmart.zerocode.samples.tests.getparamids.GetByDbNextIdTest;
7 | import org.junit.runner.RunWith;
8 |
9 | @LoadWith("load_generation.properties")
10 | @TestMapping(testClass = GetByDbNextIdTest.class, testMethod = "testGetDetailsByNextDbId")
11 | @RunWith(DbParameterizedLoadRunner.class)
12 | public class LoadDbParameterizedGetTest {
13 |
14 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/load/parallelpost/LoadPostTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.load.parallelpost;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner;
6 | import org.jsmart.zerocode.samples.tests.post.PostCorpLoanServiceTest;
7 | import org.junit.runner.RunWith;
8 |
9 | @LoadWith("load_generation.properties")
10 | @TestMapping(testClass = PostCorpLoanServiceTest.class, testMethod = "testPostNewLoan_crudOperations")
11 | @RunWith(ZeroCodeLoadRunner.class)
12 | public class LoadPostTest {
13 |
14 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/load/samplejunit/LoadExistingJUnitRestTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.load.samplejunit;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner;
6 | import org.jsmart.zerocode.samples.tests.junit.JunitExistingRestTest;
7 | import org.junit.runner.RunWith;
8 |
9 | @LoadWith("load_generation.properties")
10 | @TestMapping(testClass = JunitExistingRestTest.class, testMethod = "testGitHubGetApi")
11 | @RunWith(ZeroCodeLoadRunner.class)
12 | public class LoadExistingJUnitRestTest {
13 |
14 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/load/samplejunit/LoadExistingJUnitTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.load.samplejunit;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner;
6 | import org.jsmart.zerocode.samples.tests.junit.JunitExistingTest;
7 | import org.junit.runner.RunWith;
8 |
9 | @LoadWith("load_generation.properties")
10 | @TestMapping(testClass = JunitExistingTest.class, testMethod = "testAddTwoNumbers_firstPassThenFail")
11 | @RunWith(ZeroCodeLoadRunner.class)
12 | public class LoadExistingJUnitTest {
13 |
14 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/load/samplemore/JunitParallelMultiScenarioTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.load.samplemore;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeMultiLoadRunner;
6 | import org.jsmart.zerocode.samples.tests.get.GetScreeningServiceTest;
7 | import org.jsmart.zerocode.samples.tests.post.PostCorpLoanServiceTest;
8 | import org.jsmart.zerocode.samples.tests.put.PutCorpLoanServiceTest;
9 | import org.junit.runner.RunWith;
10 |
11 | /**
12 | * Each test mapping here is equivalent to one user, that means there are 3 concurrent users below
13 | * invoking their respective user operations as:
14 | * User-1)POST,GET
15 | * User-2)PUT,GET
16 | * User-3)GET
17 | * Note-
18 | * All 3 users are running in parallel which resembles the production like scenario where each user
19 | * doing different jobs.
20 | *
21 | * You can keep feeding/adding as many tests by using @TestMapping(TestClassName.class, "testMethodName")
22 | *
23 | * Please set "number.of.threads" >= "number of test mappings(= 3 here in this example)" giving chance for
24 | * each user scenario to get executed at least once. It's not illegal too, to set less "number.of.threads".
25 | *
26 | * If you set more(e.g. number.of.threads=6 or 9, 10 in this case), then the user scenarios will get executed
27 | * more and more times in parallel until all the threads are used up.
28 | *
29 | */
30 | @LoadWith("load_generation.properties")
31 | @TestMapping(testClass = PostCorpLoanServiceTest.class, testMethod = "testPostNewLoan_crudOperations")
32 | @TestMapping(testClass = PutCorpLoanServiceTest.class, testMethod = "testPutAmendExistingLoan")
33 | @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
34 | @RunWith(ZeroCodeMultiLoadRunner.class)
35 | public class JunitParallelMultiScenarioTest {
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/load/samplemore/JunitParallelSingleScenarioLoadTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.load.samplemore;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner;
6 | import org.jsmart.zerocode.samples.tests.get.GetScreeningServiceTest;
7 | import org.junit.runner.RunWith;
8 |
9 | @LoadWith("load_generation.properties")
10 | @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
11 | @RunWith(ZeroCodeLoadRunner.class)
12 | public class JunitParallelSingleScenarioLoadTest {
13 |
14 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/load/samplemore/LoadMultipleGroupAnnotationTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.load.samplemore;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.domain.TestMappings;
6 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeMultiLoadRunner;
7 | import org.jsmart.zerocode.samples.tests.get.GetScreeningServiceTest;
8 | import org.jsmart.zerocode.samples.tests.post.PostCorpLoanServiceTest;
9 | import org.jsmart.zerocode.samples.tests.put.PutCorpLoanServiceTest;
10 | import org.junit.runner.RunWith;
11 |
12 | /**
13 | * What's new in ZeroCodeMultiLoadRunner.class ?
14 | * ---------------------------------------------
15 | * While running with "ZeroCodeMultiLoadRunner.class", each test mapping here is equivalent to one user,
16 | * that means there are 3 concurrent users below invoking their respective user operations as:
17 | * User-1) POST,GET
18 | * User-2) PUT,GET
19 | * User-3) GET
20 | * User-N) so on
21 | *
22 | * Note :
23 | * ------
24 | * All 3 users are running in parallel which resembles the production like scenario where each user
25 | * doing different jobs.
26 | *
27 | * You can keep feeding/adding as many tests by using @TestMapping(TestClassName.class, "testMethodName")
28 | *
29 | * Please make sure you set "number.of.threads" >= "number of test mappings(= 3 here)" giving chance for
30 | * each scenario to get executed at least once.
31 | *
32 | */
33 | @LoadWith("load_generation.properties")
34 | @TestMappings({
35 | @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal"),
36 | @TestMapping(testClass = PostCorpLoanServiceTest.class, testMethod = "testPostNewLoan_crudOperations"),
37 | @TestMapping(testClass = PutCorpLoanServiceTest.class, testMethod = "testPutAmendExistingLoan")
38 | })
39 | @RunWith(ZeroCodeMultiLoadRunner.class)
40 | public class LoadMultipleGroupAnnotationTest {
41 |
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/loadgradually/LoadGraduallyTestSuite.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.loadgradually;
2 |
3 | import org.jsmart.zerocode.samples.loadgradually.get.LoadGet1Per1SecTest;
4 | import org.jsmart.zerocode.samples.loadgradually.get.LoadGet1Per5SecTest;
5 | import org.jsmart.zerocode.samples.loadgradually.get.LoadGet5Per1SecTest;
6 | import org.junit.runner.RunWith;
7 | import org.junit.runners.Suite;
8 |
9 | @Suite.SuiteClasses({
10 |
11 | LoadGet1Per5SecTest.class, // <-- Less load (5 sec gap)
12 | LoadGet1Per1SecTest.class, // <-- Bit more load (1 sec gap)
13 | LoadGet5Per1SecTest.class // <-- Heavy load (0.2 sec gap)
14 |
15 | })
16 | @RunWith(Suite.class)
17 | public class LoadGraduallyTestSuite {
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/loadgradually/get/LoadGet1Per1SecTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.loadgradually.get;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner;
6 | import org.jsmart.zerocode.samples.tests.get.GetScreeningServiceTest;
7 | import org.junit.runner.RunWith;
8 |
9 | @LoadWith("load_generation_1per1sec.properties")
10 | @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
11 | @RunWith(ZeroCodeLoadRunner.class)
12 | public class LoadGet1Per1SecTest {
13 |
14 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/loadgradually/get/LoadGet1Per5SecTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.loadgradually.get;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner;
6 | import org.jsmart.zerocode.samples.tests.get.GetScreeningServiceTest;
7 | import org.junit.runner.RunWith;
8 |
9 | @LoadWith("load_generation_1per5sec.properties")
10 | @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
11 | @RunWith(ZeroCodeLoadRunner.class)
12 | public class LoadGet1Per5SecTest {
13 |
14 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/loadgradually/get/LoadGet5Per1SecTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.loadgradually.get;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.runner.parallel.ZeroCodeLoadRunner;
6 | import org.jsmart.zerocode.samples.tests.get.GetScreeningServiceTest;
7 | import org.junit.runner.RunWith;
8 |
9 | @LoadWith("load_generation_5per1sec.properties")
10 | @TestMapping(testClass = GetScreeningServiceTest.class, testMethod = "testGetScreeningLocalAndGlobal")
11 | @RunWith(ZeroCodeLoadRunner.class)
12 | public class LoadGet5Per1SecTest {
13 |
14 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/tests/get/GetScreeningServiceTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.tests.get;
2 |
3 | import org.jsmart.zerocode.core.domain.JsonTestCase;
4 | import org.jsmart.zerocode.core.domain.TargetEnv;
5 | import org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 |
9 | @TargetEnv("screening_service_host.properties")
10 | @RunWith(ZeroCodeUnitRunner.class)
11 | public class GetScreeningServiceTest {
12 |
13 | @Test
14 | @JsonTestCase("load_tests/get/get_screening_details_by_custid.json")
15 | public void testGetScreeningLocalAndGlobal() throws Exception {
16 |
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/tests/getparamids/GetByDbNextIdTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.tests.getparamids;
2 |
3 | import org.jsmart.zerocode.core.domain.JsonTestCase;
4 | import org.jsmart.zerocode.core.domain.TargetEnv;
5 | import org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner;
6 | import org.junit.Test;
7 | import org.junit.runner.RunWith;
8 |
9 | @TargetEnv("screening_service_host.properties")
10 | @RunWith(ZeroCodeUnitRunner.class)
11 | public class GetByDbNextIdTest {
12 |
13 | @Test
14 | @JsonTestCase("load_tests/get_with_database_ids/get_details_by_next_db_custid.json")
15 | public void testGetDetailsByNextDbId() throws Exception {
16 |
17 | }
18 |
19 | }
20 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/tests/junit/JunitExistingRestTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.tests.junit;
2 |
3 | import org.apache.commons.io.IOUtils;
4 | import org.apache.http.HttpResponse;
5 | import org.apache.http.client.methods.HttpGet;
6 | import org.apache.http.impl.client.CloseableHttpClient;
7 | import org.apache.http.impl.client.HttpClients;
8 | import org.hamcrest.CoreMatchers;
9 | import org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner;
10 | import org.junit.Test;
11 | import org.junit.runner.RunWith;
12 |
13 | import java.io.IOException;
14 |
15 | import static org.hamcrest.MatcherAssert.assertThat;
16 | import static org.hamcrest.core.Is.is;
17 |
18 | @RunWith(ZeroCodeUnitRunner.class)
19 | public class JunitExistingRestTest {
20 |
21 | /**
22 | * This test sometimes failed due to GitHub rate limiting settings.
23 | * The failures should be captured in the reports(CSV and html).
24 | * This is knowing kept here to test the rate limiting and show
25 | * how a failed test can be tracked in the log/reports
26 | */
27 | @Test
28 | public void testGitHubGetApi() throws IOException, InterruptedException {
29 | CloseableHttpClient httpClient = HttpClients.createDefault();
30 | HttpGet request = new HttpGet("https://api.github.com//users/octocat");
31 |
32 | // - - - - - - - - - - - - - - - - - - - - - - - - -
33 | // Add known delay to reflect "responseDelay" value
34 | // in the CSV report at least more than this number.
35 | // - - - - - - - - - - - - - - - - - - - - - - - - -
36 | Thread.sleep(1000);
37 |
38 | HttpResponse response = httpClient.execute(request);
39 | final String responseBodyActual = IOUtils.toString(response.getEntity().getContent(), "UTF-8");
40 | System.out.println("### response: \n" + responseBodyActual);
41 |
42 | assertThat(response.getStatusLine().getStatusCode(), CoreMatchers.is(200));
43 | assertThat(responseBodyActual, CoreMatchers.containsString("\"login\":\"octocat\""));
44 |
45 | }
46 | }
47 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/tests/junit/JunitExistingTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.tests.junit;
2 |
3 | import org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner;
4 | import org.junit.Test;
5 | import org.junit.runner.RunWith;
6 |
7 | import static org.hamcrest.MatcherAssert.assertThat;
8 | import static org.hamcrest.core.Is.is;
9 |
10 | //@RunWith(ZeroCodeUnitRunner.class) //<--- Enable this for reports only. Otherwise not needed.
11 | public class JunitExistingTest {
12 | static int a = 2;
13 | static int b = 3;
14 |
15 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
16 | // 1st run passes, but subsequent run fails, this is deliberately
17 | // done to see the failures reflects in the CSV reports and conslosole
18 | // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
19 | @Test
20 | public void testAddTwoNumbers_firstPassThenFail() {
21 | int sum = a + b;
22 | assertThat(sum, is(5));
23 |
24 | a++;
25 | b++;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/tests/post/PostCorpLoanServiceTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.tests.post;
2 |
3 | import org.jsmart.zerocode.core.domain.JsonTestCase;
4 | import org.jsmart.zerocode.core.domain.TargetEnv;
5 | import org.jsmart.zerocode.core.domain.UseHttpClient;
6 | import org.jsmart.zerocode.core.httpclient.ssl.SslTrustHttpClient;
7 | import org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner;
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | @TargetEnv("corploan_server_host.properties")
12 | @UseHttpClient(SslTrustHttpClient.class)
13 | @RunWith(ZeroCodeUnitRunner.class)
14 | public class PostCorpLoanServiceTest {
15 |
16 |
17 | @Test
18 | @JsonTestCase("load_tests/post/create_post_and_get_new_loan.json")
19 | public void testPostNewLoan_crudOperations() throws Exception {
20 |
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samples/tests/put/PutCorpLoanServiceTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samples.tests.put;
2 |
3 | import org.jsmart.zerocode.core.domain.JsonTestCase;
4 | import org.jsmart.zerocode.core.domain.TargetEnv;
5 | import org.jsmart.zerocode.core.domain.UseHttpClient;
6 | import org.jsmart.zerocode.core.httpclient.ssl.SslTrustHttpClient;
7 | import org.jsmart.zerocode.core.runner.ZeroCodeUnitRunner;
8 | import org.junit.Test;
9 | import org.junit.runner.RunWith;
10 |
11 | @TargetEnv("corploan_server_host.properties")
12 | @UseHttpClient(SslTrustHttpClient.class)
13 | @RunWith(ZeroCodeUnitRunner.class)
14 | public class PutCorpLoanServiceTest {
15 |
16 | @Test
17 | @JsonTestCase("load_tests/put/amend_put_and_get_existing_loan.json")
18 | public void testPutAmendExistingLoan() throws Exception {
19 |
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samplesjunit5/jupiter/JUnit5MoreTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samplesjunit5.jupiter;
2 |
3 | import org.jsmart.zerocode.samplesjunit5.jupiter.extension.ExtensionA;
4 | import org.jsmart.zerocode.samplesjunit5.jupiter.extension.ExtensionB;
5 | import org.junit.jupiter.api.Test;
6 | import org.junit.jupiter.api.extension.ExtendWith;
7 |
8 | import static java.lang.System.out;
9 | import static org.junit.jupiter.api.Assertions.assertTrue;
10 |
11 | @ExtendWith({ExtensionA.class, ExtensionB.class})
12 | public class JUnit5MoreTest {
13 |
14 | @Test
15 | public void testZ() throws InterruptedException {
16 | Thread.sleep(1000);
17 | out.println("*JUnit5 ---> testZ()");
18 | assertTrue(2 == 2); //jupiter assertion
19 | }
20 |
21 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samplesjunit5/jupiter/JUnit5Test.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samplesjunit5.jupiter;
2 |
3 | import org.jsmart.zerocode.samplesjunit5.jupiter.extension.ExtensionA;
4 | import org.jsmart.zerocode.samplesjunit5.jupiter.extension.ExtensionB;
5 | import org.junit.jupiter.api.Test;
6 | import org.junit.jupiter.api.extension.ExtendWith;
7 |
8 | import static java.lang.System.out;
9 | import static org.junit.jupiter.api.Assertions.assertTrue;
10 |
11 | @ExtendWith({ExtensionA.class, ExtensionB.class})
12 | public class JUnit5Test {
13 |
14 | @Test
15 | public void testX() {
16 | out.println("*JUnit5 ---> testX()");
17 | assertTrue(2 == 2); //jupiter assertion
18 | }
19 |
20 | @Test
21 | public void testY() throws InterruptedException {
22 | Thread.sleep(500);
23 | out.println("*JUnit5 ---> testY()");
24 | assertTrue(2 == 2); //jupiter assertion
25 | }
26 |
27 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samplesjunit5/jupiter/extension/ExtensionA.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samplesjunit5.jupiter.extension;
2 |
3 | import org.junit.jupiter.api.extension.AfterAllCallback;
4 | import org.junit.jupiter.api.extension.AfterEachCallback;
5 | import org.junit.jupiter.api.extension.BeforeAllCallback;
6 | import org.junit.jupiter.api.extension.BeforeEachCallback;
7 | import org.junit.jupiter.api.extension.ExtensionContext;
8 |
9 | public class ExtensionA implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback {
10 |
11 | @Override
12 | public void afterEach(ExtensionContext extensionContext) throws Exception {
13 | System.out.println("ExtentionA - afterEach");
14 | }
15 |
16 | @Override
17 | public void beforeEach(ExtensionContext extensionContext) throws Exception {
18 | System.out.println("ExtentionA - beforeEach");
19 |
20 | }
21 |
22 | @Override
23 | public void afterAll(ExtensionContext extensionContext) throws Exception {
24 | System.out.println("ExtentionA - afterAll");
25 |
26 | }
27 |
28 | @Override
29 | public void beforeAll(ExtensionContext extensionContext) throws Exception {
30 | System.out.println("ExtentionA - beforeAll");
31 |
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samplesjunit5/jupiter/extension/ExtensionB.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samplesjunit5.jupiter.extension;
2 |
3 |
4 | import org.junit.jupiter.api.extension.AfterAllCallback;
5 | import org.junit.jupiter.api.extension.AfterEachCallback;
6 | import org.junit.jupiter.api.extension.BeforeAllCallback;
7 | import org.junit.jupiter.api.extension.BeforeEachCallback;
8 | import org.junit.jupiter.api.extension.ExtensionContext;
9 |
10 | public class ExtensionB implements BeforeAllCallback, AfterAllCallback, BeforeEachCallback, AfterEachCallback {
11 |
12 | @Override
13 | public void afterEach(ExtensionContext extensionContext) throws Exception {
14 | System.out.println("ExtentionB - afterEach");
15 | }
16 |
17 | @Override
18 | public void beforeEach(ExtensionContext extensionContext) throws Exception {
19 | System.out.println("ExtentionB - beforeEach");
20 |
21 | }
22 |
23 | @Override
24 | public void afterAll(ExtensionContext extensionContext) throws Exception {
25 | System.out.println("ExtentionB - afterAll");
26 |
27 | }
28 |
29 | @Override
30 | public void beforeAll(ExtensionContext extensionContext) throws Exception {
31 | System.out.println("ExtentionB - beforeAll");
32 |
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samplesjunit5/loadjupiter/ParallelLoadTestSuite.java:
--------------------------------------------------------------------------------
1 | /*
2 | * Copyright 2016-2019 the original author or authors.
3 | *
4 | * Licensed under the Apache License, Version 2.0 (the "License");
5 | * you may not use this file except in compliance with the License.
6 | * You may obtain a copy of the License at
7 | *
8 | * http://www.apache.org/licenses/LICENSE-2.0
9 | *
10 | * Unless required by applicable law or agreed to in writing, software
11 | * distributed under the License is distributed on an "AS IS" BASIS,
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 | * See the License for the specific language governing permissions and
14 | * limitations under the License.
15 | */
16 |
17 | package org.jsmart.zerocode.samplesjunit5.loadjupiter;
18 |
19 | import org.jsmart.zerocode.jupiter.extension.ParallelLoadExtension;
20 | import org.jsmart.zerocode.samplesjunit5.loadjupiter.commonload.JUnit5LoadCommonLoadTest;
21 | import org.jsmart.zerocode.samplesjunit5.loadjupiter.differentload.JUnit5LoadDifferentLoadTest;
22 | import org.jsmart.zerocode.samplesjunit5.loadjupiter.simpleload.JUnit5LoadTest;
23 | import org.junit.platform.runner.JUnitPlatform;
24 | import org.junit.platform.suite.api.IncludeEngines;
25 | import org.junit.platform.suite.api.SelectPackages;
26 | import org.junit.runner.RunWith;
27 |
28 | /**
29 | * Test suite which demonstrates that the load tests can be run as a Suite in JUnit 5.
30 | * Single type of load or different types of load can be generated via {@link ParallelLoadExtension}.
31 | *
32 | * @author N Chandra
33 | * @since 5.0
34 | * @see JUnit5LoadTest
35 | * @see JUnit5LoadDifferentLoadTest
36 | * @see JUnit5LoadCommonLoadTest
37 | */
38 | @RunWith(JUnitPlatform.class)
39 | @IncludeEngines("junit-jupiter")
40 | @SelectPackages("org.jsmart.zerocode.samplesjunit5.loadjupiter")
41 | public class ParallelLoadTestSuite {
42 | }
43 |
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samplesjunit5/loadjupiter/commonload/JUnit5LoadCommonLoadTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samplesjunit5.loadjupiter.commonload;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.domain.TestMappings;
6 | import org.jsmart.zerocode.jupiter.extension.ParallelLoadExtension;
7 | import org.jsmart.zerocode.samplesjunit5.jupiter.JUnit5MoreTest;
8 | import org.jsmart.zerocode.samplesjunit5.jupiter.JUnit5Test;
9 | import org.junit.jupiter.api.DisplayName;
10 | import org.junit.jupiter.api.Test;
11 | import org.junit.jupiter.api.extension.ExtendWith;
12 |
13 | /**
14 | * How the load is generated?
15 | * Ans:
16 | * testLoad_xy() - Runs all the tests annotated with '@TestMapping' in parallel - as per @LoadWith properties
17 | * testLoad_xyz() - Runs all the tests annotated with '@TestMapping' in parallel - as per @LoadWith properties
18 | *
19 | * Note:
20 | * Both cases use a common load properties i.e. "load_generation.properties" - Annotated on Class level
21 | *
22 | * testLoad_xy(), testLoad_xyz() - Runs in sequence.
23 | * That means it once the first load scenario finishes, the next one triggers.
24 | * This is usual behaviour of the Test-Suite run. This is setup as a Suite setup,
25 | * which means you don't need another Suite-Runner to
26 | */
27 |
28 | @LoadWith("load_generation.properties")
29 | @ExtendWith({ParallelLoadExtension.class})
30 | public class JUnit5LoadCommonLoadTest {
31 |
32 | @Test
33 | @DisplayName("testing parallel load for X and Y scenarios")
34 | @TestMappings({
35 | @TestMapping(testClass = JUnit5Test.class, testMethod = "testX"),
36 | @TestMapping(testClass = JUnit5Test.class, testMethod = "testY")
37 | })
38 | public void testLoad_xy() {
39 | // This space remains empty
40 | }
41 |
42 | @Test
43 | @DisplayName("testing parallel load for X, Y and Z scenarios")
44 | @TestMappings({
45 | @TestMapping(testClass = JUnit5Test.class, testMethod = "testX"),
46 | @TestMapping(testClass = JUnit5Test.class, testMethod = "testY"),
47 | @TestMapping(testClass = JUnit5MoreTest.class, testMethod = "testZ")
48 | })
49 | public void testLoad_xyz() {
50 | // This space remains empty
51 | }
52 |
53 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samplesjunit5/loadjupiter/differentload/JUnit5LoadDifferentLoadTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samplesjunit5.loadjupiter.differentload;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.domain.TestMappings;
6 | import org.jsmart.zerocode.jupiter.extension.ParallelLoadExtension;
7 | import org.jsmart.zerocode.samplesjunit5.jupiter.JUnit5MoreTest;
8 | import org.jsmart.zerocode.samplesjunit5.jupiter.JUnit5Test;
9 | import org.junit.jupiter.api.DisplayName;
10 | import org.junit.jupiter.api.Test;
11 | import org.junit.jupiter.api.extension.ExtendWith;
12 |
13 | /**
14 | * How the load is generated?
15 | * Ans:
16 | * testLoad_xy() - Runs all the tests annotated with '@TestMapping' in parallel - as per @LoadWith properties
17 | * testLoad_xyz() - Runs all the tests annotated with '@TestMapping' in parallel - as per @LoadWith properties
18 | *
19 | * Note:
20 | * Both cases use a different load properties - Annotated on method level
21 | * i.e.
22 | * - "load_generation.properties"
23 | * - "load_generation_1per1sec.properties"
24 | *
25 | * testLoad_xy(), testLoad_xyz() - Runs in sequence.
26 | * That means it once the first load scenario finishes, the next one triggers.
27 | * This is usual behaviour of the Test-Suite run. This is setup as a Suite setup,
28 | * which means you don't need another Suite-Runner to
29 | */
30 | @ExtendWith({ParallelLoadExtension.class})
31 | public class JUnit5LoadDifferentLoadTest {
32 |
33 | @Test
34 | @DisplayName("1sec gap per user - Firing parallel load for X and Y scenarios")
35 | @TestMappings({
36 | @TestMapping(testClass = JUnit5Test.class, testMethod = "testX"),
37 | @TestMapping(testClass = JUnit5Test.class, testMethod = "testY")
38 | })
39 | @LoadWith("load_generation.properties")
40 | public void testLoad_xy() {
41 | // This space remains empty
42 | }
43 |
44 | @Test
45 | @DisplayName("2sec gap per user - Firing parallel load for X and Y scenarios")
46 | @TestMappings({
47 | @TestMapping(testClass = JUnit5Test.class, testMethod = "testX"),
48 | @TestMapping(testClass = JUnit5Test.class, testMethod = "testY"),
49 | @TestMapping(testClass = JUnit5MoreTest.class, testMethod = "testZ")
50 | })
51 | @LoadWith("load_generation_1per1sec.properties")
52 | public void testLoad_xyz() {
53 | // This space remains empty
54 | }
55 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/samplesjunit5/loadjupiter/simpleload/JUnit5LoadTest.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.samplesjunit5.loadjupiter.simpleload;
2 |
3 | import org.jsmart.zerocode.core.domain.LoadWith;
4 | import org.jsmart.zerocode.core.domain.TestMapping;
5 | import org.jsmart.zerocode.core.domain.TestMappings;
6 | import org.jsmart.zerocode.jupiter.extension.ParallelLoadExtension;
7 | import org.jsmart.zerocode.samplesjunit5.jupiter.JUnit5Test;
8 | import org.junit.jupiter.api.DisplayName;
9 | import org.junit.jupiter.api.Test;
10 | import org.junit.jupiter.api.extension.ExtendWith;
11 |
12 | @ExtendWith({ParallelLoadExtension.class})
13 | public class JUnit5LoadTest {
14 |
15 | @Test
16 | @DisplayName("Test parallel load for X and Y scenarios")
17 | @LoadWith("load_generation.properties")
18 | @TestMappings({
19 | @TestMapping(testClass = JUnit5Test.class, testMethod = "testX"),
20 | @TestMapping(testClass = JUnit5Test.class, testMethod = "testY")
21 | })
22 | public void testLoad() {
23 | // This space remains empty
24 | }
25 |
26 | }
--------------------------------------------------------------------------------
/src/test/java/org/jsmart/zerocode/utils/DbIdPicker.java:
--------------------------------------------------------------------------------
1 | package org.jsmart.zerocode.utils;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | public class DbIdPicker {
9 | private static final Logger LOGGER = LoggerFactory.getLogger(DbIdPicker.class);
10 |
11 | private static int nextId = 0;
12 | public static List ids = new ArrayList<>();
13 |
14 | public String nextId() {
15 | if (ids.size() == 0) {
16 | return null;
17 | }
18 |
19 | if (nextId >= ids.size()) {
20 | nextId = 0;
21 | }
22 |
23 | return ids.get(nextId++);
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/src/test/resources/corploan_server_host.properties:
--------------------------------------------------------------------------------
1 | # Web Server host and port
2 | restful.application.endpoint.host=http://localhost
3 | restful.application.endpoint.port=8088
4 |
5 | # Web Service context; Leave it blank in case you do not have a common context
6 | restful.application.endpoint.context=
7 |
--------------------------------------------------------------------------------
/src/test/resources/load_generation.properties:
--------------------------------------------------------------------------------
1 | # You can enter as many threads to stimulate a load test. A single user is represented by each Thread. So if you wish
2 | # to simulate a load test with 5 concurrent users then you need to enter 5 as the value for this property. A high end
3 | # machine will be able to spawn more number of threads. To keep the consistent(or nearly consistent) gap between the
4 | # threads, adjust this number with 'ramp.up.period.in.seconds' and the actual response time of the API end point.
5 | # For "@RunWith(ZeroCodeMultiLoadRunner.class)", set this to at least equal to number of "@TestMapping" or more,
6 | # otherwise there wont be enough threads to run each test.
7 | number.of.threads=3
8 |
9 | # It indicates the time taken to create all of the threads needed to fork the requests. If you set 10 seconds as the
10 | # ramp-up period for 5 threads then the framework will take 10 seconds to create those 5 threads, i.e. each thread
11 | # will be at work appx 2 secs gap between the requests. Also by setting its value to 0 all the threads can be created
12 | # at once at the same time. Note- If you want to fire more threads/user-requests in less ramp up time e.g. 5 threads
13 | # in 2secs(or 5 threads in 1 sec), then, use '@UseHttpClient(SslTrustHttpClient.class)' as this 'client' closes the
14 | # connection before making the next connection.
15 | ramp.up.period.in.seconds=6
16 |
17 | # By specifying its value framework gets to know that how many times the test(s), i.e. the number of requests will be
18 | # repeated per every 'ramp.up.period.in.seconds'.
19 | # Supposing number.of.threads = x, ramp.up.period.in.seconds = y, loop.count = i
20 | # then (x * i) = number of requests will be fired over (y * i) seconds. If x=5, i=3, y=20, then 15 requests will be
21 | # fired in 60 seconds which means- every request in 4 seconds gap. 60/15 or 20/5 = 4seconds.
22 | loop.count=1
23 |
--------------------------------------------------------------------------------
/src/test/resources/load_generation_1per1sec.properties:
--------------------------------------------------------------------------------
1 | # You can enter as many threads to stimulate a load test. A single user is represented by each Thread. So if you wish
2 | # to simulate a load test with 5 concurrent users then you need to enter 5 as the value for this property. A high end
3 | # machine will be able to spawn more number of threads. To keep the consistent(or nearly consistent) gap between the
4 | # threads, adjust this number with 'ramp.up.period.in.seconds' and the actual response time of the API end point.
5 | # For "@RunWith(ZeroCodeMultiLoadRunner.class)", set this to at least equal to number of "@TestMapping" or more,
6 | # otherwise there wont be enough threads to run each test.
7 | number.of.threads=3
8 |
9 | # It indicates the time taken to create all of the threads needed to fork the requests. If you set 10 seconds as the
10 | # ramp-up period for 5 threads then the framework will take 10 seconds to create those 5 threads, i.e. each thread
11 | # will be at work appx 2 secs gap between the requests. Also by setting its value to 0 all the threads can be created
12 | # at once at the same time. Note- If you want to fire more threads/user-requests in less ramp up time e.g. 5 threads
13 | # in 2secs(or 5 threads in 1 sec), then, use '@UseHttpClient(SslTrustHttpClient.class)' as this closes the connection
14 | # before making the next connection.
15 | ramp.up.period.in.seconds=3
16 |
17 | # By specifying its value framework gets to know that how many times the test(s), i.e. the number of requests will be
18 | # repeated per every 'ramp.up.period.in.seconds'.
19 | # Supposing number.of.threads = x, ramp.up.period.in.seconds = y, loop.count = i
20 | # then (x * i) = number of requests will be fired over (y * i) seconds. If x=5, i=3, y=20, then 15 requests will be
21 | # fired in 60 seconds which means- every request in 4 seconds gap. 60/15 or 20/5 = 4seconds.
22 | loop.count=1
23 |
24 | # If you have set the loop count to a higher digit which e.g. should take 3hrs(3*60*60=10800sec),
25 | # but due to load or network delay it could take more time(you are speculating) e.g. 4hrs, then you can
26 | # set this abort value to 3hrs i.e. 3*60*60=10800sec.
27 | abort.after.time.lapsed.in.seconds=600
--------------------------------------------------------------------------------
/src/test/resources/load_generation_1per5sec.properties:
--------------------------------------------------------------------------------
1 | # You can enter as many threads to stimulate a load test. A single user is represented by each Thread. So if you wish
2 | # to simulate a load test with 5 concurrent users then you need to enter 5 as the value for this property. A high end
3 | # machine will be able to spawn more number of threads. To keep the consistent(or nearly consistent) gap between the
4 | # threads, adjust this number with 'ramp.up.period.in.seconds' and the actual response time of the API end point.
5 | # For "@RunWith(ZeroCodeMultiLoadRunner.class)", set this to at least equal to number of "@TestMapping" or more,
6 | # otherwise there wont be enough threads to run each test.
7 | number.of.threads=3
8 |
9 | # It indicates the time taken to create all of the threads needed to fork the requests. If you set 10 seconds as the
10 | # ramp-up period for 5 threads then the framework will take 10 seconds to create those 5 threads, i.e. each thread
11 | # will be at work appx 2 secs gap between the requests. Also by setting its value to 0 all the threads can be created
12 | # at once at the same time. Note- If you want to fire more threads/user-requests in less ramp up time e.g. 5 threads
13 | # in 2secs(or 5 threads in 1 sec), then, use '@UseHttpClient(SslTrustHttpClient.class)' as this closes the connection
14 | # before making the next connection.
15 | ramp.up.period.in.seconds=15
16 |
17 | # By specifying its value framework gets to know that how many times the test(s), i.e. the number of requests will be
18 | # repeated per every 'ramp.up.period.in.seconds'.
19 | # Supposing number.of.threads = x, ramp.up.period.in.seconds = y, loop.count = i
20 | # then (x * i) = number of requests will be fired over (y * i) seconds. If x=5, i=3, y=20, then 15 requests will be
21 | # fired in 60 seconds which means- every request in 4 seconds gap. 60/15 or 20/5 = 4seconds.
22 | loop.count=1
23 |
24 | # If you have set the loop count to a higher digit which e.g. should take 3hrs(3*60*60=10800sec),
25 | # but due to load or network delay it could take more time(you are speculating) e.g. 4hrs, then you can
26 | # set this abort value to 3hrs i.e. 3*60*60=10800sec.
27 | abort.after.time.lapsed.in.seconds=600
--------------------------------------------------------------------------------
/src/test/resources/load_generation_5per1sec.properties:
--------------------------------------------------------------------------------
1 | # You can enter as many threads to stimulate a load test. A single user is represented by each Thread. So if you wish
2 | # to simulate a load test with 5 concurrent users then you need to enter 5 as the value for this property. A high end
3 | # machine will be able to spawn more number of threads. To keep the consistent(or nearly consistent) gap between the
4 | # threads, adjust this number with 'ramp.up.period.in.seconds' and the actual response time of the API end point.
5 | # For "@RunWith(ZeroCodeMultiLoadRunner.class)", set this to at least equal to number of "@TestMapping" or more,
6 | # otherwise there wont be enough threads to run each test.
7 | number.of.threads=5
8 |
9 | # It indicates the time taken to create all of the threads needed to fork the requests. If you set 10 seconds as the
10 | # ramp-up period for 5 threads then the framework will take 10 seconds to create those 5 threads, i.e. each thread
11 | # will be at work appx 2 secs gap between the requests. Also by setting its value to 0 all the threads can be created
12 | # at once at the same time. Note- If you want to fire more threads/user-requests in less ramp up time e.g. 5 threads
13 | # in 2secs(or 5 threads in 1 sec), then, use '@UseHttpClient(SslTrustHttpClient.class)' as this closes the connection
14 | # before making the next connection.
15 | ramp.up.period.in.seconds=1
16 |
17 | # By specifying its value framework gets to know that how many times the test(s), i.e. the number of requests will be
18 | # repeated per every 'ramp.up.period.in.seconds'.
19 | # Supposing number.of.threads = x, ramp.up.period.in.seconds = y, loop.count = i
20 | # then (x * i) = number of requests will be fired over (y * i) seconds. If x=5, i=3, y=20, then 15 requests will be
21 | # fired in 60 seconds which means- every request in 4 seconds gap. 60/15 or 20/5 = 4seconds.
22 | loop.count=1
23 |
24 | # If you have set the loop count to a higher digit which e.g. should take 3hrs(3*60*60=10800sec),
25 | # but due to load or network delay it could take more time(you are speculating) e.g. 4hrs, then you can
26 | # set this abort value to 3hrs i.e. 3*60*60=10800sec.
27 | abort.after.time.lapsed.in.seconds=600
--------------------------------------------------------------------------------
/src/test/resources/load_tests/get/get_details_by_id.json:
--------------------------------------------------------------------------------
1 | {
2 | "scenarioName": "Regulatory API- Get by ID test",
3 | "steps": [
4 | {
5 | "name": "get_user_details",
6 | "url": "/api/v1/regulatory/bank-ids/CORPBANKUK0101",
7 | "operation": "GET",
8 | "request": {
9 | },
10 | "assertions": {
11 | "status": 200,
12 | "body": {
13 | "id" : "CORPBANKUK0101",
14 | "login" : "corp-bank-uk-london",
15 | "isActive" : true
16 | }
17 | }
18 | }
19 |
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/load_tests/get/get_screening_details_by_custid.json:
--------------------------------------------------------------------------------
1 | {
2 | "scenarioName": "Screening API- Get Screening by customerId test",
3 | "steps": [
4 | {
5 | "name": "get_screening_details",
6 | "url": "/api/v1/screening/cust-ids/SINGAHV3033",
7 | "operation": "GET",
8 | "request": {
9 | },
10 | "assertions": {
11 | "status": 200,
12 | "body": {
13 | "id" : "SINGAHV3033",
14 | "localScreeningStatus" : "Green",
15 | "globalScreeningStatus" : "Red"
16 | }
17 | }
18 | }
19 |
20 | ]
21 | }
22 |
--------------------------------------------------------------------------------
/src/test/resources/load_tests/get_with_database_ids/get_details_by_next_db_custid.json:
--------------------------------------------------------------------------------
1 | {
2 | "scenarioName": "Screening API- Get Screening by Next customerId from DB",
3 | "steps": [
4 | {
5 | "name": "get_next_id",
6 | "url": "org.jsmart.zerocode.utils.DbIdPicker",
7 | "operation": "nextId",
8 | "request": "",
9 | "assertions": {
10 | }
11 | },
12 | {
13 | "name": "get_screening_details",
14 | "url": "/api/v1/screening/cust-ids/${$.get_next_id.response}",
15 | "operation": "GET",
16 | "request": {
17 | },
18 | "assertions": {
19 | "status": 200,
20 | "body": {
21 | "id": "${$.get_next_id.response}"
22 | }
23 | }
24 | }
25 | ]
26 | }
27 |
--------------------------------------------------------------------------------
/src/test/resources/load_tests/post/create_post_and_get_new_loan.json:
--------------------------------------------------------------------------------
1 | {
2 | "scenarioName": "Corp Loan API- Create and Get Details Test",
3 | "steps": [
4 | {
5 | "name": "create_approved_loan",
6 | "url": "/api/v1/corp-loan/companies/ABC-Jewels",
7 | "operation": "POST",
8 | "request": {
9 | "body":{
10 | "amountApplied": 100000,
11 | "amountSanctioned": 90000,
12 | "currency": "USD",
13 | "dateSanctioned":"2018-05-31"
14 | }
15 | },
16 | "assertions": {
17 | "status": 201,
18 | "body": {
19 | "id" : "LOANCORPABCJ-20180531"
20 | }
21 | }
22 | },
23 | {
24 | "name": "get_loan_details",
25 | "url": "/api/v1/corp-loan/ids/LOANCORPABCJ-20180531",
26 | "operation": "GET",
27 | "request": {
28 | },
29 | "assertions": {
30 | "status": 200,
31 | "body":{
32 | "id" : "LOANCORPABCJ-20180531",
33 | "amountApplied": 100000,
34 | "amountSanctioned": 90000,
35 | "currency": "USD",
36 | "dateSanctioned":"2018-05-31"
37 | }
38 | }
39 | },
40 | {
41 | "name": "get_loan_details_without_hard_coding",
42 | "url": "/api/v1/corp-loan/ids/${$.create_approved_loan.response.body.id}",
43 | "operation": "GET",
44 | "request": {
45 | },
46 | "assertions": {
47 | "status": 200,
48 | "body":{
49 | "id" : "${$.create_approved_loan.response.body.id}",
50 | "currency": "${$.create_approved_loan.request.body.currency}",
51 | "dateSanctioned":"${$.create_approved_loan.request.body.dateSanctioned}",
52 | "amountApplied": "$EQ.${$.create_approved_loan.request.body.amountApplied}",
53 | "amountSanctioned": "$EQ.${$.create_approved_loan.request.body.amountSanctioned}"
54 | }
55 | }
56 | }
57 |
58 |
59 | ]
60 | }
61 |
--------------------------------------------------------------------------------
/src/test/resources/load_tests/put/amend_put_and_get_existing_loan.json:
--------------------------------------------------------------------------------
1 | {
2 | "scenarioName": "Corp Loan API- Amend Existing Loan Test",
3 | "steps": [
4 | {
5 | "name": "amend_existing_loan",
6 | "url": "/api/v1/corp-loan/companies/ABC-Jewels/LOANCORPABCJ-20180540",
7 | "operation": "PUT",
8 | "request": {
9 | "body":{
10 | "amountApplied": 100000,
11 | "amountSanctioned": 90000,
12 | "amountAmended": 10000,
13 | "currency": "USD",
14 | "dateAmended":"2018-06-31"
15 | }
16 | },
17 | "assertions": {
18 | "status": 200,
19 | "body": {
20 | "id" : "LOANCORPABCJ-20180540"
21 | }
22 | }
23 | },
24 | {
25 | "name": "get_loan_details",
26 | "url": "/api/v1/corp-loan/ids/LOANCORPABCJ-20180540",
27 | "operation": "GET",
28 | "request": {
29 | },
30 | "assertions": {
31 | "status": 200,
32 | "body":{
33 | "id" : "LOANCORPABCJ-20180540",
34 | "amountApplied": 100000,
35 | "amountSanctioned": 100000,
36 | "currency": "USD",
37 | "dateAmended":"2018-06-31",
38 | "dateSanctioned":"2018-05-31"
39 | }
40 | }
41 | }
42 |
43 | ]
44 | }
45 |
--------------------------------------------------------------------------------
/src/test/resources/localhost_stubs/localhost_REST_fake_end_points_stubs.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "Stub aka Mock - Localhost REST Endpoints - GET POST PUT APIs",
3 | "apis": [
4 | {
5 | "name": "get_regulatory_entry_details_mock",
6 | "operation": "GET",
7 | "url": "/api/v1/regulatory/bank-ids/CORPBANKUK0101",
8 | "response": {
9 | "status": 200,
10 | "body": {
11 | "id": "CORPBANKUK0101",
12 | "login": "corp-bank-uk-london",
13 | "isActive": true
14 | }
15 | }
16 | },
17 | {
18 | "name": "create_approved_loan_mock",
19 | "operation": "POST",
20 | "url": "/api/v1/corp-loan/companies/ABC-Jewels",
21 | "ignoreBody": true,
22 | "response": {
23 | "status": 201,
24 | "body": {
25 | "id": "LOANCORPABCJ-20180531"
26 | }
27 | }
28 | },
29 | {
30 | "name": "get_approved_loan_mock",
31 | "operation": "GET",
32 | "url": "/api/v1/corp-loan/ids/LOANCORPABCJ-20180531",
33 | "response": {
34 | "status": 200,
35 | "body": {
36 | "id": "LOANCORPABCJ-20180531",
37 | "amountApplied": 100000,
38 | "amountSanctioned": 90000,
39 | "currency": "USD",
40 | "dateSanctioned": "2018-05-31"
41 | }
42 | }
43 | },
44 | {
45 | "name": "amend_existing_loan_mock",
46 | "operation": "PUT",
47 | "url": "/api/v1/corp-loan/companies/ABC-Jewels/LOANCORPABCJ-20180540",
48 | "ignoreBody": true,
49 | "response": {
50 | "status": 200,
51 | "body": {
52 | "id": "LOANCORPABCJ-20180540"
53 | }
54 | }
55 | },
56 | {
57 | "name": "get_amended_loan_mock",
58 | "operation": "GET",
59 | "url": "/api/v1/corp-loan/ids/LOANCORPABCJ-20180540",
60 | "response": {
61 | "status": 200,
62 | "body": {
63 | "id": "LOANCORPABCJ-20180540",
64 | "amountApplied": 100000,
65 | "amountSanctioned": 100000,
66 | "currency": "USD",
67 | "dateAmended": "2018-06-31",
68 | "dateSanctioned": "2018-05-31"
69 | }
70 | }
71 | },
72 | {
73 | "name": "get_screening_status_id1",
74 | "operation": "GET",
75 | "url": "/api/v1/screening/cust-ids/SINGAHV3033",
76 | "response": {
77 | "status": 200,
78 | "body": {
79 | "id" : "SINGAHV3033",
80 | "localScreeningStatus" : "Green",
81 | "globalScreeningStatus" : "Red"
82 | }
83 | }
84 | },
85 | {
86 | "name": "get_screening_status_id2",
87 | "operation": "GET",
88 | "url": "/api/v1/screening/cust-ids/SINGAHV3034",
89 | "response": {
90 | "status": 200,
91 | "body": {
92 | "id" : "SINGAHV3034",
93 | "localScreeningStatus" : "Amber",
94 | "globalScreeningStatus" : "Amber"
95 | }
96 | }
97 | }
98 | ]
99 | }
--------------------------------------------------------------------------------
/src/test/resources/screening_service_host.properties:
--------------------------------------------------------------------------------
1 | # Web Server host and port
2 | restful.application.endpoint.host=http://localhost
3 | restful.application.endpoint.port=8088
4 |
5 | # Web Service context; Leave it blank in case you do not have a common context
6 | restful.application.endpoint.context=
7 |
--------------------------------------------------------------------------------