0

I have a series of Servlets and Servlet Filters in a maven project that are packaged into a jar and that jar is meant to be included in the /lib directory of a series of other "host" web applications. These Servlets are not meant to be run alone - and do not warrant their own war (it is not a stand-alone web app).

In my src/test/java directory I have some Mock objects that loosely mimic these "host" applications.

I am using cargo during my integration-test phase to start up an instance of tomcat, but I am having a hard time getting tomcat to use my mock "host" servlets in src/test/java.

Is there a recommended way to do this? Do I need to build a war from the sources in src/test/java first?

Also, I will need to move my actual project's jar to WEB-INF/lib before starting the container. I had considered using the maven assembly plugin to do this? Is there a way to do this with just cargo configuration options?

Thank you so much for any input.

D Parsin
  • 731
  • 2
  • 7
  • 17

2 Answers2

0

Yes, you must build a WAR for this.

Cargo deploys what the container understands, and that is either WAR or EAR files, but not JAR files.

Axel Fontaine
  • 34,542
  • 16
  • 106
  • 137
0

What I ended up doing was using the maven-war-plugin on the pre-integration-test phase to build a war.

I then used the maven-dependency-plugin to copy some needed dependencies to the war build location.

And then I pointed cargo at that new war location for the integration tests.

That way when I do mvn package, I get a jar with all of the classes that I want packaged, and when I run mvn integration-test I get a war that cargo starts up as a test harness. It worked out pretty well.

Thank you for looking at my question.

D Parsin
  • 731
  • 2
  • 7
  • 17