Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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)

Co-Authored-By: Alexey Loubyansky <olubyans@redhat.com>
holly-cummins and aloubyansky committed Aug 7, 2023
1 parent 772d5e1 commit e34abf7
Showing 63 changed files with 2,094 additions and 223 deletions.
Original file line number Diff line number Diff line change
@@ -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);

@@ -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();
}
Original file line number Diff line number Diff line change
@@ -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);

@@ -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();
}
Original file line number Diff line number Diff line change
@@ -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);

Original file line number Diff line number Diff line change
@@ -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);

@@ -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();
}
Original file line number Diff line number Diff line change
@@ -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);

@@ -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();
}
Original file line number Diff line number Diff line change
@@ -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);
@@ -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);
@@ -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() {
Original file line number Diff line number Diff line change
@@ -14,6 +14,7 @@
public class BasicJavaNativeBuildIT extends QuarkusNativeGradleITBase {

public static final String NATIVE_IMAGE_NAME = "foo-1.0.0-SNAPSHOT-runner";
private DevModeTestUtils devModeTestUtils = new DevModeTestUtils();

@Test
public void shouldBuildNativeImage() throws Exception {
@@ -33,7 +34,7 @@ public void shouldBuildNativeImage() throws Exception {
assertThat(nativeImagePath).exists();
Process nativeImageProcess = runNativeImage(nativeImagePath.toAbsolutePath().toString());
try {
final String response = DevModeTestUtils.getHttpResponse("/hello");
final String response = devModeTestUtils.getHttpResponse("/hello");
assertThat(response)
.withFailMessage("Response %s for /hello was expected to contain the hello, but didn't", response)
.contains("hello");
@@ -63,7 +64,7 @@ public void shouldBuildNativeImageWithCustomName() throws Exception {
assertThat(nativeImagePath).exists();
Process nativeImageProcess = runNativeImage(nativeImagePath.toAbsolutePath().toString());
try {
final String response = DevModeTestUtils.getHttpResponse("/hello");
final String response = devModeTestUtils.getHttpResponse("/hello");
assertThat(response)
.withFailMessage("Response %s for /hello was expected to contain the hello, but didn't", response)
.contains("hello");
@@ -93,7 +94,7 @@ public void shouldBuildNativeImageWithCustomNameWithoutSuffix() throws Exception
assertThat(nativeImagePath).exists();
Process nativeImageProcess = runNativeImage(nativeImagePath.toAbsolutePath().toString());
try {
final String response = DevModeTestUtils.getHttpResponse("/hello");
final String response = devModeTestUtils.getHttpResponse("/hello");
assertThat(response)
.withFailMessage("Response %s for /hello was expected to contain the hello, but didn't", response)
.contains("hello");
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
import org.junit.jupiter.api.Test;

import io.quarkus.maven.it.RunAndCheckMojoTestBase;
import io.quarkus.test.devmode.util.DevModeTestUtils;

public class KotlinDevModeIT extends RunAndCheckMojoTestBase {

@@ -30,7 +29,7 @@ public void testThatTheApplicationIsReloadedOnKotlinChange() throws MavenInvocat
// Wait until we get "uuid"
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid));
.atMost(1, TimeUnit.MINUTES).until(() -> devModeTestUtils.getHttpResponse("/app/hello").contains(uuid));

await()
.pollDelay(1, TimeUnit.SECONDS)
@@ -42,7 +41,7 @@ public void testThatTheApplicationIsReloadedOnKotlinChange() throws MavenInvocat
// Wait until we get "carambar"
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar"));
.atMost(1, TimeUnit.MINUTES).until(() -> devModeTestUtils.getHttpResponse("/app/hello").contains("carambar"));

File greetingService = new File(testDir, "src/main/kotlin/org/acme/GreetingService.kt");
String newUuid = UUID.randomUUID().toString();
@@ -51,7 +50,7 @@ public void testThatTheApplicationIsReloadedOnKotlinChange() throws MavenInvocat
// Wait until we get "newUuid"
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello/bean").contains(newUuid));
.atMost(1, TimeUnit.MINUTES).until(() -> devModeTestUtils.getHttpResponse("/app/hello/bean").contains(newUuid));
}

@Test
@@ -68,11 +67,11 @@ public void testThatTheApplicationIsReloadedOnKotlinChangeWithCustomCompilerArgs
// Wait until we get "uuid"
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid));
.atMost(1, TimeUnit.MINUTES).until(() -> devModeTestUtils.getHttpResponse("/app/hello").contains(uuid));
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(1, TimeUnit.MINUTES)
.until(() -> DevModeTestUtils.getHttpResponse("/graphql/schema.graphql").contains("[Banana!]!"));
.until(() -> devModeTestUtils.getHttpResponse("/graphql/schema.graphql").contains("[Banana!]!"));
}

@Test
@@ -94,7 +93,7 @@ public void testExternalKotlinReloadableArtifacts() throws Exception {
await()
.pollDelay(100, TimeUnit.MILLISECONDS)
.atMost(1, TimeUnit.MINUTES)
.until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("Hello"));
.until(() -> devModeTestUtils.getHttpResponse("/hello").contains("Hello"));

final File greetingKotlin = externalJarDir.toPath().resolve("src").resolve("main")
.resolve("kotlin").resolve("org").resolve("acme").resolve("lib")
@@ -117,7 +116,7 @@ public void testExternalKotlinReloadableArtifacts() throws Exception {
await()
.pollDelay(100, TimeUnit.MILLISECONDS)
.atMost(1, TimeUnit.MINUTES)
.until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("Bonjour"));
.until(() -> devModeTestUtils.getHttpResponse("/hello").contains("Bonjour"));

// Change bonjour() method content in Greeting.kt
filter(greetingKotlin, Map.of("Bonjour", "Bonjour!"));
@@ -129,6 +128,6 @@ public void testExternalKotlinReloadableArtifacts() throws Exception {
await()
.pollDelay(100, TimeUnit.MILLISECONDS)
.atMost(1, TimeUnit.MINUTES)
.until(() -> DevModeTestUtils.getHttpResponse("/hello").contains("BONJOUR!"));
.until(() -> devModeTestUtils.getHttpResponse("/hello").contains("BONJOUR!"));
}
}
Original file line number Diff line number Diff line change
@@ -12,7 +12,6 @@
import org.junit.jupiter.api.Test;

import io.quarkus.maven.it.RunAndCheckWithAgentMojoTestBase;
import io.quarkus.test.devmode.util.DevModeTestUtils;

public class KotlinRemoteDevModeIT extends RunAndCheckWithAgentMojoTestBase {

@@ -31,7 +30,7 @@ public void testThatTheApplicationIsReloadedOnKotlinChange()
// Wait until we get "uuid"
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(3, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains(uuid));
.atMost(3, TimeUnit.MINUTES).until(() -> devModeTestUtils.getHttpResponse("/app/hello").contains(uuid));

await()
.pollDelay(1, TimeUnit.SECONDS)
@@ -43,6 +42,6 @@ public void testThatTheApplicationIsReloadedOnKotlinChange()
// Wait until we get "carambar"
await()
.pollDelay(1, TimeUnit.SECONDS)
.atMost(3, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/app/hello").contains("carambar"));
.atMost(3, TimeUnit.MINUTES).until(() -> devModeTestUtils.getHttpResponse("/app/hello").contains("carambar"));
}
}
Original file line number Diff line number Diff line change
@@ -28,6 +28,8 @@
@DisableForNative
class BuildIT extends MojoTestBase {

private DevModeTestUtils devModeTestUtils = new DevModeTestUtils();

private RunningInvoker running;
private File testDir;

@@ -206,7 +208,7 @@ private void launch(TestContext context, String path, File testDir, String outpu
List.of())
.start();
try {
Assertions.assertEquals(expectedMessage, DevModeTestUtils.getHttpResponse(path));
Assertions.assertEquals(expectedMessage, devModeTestUtils.getHttpResponse(path));
} finally {
process.destroy();
}
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@

import io.quarkus.maven.it.verifier.MavenProcessInvocationResult;
import io.quarkus.maven.it.verifier.RunningInvoker;
import io.quarkus.test.devmode.util.DevModeTestUtils;

/**
* <p>
@@ -28,7 +27,7 @@ public class CodeGenIT extends RunAndCheckMojoTestBase {
public void shouldCompileAndRunWithCodegenEnabled() throws MavenInvocationException, FileNotFoundException {
testDir = initProject("projects/proto-gen");
run(true);
assertThat(DevModeTestUtils.getHttpResponse("/hello")).isEqualTo("Hello, World!");
assertThat(devModeTestUtils.getHttpResponse("/hello")).isEqualTo("Hello, World!");
}

@Test
Original file line number Diff line number Diff line change
@@ -49,6 +49,8 @@
@DisableForNative
public class CreateProjectMojoIT extends QuarkusPlatformAwareMojoTestBase {

private DevModeTestUtils devModeTestUtils = new DevModeTestUtils();

private Invoker invoker;
private RunningInvoker running;
private File testDir;
@@ -588,13 +590,13 @@ public void generateNewProjectAndRun() throws Exception {
mvnRunProps.setProperty("debug", "false");
running.execute(Arrays.asList("compile", "quarkus:dev"), Collections.emptyMap(), mvnRunProps);

String resp = DevModeTestUtils.getHttpResponse();
String resp = devModeTestUtils.getHttpResponse();

assertThat(resp).containsIgnoringCase("Congratulations!").containsIgnoringCase("application")
.containsIgnoringCase("org.acme")
.containsIgnoringCase("1.0.0-SNAPSHOT");

String greeting = DevModeTestUtils.getHttpResponse("/hello");
String greeting = devModeTestUtils.getHttpResponse("/hello");
assertThat(greeting).containsIgnoringCase("hello");
}

Loading

0 comments on commit e34abf7

Please sign in to comment.