-
Notifications
You must be signed in to change notification settings - Fork 2.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add and remove extension from single module project
- Loading branch information
Garima Monga
committed
Jul 13, 2020
1 parent
5c4d64b
commit 3ebdda4
Showing
8 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
...n-tests/gradle/src/test/java/io/quarkus/gradle/AddExtensionToSingleModuleProjectTest.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,48 @@ | ||
package io.quarkus.gradle; | ||
|
||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.net.URISyntaxException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
public class AddExtensionToSingleModuleProjectTest extends QuarkusGradleWrapperTestBase { | ||
|
||
@Test | ||
public void testAddAndRemoveExtension() throws IOException, URISyntaxException, InterruptedException { | ||
|
||
final File projectDir = getProjectDir("add-remove-extension-single-module"); | ||
|
||
runGradleWrapper(projectDir, ":addExtension", "--extensions=hibernate-orm"); | ||
|
||
final Path Build = projectDir.toPath().resolve("build.gradle"); | ||
assertThat(Build).exists(); | ||
assertThat(Files.readString(Build)).contains("implementation 'io.quarkus:quarkus-hibernate-orm'"); | ||
|
||
runGradleWrapper(projectDir, ":removeExtension", "--extensions=hibernate-orm"); | ||
assertThat(Files.readString(Build)).doesNotContain("implementation 'io.quarkus:quarkus-hibernate-orm'"); | ||
|
||
} | ||
|
||
@Test | ||
public void testRemoveNonExistentExtension() throws IOException, URISyntaxException, InterruptedException { | ||
|
||
final File projectDir = getProjectDir("add-remove-extension-single-module"); | ||
|
||
runGradleWrapper(projectDir, "clean", "build"); | ||
|
||
final Path Build = projectDir.toPath().resolve("build.gradle"); | ||
assertThat(Build).exists(); | ||
assertThat(Files.readString(Build)).doesNotContain("implementation 'io.quarkus:quarkus-hibernate-orm'"); | ||
|
||
runGradleWrapper(projectDir, ":removeExtension", "--extensions=hibernate-orm"); | ||
|
||
assertThat(Files.readString(Build)).doesNotContain("implementation 'io.quarkus:quarkus-hibernate-orm'"); | ||
|
||
} | ||
|
||
} |
29 changes: 29 additions & 0 deletions
29
integration-tests/gradle/src/test/resources/add-remove-extension-single-module/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
...tion-tests/gradle/src/test/resources/add-remove-extension-single-module/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
...ration-tests/gradle/src/test/resources/add-remove-extension-single-module/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='code-with-quarkus' |
24 changes: 24 additions & 0 deletions
24
.../resources/add-remove-extension-single-module/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,24 @@ | ||
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 { | ||
|
||
@ConfigProperty(name = "my-app-name") | ||
String appName; | ||
@ConfigProperty(name = "quarkus.application.version") | ||
String appVersion; | ||
|
||
@GET | ||
@Produces(MediaType.TEXT_PLAIN) | ||
public String hello() { | ||
return appName + " " + appVersion; | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...st/resources/add-remove-extension-single-module/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,3 @@ | ||
# Configuration file | ||
# key = value | ||
my-app-name=${quarkus.application.name} |
29 changes: 29 additions & 0 deletions
29
...ources/add-remove-extension-single-module/src/test/java/org/acme/ExampleResourceTest.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,29 @@ | ||
package org.acme; | ||
|
||
import io.quarkus.test.junit.QuarkusTest; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import static io.restassured.RestAssured.given; | ||
import static org.hamcrest.CoreMatchers.is; | ||
|
||
@QuarkusTest | ||
public class ExampleResourceTest { | ||
|
||
@Test | ||
public void testHelloEndpoint() { | ||
given() | ||
.when().get("/hello") | ||
.then() | ||
.statusCode(200) | ||
.body(is("Hello from Test")); | ||
} | ||
|
||
@Test | ||
public void testTestOnly() { | ||
given() | ||
.when().get("test-only") | ||
.then() | ||
.statusCode(200) | ||
.body(is("Test only")); | ||
} | ||
} |
5 changes: 5 additions & 0 deletions
5
...st/resources/add-remove-extension-single-module/src/test/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,5 @@ | ||
# Configuration file | ||
# key = value | ||
example.message=Hello from Test | ||
test-only=Test only | ||
|