Skip to content

Commit

Permalink
Merge pull request #118 from jhanders34/jhanders34-branch
Browse files Browse the repository at this point in the history
Use the new REST protocol option to not depend on servlet to run tests
  • Loading branch information
jhanders34 authored Aug 5, 2022
2 parents a5ed501 + 00b49f2 commit 3944125
Show file tree
Hide file tree
Showing 22 changed files with 460 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
os: [ubuntu-latest, windows-latest]
java: [1.8, 11]
runtime: [ol]
runtime_version: [22.0.0.6]
runtime_version: [22.0.0.9-beta]

steps:
- uses: actions/checkout@v2
Expand Down
23 changes: 18 additions & 5 deletions liberty-managed/JakartaEE9_README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,22 @@ The following features are required in the `server.xml` of the Liberty server.
<featureManager>
<feature>pages-3.0</feature>
<feature>localConnector-1.0</feature>
<feature>usr:arquillian-support-jakarta-2.0</feature> <!-- Optional, needed for reliable reporting of correct DeploymentExceptions -->
<feature>usr:arquillian-support-jakarta-2.1</feature> <!-- Optional, needed for reliable reporting of correct DeploymentExceptions -->
</featureManager>
```

Read more about configuring the `arquillian-support-jakarta-2.0` feature [here](../liberty-support-feature/JakartaEE9_README.md).
or

```
<!-- Enable features -->
<featureManager>
<feature>restfulWS-3.0</feature>
<feature>localConnector-1.0</feature>
<feature>usr:arquillian-support-jakarta-2.1</feature> <!-- Optional, needed for reliable reporting of correct DeploymentExceptions -->
</featureManager>
```

Read more about configuring the `arquillian-support-jakarta-2.1` feature [here](../liberty-support-feature/JakartaEE9_README.md).

You will also need to enable the `applicationMonitor` MBean support in your `server.xml`:

Expand All @@ -35,16 +46,17 @@ If you need a sample server.xml, please refer to the [one in our source reposito

## Configuration

Default Protocol: Servlet 5.0
Default Protocol: Servlet 5.0 or REST 3.0 depend on configuration

To enable Arquillian Liberty Managed in your project, add the following to your `pom.xml`:

```xml
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>1.7.0.Alpha9</version>
<version>1.7.0.Alpha12</version>
<scope>import</scope>
<type>pom</type>
</dependency>
Expand All @@ -56,7 +68,7 @@ To enable Arquillian Liberty Managed in your project, add the following to your
<dependency>
<groupId>io.openliberty.arquillian</groupId>
<artifactId>arquillian-liberty-managed-jakarta</artifactId>
<version>2.0.0</version>
<version>2.1.0</version>
<scope>test</scope>
</dependency>
...
Expand Down Expand Up @@ -86,6 +98,7 @@ To enable Arquillian Liberty Managed in your project, add the following to your
| outputToConsole | Boolean | true | When enabled output from the application server process will be emitted to stdout |
| fileDeleteRetries | Integer | 30 | How many times to attempt deleting a file |
| standardFileDeleteRetryInterval | Integer | 50 | How long in milliseconds to wait between attempting to delete a file |
| testProtocol | String | servlet | Aquillian protocol to contact the server to run a test (available: servlet or rest) |


## Examples
Expand Down
157 changes: 139 additions & 18 deletions liberty-managed/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>io.openliberty.arquillian</groupId>
<artifactId>arquillian-parent-liberty-jakarta</artifactId>
<version>2.0.3-SNAPSHOT</version>
<version>2.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

