Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add and remove extension from single module project #10678

Merged
merged 1 commit into from
Jul 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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(new String(Files.readAllBytes(build))).contains("implementation 'io.quarkus:quarkus-hibernate-orm'");

runGradleWrapper(projectDir, ":removeExtension", "--extensions=hibernate-orm");
assertThat(new String(Files.readAllBytes(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(new String(Files.readAllBytes(build))).doesNotContain("implementation 'io.quarkus:quarkus-hibernate-orm'");

runGradleWrapper(projectDir, ":removeExtension", "--extensions=hibernate-orm");

assertThat(new String(Files.readAllBytes(build))).doesNotContain("implementation 'io.quarkus:quarkus-hibernate-orm'");

}

}
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'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
quarkusPlatformArtifactId=quarkus-bom
quarkusPlatformGroupId=io.quarkus
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'
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;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Configuration file
# key = value
my-app-name=${quarkus.application.name}
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"));
}
}
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