Examples of AmazonDynamoDB


Examples of com.amazonaws.services.dynamodb.AmazonDynamoDB

    @Override
    public void doStart() throws Exception {
        super.doStart();

        AmazonDynamoDB ddbClient = getDdbClient();
        String tableName = getConfiguration().getTableName();
        LOG.trace("Querying whether table [{}] already exists...", tableName);

        try {
            DescribeTableRequest request = new DescribeTableRequest().withTableName(tableName);
            TableDescription tableDescription = ddbClient.describeTable(request).getTable();
            if (!isTableActive(tableDescription)) {
                waitForTableToBecomeAvailable(tableName);
            }

            LOG.trace("Table [{}] already exists", tableName);
View Full Code Here

Examples of com.amazonaws.services.dynamodb.AmazonDynamoDB

    }

    AmazonDynamoDB createDdbClient() {
        AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(),
                configuration.getSecretKey());
        AmazonDynamoDB client = new AmazonDynamoDBClient(credentials);
        if (configuration.getAmazonDdbEndpoint() != null) {
            client.setEndpoint(configuration.getAmazonDdbEndpoint());
        }
        configuration.setAmazonDDBClient(client);
        return client;
    }
View Full Code Here

Examples of com.amazonaws.services.dynamodb.AmazonDynamoDB

    }

    AmazonDynamoDB createDdbClient() {
        AWSCredentials credentials = new BasicAWSCredentials(configuration.getAccessKey(),
                configuration.getSecretKey());
        AmazonDynamoDB client = new AmazonDynamoDBClient(credentials);
        return client;
    }
View Full Code Here

Examples of com.amazonaws.services.dynamodb.AmazonDynamoDB

    Map<String, ExpectedAttributeValue> expectedMap = new HashMap<String, ExpectedAttributeValue>();
    expectedMap.put("id", new ExpectedAttributeValue(false));

    Map<String, AttributeValue> item = createGenericItem(value, null);

    AmazonDynamoDB client = getClient();
    client.putItem(new PutItemRequest(tableName, item).withExpected(expectedMap));

    try {
      client.putItem(new PutItemRequest(tableName, item).withExpected(expectedMap));
      Assert.assertTrue(false);// Should have thrown a ConditionalCheckFailedException
    } catch (ConditionalCheckFailedException ccfe) {
    }
  }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.AmazonDynamoDB

* You should write something useful here.
*/
public class DynamoBackedConfigurationTest {
    @Test
    public void testPropertyChange() throws Exception {
        AmazonDynamoDB mockBasicDbClient = mock(AmazonDynamoDB.class);

        //3 of the first config to cover: object creation, threadRun at 0 delay, load properties
        when(mockBasicDbClient.scan(any(ScanRequest.class))).thenReturn(DynamoDbMocks.basicScanResult1,
                DynamoDbMocks.basicScanResult1, DynamoDbMocks.basicScanResult1, DynamoDbMocks.basicScanResult2);
        DynamoDbConfigurationSource source = new DynamoDbConfigurationSource(mockBasicDbClient);

        FixedDelayPollingScheduler scheduler = new FixedDelayPollingScheduler(0, 500, false);
        DynamicConfiguration dynamicConfig = new DynamicConfiguration(source, scheduler);
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.AmazonDynamoDB

            new PropertyWithDeploymentContext(null,
                    null, "foo", "bar");

    @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());
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.AmazonDynamoDB

*/
public class DynamoDbConfigurationSourceTest {

    @Test
    public void testPoll() throws Exception {
        AmazonDynamoDB mockBasicDbClient = mock(AmazonDynamoDB.class);
        when(mockBasicDbClient.scan(any(ScanRequest.class))).thenReturn(DynamoDbMocks.basicScanResult1);

        DynamoDbConfigurationSource testConfigSource = new DynamoDbConfigurationSource(mockBasicDbClient);
        PollResult result = testConfigSource.poll(false, null);
        assertEquals(3, result.getComplete().size());
        assertEquals("bar", result.getComplete().get("foo"));
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.AmazonDynamoDB

        assertEquals("who", result.getComplete().get("boo"));
    }

    @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());
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.AmazonDynamoDB

    Map<String, ExpectedAttributeValue> expectedMap = new HashMap<String, ExpectedAttributeValue>();
    expectedMap.put("id", new ExpectedAttributeValue(false));

    Map<String, AttributeValue> item = createGenericItem(value, null);

    AmazonDynamoDB client = getClient();
    client.putItem(new PutItemRequest(tableName, item).withExpected(expectedMap));

    try {
      client.putItem(new PutItemRequest(tableName, item).withExpected(expectedMap));
      Assert.assertTrue(false);// Should have thrown a ConditionalCheckFailedException
    } catch (ConditionalCheckFailedException ccfe) {
    }
  }
View Full Code Here

Examples of com.amazonaws.services.dynamodbv2.AmazonDynamoDB

     * DefaultDynamo can load configuration.
     * @throws Exception If there is some problem inside
     */
    @Test
    public void loadsDynamoConfiguration() throws Exception {
        final AmazonDynamoDB amazon = this.amazon();
        final Dynamo dynamo = new DefaultDynamo(
            new Dynamo.Client() {
                @Override
                public AmazonDynamoDB get() {
                    return amazon;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.