Maven deploy multiple wars to embedded server for integration tests - maven

I have had no issue running a maven war project on an embedded server for its own integration tests, but now I need to run multiple wars and test from a different project.
I would like to setup the following scenario...
I have two Maven war projects in my local workspace called War1 and War2. I would like to have a 3rd Maven project, WarIntegration, that contains only integration tests and does the following:
Packages War1
Packages War2
Starts an embedded server
Deploys both wars to same embedded server
Runs integration tests contained within WarIntegration (which will make http calls to War1 and War2)
Stops embedded server
Is this possible? What plugin setup will achieve this? What kind of project should WarIntergration be (packaging)? Should War1 and War2 be modules in WarIntegration or dependencies? Can all of the configuration be aded to the WarIntegration project or would it have to be spread across the projects?
This is similar to this question, except we must use an embedded server that is started and stopped by the project (probably when we run verify) and we need a separate project for integration tests:
I have a multi-module Maven 2 POM that has two WARs, how can I configure it to deploy both wars prior to running tests?

I was able to achieve this using the cargo-maven2-plugin.
Here are the relevant pieces of the pom for anyone who is interested...
...
<groupId>com.test</groupId>
<artifactId>webapp-integration</artifactId>
<packaging>jar</packaging>
<version>1.0-SNAPSHOT</version>
...
<dependencies>
...
<dependency>
<artifactId>webapp1</artifactId>
<groupId>com.test</groupId>
<version>1.0</version>
<type>war</type>
</dependency>
<dependency>
<groupId>webapp2</groupId>
<artifactId>com.test</artifactId>
<version>1.0-SNAPSHOT</version>
<type>war</type>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<container>
<containerId>jetty6x</containerId>
<type>embedded</type>
</container>
<configuration>
<type>standalone</type>
<properties>
<cargo.servlet.port>8085</cargo.servlet.port>
</properties>
<deployables>
<deployable>
<artifactId>webapp1</artifactId>
<groupId>com.test</groupId>
<type>war</type>
<pingURL>http://localhost:8085/testapp/</pingURL>
<properties>
<context>testapp</context>
</properties>
</deployable>
<deployable>
<artifactId>webapp2</artifactId>
<groupId>com.test</groupId>
<type>war</type>
<pingURL>http://localhost:8085/testapp2/</pingURL>
<properties>
<context>testapp2</context>
</properties>
</deployable>
</deployables>
</configuration>
</configuration>
<executions>
<execution>
<id>start-server</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-server</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.12</version>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.12</version>
</dependency>
</dependencies>
<configuration>
<groups>com.test.integration.IntegrationTestMarker</groups>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
</goals>
<configuration>
<includes>
<include>**/*.class</include>
</includes>
<skipTests>false</skipTests>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>

Watch out, the DEPLOYABLES element is a child of plugin/configuration, NOT plugin/configuration/configuration.
The example above should be :
<plugins>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.2.2</version>
<configuration>
<container>...</container>
<configuration>
<type>standalone</type>
<properties>
<cargo.servlet.port>8085</cargo.servlet.port>
</properties>
</configuration>
<deployables>
<deployable>
<artifactId>webapp1</artifactId>
<groupId>com.test</groupId>
<type>war</type>
<pingURL>http://localhost:8085/testapp/</pingURL>
<properties>
<context>testapp</context>
</properties>
</deployable>
<deployable>
<artifactId>webapp2</artifactId>
<groupId>com.test</groupId>
<type>war</type>
<pingURL>http://localhost:8085/testapp2/</pingURL>
<properties>
<context>testapp2</context>
</properties>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
Hope that helps !

Related

Maven release: Developer information missing

Getting this error on mvn release:perform
[ERROR] Repository "comconvertapi-1002" failures
[ERROR] Rule "pom-staging" failures
[ERROR] * Invalid POM: /com/convertapi/client/convertapi/1.7/convertapi-1.7.pom: Developer information missing
Releasing from branch: https://github.com/ConvertAPI/convertapi-java/tree/feature/maven (could this error be related with that?)
This is POM file:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.convertapi.client</groupId>
<artifactId>convertapi</artifactId>
<packaging>jar</packaging>
<version>1.8-SNAPSHOT</version>
<name>ConvertAPI Java Client</name>
<description>
The ConvertAPI helps converting various file formats.
Creating PDF and Images from various sources like Word, Excel, Powerpoint, images, web pages or raw HTML codes.
Merge, Encrypt, Split, Repair and Decrypt PDF files.
And many others files manipulations.
In just few minutes you can integrate it into your application and use it easily.
The ConvertAPI client library makes it easier to use the Convert API from your Java 8 projects without having to
build your own API calls.
</description>
<url>https://www.convertapi.com/</url>
<licenses>
<license>
<name>The MIT License</name>
<url>https://raw.githubusercontent.com/ConvertAPI/convertapi-java/master/LICENSE.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>jonas</id>
<name>Jonas Jasas</name>
<email>jonas#baltsoft.com</email>
<organization>Baltsoft</organization>
<organizationUrl>http://www.baltsoft.com/</organizationUrl>
<roles>
<role>architect</role>
<role>developer</role>
</roles>
<timezone>+3</timezone>
<properties>
<picUrl>https://avatars3.githubusercontent.com/u/16254748</picUrl>
</properties>
</developer>
</developers>
<scm>
<connection>scm:git:git://github.com/ConvertAPI/convertapi-java.git</connection>
<developerConnection>scm:git:git://github.com/ConvertAPI/convertapi-java.git</developerConnection>
<url>https://github.com/ConvertAPI/convertapi-java</url>
<tag>HEAD</tag>
</scm>
<distributionManagement>
<snapshotRepository>
<id>ossrh</id>
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
</snapshotRepository>
<repository>
<id>ossrh</id>
<url>https://oss.sonatype.org/service/local/staging/deploy/maven2/</url>
</repository>
</distributionManagement>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<dependencies>
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.8.5</version>
</dependency>
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>okhttp</artifactId>
<version>3.10.0</version>
</dependency>
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<excludes>
<exclude>**/examples/*</exclude>
</excludes>
<filtering>false</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
<executions>
<execution>
<id>default-deploy</id>
<phase>deploy</phase>
<goals>
<goal>deploy</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-release-plugin</artifactId>
<version>2.5.3</version>
<configuration>
<localCheckout>true</localCheckout>
<pushChanges>false</pushChanges>
<mavenExecutorId>forked-path</mavenExecutorId>
<arguments>-Dgpg.passphrase=${gpg.passphrase}</arguments>
</configuration>
<dependencies>
<dependency>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9.5</version>
</dependency>
</dependencies>
</plugin>
<plugin>
<groupId>org.sonatype.plugins</groupId>
<artifactId>nexus-staging-maven-plugin</artifactId>
<version>1.6.7</version>
<extensions>true</extensions>
<configuration>
<serverId>ossrh</serverId>
<nexusUrl>https://oss.sonatype.org/</nexusUrl>
<autoReleaseAfterClose>true</autoReleaseAfterClose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.0.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<!-- GPG Signature on release -->
<profile>
<id>release-sign-artifacts</id>
<activation>
<property>
<name>performRelease</name>
<value>true</value>
</property>
</activation>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
It's seem ok, but sometime maven plugins use cache for some info.
Try to clear cache by this sequence of commands:
mvn clean
mvn release:prepare -Dresume=false
mvn release:perform
If it not helped, try to simplify developer section (excluding sequentially properties, timezone and so on)
Publish Requirement
Please check you have fulfill all your publish requirement.
Supply Javadoc and Sources⚓︎
Sign Files with GPG/PGP
Sufficient Metadata
Correct Coordinates
Project Name, Description and URL
License Information
Developer Information
SCM Information

Pass port number from docker-maven-plugin to spring property

I'm developing Spring Data JPA project that targets a MySQL database, and I want to run end-to-end integration tests from Maven.
So far, I've configured io.fabric8.docker-maven-plugin to spin up a MySQL container during pre-integration-test phase. It will use a random available port, which I need to pass to my application.properties file.
I've tried Automatic property expansion using Maven but I suspect that the mysql.port maven property is only getting resolved after the spring properties are getting updated.
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>example</groupId>
<artifactId>pass-port-number-from-docker-maven-plugin-to-spring-property</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.6.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
<!-- other jpa dependencies ... -->
</dependencies>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>docker-test</id>
<properties>
<docker-maven.version>0.21.0</docker-maven.version>
</properties>
<build>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>3.0.0</version>
<executions>
<execution>
<id>reserve-network-port</id>
<goals>
<goal>reserve-network-port</goal>
</goals>
<phase>process-resources</phase>
<configuration>
<portNames>
<portName>mysql.port</portName>
</portNames>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>${docker-maven.version}</version>
<configuration>
<images>
<image>
<alias>mysql</alias>
<name>mysql:5.7</name>
<run>
<env>
<MYSQL_ROOT_PASSWORD>my-secret-pw</MYSQL_ROOT_PASSWORD>
</env>
<ports>
<port>mysql.port:3306</port>
</ports>
<wait>
<log>ready for connections</log>
<!-- <time>20000</time> -->
</wait>
<log>
<prefix>mysql</prefix>
<date>ISO8601</date>
<color>blue</color>
</log>
</run>
</image>
</images>
</configuration>
<!-- Connect start/stop to pre- and
post-integration-test phase, respectively if you want to start
your docker containers during integration tests -->
<executions>
<execution>
<id>start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>
application.properties
mysql.port = #mysql.port#
When I run my test I get a connection error, and when I inspect target/classes/application.properties I see that #mysql.port# hasn't been updated.
Any suggestions would be much appreciated.
# only works if you extend from spring-boot-starter-parent; you didn't show the relevant portions of your pom.xml. Assuming you did that, try attaching reserve-network-port to process-sources phase, before process-resources. It's very possible that when Maven copies the resources, the reserve-network-port hasn't ran yet.
What happens if you hardcode 3306 in application.properties?

How to run maven test with mysql running in docker

I have a maven java project. I need to run a mysql docker image in maven test stage to run tests and when its done i can remove mysql docker image.
One example would be to use the Docker Maven Plugin (https://dmp.fabric8.io/). Here is an example pom that would start a MySQL container, do your integration tests using the Maven Failsafe Plugin, then stop the MySQL container. It also would pass the property mysql.jdbc.url to the tests so they have the right JDBC URL to the MySQL container running on the specific Docker host (which could be different depending how you are running Docker).
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.example</groupId>
<artifactId>demo</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
<name>demo</name>
<description>Demo project for Spring Boot</description>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.3.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
</configuration>
</plugin>
<plugin>
<groupId>io.fabric8</groupId>
<artifactId>docker-maven-plugin</artifactId>
<version>0.20.1</version>
<extensions>true</extensions>
<configuration>
<images>
<image>
<alias>database</alias>
<name>mysql:5.7</name>
<run>
<wait>
<log>mysqld: ready for connections</log>
<time>20000</time>
</wait>
<env>
<MYSQL_ROOT_PASSWORD>abc123</MYSQL_ROOT_PASSWORD>
<MYSQL_DATABASE>testdb</MYSQL_DATABASE>
<MYSQL_USER>mysql</MYSQL_USER>
<MYSQL_PASSWORD>mysql</MYSQL_PASSWORD>
</env>
<ports>
<port>3306:3306</port>
</ports>
</run>
</image>
<image>
<name>mvndemo</name>
<build>
<from>java:8-jre</from>
<assembly>
<descriptorRef>artifact</descriptorRef>
</assembly>
</build>
</image>
</images>
</configuration>
<executions>
<execution>
<id>docker:start</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>docker:stop</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<executions>
<execution>
<id>integration-test</id>
<goals>
<goal>integration-test</goal>
</goals>
</execution>
<execution>
<id>verify</id>
<goals>
<goal>verify</goal>
</goals>
</execution>
</executions>
<configuration>
<systemPropertyVariables>
<mysql.jdbc.url>jdbc:mysql://${docker.host.address}/testdb</mysql.jdbc.url>
</systemPropertyVariables>
</configuration>
</plugin>
</plugins>
</build>
</project>
You can also opt for Testcontainers you will need to change the driver to a specific JDBC driver from testcontainer that will do the spinning up and spinning down of your required service. They also support other databases and versions. It is quite easy to do. You also get the option to startup and stop the container yourself from within a junit test if you need advanced stuff like initialization scripts.

Can I use Maven Cargo plugin to deploy a WAR to 2 different servers (production and dev stages)?

I have a project with a Maven Cargo plugin configuration shown below. When I run mvn cargo:redeploy, it deploys the current version of the application to server at AAA.BBB.CCC.DDD.
Now I want to add a second server, say EEE.FFF.GGG.HHH. EEE.FFF.GGG.HHH will be the production server and AAA.BBB.CCC.DDD - the development/test stage.
Is it possible to use mvn cargo:redeploy to deploy the application to different servers (production and test, EEE.FFF.GGG.HHH and AAA.BBB.CCC.DDD) ? If yes, how should I modify Cargo's plugin configuration below?
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.mycompany</groupId>
<artifactId>my-product</artifactId>
<packaging>war</packaging>
<version>[...]</version>
<name>my-product</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<powermock.version>1.5</powermock.version>
</properties>
<build>
<finalName>${project.artifactId}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.6</source>
<target>1.6</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.3.3</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>user name</cargo.remote.username>
<cargo.remote.password>password</cargo.remote.password>
<cargo.hostname>AAA.BBB.CCC.DDD</cargo.hostname>
<cargo.protocol>http</cargo.protocol>
<cargo.servlet.port>8080</cargo.servlet.port>
</properties>
</configuration>
<!-- Deployer configuration -->
<deployer>
<type>remote</type>
</deployer>
<deployables>
<deployable>
<groupId>com.mycompany</groupId>
<artifactId>my-product</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
</build>
As indicated by #wemu, you can put many executions in your plugin configuration as following :
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.3.3</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<!-- Deployer configuration -->
<deployer>
<type>remote</type>
</deployer>
<deployables>
<deployable>
<groupId>com.mycompany</groupId>
<artifactId>my-product</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
<executions>
<!-- First execution to deploy on AAA.BBB.CCC.DDD -->
<execution>
<id>deploy1</id>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>user name 1</cargo.remote.username>
<cargo.remote.password>password 1</cargo.remote.password>
<cargo.hostname>AAA.BBB.CCC.DDD</cargo.hostname>
<cargo.protocol>http</cargo.protocol>
<cargo.servlet.port>8080</cargo.servlet.port>
</properties>
</configuration>
</execution>
<!-- Second execution to deploy on EEE.FFF.GGG.HHH -->
<execution>
<id>deploy2</id>
<configuration>
<type>runtime</type>
<properties>
<cargo.remote.username>user name 2</cargo.remote.username>
<cargo.remote.password>password 2</cargo.remote.password>
<cargo.hostname>EEE.FFF.GGG.HHH</cargo.hostname>
<cargo.protocol>http</cargo.protocol>
<cargo.servlet.port>8080</cargo.servlet.port>
</properties>
</configuration>
</execution>
</executions>
</plugin>
And you can even mutualize some configuration elements outside of the executions like that if you need to add more executions you just have to change the user password and IP adress :
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.3.3</version>
<configuration>
<container>
<containerId>tomcat7x</containerId>
<type>remote</type>
</container>
<!-- Common configuration -->
<configuration>
<type>runtime</type>
<properties>
<cargo.protocol>http</cargo.protocol>
<cargo.servlet.port>8080</cargo.servlet.port>
</properties>
</configuration>
<!-- Deployer configuration -->
<deployer>
<type>remote</type>
</deployer>
<deployables>
<deployable>
<groupId>com.mycompany</groupId>
<artifactId>my-product</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
<executions>
<!-- First execution to deploy on AAA.BBB.CCC.DDD -->
<execution>
<id>deploy1</id>
<configuration>
<properties>
<cargo.remote.username>user name 1</cargo.remote.username>
<cargo.remote.password>password 1</cargo.remote.password>
<cargo.hostname>AAA.BBB.CCC.DDD</cargo.hostname>
</properties>
</configuration>
</execution>
<!-- Second execution to deploy on EEE.FFF.GGG.HHH -->
<execution>
<id>deploy2</id>
<configuration>
<properties>
<cargo.remote.username>user name 2</cargo.remote.username>
<cargo.remote.password>password 2</cargo.remote.password>
<cargo.hostname>EEE.FFF.GGG.HHH</cargo.hostname>
</properties>
</configuration>
</execution>
</executions>
</plugin>

JMS config settings for jetty deployment using cargo

We have a current web application that is deployed to OAS (Oracle Application Server).
I am trying to implement some functional tests using selenium for this application. I created a new maven project specifically for functional testing, which uses cargo to deploy the application war file (webapp-site.war) to the default container provided by cargo (Jetty). pom.xml attached at the end.
The problem I am facing is in trying to configure jms properties. The current setting in the web application uses OAS specific values from an environment specific jms.properties file (shown below):
java.naming.factory.initial=oracle.j2ee.rmi.RMIInitialContextFactory
java.naming.provider.url=opmn:ormi://localhost:6003:OC4J_DEV/default
java.naming.security.principal=username
java.naming.security.credentials=password
jms.queue.connection.factory.jndi=jms/QueueConnectionFactory
When I start up jetty using cargo, the deployment of the application war fails when it looks for the "RMIInitialContextFactory" and does not find it. This is an OAS specific jar which is not available in the global maven repository. I managed to download and install this jar in the local maven repo, but then it showed a missing class from another oracle specific jar not present in the global maven repo. Also, even I resolved all such dependencies to external jar, I am unsure of how it would perform with Jetty.
It would be really helpful to know how to configure these properties in cargo specific to jetty and have it picked up by the deployable application war.
Attaching the pom.xml of the functional test module below:
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>webapp-automation</artifactId>
<packaging>jar</packaging>
<url>http://maven.apache.org</url>
<parent>
<groupId>com.webapp</groupId>
<artifactId>webapp</artifactId>
<version>11.0.5</version>
</parent>
<name>Functional tests for webapp</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<servlet.port>9090</servlet.port>
<seleniumHost>localhost</seleniumHost>
<seleniumPort>4444</seleniumPort>
<selenium.version>2.3</selenium.version>
<selenium.background>true</selenium.background>
</properties>
<dependencies>
<dependency>
<groupId>com.webap</groupId>
<artifactId>webapp-site</artifactId>
<type>war</type>
<version>${project.version.number}</version>
</dependency>
<dependency>
<groupId>org.seleniumhq.selenium</groupId>
<artifactId>selenium-java</artifactId>
<version>2.42.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
<version>10.2.0.5</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.8.1</version>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<version>${selenium.version}</version>
</plugin>
<!-- CARGO is used to deploy the RAPS application for functional testing -->
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<version>1.4.2</version>
<configuration>
<container>
<dependencies>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc14</artifactId>
</dependency>
</dependencies>
</container>
<configuration>
<properties>
<cargo.servlet.port>${servlet.port}</cargo.servlet.port>
<cargo.datasource.datasource.ojdbc14>
cargo.datasource.driver=oracle.jdbc.driver.OracleDriver|
cargo.datasource.url=jdbc:oracle:thin:#deirbned01.deir.citec.qld.gov.au:1521:RAPSDEV|
cargo.datasource.jndi=jdbc/RAPSDS|
cargo.datasource.username=RAPS_9|
cargo.datasource.password=sm4u
</cargo.datasource.datasource.ojdbc14>
</properties>
</configuration>
<deployables>
<deployable>
<groupId>com.webapp</groupId>
<artifactId>webapp-site</artifactId>
<type>war</type>
</deployable>
</deployables>
</configuration>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- Skip the normal tests, we'll run them in the integration-test phase -->
<skip>true</skip>
</configuration>
<executions>
<execution>
<phase>integration-test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<skip>false</skip>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.cargo</groupId>
<artifactId>cargo-maven2-plugin</artifactId>
<executions>
<execution>
<id>start-cargo</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start</goal>
</goals>
</execution>
<execution>
<id>stop-cargo</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>selenium-maven-plugin</artifactId>
<executions>
<execution>
<id>start-selenium</id>
<phase>pre-integration-test</phase>
<goals>
<goal>start-server</goal>
</goals>
</execution>
<execution>
<id>stop-selenium</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop-server</goal>
</goals>
</execution>
</executions>
<configuration>
<background>${selenium.background}</background>
<port>${selenium.port}</port>
<logOutput>true</logOutput>
</configuration>
</plugin>
</plugins>
</build>
Any help would be great !!
Cheers,
Rahul
I found a way of solving the problem.
We use some environment specific settings in the project. I created a new environment profile in the build for functional tests and created a new jms.properties with the initial context factory pointing to the one provided by jetty.
It worked.
Cheers,
Rahul

Resources