Skip to content

Commit 9371b06

Browse files
committed
[11] Split the non-lifecycle extension into an api sub-project. Move the Deployments utility to the tooling and remove the dependency on JUnit for that utility.
Signed-off-by: James R. Perkins <jperkins@ibm.com>
1 parent a127f97 commit 9371b06

File tree

86 files changed

+340
-270
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

86 files changed

+340
-270
lines changed

README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ within this time, an exception is thrown.
272272
== Extending
273273

274274
You can extend the resource injection via the `@ServerResource` annotation by implementing a
275-
`org.wildfly.testing.junit.api.ServerResourceProducer`.
275+
`org.wildfly.testing.junit.extension.api.ServerResourceProducer`.
276276

277277
[source,java]
278278
----

api/pom.xml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!--
3+
~ Copyright The WildFly Authors
4+
~ SPDX-License-Identifier: Apache-2.0
5+
-->
6+
7+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
8+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
9+
<modelVersion>4.0.0</modelVersion>
10+
<parent>
11+
<groupId>org.wildfly.testing</groupId>
12+
<artifactId>wildfly-testing-tools-parent</artifactId>
13+
<version>1.0.0.Beta1-SNAPSHOT</version>
14+
<relativePath>../pom.xml</relativePath>
15+
</parent>
16+
17+
<artifactId>wildfly-junit-api</artifactId>
18+
<name>WildFly JUnit API</name>
19+
20+
<properties>
21+
</properties>
22+
23+
<dependencies>
24+
<dependency>
25+
<groupId>org.jboss.logging</groupId>
26+
<artifactId>jboss-logging</artifactId>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.junit.jupiter</groupId>
30+
<artifactId>junit-jupiter-api</artifactId>
31+
</dependency>
32+
<dependency>
33+
<groupId>org.wildfly.plugins</groupId>
34+
<artifactId>wildfly-plugin-tools</artifactId>
35+
</dependency>
36+
37+
<!-- Test dependencies -->
38+
<dependency>
39+
<groupId>org.junit.jupiter</groupId>
40+
<artifactId>junit-jupiter</artifactId>
41+
<scope>test</scope>
42+
</dependency>
43+
<dependency>
44+
<groupId>org.junit.platform</groupId>
45+
<artifactId>junit-platform-testkit</artifactId>
46+
<scope>test</scope>
47+
</dependency>
48+
</dependencies>
49+
50+
<build>
51+
<plugins>
52+
<plugin>
53+
<artifactId>maven-surefire-plugin</artifactId>
54+
<executions>
55+
<execution>
56+
<id>default-test</id>
57+
<configuration>
58+
<systemPropertyVariables>
59+
<jboss.home>${project.build.testOutputDirectory}/fake-modules</jboss.home>
60+
</systemPropertyVariables>
61+
<groups>system.property</groups>
62+
</configuration>
63+
</execution>
64+
<execution>
65+
<id>env-var</id>
66+
<phase>test</phase>
67+
<goals>
68+
<goal>test</goal>
69+
</goals>
70+
<configuration>
71+
<environmentVariables>
72+
<JBOSS_HOME>${project.build.testOutputDirectory}/fake-modules</JBOSS_HOME>
73+
</environmentVariables>
74+
<groups>env.var</groups>
75+
</configuration>
76+
</execution>
77+
</executions>
78+
</plugin>
79+
<!-- We need to bind a new execution of this to run after provisioning is done so the module.xml file
80+
required for testing is not deleted.
81+
-->
82+
<plugin>
83+
<artifactId>maven-resources-plugin</artifactId>
84+
<executions>
85+
<execution>
86+
<id>copy-module</id>
87+
<phase>pre-integration-test</phase>
88+
<goals>
89+
<goal>testResources</goal>
90+
</goals>
91+
</execution>
92+
</executions>
93+
</plugin>
94+
</plugins>
95+
</build>
96+
</project>

extension/src/main/java/org/wildfly/testing/junit/annotations/AnyOf.java renamed to api/src/main/java/org/wildfly/testing/junit/annotations/AnyOf.java

File renamed without changes.

extension/src/main/java/org/wildfly/testing/junit/annotations/JBossHome.java renamed to api/src/main/java/org/wildfly/testing/junit/annotations/JBossHome.java

File renamed without changes.

extension/src/main/java/org/wildfly/testing/junit/annotations/RequiresModule.java renamed to api/src/main/java/org/wildfly/testing/junit/annotations/RequiresModule.java

File renamed without changes.

extension/src/main/java/org/wildfly/testing/junit/annotations/RequiresModules.java renamed to api/src/main/java/org/wildfly/testing/junit/annotations/RequiresModules.java

File renamed without changes.

