Skip to content

Commit e1de423

Browse files
committed
Leave the TCCL how we found it after test discovery
1 parent 8a68d96 commit e1de423

File tree

10 files changed

+402
-27
lines changed

10 files changed

+402
-27
lines changed

integration-tests/maven/src/test/java/io/quarkus/maven/it/QuarkusTestIT.java

+35
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,39 @@ public void testQuarkusTestInMetaInfServicesNormalTesting()
8989
assertThat(installInvocation.getExitCode()).isEqualTo(0);
9090

9191
}
92+
93+
@Disabled("Not working, see https://github.com/quarkusio/quarkus/issues/47364")
94+
@Test
95+
public void testQuarkusTestGuardedByConditionContinuousTesting()
96+
throws MavenInvocationException, FileNotFoundException {
97+
//we also check continuous testing
98+
String sourceDir = "projects/test-test-conditions";
99+
testDir = initProject(sourceDir, sourceDir + "-processed-devmode");
100+
101+
runAndCheck();
102+
103+
ContinuousTestingMavenTestUtils testingTestUtils = new ContinuousTestingMavenTestUtils(getPort());
104+
ContinuousTestingMavenTestUtils.TestStatus results = testingTestUtils.waitForNextCompletion();
105+
// This is a bit brittle when we add tests, but failures are often so catastrophic they're not even reported as failures,
106+
// so we need to check the pass count explicitly
107+
Assertions.assertEquals(0, results.getTestsFailed());
108+
Assertions.assertEquals(1, results.getTestsPassed());
109+
}
110+
111+
@Test
112+
public void testQuarkusTestGuardedByCondition()
113+
throws MavenInvocationException, InterruptedException {
114+
String sourceDir = "projects/test-test-conditions";
115+
testDir = initProject(sourceDir, sourceDir + "-processed");
116+
RunningInvoker invoker = new RunningInvoker(testDir, false);
117+
118+
// to properly surface the problem of multiple classpath entries, we need to install the project to the local m2
119+
MavenProcessInvocationResult installInvocation = invoker.execute(
120+
List.of("clean", "verify", "-Dquarkus.analytics.disabled=true"),
121+
Collections.emptyMap());
122+
assertThat(installInvocation.getProcess().waitFor(2, TimeUnit.MINUTES)).isTrue();
123+
assertThat(installInvocation.getExecutionException()).isNull();
124+
assertThat(installInvocation.getExitCode()).isEqualTo(0);
125+
126+
}
92127
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project>
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>org.acme</groupId>
6+
<artifactId>quarkus-test-test-profile</artifactId>
7+
<version>1.0-SNAPSHOT</version>
8+
9+
<properties>
10+
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
11+
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
12+
<quarkus.platform.version>@project.version@</quarkus.platform.version>
13+
<quarkus-plugin.version>@project.version@</quarkus-plugin.version>
14+
<compiler-plugin.version>${compiler-plugin.version}</compiler-plugin.version>
15+
<surefire-plugin.version>${version.surefire.plugin}</surefire-plugin.version>
16+
<maven.compiler.source>${maven.compiler.source}</maven.compiler.source>
17+
<maven.compiler.target>${maven.compiler.target}</maven.compiler.target>
18+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
19+
</properties>
20+
21+
<dependencyManagement>
22+
<dependencies>
23+
<dependency>
24+
<groupId>\${quarkus.platform.group-id}</groupId>
25+
<artifactId>\${quarkus.platform.artifact-id}</artifactId>
26+
<version>\${quarkus.platform.version}</version>
27+
<type>pom</type>
28+
<scope>import</scope>
29+
</dependency>
30+
</dependencies>
31+
</dependencyManagement>
32+
33+
<dependencies>
34+
<dependency>
35+
<groupId>io.quarkus</groupId>
36+
<artifactId>quarkus-resteasy</artifactId>
37+
</dependency>
38+
<dependency>
39+
<groupId>io.quarkus</groupId>
40+
<artifactId>quarkus-junit5</artifactId>
41+
<scope>test</scope>
42+
</dependency>
43+
</dependencies>
44+
45+
<build>
46+
<plugins>
47+
<plugin>
48+
<artifactId>maven-surefire-plugin</artifactId>
49+
<version>\${surefire-plugin.version}</version>
50+
<configuration>
51+
<systemPropertyVariables>
52+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
53+
<maven.home>\${maven.home}</maven.home>
54+
</systemPropertyVariables>
55+
</configuration>
56+
</plugin>
57+
<plugin>
58+
<groupId>io.quarkus</groupId>
59+
<artifactId>quarkus-maven-plugin</artifactId>
60+
<version>\${quarkus-plugin.version}</version>
61+
<executions>
62+
<execution>
63+
<goals>
64+
<goal>build</goal>
65+
</goals>
66+
</execution>
67+
</executions>
68+
</plugin>
69+
</plugins>
70+
</build>
71+
72+
73+
<profiles>
74+
<profile>
75+
<id>native</id>
76+
<activation>
77+
<property>
78+
<name>native</name>
79+
</property>
80+
</activation>
81+
<properties>
82+
<quarkus.native.enabled>true</quarkus.native.enabled>
83+
</properties>
84+
<build>
85+
<plugins>
86+
<plugin>
87+
<groupId>org.apache.maven.plugins</groupId>
88+
<artifactId>maven-surefire-plugin</artifactId>
89+
<configuration>
90+
<skipTests>\${native.surefire.skip}</skipTests>
91+
</configuration>
92+
</plugin>
93+
<plugin>
94+
<artifactId>maven-failsafe-plugin</artifactId>
95+
<version>\${surefire-plugin.version}</version>
96+
<executions>
97+
<execution>
98+
<goals>
99+
<goal>integration-test</goal>
100+
<goal>verify</goal>
101+
</goals>
102+
<configuration>
103+
<systemPropertyVariables>
104+
<native.image.path>\${project.build.directory}/\${project.build.finalName}-runner</native.image.path>
105+
<java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
106+
<maven.home>\${maven.home}</maven.home>
107+
</systemPropertyVariables>
108+
</configuration>
109+
</execution>
110+
</executions>
111+
</plugin>
112+
</plugins>
113+
</build>
114+
</profile>
115+
</profiles>
116+
</project>

