Last active
February 28, 2018 18:34
-
-
Save thecarlhall/f4e8f425cb736938e1d2 to your computer and use it in GitHub Desktop.
Maven setup for integration testing with DynamoDB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<project> | |
<!-- ... --> | |
<properties> | |
<!-- | |
Choose the region that is closest to you for fastest download. | |
--> | |
<aws.region>us-west-2</aws.region> | |
</properties> | |
<build> | |
<plugins> | |
<!-- | |
Step 1: Downlaod the DynamoDB Local artifact. | |
This will download to a Maven cache on disk and is kept unless the cache is cleared. | |
--> | |
<plugin> | |
<groupId>com.googlecode.maven-download-plugin</groupId> | |
<artifactId>download-maven-plugin</artifactId> | |
<executions> | |
<execution> | |
<id>install-dynamodb_local</id> | |
<phase>pre-integration-test</phase> | |
<goals> | |
<goal>wget</goal> | |
</goals> | |
<configuration> | |
<url>http://dynamodb-local.s3-website-${aws.region}.amazonaws.com/dynamodb_local_latest.zip</url> | |
<unpack>true</unpack> | |
<outputDirectory>${project.build.directory}/dynamodb</outputDirectory> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<!-- | |
Step 2: Reserve a local port for Dynamo to start on. | |
--> | |
<plugin> | |
<groupId>org.codehaus.mojo</groupId> | |
<artifactId>build-helper-maven-plugin</artifactId> | |
<executions> | |
<execution> | |
<goals> | |
<goal>reserve-network-port</goal> | |
</goals> | |
<phase>initialize</phase> | |
<configuration> | |
<portNames> | |
<portName>dynamodblocal.port</portName> | |
</portNames> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<!-- | |
Step 3: Start DynamoDB_Local just before integration tests are run. | |
This plugin will also cleanup the process during the post-integration-test phase. | |
--> | |
<plugin> | |
<groupId>com.bazaarvoice.maven.plugins</groupId> | |
<artifactId>process-exec-maven-plugin</artifactId> | |
<executions> | |
<execution> | |
<id>dynamodb_local</id> | |
<phase>pre-integration-test</phase> | |
<goals> | |
<goal>start</goal> | |
</goals> | |
<configuration> | |
<name>dynamodb_local</name> | |
<waitAfterLaunch>1</waitAfterLaunch> | |
<arguments> | |
<argument>java</argument> | |
<argument>-Djava.library.path=dynamodb/DynamoDBLocal_lib</argument> | |
<argument>-jar</argument> | |
<argument>dynamodb/DynamoDBLocal.jar</argument> | |
<argument>-port</argument> | |
<argument>${dynamodblocal.port}</argument> | |
<argument>-sharedDb</argument> | |
<argument>-inMemory</argument> | |
</arguments> | |
</configuration> | |
</execution> | |
</executions> | |
</plugin> | |
<!-- | |
Step 4: Use the failsafe plugin to run integration tests. | |
--> | |
<plugin> | |
<groupId>org.apache.maven.plugins </groupId> | |
<artifactId>maven-failsafe-plugin</artifactId> | |
<configuration> | |
<systemPropertyVariables> | |
<dynamo.endpoint>http://localhost:${dynamodblocal.port}</dynamo.endpoint> | |
</systemPropertyVariables> | |
</configuration> | |
</plugin> | |
</plugins> | |
</build> | |
</project> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment