Skip to content
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,39 @@
plugins {
id 'java'
id 'io.quarkus'
id 'application'
}

repositories {
mavenLocal {
content {
includeGroupByRegex 'io.quarkus.*'
includeGroup 'org.hibernate.orm'
}
}
mavenCentral()
}

dependencies {
implementation enforcedPlatform("${quarkusPlatformGroupId}:${quarkusPlatformArtifactId}:${quarkusPlatformVersion}")
implementation 'io.quarkus:quarkus-resteasy'

testImplementation 'io.quarkus:quarkus-junit5'
testImplementation 'io.rest-assured:rest-assured'
}

compileJava {
options.compilerArgs << '-parameters'
}


run {
// propagate the custom local maven repo, in case it's configured
if (System.properties.containsKey('maven.repo.local')) {
systemProperty 'maven.repo.local', System.properties.get('maven.repo.local')
}
}

test {
systemProperty "java.util.logging.manager", "org.jboss.logmanager.LogManager"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
quarkusPluginVersion=${project.version}
quarkusPlatformArtifactId=quarkus-bom
quarkusPluginId=io.quarkus
quarkusPlatformGroupId=io.quarkus
quarkusPlatformVersion=${project.version}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
pluginManagement {
repositories {
mavenCentral()
gradlePluginPortal()
mavenLocal()
}
plugins {
id "${quarkusPluginId}" version "${quarkusPluginVersion}"
}
}
rootProject.name='code-with-quarkus'
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package org.acme;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

@Path("/hello")
public class GreetingResource {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "Hello from Quarkus REST";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package org.acme;

import static io.restassured.RestAssured.given;
import static org.hamcrest.CoreMatchers.is;

import org.junit.jupiter.api.Test;

import io.quarkus.test.junit.QuarkusTest;

@QuarkusTest
class GreetingResourceTest {
@Test
void testHelloEndpoint() {
given()
.when().get("/hello")
.then()
.statusCode(200)
.body(is("Hello from Quarkus REST"));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.quarkus.gradle;

import static org.assertj.core.api.AssertionsForClassTypes.assertThat;

import java.io.File;

import org.junit.jupiter.api.Test;

public class TestWithAppJunitPropertiesFileTest extends QuarkusGradleWrapperTestBase {

@Test
public void shouldRunTestsSuccessfully() throws Exception {

final File projectDir = getProjectDir("with-junit-properties-file");

BuildResult buildResult = runGradleWrapper(projectDir, "test");

assertThat(BuildResult.isSuccessful(buildResult.getTasks().get(":test"))).isTrue();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -233,4 +233,40 @@ public void testQuarkusTestWithConfigInTestProfile()
assertThat(installInvocation.getExitCode()).isEqualTo(0);

}

/*
* This should perhaps be in a different project, see https://github.com/quarkusio/quarkus/issues/46667
*/ @Test
public void testQuarkusTestInProjectWithJUnitProperties()
throws MavenInvocationException, InterruptedException {
String sourceDir = "projects/test-tests-in-project-with-junit-properties-file";
testDir = initProject(sourceDir, sourceDir + "-processed");
RunningInvoker invoker = new RunningInvoker(testDir, false);

MavenProcessInvocationResult installInvocation = invoker.execute(
List.of("clean", "verify", "-Dquarkus.analytics.disabled=true"),
Collections.emptyMap());
assertThat(installInvocation.getProcess().waitFor(2, TimeUnit.MINUTES)).isTrue();
assertThat(installInvocation.getExecutionException()).isNull();
assertThat(installInvocation.getExitCode()).isEqualTo(0);

}

@Test
public void testQuarkusTestInProjectWithJUnitPropertiesContinuousTesting()
throws MavenInvocationException, FileNotFoundException {
// This test will fail if the test extension does not reset the TCCL properly
String sourceDir = "projects/test-tests-in-project-with-junit-properties-file";
testDir = initProject(sourceDir, sourceDir + "-processed-devmode");

runAndCheck();

ContinuousTestingMavenTestUtils testingTestUtils = new ContinuousTestingMavenTestUtils(getPort());
ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion();
// This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures,
// so we need to check the pass count explicitly
Assertions.assertEquals(0, results.getTestsFailed());
Assertions.assertEquals(1, results.getTestsPassed());
Assertions.assertEquals(0, results.getTestsSkipped());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<modelVersion>4.0.0</modelVersion>

<groupId>org.acme</groupId>
<artifactId>quarkus-test-test-profile</artifactId>
<version>1.0-SNAPSHOT</version>

<properties>
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.version>@project.version@</quarkus.platform.version>
<quarkus-plugin.version>@project.version@</quarkus-plugin.version>
<compiler-plugin.version>${compiler-plugin.version}</compiler-plugin.version>
<surefire-plugin.version>${version.surefire.plugin}</surefire-plugin.version>
<maven.compiler.source>${maven.compiler.source}</maven.compiler.source>
<maven.compiler.target>${maven.compiler.target}</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencyManagement>
<dependencies>
<dependency>
<groupId>\${quarkus.platform.group-id}</groupId>
<artifactId>\${quarkus.platform.artifact-id}</artifactId>
<version>\${quarkus.platform.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>

<dependencies>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-junit5</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.rest-assured</groupId>
<artifactId>rest-assured</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>\${surefire-plugin.version}</version>
<configuration>
<systemPropertyVariables>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>\${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</plugin>
<plugin>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-maven-plugin</artifactId>
<version>\${quarkus-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>build</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>


<profiles>
<profile>
<id>native</id>
<activation>
<property>
<name>native</name>
</property>
</activation>
<properties>
<quarkus.native.enabled>true</quarkus.native.enabled>
</properties>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<skipTests>\${native.surefire.skip}</skipTests>
</configuration>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>\${surefire-plugin.version}</version>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
<configuration>
<systemPropertyVariables>
<native.image.path>\${project.build.directory}/\${project.build.finalName}-runner</native.image.path>
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
<maven.home>\${maven.home}</maven.home>
</systemPropertyVariables>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.acme;

import jakarta.ws.rs.GET;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

import org.eclipse.microprofile.config.ConfigProvider;

@Path("/hello")
public class HelloResource {

@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
// This config access only works if the TCCL is set properly
String message = ConfigProvider.getConfig().getValue("greeting.message", String.class);
return message;

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package org.acme;

import io.quarkus.runtime.Quarkus;
import io.quarkus.runtime.QuarkusApplication;
import io.quarkus.runtime.annotations.QuarkusMain;

@QuarkusMain
public class Main implements QuarkusApplication {

public static volatile String[] PARAMS;

@Override
public int run(String... args) throws Exception {
PARAMS = args;
Quarkus.waitForExit();
return 0;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.acme;

import jakarta.ws.rs.ApplicationPath;
import jakarta.ws.rs.core.Application;

@ApplicationPath("/app")
public class MyApplication extends Application {

}
Loading
Loading