Expand Down Expand Up @@ -40,6 +40,9 @@
<activation>
<jdk>[1.0,1.9)</jdk>
</activation>
<properties>
<skipEE10Tests>true</skipEE10Tests>
</properties>
<dependencies>
<dependency>
<groupId>com.sun</groupId>
Expand All @@ -55,6 +58,9 @@
<activation>
<jdk>[11,)</jdk>
</activation>
<properties>
<skipEE10Tests>false</skipEE10Tests>
</properties>
<dependencies>
<dependency>
<groupId>jakarta.annotation</groupId>
Expand Down Expand Up @@ -97,7 +103,7 @@
</configuration>
<goals>
<goal>create</goal>
</goals>
</goals>
</execution>
<execution>
<id>create-server-management</id>
Expand All @@ -108,13 +114,55 @@
<configuration>
<serverName>managementServer</serverName>
<serverXmlFile>src/test/resources/server-with-management.xml</serverXmlFile>
</configuration>
<goals>
</configuration>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
</execution>
<execution>
<id>create-rest-server</id>
<!-- Plugin execution only succeeds here in the correct order because
execution id of the test is not 'default-test'.
Because Maven. See MNG-5799 and MNG-5987 -->
<phase>test</phase>
<configuration>
<serverName>restServer</serverName>
<serverXmlFile>src/test/resources/restServer.xml</serverXmlFile>
</configuration>
<goals>
<goal>create</goal>
</goals>
</execution>
<execution>
<id>create-rest-server-management</id>
<!-- Plugin execution only succeeds here in the correct order because
execution id of the test is not 'default-test'.
Because Maven. See MNG-5799 and MNG-5987 -->
<phase>test</phase>
<configuration>
<serverName>managementRestServer</serverName>
<serverXmlFile>src/test/resources/restServer-with-management.xml</serverXmlFile>
</configuration>
<goals>
<goal>create</goal>
</goals>
</execution>
<execution>
<id>create-rest-server-management-ee10</id>
<!-- Plugin execution only succeeds here in the correct order because
execution id of the test is not 'default-test'.
Because Maven. See MNG-5799 and MNG-5987 -->
<phase>test</phase>
<configuration>
<serverName>managementRestServer-ee10</serverName>
<serverXmlFile>src/test/resources/restServer-with-management-ee10.xml</serverXmlFile>
</configuration>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
Expand Down Expand Up @@ -159,17 +207,69 @@
</configuration>
<executions>
<execution>
<id>wlp-dropins-deployment-test</id>
<id>wlp-dropins-deployment-servlet-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<reportsDirectory>${project.build.directory}/surefire-reports/wlp-dropins-deployment-servlet-test
</reportsDirectory>
<systemPropertyVariables>
<arquillian.launch>wlp-dropins-deployment-servlet</arquillian.launch>
</systemPropertyVariables>
<excludes>
<exclude>**/needsmanagementmbeans/**</exclude>
<exclude>**/needssupportfeature/**</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>wlp-xml-deployment-servlet-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<reportsDirectory>${project.build.directory}/surefire-reports/wlp-xml-deployment-servlet-test</reportsDirectory>
<systemPropertyVariables>
<arquillian.launch>wlp-xml-deployment-servlet</arquillian.launch>
</systemPropertyVariables>
<excludes>
<exclude>**/needsmanagementmbeans/**</exclude>
<exclude>**/needssupportfeature/**</exclude>
</excludes>
</configuration>
</execution>
<execution>
<id>wlp-xml-management-deployment-servlet-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<reportsDirectory>${project.build.directory}/surefire-reports/wlp-dropins-deployment-test
<reportsDirectory>${project.build.directory}/surefire-reports/wlp-xml-management-deployment-servlet-test</reportsDirectory>
<systemPropertyVariables>
<arquillian.launch>wlp-xml-management-deployment-servlet</arquillian.launch>
</systemPropertyVariables>
</configuration>
</execution>

<execution>
<id>wlp-dropins-deployment-rest-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<reportsDirectory>${project.build.directory}/surefire-reports/wlp-dropins-deployment-rest-test
</reportsDirectory>
<systemPropertyVariables>
<arquillian.launch>wlp-dropins-deployment</arquillian.launch>
<arquillian.launch>wlp-dropins-deployment-rest</arquillian.launch>
</systemPropertyVariables>
<excludes>
<exclude>**/needsmanagementmbeans/**</exclude>
Expand All @@ -178,16 +278,16 @@
</configuration>
</execution>
<execution>
<id>wlp-xml-deployment-test</id>
<id>wlp-xml-deployment-rest-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<reportsDirectory>${project.build.directory}/surefire-reports/wlp-xml-deployment-test</reportsDirectory>
<reportsDirectory>${project.build.directory}/surefire-reports/wlp-xml-deployment-rest-test</reportsDirectory>
<systemPropertyVariables>
<arquillian.launch>wlp-xml-deployment</arquillian.launch>
<arquillian.launch>wlp-xml-deployment-rest</arquillian.launch>
</systemPropertyVariables>
<excludes>
<exclude>**/needsmanagementmbeans/**</exclude>
Expand All @@ -196,20 +296,39 @@
</configuration>
</execution>
<execution>
<id>wlp-xml-management-deployment-test</id>
<id>wlp-xml-management-deployment-rest-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<reportsDirectory>${project.build.directory}/surefire-reports/wlp-xml-management-deployment-test</reportsDirectory>
<reportsDirectory>${project.build.directory}/surefire-reports/wlp-xml-management-deployment-rest-test</reportsDirectory>
<systemPropertyVariables>
<arquillian.launch>wlp-xml-management-deployment</arquillian.launch>
<arquillian.launch>wlp-xml-management-deployment-rest</arquillian.launch>
</systemPropertyVariables>
</configuration>
</execution>

<execution>
<id>wlp-xml-management-deployment-rest-ee10-test</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>${skipTests}</skip>
<skip>${skipEE10Tests}</skip>
<reportsDirectory>${project.build.directory}/surefire-reports/wlp-xml-management-deployment-rest-ee10-test</reportsDirectory>
<systemPropertyVariables>
<arquillian.launch>wlp-xml-management-deployment-rest-ee10</arquillian.launch>
</systemPropertyVariables>
<includes>
<include>**/needssupportfeature/**</include>
</includes>
</configuration>
</execution>

</executions>
</plugin>
</plugins>
Expand All @@ -227,6 +346,10 @@
<groupId>org.jboss.arquillian.container</groupId>
<artifactId>arquillian-container-test-spi</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-rest-jakarta</artifactId>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet-jakarta</artifactId>
Expand Down Expand Up @@ -284,8 +407,6 @@
<version>3.0.0</version>
</dependency>



<!-- WELD classes, these are present in FFDC
and are sometimes instances of TCK @ShouldThrow exceptions -->
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ public class WLPManagedContainer implements DeployableContainer<WLPManagedContai
private static final String JAVA_TOOL_OPTIONS = "JAVA_TOOL_OPTIONS";

private static final String ARQUILLIAN_SERVLET_NAME = "ArquillianServletRunnerEE9";
private static final String ARQUILLIAN_REST_NAME = "ArquillianRESTRunnerEE9";

private static final String className = WLPManagedContainer.class.getName();

Expand Down Expand Up @@ -557,23 +558,29 @@ public ProtocolMetaData deploy(final Archive<?> archive) throws DeploymentExcept
// register servlets
boolean addedSomeServlets = false;
for (WebModule module : modules) {
List<String> servlets = getServletNames(module);
for (String servlet : servlets) {
httpContext.add(new Servlet(servlet, module.contextRoot));
addedSomeServlets = true;
}
List<String> servlets = getServletNames(module);
for (String servlet : servlets) {
httpContext.add(new Servlet(servlet, module.contextRoot));
addedSomeServlets = true;
}
}

if (!addedSomeServlets) {
String servletToAdd = null;
if (!containerConfiguration.isServletTestProtocol()) {
servletToAdd = ARQUILLIAN_REST_NAME;
} else if (!addedSomeServlets) {
servletToAdd = ARQUILLIAN_SERVLET_NAME;
}
if (servletToAdd != null) {
// Urk, we found no servlets at all probably because we don't have the J2EE management mbeans
// Make a best guess at where servlets might be. Even if the servlet names are wrong, this at
// least allows basic URL injection to work.
if (modules.size() == 1) {
// If there's only one web module, add that
WebModule m = modules.get(0);
httpContext.add(new Servlet(ARQUILLIAN_SERVLET_NAME, m.contextRoot));
httpContext.add(new Servlet(servletToAdd, m.contextRoot));
} else {
httpContext.add(new Servlet(ARQUILLIAN_SERVLET_NAME, deployName));
httpContext.add(new Servlet(servletToAdd, deployName));
}
}

Expand Down Expand Up @@ -646,7 +653,7 @@ private List<String> getServletNames(WebModule webModule) throws DeploymentExcep
// If we didn't find any servlets and this is a testable archive it ought to
// contain the arquillian test servlet, which is all that most tests need to
// work
if (servletNames.isEmpty() && Testable.isArchiveToTest(webModule.archive)) {
if (containerConfiguration.isServletTestProtocol() && servletNames.isEmpty() && Testable.isArchiveToTest(webModule.archive)) {
servletNames.add(ARQUILLIAN_SERVLET_NAME);
}
return servletNames;
Expand Down Expand Up @@ -1366,7 +1373,7 @@ public ProtocolDescription getDefaultProtocol() {
log.entering(className, "getDefaultProtocol");
}

String defaultProtocol = "Servlet 5.0";
String defaultProtocol = containerConfiguration.isServletTestProtocol() ? "Servlet 5.0" : "REST 3.0";

if (log.isLoggable(Level.FINER)) {
log.exiting(className, "getDefaultProtocol", defaultProtocol);
Expand Down
Loading

0 comments on commit 3944125

Please sign in to comment.