All Projects → redskap → aws-dynamodb-java-example-local-testing

redskap / aws-dynamodb-java-example-local-testing

Licence: Apache-2.0 License
Example Gradle Java project for using AWS DynamoDB for local testing.

Programming Languages

java
68154 projects - #9 most used programming language

Projects that are alternatives of or similar to aws-dynamodb-java-example-local-testing

react-native-appsync-s3
React Native app for image uploads to S3 and storing their records in Amazon DynamoDB using AWS Amplify and AppSync SDK
Stars: ✭ 18 (-18.18%)
Mutual labels:  dynamodb, aws-dynamodb
telegram-stepfunctions-bot
Serverless Telegram bot made on 4 AWS Lambda chained by AWS Step Functions. All of this written on Serverless Framework using plugins.
Stars: ✭ 26 (+18.18%)
Mutual labels:  dynamodb, aws-dynamodb
dynamodb-manager
A Dynamodb admin & manager GUI for DynamoDB Local and remote.
Stars: ✭ 114 (+418.18%)
Mutual labels:  dynamodb, dynamodb-local
DynamodbToCSV4j
Dump DynamoDB data into a CSV file using java
Stars: ✭ 18 (-18.18%)
Mutual labels:  dynamodb, aws-dynamodb
cognito-to-dynamodb-lambda
Copy newly-confirmed users from Cognito to DynamoDB
Stars: ✭ 68 (+209.09%)
Mutual labels:  dynamodb, aws-dynamodb
typedorm
Strongly typed ORM for DynamoDB - Built with the single-table-design pattern in mind.
Stars: ✭ 224 (+918.18%)
Mutual labels:  dynamodb, aws-dynamodb
terraform-aws-backup
Terraform module to provision AWS Backup, a fully managed backup service that makes it easy to centralize and automate the back up of data across AWS services such as EBS volumes, RDS databases, DynamoDB tables, EFS file systems, and AWS Storage Gateway volumes.
Stars: ✭ 62 (+181.82%)
Mutual labels:  dynamodb, aws-dynamodb
dynamodb-simple
Type-safe Haskell framework for AWS DynamoDB
Stars: ✭ 16 (-27.27%)
Mutual labels:  dynamodb, aws-dynamodb
serverless-todo-demo
Serverless todo web app demo
Stars: ✭ 64 (+190.91%)
Mutual labels:  dynamodb
hyper-kube-config
H Y P E R K U B E - A Serverless API and kubectl plugin providing a storage and retrieval Kubernetes cluster credentials. Hyperkube leverages AWS Secrets Manager for storing credential information.
Stars: ✭ 27 (+22.73%)
Mutual labels:  dynamodb
go-dynamodb-stream-subscriber
Go channel for streaming Dynamodb Updates
Stars: ✭ 29 (+31.82%)
Mutual labels:  aws-dynamodb
serverless-dynamodb-ttl
⚡️ Serverless Plugin to set DynamoDB TTL
Stars: ✭ 16 (-27.27%)
Mutual labels:  dynamodb
twitter
A serverless social network that's under development with some cool stuff, such as Serverless Framework, AppSync, GraphQL, Lambda, DynamoDB, Cognito, Kinesis Firehose, and Algolia ☁️
Stars: ✭ 29 (+31.82%)
Mutual labels:  dynamodb
serverless-grocery-app
Grocery Purchase app with serverless AWS Lambda + DynamoDB + React
Stars: ✭ 28 (+27.27%)
Mutual labels:  dynamodb
Dracker
An iOS and React App to track debt and send/receive payments.
Stars: ✭ 22 (+0%)
Mutual labels:  aws-dynamodb
api-lambda-save-dynamodb
Deploy instantly on Serverless Application Repository
Stars: ✭ 55 (+150%)
Mutual labels:  dynamodb
dynamodb-api
DynamoDB API wrapper gem. like SQL and simply.
Stars: ✭ 15 (-31.82%)
Mutual labels:  dynamodb
dynamoc
A DynamoDB GUI client https://ieiayaobb.github.io/dynamoc/
Stars: ✭ 70 (+218.18%)
Mutual labels:  dynamodb
graphql-pynamodb
Graphene PynamoDB Integration
Stars: ✭ 63 (+186.36%)
Mutual labels:  dynamodb
super-serverless-sample
Backend serverless que simula o sistema de votação do BBB
Stars: ✭ 30 (+36.36%)
Mutual labels:  dynamodb

AWS DynamoDB Java Local Testing Example Build Status

Example Gradle Java project for using embedded AWS DynamoDB for local testing.

The official AWS DynamoDB example shows you how to use AWS DynamoDB with Maven, but it does not contain details about Gradle setup or how to run tests from your IDE (e.g.: IntelliJ IDEA). This example provides details about these missing areas.

You only need to call AwsDynamoDbLocalTestUtils#initSqLite() in test classes before you plan to use the local database. You can find detailed description below about setting up local testing.

You can copy the content to reuse it in your own project.

Setting Up DynamoDB Local with Gradle

AWS DynamoDB documentation has a detailed description about Setting Up DynamoDB Local, but it does not mention Gradle setup.

You can find a working setup in build.gradle file (with EU repositories).

