use of com.amazonaws.services.dynamodbv2.AmazonDynamoDB in project archaius by Netflix.
the class DynamoDbConfigurationSourceTest method testUpdate.
@Test
public void testUpdate() throws Exception {
AmazonDynamoDB mockBasicDbClient = mock(AmazonDynamoDB.class);
when(mockBasicDbClient.scan(any(ScanRequest.class))).thenReturn(DynamoDbMocks.basicScanResult1, DynamoDbMocks.basicScanResult2);
DynamoDbConfigurationSource testConfigSource = new DynamoDbConfigurationSource(mockBasicDbClient);
PollResult result = testConfigSource.poll(false, null);
assertEquals(3, result.getComplete().size());
assertEquals("bar", result.getComplete().get("foo"));
assertEquals("goo", result.getComplete().get("goo"));
assertEquals("who", result.getComplete().get("boo"));
result = testConfigSource.poll(false, null);
assertEquals(3, result.getComplete().size());
assertEquals("bar", result.getComplete().get("foo"));
assertEquals("foo", result.getComplete().get("goo"));
assertEquals("who", result.getComplete().get("boo"));
}
use of com.amazonaws.services.dynamodbv2.AmazonDynamoDB in project archaius by Netflix.
the class DynamoDbDeploymentContextTableCacheTest method testPoll.
@Test
public void testPoll() throws Exception {
AmazonDynamoDB mockContextDbClient = mock(AmazonDynamoDB.class);
when(mockContextDbClient.scan(any(ScanRequest.class))).thenReturn(DynamoDbMocks.contextScanResult1, DynamoDbMocks.contextScanResult2);
DynamoDbDeploymentContextTableCache cache = new DynamoDbDeploymentContextTableCache(mockContextDbClient, 100, 100);
Collection<PropertyWithDeploymentContext> props = cache.getProperties();
assertEquals(4, props.size());
assertTrue(props.contains(test1));
assertTrue(props.contains(test2));
assertTrue(props.contains(test5));
assertTrue(props.contains(test6));
Thread.sleep(150);
props = cache.getProperties();
assertEquals(5, props.size());
assertTrue(props.contains(test1));
assertTrue(props.contains(test3));
assertTrue(props.contains(test4));
assertTrue(props.contains(test5));
assertTrue(props.contains(test6));
}
use of com.amazonaws.services.dynamodbv2.AmazonDynamoDB in project cas by apereo.
the class DynamoDbCloudConfigBootstrapConfiguration method createSettingsTable.
@SneakyThrows
private static void createSettingsTable(final AmazonDynamoDB amazonDynamoDBClient, final boolean deleteTables) {
final String name = ColumnNames.ID.getColumnName();
final CreateTableRequest request = new CreateTableRequest().withAttributeDefinitions(new AttributeDefinition(name, ScalarAttributeType.S)).withKeySchema(new KeySchemaElement(name, KeyType.HASH)).withProvisionedThroughput(new ProvisionedThroughput(PROVISIONED_THROUGHPUT, PROVISIONED_THROUGHPUT)).withTableName(TABLE_NAME);
if (deleteTables) {
final DeleteTableRequest delete = new DeleteTableRequest(request.getTableName());
LOGGER.debug("Sending delete request [{}] to remove table if necessary", delete);
TableUtils.deleteTableIfExists(amazonDynamoDBClient, delete);
}
LOGGER.debug("Sending delete request [{}] to create table", request);
TableUtils.createTableIfNotExists(amazonDynamoDBClient, request);
LOGGER.debug("Waiting until table [{}] becomes active...", request.getTableName());
TableUtils.waitUntilActive(amazonDynamoDBClient, request.getTableName());
final DescribeTableRequest describeTableRequest = new DescribeTableRequest().withTableName(request.getTableName());
LOGGER.debug("Sending request [{}] to obtain table description...", describeTableRequest);
final TableDescription tableDescription = amazonDynamoDBClient.describeTable(describeTableRequest).getTable();
LOGGER.debug("Located newly created table with description: [{}]", tableDescription);
}
use of com.amazonaws.services.dynamodbv2.AmazonDynamoDB in project testcontainers-java by testcontainers.
the class DynaliteContainerTest method simpleTestWithManualClientCreation.
@Test
public void simpleTestWithManualClientCreation() {
final AmazonDynamoDB client = AmazonDynamoDBClientBuilder.standard().withEndpointConfiguration(dynamoDB.getEndpointConfiguration()).withCredentials(dynamoDB.getCredentials()).build();
runTest(client);
}
use of com.amazonaws.services.dynamodbv2.AmazonDynamoDB in project wildfly-camel by wildfly-extras.
the class DynamoDBUtils method createTable.
public static TableDescription createTable(AmazonDynamoDB client, String tableName) throws InterruptedException {
CreateTableRequest tableReq = new CreateTableRequest().withTableName(tableName).withKeySchema(new KeySchemaElement("Id", KeyType.HASH)).withAttributeDefinitions(new AttributeDefinition("Id", ScalarAttributeType.N)).withProvisionedThroughput(new ProvisionedThroughput(10L, 10L)).withStreamSpecification(new StreamSpecification().withStreamEnabled(true).withStreamViewType(StreamViewType.NEW_AND_OLD_IMAGES));
DynamoDB dynamoDB = new DynamoDB(client);
Table table = dynamoDB.createTable(tableReq);
return table.waitForActive();
}
Aggregations