/** * setup */ @Before public void setup() { // Create an in-memory and in-process instance of DynamoDB Local that skips HTTP dynamodbClient = DynamoDBEmbedded.create().amazonDynamoDB(); // Create and verify table final CreateTableResult createTableResult = createTable(); assertEquals(TABLE_NAME, createTableResult.getTableDescription().getTableName()); }
public static AmazonDynamoDB createInMemoryDb() { AmazonDynamoDB dynamodb = null; try { // Create an in-memory and in-process instance of DynamoDB Local AmazonDynamoDBLocal amazonDynamoDBLocal = DynamoDBEmbedded.create(); dynamodb = amazonDynamoDBLocal.amazonDynamoDB(); return dynamodb; } catch (Exception e){ if(dynamodb != null) dynamodb.shutdown();// Shutdown the thread pools in DynamoDB Local / Embedded } return dynamodb; }
@BeforeClass public static void beforeClass() { sDynamoDB = DynamoDBEmbedded.create().amazonDynamoDB(); sDynamoDBMapper = new DynamoDBMapper(sDynamoDB); sDynamoDBRepository = new DynamoDBRepository(); sDynamoDBRepository.setDynamoDBMapper(sDynamoDBMapper); sDynamoDBRepository.setLockDurationMs(LOCK_DURATION_MS); }
@Override protected void before() throws Throwable { try { amazonDynamoDB = DynamoDBEmbedded.create().amazonDynamoDB(); } catch (Exception e) { throw new RuntimeException(e); } }
@Override protected void before() throws Throwable { nativeLibraryRule.before(); System.setProperty("sqlite4java.library.path", nativeLibraryRule.getNativeLibrariesFolder().toString()); client = DynamoDBEmbedded.create().amazonDynamoDB(); }
@Before public void setup() { methodCalls = new HashMap<String, Integer>(); client = instrument(DynamoDBEmbedded.create(), AmazonDynamoDB.class, methodCalls); MetaStore.createTable(client, TABLE_NAME, new ProvisionedThroughput(1L, 1L)); store = new MetaStore(client, TABLE_NAME, ENCRYPTOR); ctx = new EncryptionContext.Builder().build(); methodCalls.clear(); }
@Before public void setup() { client = synchronize(DynamoDBEmbedded.create(), AmazonDynamoDB.class); MetaStore.createTable(client, TABLE_NAME, new ProvisionedThroughput(1L, 1L)); store = new MetaStore(client, TABLE_NAME, ENCRYPTOR); ctx = new EncryptionContext.Builder().build(); }
@Before public void setUp() { client = DynamoDBEmbedded.create(); ArrayList<AttributeDefinition> attrDef = new ArrayList<AttributeDefinition>(); attrDef.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType(ScalarAttributeType.N)); attrDef.add(new AttributeDefinition().withAttributeName("rangeKey").withAttributeType(ScalarAttributeType.N)); ArrayList<KeySchemaElement> keySchema = new ArrayList<KeySchemaElement>(); keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH)); keySchema.add(new KeySchemaElement().withAttributeName("rangeKey").withKeyType(KeyType.RANGE)); client.createTable(new CreateTableRequest().withTableName("TableName") .withAttributeDefinitions(attrDef) .withKeySchema(keySchema) .withProvisionedThroughput(new ProvisionedThroughput(100L, 100L))); attrDef = new ArrayList<AttributeDefinition>(); attrDef.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType(ScalarAttributeType.S)); keySchema = new ArrayList<KeySchemaElement>(); keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH)); client.createTable(new CreateTableRequest().withTableName("HashKeyOnly") .withAttributeDefinitions(attrDef) .withKeySchema(keySchema) .withProvisionedThroughput(new ProvisionedThroughput(100L, 100L))); attrDef = new ArrayList<AttributeDefinition>(); attrDef.add(new AttributeDefinition().withAttributeName("hashKey").withAttributeType(ScalarAttributeType.B)); attrDef.add(new AttributeDefinition().withAttributeName("rangeKey").withAttributeType(ScalarAttributeType.N)); keySchema = new ArrayList<KeySchemaElement>(); keySchema.add(new KeySchemaElement().withAttributeName("hashKey").withKeyType(KeyType.HASH)); keySchema.add(new KeySchemaElement().withAttributeName("rangeKey").withKeyType(KeyType.RANGE)); client.createTable(new CreateTableRequest().withTableName("DeterministicTable") .withAttributeDefinitions(attrDef) .withKeySchema(keySchema) .withProvisionedThroughput(new ProvisionedThroughput(100L, 100L))); }
/** * You can use mvn to run DynamoDBLocalFixture, e.g. * <p> * $ mvn clean package * <p> * $ mvn exec:java -Dexec.mainClass="com.amazonaws.services.dynamodbv2.DynamoDBLocalFixture" \ * -Dexec.classpathScope="test" \ * -Dsqlite4java.library.path=target/dependencies * <p> * It's recommended to run "aws configure" one time before you run DynamoDBLocalFixture * * @param args - no args * @throws Exception */ public static void main(String[] args) throws Exception { AmazonDynamoDB dynamodb = null; try { // Create an in-memory and in-process instance of DynamoDB Local that skips HTTP dynamodb = DynamoDBEmbedded.create().amazonDynamoDB(); // use the DynamoDB API with DynamoDBEmbedded listTables(dynamodb.listTables(), "DynamoDB Embedded"); } finally { // Shutdown the thread pools in DynamoDB Local / Embedded if(dynamodb != null) { dynamodb.shutdown(); } } // Create an in-memory and in-process instance of DynamoDB Local that runs over HTTP final String[] localArgs = { "-inMemory" }; DynamoDBProxyServer server = null; try { server = ServerRunner.createServerFromCommandLineArgs(localArgs); server.start(); dynamodb = AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration( // we can use any region here new AwsClientBuilder.EndpointConfiguration("http://localhost:8000", "us-west-2")) .build(); // use the DynamoDB API over HTTP listTables(dynamodb.listTables(), "DynamoDB Local over HTTP"); } finally { // Stop the DynamoDB Local endpoint if(server != null) { server.stop(); } } }
public CloudNoticeDAO(boolean local) { ddb = local ? DynamoDBEmbedded.create().amazonDynamoDB() : AmazonDynamoDBClientBuilder.defaultClient(); verifyTables(); mapper = new DynamoDBMapper(ddb); }
@Bean @Primary public AmazonDynamoDB createAmazonDynamoDBLocal() throws Exception { return DynamoDBEmbedded.create().amazonDynamoDB(); }