integration-tests/maven/src/test/resources-filtered/projects/test-test-conditions/src/main/resources/META-INF/beans.xml

Whitespace-only changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>acme - 1.0-SNAPSHOT</title>
6+
<style>
7+
h1, h2, h3, h4, h5, h6 {
8+
margin-bottom: 0.5rem;
9+
font-weight: 400;
10+
line-height: 1.5;
11+
}
12+
13+
h1 {
14+
font-size: 2.5rem;
15+
}
16+
17+
h2 {
18+
font-size: 2rem
19+
}
20+
21+
h3 {
22+
font-size: 1.75rem
23+
}
24+
25+
h4 {
26+
font-size: 1.5rem
27+
}
28+
29+
h5 {
30+
font-size: 1.25rem
31+
}
32+
33+
h6 {
34+
font-size: 1rem
35+
}
36+
37+
.lead {
38+
font-weight: 300;
39+
font-size: 2rem;
40+
}
41+
42+
.banner {
43+
font-size: 2.7rem;
44+
margin: 0;
45+
padding: 2rem 1rem;
46+
background-color: #00A1E2;
47+
color: white;
48+
}
49+
50+
body {
51+
margin: 0;
52+
font-family: -apple-system, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
53+
}
54+
55+
code {
56+
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
57+
font-size: 87.5%;
58+
color: #e83e8c;
59+
word-break: break-word;
60+
}
61+
62+
.left-column {
63+
padding: .75rem;
64+
max-width: 75%;
65+
min-width: 55%;
66+
}
67+
68+
.right-column {
69+
padding: .75rem;
70+
max-width: 25%;
71+
}
72+
73+
.container {
74+
display: flex;
75+
width: 100%;
76+
}
77+
78+
li {
79+
margin: 0.75rem;
80+
}
81+
82+
.right-section {
83+
margin-left: 1rem;
84+
padding-left: 0.5rem;
85+
}
86+
87+
.right-section h3 {
88+
padding-top: 0;
89+
font-weight: 200;
90+
}
91+
92+
.right-section ul {
93+
border-left: 0.3rem solid #00A1E2;
94+
list-style-type: none;
95+
padding-left: 0;
96+
}
97+
98+
</style>
99+
</head>
100+
<body>
101+
102+
<div class="banner lead">
103+
Your new Cloud-Native application is ready!
104+
</div>
105+
106+
<div class="container">
107+
<div class="left-column">
108+
<p class="lead"> Congratulations, you have created a new Quarkus application.</p>
109+
110+
<h2>Why do you see this?</h2>
111+
112+
<p>This page is served by Quarkus. The source is in
113+
<code>src/main/resources/META-INF/resources/index.html</code>.</p>
114+
115+
<h2>What can I do from here?</h2>
116+
117+
<p>If not already done, run the application in <em>dev mode</em> using: <code>mvn quarkus:dev</code>.
118+
</p>
119+
<ul>
120+
<li>Add REST resources, Servlets, functions and other services in <code>src/main/java</code>.</li>
121+
<li>Your static assets are located in <code>src/main/resources/META-INF/resources</code>.</li>
122+
<li>Configure your application in <code>src/main/resources/application.properties</code>.
123+
</li>
124+
</ul>
125+
126+
<h2>Do you like Quarkus?</h2>
127+
<p>Go give it a star on <a href="https://github.com/quarkusio/quarkus">GitHub</a>.</p>
128+
129+
<h2>How do I get rid of this page?</h2>
130+
<p>Just delete the <code>src/main/resources/META-INF/resources/index.html</code> file.</p>
131+
</div>
132+
<div class="right-column">
133+
<div class="right-section">
134+
<h3>Application</h3>
135+
<ul>
136+
<li>GroupId: org.acme</li>
137+
<li>ArtifactId: acme</li>
138+
<li>Version: 1.0-SNAPSHOT</li>
139+
<li>Quarkus Version: 999-SNAPSHOT</li>
140+
</ul>
141+
</div>
142+
<div class="right-section">
143+
<h3>Next steps</h3>
144+
<ul>
145+
<!-- the url have been erased on purpose -->
146+
<li><a href="#">Setup your IDE</a></li>
147+
<li><a href="#">Getting started</a></li>
148+
<li><a href="#">Documentation</a></li>
149+
</ul>
150+
</div>
151+
</div>
152+
</div>
153+
154+
155+
</body>
156+
</html>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
quarkus.test.continuous-testing=enabled
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package org.acme;
2+
3+
import java.lang.annotation.Documented;
4+
import java.lang.annotation.ElementType;
5+
import java.lang.annotation.Retention;
6+
import java.lang.annotation.RetentionPolicy;
7+
import java.lang.annotation.Target;
8+
9+
import org.junit.jupiter.api.extension.ExtendWith;
10+
11+
@Target({ ElementType.TYPE, ElementType.METHOD })
12+
@Retention(RetentionPolicy.RUNTIME)
13+
@Documented
14+
@ExtendWith(AlwaysEnabledCondition.class)
15+
public @interface AlwaysEnabled {
16+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package org.acme;
2+
3+
import org.eclipse.microprofile.config.ConfigProvider;
4+
import org.junit.jupiter.api.extension.ConditionEvaluationResult;
5+
import org.junit.jupiter.api.extension.ExecutionCondition;
6+
import org.junit.jupiter.api.extension.ExtensionContext;
7+
8+
public class AlwaysEnabledCondition implements ExecutionCondition {
9+
private static final Boolean switchTCCL = Boolean.getBoolean("switchTCCL");
10+
11+
@Override
12+
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext context) {
13+
String os = ConfigProvider.getConfig().getValue("os.name", String.class);
14+
return ConditionEvaluationResult.enabled("enabled");
15+
16+
}
17+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package org.acme;
2+
3+
import org.junit.jupiter.api.Test;
4+
5+
import io.quarkus.test.junit.QuarkusTest;
6+
7+
@AlwaysEnabled
8+
@QuarkusTest
9+
class GreetingResourceTest {
10+
@Test
11+
void testThatAlwaysRuns() {
12+
}
13+
}

0 commit comments

Comments
 (0)