Integration Testing a Multiuser Application in Spring Download

I have an application consisting of several maven war projects.

I have another maven project that runs JUnit integration tests against a manually launched multi-user application using tomcat using calls to org.springframework.web.client.RestTemplate.

However, I would like my integration testing project to actually run a multi-user application (once during the whole package) before running my tests ... in spring-boot!

From my integration project, I would like to be able to run all military projects together as a spring-boot application, each with its own contextPath (for example, localhost: 8080 / a for project "a", localhost: 8080 / b for project 'b ', etc.) and without changing the original military projects (which are not (yet) spring-boot aware). If I cannot make these projects run from my spring-boot integration project without changing them, I would at least want to minimize the use of spring-boot dependencies and configurations in packaged war files ... as much as possible.

I was able to get an integration project to depend on one military project, run it and run tests against it ... but I could not get two military projects working together in spring-boot under a separate context ..

Any suggestions are welcome!

Here are some of the resources I used to combine:

+6
source share
1 answer

As per Andy's suggestion, I went with the Tomcat7 Maven plugin and everything worked out just fine. The Jetty Maven plugin was another option (and a better documented IMO), although I could not find a way to avoid providing a β€œpath” to my WAR files. Tomcat7 Maven plugin, let me download my WARs from my local .m2 repository. I should also say that the following links were helpful ...

Here is part of my pom project integration project ...

<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <version>2.17</version> <configuration> <skipTests>true</skipTests> </configuration> </plugin> <plugin> <artifactId>maven-failsafe-plugin</artifactId> <version>2.17</version> <configuration> <includes> <include>**/*Test*</include> </includes> </configuration> <executions> <execution> <goals> <goal>integration-test</goal> <goal>verify</goal> </goals> </execution> </executions> </plugin> <plugin> <groupId>org.apache.tomcat.maven</groupId> <artifactId>tomcat7-maven-plugin</artifactId> <version>2.2</version> <configuration> <path>/</path> <webapps> <webapp> <groupId>com.mycompany</groupId> <artifactId>app1</artifactId> <version>${project.version}</version> <type>war</type> <asWebapp>true</asWebapp> </webapp> <webapp> <groupId>com.mycompany</groupId> <artifactId>app2</artifactId> <version>${project.version}</version> <type>war</type> <asWebapp>true</asWebapp> </webapp> </webapps> </configuration> <executions> <execution> <id>start-tomcat</id> <phase>pre-integration-test</phase> <goals> <goal>run-war</goal> </goals> <configuration> <fork>true</fork> </configuration> </execution> <execution> <id>stop-tomcat</id> <phase>post-integration-test</phase> <goals> <goal>shutdown</goal> </goals> </execution> </executions> </plugin> </plugins> </build> 
+6
source

Source: https://habr.com/ru/post/976121/


All Articles