Skip to content

Commit

Permalink
Add and remove extension from single module project
Browse files Browse the repository at this point in the history
  • Loading branch information
Garima Monga committed Jul 13, 2020
1 parent 5c4d64b commit 3ebdda4
Show file tree
Hide file tree
Showing 8 changed files with 151 additions and 0 deletions.
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'");

}

}
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

0 comments on commit 3ebdda4

Please sign in to comment.