Skip to content

Commit

Permalink
Merge pull request #20123 from gastaldi/logerror
Browse files Browse the repository at this point in the history
Improved assertions in BasicJavaNativeBuildIT
  • Loading branch information
geoand authored Sep 14, 2021
2 parents 91d96c7 + daa7878 commit e409b1b
Showing 1 changed file with 6 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package io.quarkus.gradle.nativeimage;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertTrue;

import java.io.File;
import java.io.IOException;
import java.nio.file.Path;

import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Test;

import io.quarkus.gradle.BuildResult;
Expand All @@ -24,15 +22,17 @@ public void shouldBuildNativeImage() throws Exception {
assertThat(build.getTasks().get(":quarkusBuild")).isEqualTo(BuildResult.SUCCESS_OUTCOME);
final String buildOutput = build.getOutput();
// make sure the output log during the build contains some expected logs from the native-image process
assertTrue(buildOutput.contains("(clinit):") && buildOutput.contains("(typeflow):") && buildOutput.contains("[total]:"),
"native-image build log is missing certain expected log messages");
assertThat(buildOutput)
.withFailMessage("native-image build log is missing certain expected log messages: \n\n %s", buildOutput)
.contains("(clinit):", "(typeflow):", "[total]:");
Path nativeImagePath = projectDir.toPath().resolve("build").resolve("foo-1.0.0-SNAPSHOT-runner");
assertThat(nativeImagePath).exists();
Process nativeImageProcess = runNativeImage(nativeImagePath.toAbsolutePath().toString());
try {
final String response = DevModeTestUtils.getHttpResponse("/hello");
Assertions.assertTrue(response.contains("hello"),
"Response " + response + " for /hello was expected to contain the hello, but didn't");
assertThat(response)
.withFailMessage("Response %s for /hello was expected to contain the hello, but didn't", response)
.contains("hello");
} finally {
nativeImageProcess.destroy();
}
Expand Down

0 comments on commit e409b1b

Please sign in to comment.