-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathDevModeGreetingResourceIT.java
62 lines (50 loc) · 2.2 KB
/
DevModeGreetingResourceIT.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package io.quarkus.qe;
import static org.hamcrest.Matchers.is;
import org.apache.http.HttpStatus;
import org.junit.jupiter.api.MethodOrderer;
import org.junit.jupiter.api.Order;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestMethodOrder;
import io.quarkus.test.bootstrap.DevModeQuarkusService;
import io.quarkus.test.scenarios.QuarkusScenario;
import io.quarkus.test.services.DevModeQuarkusApplication;
import io.quarkus.test.utils.AwaitilityUtils;
@QuarkusScenario
@TestMethodOrder(MethodOrderer.OrderAnnotation.class)
public class DevModeGreetingResourceIT {
static final String VICTOR_NAME = "victor";
static final String HELLO_IN_ENGLISH = "Hello";
static final String HELLO_IN_SPANISH = "Hola";
@DevModeQuarkusApplication
static final DevModeQuarkusService app = new DevModeQuarkusService();
@Test
@Order(1)
public void shouldDetectNewTests() {
// At first, there are no tests annotated with @QuarkusTest
app.logs().assertContains("Tests paused");
// Now, we enable continuous testing via DEV UI
app.enableContinuousTesting();
// We add a new test
app.copyFile("src/test/resources/GreetingResourceTest.java.template",
"src/test/java/GreetingResourceTest.java");
// So good so far!
app.logs().assertContains("All 1 test is passing");
}
@Test
@Order(2)
public void shouldUpdateResourcesAndSources() {
// Should say first Victor (the default name)
app.given().get("/greeting").then().statusCode(HttpStatus.SC_OK).body(is(HELLO_IN_ENGLISH + ", I'm " + VICTOR_NAME));
// Modify default name to manuel
app.modifyFile("src/main/java/io/quarkus/qe/GreetingResource.java",
content -> content.replace(HELLO_IN_ENGLISH, HELLO_IN_SPANISH));
// Now, the app should say Manuel
AwaitilityUtils.untilAsserted(
() -> app.given().get("/greeting").then().statusCode(HttpStatus.SC_OK)
.body(is(HELLO_IN_SPANISH + ", I'm " + VICTOR_NAME)));
}
@Test
public void shouldLoadResources() {
app.given().get("/greeting/file").then().statusCode(HttpStatus.SC_OK).body(is("found!"));
}
}