LifeStartsAtHelloWorld
LifeStartsAtHelloWorld

Reputation: 979

Implement tomcat in java to deploy war

I am trying to deploy my war using tomcat (implement in java) before running my functional test. Initially I implemented Jetty Server in java and I successfully exposed the URI and I could execute my test. But I want to deploy my war to test it and not just expose the URI,I can obviously use jetty plugin and cargo in my pom file, but I want to use tomcat to do so. I thoroughly searched online, I found sample code on deploying war using tomcat implementation in java [1], so that I can start tomcat, deploy my war and then run my functional test. But it is not clearly explained. Can I refer to any good documentation online which will help me with deploying my war using tomcat?

[1] http://www.programcreek.com/java-api-examples/index.php?api=org.apache.catalina.startup.Tomcat

Upvotes: 0

Views: 166

Answers (1)

redge
redge

Reputation: 1192

Depending on your level of testing the recommended maven approach would be one of the following

For unit tests Put any startup of maven and possibly deployment in the pretest phase

  • process-test-classes

Then run the tests in the test phase

  • test

This approach will work if the unit tests themselves need to be deployed to tomcat to run small parts of the code base note there is no way here to shutdown tomcat you will need to find a phase to bind the shutdown to.

For integration tests that need to run the whole war file Put any startup of maven and possibly deployment in the pre-test phases

  • pre-integration-test

Run the test in the test phase

  • integration-test

Undeploy and shutdown during the post test phase

  • post-integration-test

Under this scenario the link you included in your question becomes relevant.

Upvotes: 2

Related Questions