S3Mock
is a lightweight server that implements parts of the Amazon S3 API.
It has been created to support hermetic testing and reduces the infrastructure dependencies while testing.
The mock server can be started as a Docker container or using a JUnit Rule
.
Similiar projects are e.g.:
Run the s3 mock (adjust the port numbers as desired):
mvn clean package docker:start -Ddocker.follow -Dit.s3mock.port_http=9090 -Dit.s3mock.port_https=9191
... stop with ctrl-c.
Build and create the docker container:
mvn clean package
Run the created docker container:
docker run -p 9090:9090 -p 9191:9191 -t adobe/s3mock
... stop with ctrl-c.
The mock can be configured with the following environment parameters:
validKmsKeys
: list of KMS Key-Refs that are to be treated as valid.initialBuckets
: list of names for buckets that will be available initially.
Our integration tests are using the Amazon S3 Client to verify the server functionality against the S3Mock. During the Maven build, the Docker image is started using the docker-maven-plugin and the corresponding ports are passed to the JUnit test through the maven-failsafe-plugin
. See AmazonClientUploadIT
how it's used in the code.
This way, one can easily switch between calling the S3Mock or the real S3 endpoint and this doesn't add any additional Java dependencies to the project.
The test S3MockRuleTest
demonstrates the usage of the S3MockRule
. This requires the Maven artifact to be added to the project in test
scope:
<dependency>
<groupId>com.adobe.testing</groupId>
<artifactId>s3mock</artifactId>
<version>...</version>
<scope>test</scope>
<dependency>
Contributions are welcomed! Read the Contributing Guide for more information.
This project is licensed under the Apache V2 License. See LICENSE for more information.