Table of Contents
Note
|
This documentation is for the HEAD of the repository.
To see documentation at a specific version see the GitHub Releases page
|
Add as a dependency
repositories {
jcenter()
// You will also need a repository to retrieve the DynamoDB Local transitive dependencies.
// These are listed on https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html
maven {
description = "Repository from US West 2 - https://docs.aws.amazon.com/amazondynamodb/latest/developerguide/DynamoDBLocal.html"
name = "dynamodb-local-oregon"
url = uri("https://s3-us-west-2.amazonaws.com/dynamodb-local/release")
}
}
dependencies {
testImplementation("com.mkobit.junit.jupiter.aws:junit5-dynamodb-local-extension:x.x.x")
}
Note
|
The extension modifies the sqlite4java.library.path JVM system property.
An explanation for why can be found on this Stack Overflow question and answers.
|
The extension will create a new embedded DynamoDB instance for each test. It attempts to locate the native dependencies on the classpath, place them into a temporary directory, and then set a system property before creating the database for test injection.
Annotate your test class or methods with @DynamoDBLocal
and have one of the supported types automatically injected for use in your test.
It will be torn down afterwards.
Example showing different types that can be injected.
import com.mkobit.junit.jupiter.aws.dynamodb.DynamoDBLocal;
import com.amazonaws.services.dynamodbv2.AmazonDynamoDB
import com.amazonaws.services.dynamodbv2.AmazonDynamoDBStreams
import com.amazonaws.services.dynamodbv2.local.shared.access.AmazonDynamoDBLocal
@DynamoDBLocal
class MyDynamoDbTest {
@Test
void usingAmazonDynamoDBLocal(final AmazonDynamoDBLocal amazonDynamoDBLocal) {
}
@Test
void usingAmazonDynamoDB(final AmazonDynamoDB amazonDynamoDB) {
}
@Test
void usingAmazonDynamoDBStreams(final AmazonDynamoDBStreams amazonDynamoDBStreams) {
}
}