Skip to content

Commit

Permalink
Add tests which exercise more complex JUnit extensions (and all fail,…
Browse files Browse the repository at this point in the history
… so all disabled)
  • Loading branch information
holly-cummins committed Jul 31, 2023
1 parent 416dfdc commit 7c1512c
Show file tree
Hide file tree
Showing 56 changed files with 2,035 additions and 162 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,16 @@ public void testFastJarFormatWorks() throws Exception {

File output = new File(projectDir, "build/output.log");
output.createNewFile();

DevModeTestUtils devModeTestUtils = new DevModeTestUtils();
Process process = launch(jar, output);
try {
//Wait until server up
dumpFileContentOnFailure(() -> {
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES)
.until(() -> DevModeTestUtils.isCode("/hello", 200));
.until(() -> devModeTestUtils.isCode("/hello", 200));
return null;
}, output, ConditionTimeoutException.class);

Expand All @@ -47,7 +49,7 @@ public void testFastJarFormatWorks() throws Exception {
assertThat(logs).contains("INFO").contains("cdi, resteasy");

// test that the application name and version are properly set
assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello");
assertThat(devModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello");
} finally {
process.destroy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,15 @@ public void testLegacyJarFormatWorks() throws Exception {
File output = new File(projectDir, "build/output.log");
output.createNewFile();
Process process = launch(runnerJar, output);
DevModeTestUtils devModeTestUtils = new DevModeTestUtils();

try {
//Wait until server up
dumpFileContentOnFailure(() -> {
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES)
.until(() -> DevModeTestUtils.isCode("/hello", 200));
.until(() -> devModeTestUtils.isCode("/hello", 200));
return null;
}, output, ConditionTimeoutException.class);

Expand All @@ -46,7 +48,7 @@ public void testLegacyJarFormatWorks() throws Exception {
assertThat(logs).contains("INFO").contains("cdi, resteasy");

// test that the application name and version are properly set
assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello");
assertThat(devModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello");
} finally {
process.destroy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,16 @@ public void testUberJarForMultiModule() throws Exception {

File output = new File(projectDir, "application/build/output.log");
output.createNewFile();
DevModeTestUtils devModeTestUtils = new DevModeTestUtils();

Process process = launch(jar, output);
try {
// Wait until server up
dumpFileContentOnFailure(() -> {
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES)
.until(() -> DevModeTestUtils.isCode("/hello", 200));
.until(() -> devModeTestUtils.isCode("/hello", 200));
return null;
}, output, ConditionTimeoutException.class);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,16 @@ public void testFastJarFormatWorks() throws Exception {

File output = new File(projectDir, "build/output.log");
output.createNewFile();
DevModeTestUtils devModeTestUtils = new DevModeTestUtils();

Process process = launch(jar, output, Collections.singletonMap("QUARKUS_LAUNCH_DEVMODE", "true"));
try {
//Wait until server up
dumpFileContentOnFailure(() -> {
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES)
.until(() -> DevModeTestUtils.isCode("/hello", 200));
.until(() -> devModeTestUtils.isCode("/hello", 200));
return null;
}, output, ConditionTimeoutException.class);

Expand All @@ -48,7 +50,7 @@ public void testFastJarFormatWorks() throws Exception {
assertThat(logs).contains("INFO").contains("cdi, resteasy");

// test that the application name and version are properly set
assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello");
assertThat(devModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello");
} finally {
process.destroy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,16 @@ public void testUberJarFormatWorks() throws Exception {

File output = new File(projectDir, "build/output.log");
output.createNewFile();
DevModeTestUtils devModeTestUtils = new DevModeTestUtils();

Process process = launch(jar, output);
try {
// Wait until server up
dumpFileContentOnFailure(() -> {
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES)
.until(() -> DevModeTestUtils.isCode("/hello", 200));
.until(() -> devModeTestUtils.isCode("/hello", 200));
return null;
}, output, ConditionTimeoutException.class);

Expand All @@ -45,7 +47,7 @@ public void testUberJarFormatWorks() throws Exception {
assertThat(logs).contains("INFO").contains("cdi, resteasy");

// test that the application name and version are properly set
assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello");
assertThat(devModeTestUtils.getHttpResponse("/hello")).isEqualTo("hello");
} finally {
process.destroy();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ public abstract class QuarkusDevGradleTestBase extends QuarkusGradleWrapperTestB
private Future<?> quarkusDev;
protected File projectDir;

protected DevModeTestUtils devModeTestUtils = new DevModeTestUtils();

@Override
protected void setupTestCommand() {
gradleNoWatchFs(false);
Expand Down Expand Up @@ -69,7 +71,7 @@ public void main() throws Exception {
// Kill all processes that were (indirectly) spawned by the current process.
List<ProcessHandle> childProcesses = DevModeTestUtils.killDescendingProcesses();

DevModeTestUtils.awaitUntilServerDown();
devModeTestUtils.awaitUntilServerDown();

// sanity: forcefully terminate left-over processes
childProcesses.forEach(ProcessHandle::destroyForcibly);
Expand Down Expand Up @@ -151,15 +153,15 @@ protected void beforeQuarkusDev() throws Exception {
protected abstract void testDevMode() throws Exception;

protected String getHttpResponse() {
return DevModeTestUtils.getHttpResponse(getQuarkusDevBrokenReason());
return devModeTestUtils.getHttpResponse(getQuarkusDevBrokenReason());
}

protected String getHttpResponse(String path) {
return getHttpResponse(path, devModeTimeoutSeconds(), TimeUnit.SECONDS);
}

protected String getHttpResponse(String path, long timeout, TimeUnit tu) {
return DevModeTestUtils.getHttpResponse(path, false, getQuarkusDevBrokenReason(), timeout, tu);
return devModeTestUtils.getHttpResponse(path, false, getQuarkusDevBrokenReason(), timeout, tu);
}

private Supplier<String> getQuarkusDevBrokenReason() {
Expand Down
Loading

0 comments on commit 7c1512c

Please sign in to comment.