-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated Uber-Jar,Fast-jar test and LaunchUtils
- Loading branch information
Garima Monga
committed
Jul 2, 2020
1 parent
a2918c8
commit dd023c5
Showing
8 changed files
with
155 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
66 changes: 66 additions & 0 deletions
66
integration-tests/gradle/src/test/java/io/quarkus/gradle/UberJarFormatWorksTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
package io.quarkus.gradle; | ||
|
||
import static io.quarkus.gradle.LaunchUtils.dumpFileContentOnFailure; | ||
import static io.quarkus.gradle.LaunchUtils.launch; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.awaitility.Awaitility.await; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
import java.util.concurrent.Future; | ||
import java.util.concurrent.TimeUnit; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
import org.awaitility.core.ConditionTimeoutException; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import io.quarkus.test.devmode.util.DevModeTestUtils; | ||
|
||
public class UberJarFormatWorksTest extends QuarkusGradleWrapperTestBase { | ||
|
||
private static Future<?> jarRun; | ||
|
||
@Test | ||
public void testUberJarFormatWorks() throws Exception { | ||
|
||
final File projectDir = getProjectDir("test-uber-jar-format-works"); | ||
runGradleWrapper(projectDir, "clean", "build"); | ||
final Path quarkusApp = projectDir.toPath().resolve("build"); | ||
assertThat(quarkusApp).exists(); | ||
Path jar = quarkusApp.resolve("uber-jar-test-1.0.0-SNAPSHOT-runner.jar"); | ||
assertThat(jar).exists(); | ||
|
||
File output = new File(projectDir, "build/output.log"); | ||
output.createNewFile(); | ||
Process process = launch(jar, output); | ||
try { | ||
// Wait until server up | ||
dumpFileContentOnFailure(() -> { | ||
await() | ||
.pollDelay(1, TimeUnit.SECONDS) | ||
.atMost(1, TimeUnit.MINUTES).until(() -> DevModeTestUtils.getHttpResponse("/hello", 200)); | ||
return null; | ||
}, output, ConditionTimeoutException.class); | ||
|
||
String logs = FileUtils.readFileToString(output, "UTF-8"); | ||
|
||
assertThatOutputWorksCorrectly(logs); | ||
|
||
// test that the application name and version are properly set | ||
assertThat(DevModeTestUtils.getHttpResponse("/hello", () -> { | ||
return jarRun == null ? null : jarRun.isDone() ? "jar run mode has terminated" : null; | ||
}).equals("hello")); | ||
} finally { | ||
process.destroy(); | ||
} | ||
|
||
} | ||
|
||
private void assertThatOutputWorksCorrectly(String logs) { | ||
assertThat(logs.isEmpty()).isFalse(); | ||
String infoLogLevel = "INFO"; | ||
assertThat(logs.contains(infoLogLevel)).isTrue(); | ||
assertThat(logs.contains("cdi, resteasy")).isTrue(); | ||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
integration-tests/gradle/src/test/resources/test-uber-jar-format-works/build.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
plugins { | ||
id 'java' | ||
id 'io.quarkus' | ||
} | ||
|
||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
} | ||
|
||
dependencies { | ||
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}") | ||
implementation 'io.quarkus:quarkus-resteasy' | ||
|
||
testImplementation 'io.quarkus:quarkus-junit5' | ||
testImplementation 'io.rest-assured:rest-assured' | ||
} | ||
|
||
group 'org.acme' | ||
version '1.0.0-SNAPSHOT' | ||
|
||
compileJava { | ||
options.encoding = 'UTF-8' | ||
options.compilerArgs << '-parameters' | ||
} | ||
|
||
compileTestJava { | ||
options.encoding = 'UTF-8' | ||
} |
2 changes: 2 additions & 0 deletions
2
integration-tests/gradle/src/test/resources/test-uber-jar-format-works/gradle.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
quarkusPlatformArtifactId=quarkus-bom | ||
quarkusPlatformGroupId=io.quarkus |
11 changes: 11 additions & 0 deletions
11
integration-tests/gradle/src/test/resources/test-uber-jar-format-works/settings.gradle
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
pluginManagement { | ||
repositories { | ||
mavenLocal() | ||
mavenCentral() | ||
gradlePluginPortal() | ||
} | ||
plugins { | ||
id 'io.quarkus' version "${quarkusPluginVersion}" | ||
} | ||
} | ||
rootProject.name='uber-jar-test' |
19 changes: 19 additions & 0 deletions
19
...src/test/resources/test-uber-jar-format-works/src/main/java/org/acme/ExampleResource.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.acme; | ||
|
||
import javax.inject.Inject; | ||
import javax.ws.rs.GET; | ||
import javax.ws.rs.Path; | ||
import javax.ws.rs.Produces; | ||
import javax.ws.rs.core.MediaType; | ||
|
||
import org.eclipse.microprofile.config.inject.ConfigProperty; | ||
|
||
@Path("/hello") | ||
public class ExampleResource { | ||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello() { | ||
return "hello"; | ||
} | ||
|
||
} |
4 changes: 4 additions & 0 deletions
4
...e/src/test/resources/test-uber-jar-format-works/src/main/resources/application.properties
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# Configuration file | ||
# key = value | ||
my-app-name=${quarkus.application.name} | ||
quarkus.package.type=uber-jar |