Skip to content

Instantly share code, notes, and snippets.

@ddossot
Last active April 6, 2018 11:56
Show Gist options
  • Save ddossot/277699b86d0748639a95 to your computer and use it in GitHub Desktop.
Save ddossot/277699b86d0748639a95 to your computer and use it in GitHub Desktop.
Integration tests with REST Assured and Jetty
@BeforeClass
public static void configureRestAssured() throws Exception
{
RestAssured.port = Integer.getInteger("api.server.port");
RestAssured.basePath = System.getProperty("api.server.path") + "/api/v1";
}
<plugin>
<groupId>org.eclipse.jetty</groupId>
<artifactId>jetty-maven-plugin</artifactId>
<version>${jetty-plugin.version}</version>
<configuration>
<webApp>
<contextPath>${local.server.path}</contextPath>
</webApp>
<httpConnector>
<port>${local.server.port}</port>
</httpConnector>
<stopKey>rest-tests-jetty</stopKey>
<stopPort>${local.server.stop-port}</stopPort>
</configuration>
<executions>
<execution>
<id>start-jetty</id>
<phase>pre-integration-test</phase>
<goals>
<goal>deploy-war</goal>
</goals>
<configuration>
<daemon>true</daemon>
<scanIntervalSeconds>0</scanIntervalSeconds>
</configuration>
</execution>
<execution>
<id>stop-jetty</id>
<phase>post-integration-test</phase>
<goals>
<goal>stop</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<version>2.17</version>
<configuration>
<systemPropertyVariables>
<api.server.port>${local.server.port}</api.server.port>
<api.server.path>${local.server.path}</api.server.path>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
<goals>
<goal>integration-test</goal>
<goal>verify</goal>
</goals>
</execution>
</executions>
</plugin>
<jetty-plugin.version>9.2.2.v20140723</jetty-plugin.version>
<local.server.port>8889</local.server.port>
<local.server.path>/<_something that makes sense_></local.server.path>
<local.server.stop-port>8899</local.server.stop-port>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment