Skip to content

Conversation

@WolfgangHG
Copy link
Contributor

Part three to resolve #145: I added two profiles "provisioning" and "arq-provisioned" to the ear archetype. The first builds the project and provisions a server (without running tests), the second profile runs the arquillian tests using this server.

So the tests have to be invoked like this:

mvn clean install -Pprovision
mvn verify -Parq-provisioned

The problem here is that the integration tests of the webapp project are executed before the server is provisioned. So they could not be run using the provisioned server.
There was a dicussion between @jfdenise and me. @jfdenise suggested a bigger change (see #145 (comment)) to separate the tests from the deployment code.
In this pull request, I picked a simpler approach - running the tests on the provisioned server requires two maven runs.

What do you think?

I will mark this request as "draft", as several readmes must be fixed before it is merged. Just wanted to avoid this work in case you prefer the approach suggested by @jfdenise

The provisioning profile required a change to the way the arquillian test deployment is created, see explanation in the webapp archetype.

@jmesnil
Copy link
Member

jmesnil commented Apr 29, 2025

@WolfgangHG If you want to provision the WildFly server with Maven in the archetype, you can streamline the integration tests:

  1. Use the wildfly-maven-plugin (and Glow) to provision the server in the ear maven module
  2. Move the integration tests from web/src/test to ear/src/test (so that the EAR has been built and deployed)
  3. Update the SampleIT
    1. remove the getEarArchive() method: the actual EAR is already deployed in the provisioned server

@WolfgangHG
Copy link
Contributor Author

@jmesnil Thanks for the suggestion to move the test classes to "ear/src/test", I will give it a try the next few days. But I am not sure whether we can remove the shrinkwrap EAR creation, as we have to enrich the deployed archive with the server side test classes.

@WolfgangHG
Copy link
Contributor Author

@jmesnil I tried to add test classes to "ear/src/test". But this will not work with Eclipse, probably as Eclipse does not support the java nature in ear projects - the nature is not added by default when M2E imports the exiting maven project. And the root project does not seem to support java classes either.

So I tried to move the arquillian tests to a separate module/project as suggested here by @jfdenise, and made some progress. I will update this pull request the next few days.

@WolfgangHG
Copy link
Contributor Author

I added a module "integration-tests" to the EAR archetype and moved the arquillian test to this project. This simplifies building the test deployment as you don't have to build the ear yourself by adding the ejb jar and web war output of the sub modules. We can now pick the ear file that was built by maven and just add the test classes to the web module.

Now, the "arq-provisioned" profile can be executed in one single step, without having to run an extra profile "provision" before.
"arq-provisioned" builds the server with option "skipDeployment=true" so that it does not contain the ear application as deploment. Thus, the arquillian test does not have to rename the test deployment. Before this was easy as the test built the ear itself. But as I can use the ear built by maven now, and this one contains an "application.xml" file that defines module names, I cannot simply rename the war file inside the ear, but would have to also change "application.xml".

As the arquillian build now created a provisioned server without the deployment, I added a profile "provision" that is used to provision a server including the deployment.

I configured both profiles so that the provisioned server is placed in different directories (using the "provisioningDir" parameter). If you run the profile "provision" and then execute "arq-provisioned" without "mvn clean", it would otherwise probably reuse a server that contains the deployment, and deploying the test ear file would fail.

What do you think?


<dependencies>

<!-- Import the CDI API, we use provided scope as the API is included in WildFly / JBoss EAP -->

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you mention JBoss EAP?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied the text from the other profiles. "JBoss EAP" is there since the first version of the archetype (JBoss 7) ;-). I can remove them all if you consider this reasonable.

@WolfgangHG
Copy link
Contributor Author

I updated the documentation of the ear archetype and thus remove the "draft" state.

@WolfgangHG WolfgangHG marked this pull request as ready for review May 20, 2025 19:00
@WolfgangHG
Copy link
Contributor Author

A question to the reviewers:

Previously, both the EJB and web project contained a file "arquillian.xml", though the sample test was in the web project. The file in the ejb module existed since the beginning of the archetype, with the argument that here also arquillian tests were possible.

As part of the changes of this pull request, I moved "arquillian.xml" and the test class from the web project to the new module "integration_tests".

But the ejb project still contains "arquillian.xml" (link to original file: https://github.com/wildfly/wildfly-archetypes/blob/main/wildfly-jakartaee-ear-archetype/src/main/resources/archetype-resources/ejb/src/test/resources/arquillian.xml). Do you think this still makes sense? At least arquillian tests which create a deployment would no longer work in the "arq_provisioned" profile, as the provisioned server is created later during the ear project built.
In order to make the archetype simpler, I tend to removing this file, and maybe also related dependencies in the ejb pom.xml ("org.jboss.arquillian.junit5:arquillian-junit5-container" and maybe even "org.junit.jupiter:junit-jupiter").

What do you think?

@WolfgangHG WolfgangHG force-pushed the provisioning_ear branch 2 times, most recently from 9494be9 to e715216 Compare July 13, 2025 18:05
@WolfgangHG
Copy link
Contributor Author

After latest rebase, build failed due to the JBoss repository not being available. Had to do a git commit --amend to re-run the failed tests.

@WolfgangHG WolfgangHG force-pushed the provisioning_ear branch 2 times, most recently from 995e765 to 4e4b3dd Compare October 16, 2025 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

WildFly Glow support in the WildFly Maven Plugin should be used

3 participants