PROBLEM SOLVED -- FOR SOME REASONS ITS NOT OCCURRING ANYMORE
My JEE OpenLiberty integration tests should look up the port and application context root dynamically, such as:
String port = System.getProperty("http.port");
String context = System.getProperty("context.root");
This works fine when running the test from Intellij. Somehow (maven-failsafe-plugin?) the variables in my pom.xml
file make it into the VM and are available for lookup in the test.
Now when I trigger running tests in "dev mode" by pressing ENTER once the server has started both properties return null
.
How can I fix this?
----------- EDIT: ----------
These are my pom.xml properties:
<properties>
<maven.compiler.source>21</maven.compiler.source>
<maven.compiler.target>21</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<liberty.var.http.port>9080</liberty.var.http.port>
<liberty.var.https.port>9443</liberty.var.https.port>
<liberty.var.app.context.root>myapp</liberty.var.app.context.root>
<junit.version>5.10.0</junit.version>
</properties>
and this my failsafe configuration:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<systemPropertyVariables>
<http.port>${liberty.var.http.port}</http.port>
<app.context.root>${liberty.var.app.context.root}</app.context.root>
</systemPropertyVariables>
</configuration>
</plugin>
You can set the values for variables used in the server.xml using Maven properties. These can be set in the pom.xml or passed on the command line. See the documentation here for how properties that start with 'liberty.var' get set in the server in the target directory.
<properties>
<liberty.var.http.port>9080</liberty.var.http.port>
</properties>