Package com.amazonaws.services.dynamodbv2

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


            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

*/
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

        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

    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

     * 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

        final List<Map<String, AttributeValue>> items =
            new LinkedList<Map<String, AttributeValue>>();
        for (int num = 0; num < Tv.TWENTY; ++num) {
            items.add(this.item());
        }
        final AmazonDynamoDB aws =
            Mockito.mock(AmazonDynamoDB.class);
        Mockito.doAnswer(
            new Answer<ScanResult>() {
                @Override
                public ScanResult answer(final InvocationOnMock invocation) {
View Full Code Here

    DefaultDynamo() {
        this(
            new Dynamo.Client() {
                @Override
                public AmazonDynamoDB get() {
                    final AmazonDynamoDB aws = new AmazonDynamoDBClient(
                        new BasicAWSCredentials(
                            Manifests.read("S3Auth-AwsDynamoKey"),
                            Manifests.read("S3Auth-AwsDynamoSecret")
                        )
                    );
                    // @checkstyle MultipleStringLiterals (1 line)
                    if (Manifests.exists("S3Auth-AwsDynamoEntryPoint")) {
                        aws.setEndpoint(
                            Manifests.read("S3Auth-AwsDynamoEntryPoint")
                        );
                    }
                    return aws;
                }
View Full Code Here

    @SuppressWarnings("PMD.AvoidInstantiatingObjectsInLoops")
    @Cacheable(lifetime = DefaultDynamo.LIFETIME, unit = TimeUnit.MINUTES)
    public ConcurrentMap<URN, Domains> load() {
        final ConcurrentMap<URN, Domains> domains =
            new ConcurrentHashMap<URN, Domains>(0);
        final AmazonDynamoDB amazon = this.client.get();
        final ScanResult result = amazon.scan(new ScanRequest(this.table));
        for (final Map<String, AttributeValue> item : result.getItems()) {
            final String syslog;
            if (item.containsKey(DefaultDynamo.SYSLOG)) {
                syslog = item.get(DefaultDynamo.SYSLOG).getS();
            } else {
                syslog = "syslog.s3auth.com:514";
            }
            final String bucket;
            if (item.containsKey(DefaultDynamo.BUCKET)) {
                bucket = item.get(DefaultDynamo.BUCKET).getS();
            } else {
                bucket = item.get(DefaultDynamo.NAME).getS();
            }
            final URN user = URN.create(item.get(DefaultDynamo.USER).getS());
            domains.putIfAbsent(user, new Domains());
            domains.get(user).add(
                new DefaultDomain(
                    item.get(DefaultDynamo.NAME).getS(),
                    item.get(DefaultDynamo.KEY).getS(),
                    item.get(DefaultDynamo.SECRET).getS(),
                    bucket,
                    item.get(DefaultDynamo.REGION).getS(),
                    syslog
                )
            );
        }
        amazon.shutdown();
        return domains;
    }
View Full Code Here

        attrs.put(DefaultDynamo.KEY, new AttributeValue(domain.key()));
        attrs.put(DefaultDynamo.SECRET, new AttributeValue(domain.secret()));
        attrs.put(DefaultDynamo.REGION, new AttributeValue(domain.region()));
        attrs.put(DefaultDynamo.SYSLOG, new AttributeValue(domain.syslog()));
        attrs.put(DefaultDynamo.BUCKET, new AttributeValue(domain.bucket()));
        final AmazonDynamoDB amazon = this.client.get();
        amazon.putItem(new PutItemRequest(this.table, attrs));
        amazon.shutdown();
        return true;
    }
View Full Code Here

TOP

Related Classes of com.amazonaws.services.dynamodbv2.AmazonDynamoDB

Copyright © 2018 www.massapicom. 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.