For each regions, first you need to set the proper repository:

  • repositories {
        mavenCentral()
    
        maven {
            name "DynamoDB Local Release Repository - Asia Pacific (Mumbai) Region"
            url "https://s3.ap-south-1.amazonaws.com/dynamodb-local-mumbai/release"
        }
    }
  • repositories {
        mavenCentral()
      
        maven {
            name "DynamoDB Local Release Repository - Asia Pacific (Singapore) Region"
            url "https://s3-ap-southeast-1.amazonaws.com/dynamodb-local-singapore/release"
        }
    }
  • repositories {
        mavenCentral()
    
        maven {
            name "DynamoDB Local Release Repository - Asia Pacific (Tokyo) Region"
            url "https://s3-ap-northeast-1.amazonaws.com/dynamodb-local-tokyo/release"
        }
    }
  • repositories {
        mavenCentral()
    
        maven {
            name "DynamoDB Local Release Repository - EU (Frankfurt) Region"
            url "https://s3.eu-central-1.amazonaws.com/dynamodb-local-frankfurt/release"
        }
    }
  • repositories {
        mavenCentral()
     
        maven {
            name "DynamoDB Local Release Repository - South America (São Paulo) Region"
            url "https://s3-sa-east-1.amazonaws.com/dynamodb-local-sao-paulo"
        }
    }
  • repositories {
        mavenCentral()
    
        maven {
            name "DynamoDB Local Release Repository - US West (Oregon) Region"
            url "https://s3-us-west-2.amazonaws.com/dynamodb-local/release"
        }
    }

Then set the dependency:

dependencies {
    testCompile group: 'com.amazonaws', name: 'DynamoDBLocal', version: '1.11.119'
}

You can get the version numbers from each regions:

Initialize sqlite4java for testing

AWS DynamoDB provides possibility to test locally and it requires sqlite4java.library.path system property to be set. In the official example it is set for the Maven project.

If you run it from Gradle or from your IDE, local database might not start as the sqlite4java native libraries are not available. These are downloaded as a dependency of DynamoDBLocal artifact, but it is not visible by default. Sqlite4java loads it from the path defined by sqlite4java.library.path system property.

If it is not set or not valid, you probably see something similar in the logs:

WARNING: [sqlite] cannot open DB[1]: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: no sqlite4java-linux-i386-1.0.392 in java.library.path
SEVERE: [sqlite] SQLiteQueue[]: error running job queue
com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: no sqlite4java-linux-i386-1.0.392 in java.library.path
Caused by: java.lang.UnsatisfiedLinkError: no sqlite4java-linux-i386-1.0.392 in java.library.path
SEVERE: [sqlite] SQLiteQueue[]: stopped abnormally, reincarnation is not possible for in-memory database
WARNING: [sqlite] cannot open DB[1]: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: no sqlite4java-linux-amd64-1.0.392 in java.library.path
SEVERE: [sqlite] SQLiteQueue[]: error running job queue
com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: no sqlite4java-linux-amd64-1.0.392 in java.library.path
Caused by: java.lang.UnsatisfiedLinkError: no sqlite4java-linux-amd64-1.0.392 in java.library.path
SEVERE: [sqlite] SQLiteQueue[]: stopped abnormally, reincarnation is not possible for in-memory database
WARNING: [sqlite] cannot open DB[1]: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: no sqlite4java-win32-x64-1.0.392 in java.library.path
SEVERE: [sqlite] SQLiteQueue[]: error running job queue
com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: no sqlite4java-win32-x64-1.0.392 in java.library.path
Caused by: java.lang.UnsatisfiedLinkError: no sqlite4java-win32-x64-1.0.392 in java.library.path
SEVERE: [sqlite] SQLiteQueue[]: stopped abnormally, reincarnation is not possible for in-memory database
WARNING: [sqlite] cannot open DB[1]: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: no sqlite4java-win32-x86-1.0.392 in java.library.path
SEVERE: [sqlite] SQLiteQueue[]: error running job queue
com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: no sqlite4java-win32-x86-1.0.392 in java.library.path
Caused by: java.lang.UnsatisfiedLinkError: no sqlite4java-win32-x86-1.0.392 in java.library.path
SEVERE: [sqlite] SQLiteQueue[]: stopped abnormally, reincarnation is not possible for in-memory database
WARNING: [sqlite] cannot open DB[1]: com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: no sqlite4java-osx-1.0.392 in java.library.path
SEVERE: [sqlite] SQLiteQueue[]: error running job queue
com.almworks.sqlite4java.SQLiteException: [-91] cannot load library: java.lang.UnsatisfiedLinkError: no sqlite4java-osx-1.0.392 in java.library.path
Caused by: java.lang.UnsatisfiedLinkError: no sqlite4java-osx-1.0.392 in java.library.path
SEVERE: [sqlite] SQLiteQueue[]: stopped abnormally, reincarnation is not possible for in-memory database

The example contains a simple AwsDynamoDbLocalTestUtils class that can be used for initializing this property for DynamoDB at runtime, so it will work from both your IDE and from Gradle.

You only need to call AwsDynamoDbLocalTestUtils#initSqLite() before you plan to use the local database. If the property is already initialized, the call will skip initialization.

There is an example test, that uses the local database. The test calls the initialization at the @BeforeAll setUp method SimpleCrudTest

Build

To build the example type the following command:

./gradlew clean build

Do not forget to set JAVA_HOME environment variable.

References

License

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].