Skip to content

Commit b678bac

Browse files
Merge pull request #23 from holly-cummins/simplify-build-instructions
Restructure testing strategy to remove need for extra flag on build
2 parents e15df69 + 1e20f14 commit b678bac

9 files changed

Lines changed: 196 additions & 36 deletions

File tree

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,5 +63,4 @@ jobs:
6363
run: |
6464
./mvnw -B clean verify \
6565
-Dmaven.compiler.release=${{ matrix.java }} \
66-
-Djava.version=${{ matrix.java }} \
67-
-Dquarkus.hibernate-orm.sql-load-script=import.sql
66+
-Djava.version=${{ matrix.java }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ This project contains the following modules:
1111

1212
## Building
1313

14-
`./mvnw clean verify -Dquarkus.hibernate-orm.sql-load-script=import.sql`
14+
`./mvnw clean verify`
1515

1616
## Application requirements/dependencies
1717

quarkus3-spring-compatibility/src/main/resources/application.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,6 @@ quarkus:
1313
password: fruits
1414
jdbc:
1515
url: jdbc:postgresql://localhost:5432/fruits
16+
hibernate-orm:
17+
sql-load-script: ""
18+

quarkus3-spring-compatibility/src/main/resources/import.sql renamed to quarkus3-spring-compatibility/src/main/resources/data.sql

File renamed without changes.

quarkus3-spring-compatibility/src/test/java/org/acme/rest/FruitControllerIT.java renamed to quarkus3-spring-compatibility/src/test/java/org/acme/e2e/FruitControllerEndToEndTest.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
package org.acme.rest;
2-
3-
import static io.restassured.RestAssured.get;
4-
import static io.restassured.RestAssured.given;
5-
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
6-
import static org.hamcrest.Matchers.is;
7-
8-
import java.math.BigDecimal;
1+
package org.acme.e2e;
92

3+
import io.quarkus.test.junit.QuarkusTest;
4+
import io.restassured.http.ContentType;
105
import jakarta.ws.rs.core.Response.Status;
11-
126
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
137
import org.junit.jupiter.api.Order;
148
import org.junit.jupiter.api.Test;
159
import org.junit.jupiter.api.TestMethodOrder;
1610

17-
import io.quarkus.test.junit.QuarkusIntegrationTest;
11+
import java.math.BigDecimal;
1812

19-
import io.restassured.http.ContentType;
13+
import static io.restassured.RestAssured.get;
14+
import static io.restassured.RestAssured.given;
15+
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
16+
import static org.hamcrest.Matchers.is;
2017

21-
@QuarkusIntegrationTest
18+
// Note: There isn't an equivalent of this test in the Spring projects. It tests the entire application, without mocking.
19+
// The tests run in test mode, in the same process as the application under test.
20+
@QuarkusTest
2221
@TestMethodOrder(OrderAnnotation.class)
23-
public class FruitControllerIT {
22+
public class FruitControllerEndToEndTest {
2423
private static final int DEFAULT_ORDER = 1;
2524

2625
@Test
@@ -100,14 +99,14 @@ public void addFruit() {
10099

101100
given()
102101
.contentType(ContentType.JSON)
103-
.body("{\"name\":\"Grapefruit\",\"description\":\"Summer fruit\"}")
102+
.body("{\"name\":\"Lemon\",\"description\":\"Acidic fruit\"}")
104103
.when().post("/fruits")
105104
.then()
106105
.contentType(ContentType.JSON)
107106
.statusCode(Status.OK.getStatusCode())
108107
.body("id", greaterThanOrEqualTo(3))
109-
.body("name", is("Grapefruit"))
110-
.body("description", is("Summer fruit"));
108+
.body("name", is("Lemon"))
109+
.body("description", is("Acidic fruit"));
111110

112111
get("/fruits").then()
113112
.body("$.size()", is(3));
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package org.acme.e2e;
2+
3+
import static io.restassured.RestAssured.get;
4+
import static io.restassured.RestAssured.given;
5+
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
6+
import static org.hamcrest.Matchers.is;
7+
8+
import jakarta.ws.rs.core.Response.Status;
9+
10+
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
11+
import org.junit.jupiter.api.Order;
12+
import org.junit.jupiter.api.Test;
13+
import org.junit.jupiter.api.TestMethodOrder;
14+
15+
import io.quarkus.test.junit.QuarkusIntegrationTest;
16+
17+
import io.restassured.http.ContentType;
18+
19+
20+
// Note: There isn't an equivalent of this test in the Spring projects.
21+
// It tests the application as a prod mode application, from a different process.
22+
// Because the process is not shared and the application is run in prod mode, the database is empty initially.
23+
@QuarkusIntegrationTest
24+
@TestMethodOrder(OrderAnnotation.class)
25+
public class FruitControllerIT {
26+
private static final int DEFAULT_ORDER = 1;
27+
28+
@Test
29+
@Order(DEFAULT_ORDER)
30+
public void getFruitNotFound() {
31+
get("/fruits/Watermelon").then()
32+
.statusCode(Status.NOT_FOUND.getStatusCode());
33+
}
34+
35+
@Test
36+
@Order(DEFAULT_ORDER + 1)
37+
public void addFruit() {
38+
get("/fruits").then()
39+
.body("$.size()", is(0));
40+
41+
given()
42+
.contentType(ContentType.JSON)
43+
.body("{\"name\":\"Pomelo\",\"description\":\"Exotic fruit\"}")
44+
.when().post("/fruits")
45+
.then()
46+
.contentType(ContentType.JSON)
47+
.statusCode(Status.OK.getStatusCode())
48+
.body("id", greaterThanOrEqualTo(1))
49+
.body("name", is("Pomelo"))
50+
.body("description", is("Exotic fruit"));
51+
52+
get("/fruits").then()
53+
.body("$.size()", is(1));
54+
}
55+
56+
57+
@Test
58+
@Order(DEFAULT_ORDER+2)
59+
public void getFruitFound() {
60+
get("/fruits/Pomelo").then()
61+
.statusCode(Status.OK.getStatusCode())
62+
.contentType(ContentType.JSON)
63+
.body("id", greaterThanOrEqualTo(1))
64+
.body("name", is("Pomelo"))
65+
.body("description", is("Exotic fruit"));
66+
}
67+
68+
@Test
69+
@Order(DEFAULT_ORDER+3)
70+
public void getAll() {
71+
get("/fruits").then()
72+
.statusCode(Status.OK.getStatusCode())
73+
.contentType(ContentType.JSON)
74+
.body("$.size()", is(1))
75+
.body("[0].id", greaterThanOrEqualTo(1))
76+
.body("[0].name", is("Pomelo"))
77+
.body("[0].description", is("Exotic fruit"));
78+
}
79+
80+
}

quarkus3/src/test/java/org/acme/rest/FruitControllerIT.java renamed to quarkus3/src/test/java/org/acme/e2e/FruitControllerEndToEndTest.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,25 @@
1-
package org.acme.rest;
2-
3-
import static io.restassured.RestAssured.get;
4-
import static io.restassured.RestAssured.given;
5-
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
6-
import static org.hamcrest.Matchers.is;
7-
8-
import java.math.BigDecimal;
1+
package org.acme.e2e;
92

3+
import io.quarkus.test.junit.QuarkusTest;
4+
import io.restassured.http.ContentType;
105
import jakarta.ws.rs.core.Response.Status;
11-
126
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
137
import org.junit.jupiter.api.Order;
148
import org.junit.jupiter.api.Test;
159
import org.junit.jupiter.api.TestMethodOrder;
1610

17-
import io.quarkus.test.junit.QuarkusIntegrationTest;
11+
import java.math.BigDecimal;
1812

19-
import io.restassured.http.ContentType;
13+
import static io.restassured.RestAssured.get;
14+
import static io.restassured.RestAssured.given;
15+
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
16+
import static org.hamcrest.Matchers.is;
2017

21-
@QuarkusIntegrationTest
18+
// Note: There isn't an equivalent of this test in the Spring projects. It tests the entire application, without mocking.
19+
// The tests run in test mode, in the same process as the application under test.
20+
@QuarkusTest
2221
@TestMethodOrder(OrderAnnotation.class)
23-
public class FruitControllerIT {
22+
public class FruitControllerEndToEndTest {
2423
private static final int DEFAULT_ORDER = 1;
2524

2625
@Test
@@ -100,14 +99,14 @@ public void addFruit() {
10099

101100
given()
102101
.contentType(ContentType.JSON)
103-
.body("{\"name\":\"Grapefruit\",\"description\":\"Summer fruit\"}")
102+
.body("{\"name\":\"Lemon\",\"description\":\"Acidic fruit\"}")
104103
.when().post("/fruits")
105104
.then()
106105
.contentType(ContentType.JSON)
107106
.statusCode(Status.OK.getStatusCode())
108107
.body("id", greaterThanOrEqualTo(3))
109-
.body("name", is("Grapefruit"))
110-
.body("description", is("Summer fruit"));
108+
.body("name", is("Lemon"))
109+
.body("description", is("Acidic fruit"));
111110

112111
get("/fruits").then()
113112
.body("$.size()", is(3));
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
package org.acme.e2e;
2+
3+
import static io.restassured.RestAssured.get;
4+
import static io.restassured.RestAssured.given;
5+
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
6+
import static org.hamcrest.Matchers.is;
7+
8+
import jakarta.ws.rs.core.Response.Status;
9+
10+
import org.junit.jupiter.api.MethodOrderer.OrderAnnotation;
11+
import org.junit.jupiter.api.Order;
12+
import org.junit.jupiter.api.Test;
13+
import org.junit.jupiter.api.TestMethodOrder;
14+
15+
import io.quarkus.test.junit.QuarkusIntegrationTest;
16+
17+
import io.restassured.http.ContentType;
18+
19+
20+
// Note: There isn't an equivalent of this test in the Spring projects.
21+
// It tests the application as a prod mode application, from a different process.
22+
// Because the process is not shared and the application is run in prod mode, the database is empty initially.
23+
@QuarkusIntegrationTest
24+
@TestMethodOrder(OrderAnnotation.class)
25+
public class FruitControllerIT {
26+
private static final int DEFAULT_ORDER = 1;
27+
28+
@Test
29+
@Order(DEFAULT_ORDER)
30+
public void getFruitNotFound() {
31+
get("/fruits/Watermelon").then()
32+
.statusCode(Status.NOT_FOUND.getStatusCode());
33+
}
34+
35+
@Test
36+
@Order(DEFAULT_ORDER + 1)
37+
public void addFruit() {
38+
get("/fruits").then()
39+
.body("$.size()", is(0));
40+
41+
given()
42+
.contentType(ContentType.JSON)
43+
.body("{\"name\":\"Pomelo\",\"description\":\"Exotic fruit\"}")
44+
.when().post("/fruits")
45+
.then()
46+
.contentType(ContentType.JSON)
47+
.statusCode(Status.OK.getStatusCode())
48+
.body("id", greaterThanOrEqualTo(1))
49+
.body("name", is("Pomelo"))
50+
.body("description", is("Exotic fruit"));
51+
52+
get("/fruits").then()
53+
.body("$.size()", is(1));
54+
}
55+
56+
57+
@Test
58+
@Order(DEFAULT_ORDER+2)
59+
public void getFruitFound() {
60+
get("/fruits/Pomelo").then()
61+
.statusCode(Status.OK.getStatusCode())
62+
.contentType(ContentType.JSON)
63+
.body("id", greaterThanOrEqualTo(1))
64+
.body("name", is("Pomelo"))
65+
.body("description", is("Exotic fruit"));
66+
}
67+
68+
@Test
69+
@Order(DEFAULT_ORDER+3)
70+
public void getAll() {
71+
get("/fruits").then()
72+
.statusCode(Status.OK.getStatusCode())
73+
.contentType(ContentType.JSON)
74+
.body("$.size()", is(1))
75+
.body("[0].id", greaterThanOrEqualTo(1))
76+
.body("[0].name", is("Pomelo"))
77+
.body("[0].description", is("Exotic fruit"));
78+
}
79+
80+
}

scripts/perf-lab/scripts/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
time.js
22
=======
33

4-
Node.js script to measure the start time of an application without having to modicfy application code.
4+
Node.js script to measure the start time of an application without having to modify application code.
55

66
The application is spawned in a background process and a URL is tested until a HTTP 200 response is returned. The time taken to spawn the process and a HTTP 200 reponse is measured and reported to the terminal.
77

0 commit comments

Comments
 (0)