Search code examples
javamavendropwizardacceptance-testingmaven-antrun-plugin

Shutdown Dropwizard after starting it from maven for acceptance tests


I'm working on a multimodule maven project. We use dropwizard and in order to execute the acceptance tests we start the application using maven-antrun-plugin but the problem is that the appliction does not stop when the tests are finished then I have to kill the process from the task manager. I googled a lot but without result. Is there any way to do that from maven(for Jenkins)?

I tried with stop goal but it doesn't work:

<execution>
   <id>stop-container</id>
   <phase>post-integration-test</phase>
   <goals>
      <goal>stop</goal>
   </goals>
</execution>

Solution

  • As I didn't find a maven solution, I added a task to drop wizard to make a shutdown then I make an http post to the task using implemented class in the acceptance module.

    <plugin>
      <groupId>org.codehaus.mojo</groupId>
      <artifactId>exec-maven-plugin</artifactId>
      <version>1.3.2</version>
      <executions>
        <execution>
          <id>stop-container</id>
          <phase>post-integration-test</phase>
          <goals>
            <goal>java</goal>
          </goals>
        </execution>
      </executions>
      <configuration>
        <mainClass>your.main.class</mainClass>
      </configuration>
    </plugin>