extension/src/main/java/org/wildfly/testing/junit/condition/JBossHomeParameterResolver.java renamed to api/src/main/java/org/wildfly/testing/junit/condition/JBossHomeParameterResolver.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@
1414
import org.junit.jupiter.api.extension.ParameterResolutionException;
1515
import org.junit.jupiter.api.extension.ParameterResolver;
1616
import org.wildfly.testing.junit.annotations.JBossHome;
17-
import org.wildfly.testing.junit.api.ServerConfiguration;
1817

1918
/**
2019
* Resolves the {@code jboss.home} system property or if not set the {@code JBOSS_HOME} environment variable. If neither
@@ -38,7 +37,8 @@ public boolean supportsParameter(final ParameterContext parameterContext, final
3837
@Override
3938
public Object resolveParameter(final ParameterContext parameterContext, final ExtensionContext extensionContext)
4039
throws ParameterResolutionException {
41-
final Optional<Path> value = ServerConfiguration.resolveJBossHome(extensionContext);
40+
// TODO (jrp) look at how we did this before
41+
final Optional<Path> value = Support.resolveJBossHome(extensionContext);
4242
if (value.isEmpty()) {
4343
throw new ParameterResolutionException(
4444
"Could not resolve the jboss.home system property or JBOSS_HOME environment variable.");

extension/src/main/java/org/wildfly/testing/junit/condition/RequiresModuleExecutionCondition.java renamed to api/src/main/java/org/wildfly/testing/junit/condition/RequiresModuleExecutionCondition.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
import org.wildfly.plugin.tools.VersionComparator;
3131
import org.wildfly.testing.junit.annotations.AnyOf;
3232
import org.wildfly.testing.junit.annotations.RequiresModule;
33-
import org.wildfly.testing.junit.api.ServerConfiguration;
3433
import org.xml.sax.SAXException;
3534

3635
/**
@@ -230,9 +229,9 @@ private static String formatReason(final RequiresModule requiresModule, final St
230229
}
231230

232231
private static Path resolveModulesDir(final ExtensionContext context) {
233-
final Optional<String> moduleDir = ServerConfiguration.resolveModulePath(context);
232+
final Optional<String> moduleDir = Support.resolveModulePath(context);
234233
return moduleDir.map(Path::of)
235-
.orElseGet(() -> ServerConfiguration.resolveJBossHome(context).map(p -> p.resolve("modules")).orElse(null));
234+
.orElseGet(() -> Support.resolveJBossHome(context).map(p -> p.resolve("modules")).orElse(null));
236235
}
237236

238237
private record ModuleDefinition(Path path, String name, String version) {
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/*
2+
* Copyright The WildFly Authors
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
package org.wildfly.testing.junit.condition;
7+
8+
import java.nio.file.Path;
9+
import java.util.Optional;
10+
11+
import org.junit.jupiter.api.extension.ExtensionContext;
12+
13+
/**
14+
* Support for resolving information about the local server installation.
15+
*
16+
* @author <a href="mailto:jperkins@ibm.com">James R. Perkins</a>
17+
*/
18+
public class Support {
19+
20+
/**
21+
* Resolves the servers base directory. This first uses the
22+
* {@link ExtensionContext#getConfigurationParameter(String)} with the {@code jboss.home} key. If not found, it
23+
* checks for the environment variable {@code JBOSS_HOME}. If none of those are set, a
24+
* {@link org.junit.platform.commons.JUnitException} is thrown.
25+
*
26+
* @param context the extension context used to look up the property
27+
*
28+
* @return the path to the server
29+
*/
30+
static Optional<Path> resolveJBossHome(final ExtensionContext context) {
31+
return context.getConfigurationParameter("jboss.home")
32+
.or(() -> Optional.ofNullable(System.getenv("JBOSS_HOME")))
33+
.or(() -> context.getConfigurationParameter("jboss.home.dir"))
34+
.map(Path::of);
35+
}
36+
37+
/**
38+
* Resolves the {@code wildfly.module.path} property from the context.
39+
*
40+
* @param context the extension context
41+
*
42+
* @return the value of the {@code wildfly.module.path}, otherwise empty
43+
*/
44+
static Optional<String> resolveModulePath(final ExtensionContext context) {
45+
return context.getConfigurationParameter("wildfly.module.path");
46+
}
47+
}

extension/src/test/java/org/wildfly/testing/junit/jboss/home/JBossHomeParameterTestCase.java renamed to api/src/test/java/org/wildfly/testing/junit/JBossHomeParameterTestCase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* SPDX-License-Identifier: Apache-2.0
44
*/
55

6-
package org.wildfly.testing.junit.jboss.home;
6+
package org.wildfly.testing.junit;
77

88
import java.io.File;
99
import java.nio.file.Path;

0 commit comments

Comments
 (0)