camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r1240737 [2/2] - in /camel/trunk: components/camel-aws/ components/camel-aws/src/main/java/org/apache/camel/component/aws/ddb/ components/camel-aws/src/main/resources/META-INF/services/org/apache/camel/component/ components/camel-aws/src/te...
Date Sun, 05 Feb 2012 14:04:12 GMT
Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteItemCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteItemCommandTest.java?rev=1240737&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteItemCommandTest.java
(added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteItemCommandTest.java
Sun Feb  5 14:04:10 2012
@@ -0,0 +1,72 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.aws.ddb;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.amazonaws.services.dynamodb.model.AttributeValue;
+import com.amazonaws.services.dynamodb.model.ExpectedAttributeValue;
+import com.amazonaws.services.dynamodb.model.Key;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class DeleteItemCommandTest {
+
+    private DeleteItemCommand command;
+    private AmazonDDBClientMock ddbClient;
+    private DdbConfiguration configuration;
+    private Exchange exchange;
+
+    @Before
+    public void setUp() {
+        ddbClient = new AmazonDDBClientMock();
+        configuration = new DdbConfiguration();
+        configuration.setTableName("DOMAIN1");
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        command = new DeleteItemCommand(ddbClient, configuration, exchange);
+    }
+
+    @Test
+    public void execute() {
+        Key key = new Key(new AttributeValue("Key_1"));
+        exchange.getIn().setHeader(DdbConstants.KEY, key);
+
+
+        Map<String, ExpectedAttributeValue> updateCondition = new HashMap<String,
ExpectedAttributeValue>();
+        updateCondition
+                .put("name", new ExpectedAttributeValue(new AttributeValue("expected value")));
+        exchange.getIn().setHeader(DdbConstants.UPDATE_CONDITION, updateCondition);
+        exchange.getIn().setHeader(DdbConstants.RETURN_VALUES, "ALL_OLD");
+
+        command.execute();
+
+        assertEquals("DOMAIN1", ddbClient.deleteItemRequest.getTableName());
+        assertEquals(key, ddbClient.deleteItemRequest.getKey());
+        assertEquals(updateCondition, ddbClient.deleteItemRequest.getExpected());
+        assertEquals("ALL_OLD", ddbClient.deleteItemRequest.getReturnValues());
+        assertEquals(new AttributeValue("attrValue"),
+                exchange.getIn().getHeader(DdbConstants.ATTRIBUTES, Map.class).get(
+                        "attrName"));
+    }
+}

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteItemCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteItemCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteTableCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteTableCommandTest.java?rev=1240737&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteTableCommandTest.java
(added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteTableCommandTest.java
Sun Feb  5 14:04:10 2012
@@ -0,0 +1,67 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.aws.ddb;
+
+import java.util.Date;
+
+import com.amazonaws.services.dynamodb.model.KeySchema;
+import com.amazonaws.services.dynamodb.model.ProvisionedThroughput;
+import com.amazonaws.services.dynamodb.model.ProvisionedThroughputDescription;
+import com.amazonaws.services.dynamodb.model.TableDescription;
+import com.amazonaws.services.dynamodb.model.TableStatus;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.aws.sdb.AmazonSDBClientMock;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class DeleteTableCommandTest {
+
+    private DeleteTableCommand command;
+    private AmazonDDBClientMock ddbClient;
+    private DdbConfiguration configuration;
+    private Exchange exchange;
+    
+    @Before
+    public void setUp() {
+        ddbClient = new AmazonDDBClientMock();
+        configuration = new DdbConfiguration();
+        configuration.setTableName("DOMAIN1");
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        
+        command = new DeleteTableCommand(ddbClient, configuration, exchange);
+    }
+
+    @Test
+    public void testExecute() {
+        command.execute();
+        
+        assertEquals("DOMAIN1", ddbClient.deleteTableRequest.getTableName());
+        assertEquals(new ProvisionedThroughputDescription(), exchange.getIn().getHeader(
+                DdbConstants.PROVISIONED_THROUGHPUT));
+        assertEquals(new Date(AmazonDDBClientMock.NOW), exchange.getIn().getHeader(DdbConstants.CREATION_DATE,
+                Date.class));
+        assertEquals(Long.valueOf(10L), exchange.getIn().getHeader(DdbConstants.ITEM_COUNT,
Long.class));
+        assertEquals(new KeySchema(), exchange.getIn().getHeader(DdbConstants.KEY_SCHEMA,
KeySchema.class));
+        assertEquals(Long.valueOf(20L), exchange.getIn().getHeader(DdbConstants.TABLE_SIZE,
Long.class));
+        assertEquals(TableStatus.ACTIVE, exchange.getIn().getHeader(DdbConstants.TABLE_STATUS,
TableStatus.class));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteTableCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DeleteTableCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DescribeTableCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DescribeTableCommandTest.java?rev=1240737&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DescribeTableCommandTest.java
(added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DescribeTableCommandTest.java
Sun Feb  5 14:04:10 2012
@@ -0,0 +1,62 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.aws.ddb;
+
+import java.util.Date;
+
+import com.amazonaws.services.dynamodb.model.KeySchema;
+import com.amazonaws.services.dynamodb.model.KeySchemaElement;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class DescribeTableCommandTest {
+
+    private DescribeTableCommand command;
+    private AmazonDDBClientMock ddbClient;
+    private DdbConfiguration configuration;
+    private Exchange exchange;
+
+    @Before
+    public void setUp() {
+        ddbClient = new AmazonDDBClientMock();
+        configuration = new DdbConfiguration();
+        configuration.setTableName("FULL_DESCRIBE_TABLE");
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        command = new DescribeTableCommand(ddbClient, configuration, exchange);
+    }
+
+    @Test
+    public void testExecute() {
+        command.execute();
+        assertEquals("FULL_DESCRIBE_TABLE", ddbClient.describeTableRequest.getTableName());
+        assertEquals("FULL_DESCRIBE_TABLE", exchange.getIn().getHeader(DdbConstants.TABLE_NAME));
+        assertEquals("ACTIVE", exchange.getIn().getHeader(DdbConstants.TABLE_STATUS));
+        assertEquals(new Date(AmazonDDBClientMock.NOW), exchange.getIn().getHeader(DdbConstants.TABLE_CREATION_DATE));
+        assertEquals(100L, exchange.getIn().getHeader(DdbConstants.ITEM_COUNT));
+        assertEquals(new KeySchema(new KeySchemaElement().withAttributeName("name")),
+                exchange.getIn().getHeader(DdbConstants.KEY_SCHEMA));
+        assertEquals(20L, exchange.getIn().getHeader(DdbConstants.READ_CAPACITY));
+        assertEquals(10L, exchange.getIn().getHeader(DdbConstants.WRITE_CAPACITY));
+        assertEquals(1000L, exchange.getIn().getHeader(DdbConstants.TABLE_SIZE));
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DescribeTableCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/DescribeTableCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/GetItemCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/GetItemCommandTest.java?rev=1240737&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/GetItemCommandTest.java
(added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/GetItemCommandTest.java
Sun Feb  5 14:04:10 2012
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.aws.ddb;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+
+import com.amazonaws.services.dynamodb.model.AttributeValue;
+import com.amazonaws.services.dynamodb.model.Key;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class GetItemCommandTest {
+    private GetItemCommand command;
+    private AmazonDDBClientMock ddbClient;
+    private DdbConfiguration configuration;
+    private Exchange exchange;
+
+    @Before
+    public void setUp() {
+        ddbClient = new AmazonDDBClientMock();
+        configuration = new DdbConfiguration();
+        configuration.setTableName("DOMAIN1");
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        command = new GetItemCommand(ddbClient, configuration, exchange);
+    }
+
+    @Test
+    public void execute() {
+        Key key = new Key(new AttributeValue("Key_1"));
+        exchange.getIn().setHeader(DdbConstants.KEY, key);
+
+        List<String> attrNames = Arrays.asList("attrName");
+        exchange.getIn().setHeader(DdbConstants.ATTRIBUTE_NAMES, attrNames);
+        exchange.getIn().setHeader(DdbConstants.CONSISTENT_READ, true);
+
+        command.execute();
+
+        assertEquals("DOMAIN1", ddbClient.getItemRequest.getTableName());
+        assertEquals(attrNames, ddbClient.getItemRequest.getAttributesToGet());
+        assertEquals(true, ddbClient.getItemRequest.getConsistentRead());
+        assertEquals(key, ddbClient.getItemRequest.getKey());
+        assertEquals(new AttributeValue("attrValue"),
+                exchange.getIn().getHeader(DdbConstants.ATTRIBUTES, Map.class).get(
+                        "attrName"));
+    }
+}

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/GetItemCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/GetItemCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/PutItemCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/PutItemCommandTest.java?rev=1240737&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/PutItemCommandTest.java
(added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/PutItemCommandTest.java
Sun Feb  5 14:04:10 2012
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.aws.ddb;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.amazonaws.services.dynamodb.model.AttributeValue;
+import com.amazonaws.services.dynamodb.model.ExpectedAttributeValue;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class PutItemCommandTest {
+
+    private PutItemCommand command;
+    private AmazonDDBClientMock ddbClient;
+    private DdbConfiguration configuration;
+    private Exchange exchange;
+
+    @Before
+    public void setUp() {
+        ddbClient = new AmazonDDBClientMock();
+        configuration = new DdbConfiguration();
+        configuration.setTableName("DOMAIN1");
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        command = new PutItemCommand(ddbClient, configuration, exchange);
+    }
+
+    @Test
+    public void execute() {
+        Map<String, AttributeValue> attributeMap = new HashMap<String, AttributeValue>();
+        AttributeValue attributeValue = new AttributeValue("test value");
+        attributeMap.put("name", attributeValue);
+        exchange.getIn().setHeader(DdbConstants.ITEM, attributeMap);
+
+        Map<String, ExpectedAttributeValue> expectedAttributeValueMap = new HashMap<String,
ExpectedAttributeValue>();
+        expectedAttributeValueMap.put("name", new ExpectedAttributeValue(attributeValue));
+        exchange.getIn().setHeader(DdbConstants.UPDATE_CONDITION, expectedAttributeValueMap);
+
+        command.execute();
+
+        assertEquals("DOMAIN1", ddbClient.putItemRequest.getTableName());
+        assertEquals(attributeMap, ddbClient.putItemRequest.getItem());
+        assertEquals(expectedAttributeValueMap, ddbClient.putItemRequest.getExpected());
+        assertEquals(new AttributeValue("attrValue"),
+                exchange.getIn().getHeader(DdbConstants.ATTRIBUTES, Map.class).get("attrName"));
+    }
+}

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/PutItemCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/PutItemCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/QueryCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/QueryCommandTest.java?rev=1240737&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/QueryCommandTest.java
(added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/QueryCommandTest.java
Sun Feb  5 14:04:10 2012
@@ -0,0 +1,84 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.aws.ddb;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.amazonaws.services.dynamodb.model.AttributeValue;
+import com.amazonaws.services.dynamodb.model.ComparisonOperator;
+import com.amazonaws.services.dynamodb.model.Condition;
+import com.amazonaws.services.dynamodb.model.Key;
+import com.amazonaws.services.dynamodb.model.QueryResult;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class QueryCommandTest {
+
+    private QueryCommand command;
+    private AmazonDDBClientMock ddbClient;
+    private DdbConfiguration configuration;
+    private Exchange exchange;
+
+    @Before
+    public void setUp() {
+        ddbClient = new AmazonDDBClientMock();
+        configuration = new DdbConfiguration();
+        configuration.setTableName("DOMAIN1");
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        command = new QueryCommand(ddbClient, configuration, exchange);
+    }
+
+    @Test
+    public void execute() {
+
+        Key startKey = new Key(new AttributeValue("startKey"));
+        AttributeValue attributeValue = new AttributeValue().withN("1985");
+        Condition condition = new Condition()
+                .withComparisonOperator(ComparisonOperator.GT.toString())
+                .withAttributeValueList(new AttributeValue().withN("1985"));
+
+        List<String> attributeNames = Arrays.asList("attrNameOne", "attrNameTwo");
+        exchange.getIn().setHeader(DdbConstants.ATTRIBUTE_NAMES, attributeNames);
+        exchange.getIn().setHeader(DdbConstants.EXACT_COUNT, true);
+        exchange.getIn().setHeader(DdbConstants.CONSISTENT_READ, true);
+        exchange.getIn().setHeader(DdbConstants.START_KEY, startKey);
+        exchange.getIn().setHeader(DdbConstants.HASH_KEY_VALUE, attributeValue);
+        exchange.getIn().setHeader(DdbConstants.LIMIT, 10);
+        exchange.getIn().setHeader(DdbConstants.SCAN_RANGE_KEY_CONDITION, condition);
+        exchange.getIn().setHeader(DdbConstants.SCAN_INDEX_FORWARD, true);
+
+        command.execute();
+
+        assertEquals(Integer.valueOf(1), exchange.getIn().getHeader(DdbConstants.COUNT, Integer.class));
+        assertEquals(Double.valueOf(1.0), exchange.getIn().getHeader(DdbConstants.CONSUMED_CAPACITY,
+                Double.class));
+        assertEquals(new Key(new AttributeValue("LAST_KEY")), exchange.getIn().getHeader(
+                DdbConstants.LAST_EVALUATED_KEY, Key.class));
+        Map<String, AttributeValue> items = (Map<String, AttributeValue>)exchange.getIn().getHeader(
+                DdbConstants.ITEMS, List.class).get(0);
+        assertEquals(new AttributeValue("attrValue"), items.get("attrName"));
+    }
+}

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/QueryCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/QueryCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/ScanCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/ScanCommandTest.java?rev=1240737&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/ScanCommandTest.java
(added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/ScanCommandTest.java
Sun Feb  5 14:04:10 2012
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.aws.ddb;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.amazonaws.services.dynamodb.model.AttributeValue;
+import com.amazonaws.services.dynamodb.model.ComparisonOperator;
+import com.amazonaws.services.dynamodb.model.Condition;
+import com.amazonaws.services.dynamodb.model.Key;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class ScanCommandTest {
+
+    private ScanCommand command;
+    private AmazonDDBClientMock ddbClient;
+    private DdbConfiguration configuration;
+    private Exchange exchange;
+
+    @Before
+    public void setUp() {
+        ddbClient = new AmazonDDBClientMock();
+        configuration = new DdbConfiguration();
+        configuration.setTableName("DOMAIN1");
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        command = new ScanCommand(ddbClient, configuration, exchange);
+    }
+
+    @Test
+    public void execute() {
+        HashMap<String, Condition> scanFilter = new HashMap<String, Condition>();
+        Condition condition = new Condition()
+                .withComparisonOperator(ComparisonOperator.GT.toString())
+                .withAttributeValueList(new AttributeValue().withN("1985"));
+        scanFilter.put("year", condition);
+        exchange.getIn().setHeader(DdbConstants.SCAN_FILTER, scanFilter);
+
+        command.execute();
+
+        assertEquals(scanFilter, ddbClient.scanRequest.getScanFilter());
+        assertEquals(Integer.valueOf(10), exchange.getIn().getHeader(DdbConstants.SCANNED_COUNT,
+                Integer.class));
+        assertEquals(Integer.valueOf(1), exchange.getIn().getHeader(DdbConstants.COUNT, Integer.class));
+        assertEquals(Double.valueOf(1.0), exchange.getIn().getHeader(DdbConstants.CONSUMED_CAPACITY,
+                Double.class));
+        assertEquals(new Key(new AttributeValue("LAST_KEY")), exchange.getIn().getHeader(
+                DdbConstants.LAST_EVALUATED_KEY, Key.class));
+
+        Map<String, AttributeValue> items = (Map<String, AttributeValue>)exchange.getIn().getHeader(
+                DdbConstants.ITEMS, List.class).get(0);
+
+        assertEquals(new AttributeValue("attrValue"), items.get("attrName"));
+
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/ScanCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/ScanCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateItemCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateItemCommandTest.java?rev=1240737&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateItemCommandTest.java
(added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateItemCommandTest.java
Sun Feb  5 14:04:10 2012
@@ -0,0 +1,80 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.aws.ddb;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import com.amazonaws.services.dynamodb.model.AttributeAction;
+import com.amazonaws.services.dynamodb.model.AttributeValue;
+import com.amazonaws.services.dynamodb.model.AttributeValueUpdate;
+import com.amazonaws.services.dynamodb.model.ExpectedAttributeValue;
+import com.amazonaws.services.dynamodb.model.Key;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class UpdateItemCommandTest {
+
+    private UpdateItemCommand command;
+    private AmazonDDBClientMock ddbClient;
+    private DdbConfiguration configuration;
+    private Exchange exchange;
+
+    @Before
+    public void setUp() {
+        ddbClient = new AmazonDDBClientMock();
+        configuration = new DdbConfiguration();
+        configuration.setTableName("DOMAIN1");
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        command = new UpdateItemCommand(ddbClient, configuration, exchange);
+    }
+
+    @Test
+    public void execute() {
+        Key key = new Key(new AttributeValue("Key_1"));
+        exchange.getIn().setHeader(DdbConstants.KEY, key);
+
+        Map<String, AttributeValueUpdate> attributeMap = new HashMap<String, AttributeValueUpdate>();
+        AttributeValueUpdate attributeValue = new AttributeValueUpdate(
+                new AttributeValue("new value"), AttributeAction.ADD);
+        attributeMap.put("name", attributeValue);
+        exchange.getIn().setHeader(DdbConstants.UPDATE_VALUES, attributeMap);
+
+        Map<String, ExpectedAttributeValue> expectedAttributeValueMap = new HashMap<String,
ExpectedAttributeValue>();
+        expectedAttributeValueMap
+                .put("name", new ExpectedAttributeValue(new AttributeValue("expected value")));
+        exchange.getIn().setHeader(DdbConstants.UPDATE_CONDITION, expectedAttributeValueMap);
+        exchange.getIn().setHeader(DdbConstants.RETURN_VALUES, "ALL_OLD");
+
+        command.execute();
+
+        assertEquals("DOMAIN1", ddbClient.updateItemRequest.getTableName());
+        assertEquals(attributeMap, ddbClient.updateItemRequest.getAttributeUpdates());
+        assertEquals(key, ddbClient.updateItemRequest.getKey());
+        assertEquals(expectedAttributeValueMap, ddbClient.updateItemRequest.getExpected());
+        assertEquals("ALL_OLD", ddbClient.updateItemRequest.getReturnValues());
+        assertEquals(new AttributeValue("attrValue"),
+                exchange.getIn().getHeader(DdbConstants.ATTRIBUTES, Map.class).get(
+                        "attrName"));
+    }
+}

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateItemCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateItemCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateTableCommandTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateTableCommandTest.java?rev=1240737&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateTableCommandTest.java
(added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateTableCommandTest.java
Sun Feb  5 14:04:10 2012
@@ -0,0 +1,55 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.aws.ddb;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.component.aws.sdb.AmazonSDBClientMock;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.junit.Before;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class UpdateTableCommandTest {
+
+    private UpdateTableCommand command;
+    private AmazonDDBClientMock ddbClient;
+    private DdbConfiguration configuration;
+    private Exchange exchange;
+    
+    @Before
+    public void setUp() {
+        ddbClient = new AmazonDDBClientMock();
+        configuration = new DdbConfiguration();
+        configuration.setTableName("DOMAIN1");
+        configuration.setReadCapacity(20L);
+        configuration.setWriteCapacity(30L);
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        
+        command = new UpdateTableCommand(ddbClient, configuration, exchange);
+    }
+
+    @Test
+    public void testExecute() {
+        command.execute();
+        
+        assertEquals("DOMAIN1", ddbClient.updateTableRequest.getTableName());
+        assertEquals(Long.valueOf(20), ddbClient.updateTableRequest.getProvisionedThroughput().getReadCapacityUnits());
+        assertEquals(Long.valueOf(30), ddbClient.updateTableRequest.getProvisionedThroughput().getWriteCapacityUnits());
+    }
+}
\ No newline at end of file

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateTableCommandTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/UpdateTableCommandTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/integration/DdbComponentIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/integration/DdbComponentIntegrationTest.java?rev=1240737&view=auto
==============================================================================
--- camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/integration/DdbComponentIntegrationTest.java
(added)
+++ camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/integration/DdbComponentIntegrationTest.java
Sun Feb  5 14:04:10 2012
@@ -0,0 +1,68 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ */
+package org.apache.camel.component.aws.ddb.integration;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import com.amazonaws.services.dynamodb.model.AttributeValue;
+
+import org.apache.camel.EndpointInject;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.aws.ddb.DdbConstants;
+import org.apache.camel.component.aws.ddb.DdbOperations;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore("Must be manually tested. Provide your own accessKey and secretKey!")
+public class DdbComponentIntegrationTest extends CamelTestSupport {
+
+    @EndpointInject(uri = "direct:start")
+    private ProducerTemplate template;
+
+    @Test
+    public void select() {
+        final Map<String, AttributeValue> attributeMap = new HashMap<String, AttributeValue>();
+        AttributeValue attributeValue = new AttributeValue("test value");
+        attributeMap.put("name", attributeValue);
+
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(DdbConstants.OPERATION, DdbOperations.PutItem);
+                exchange.getIn().setHeader(DdbConstants.RETURN_VALUES, "ALL_OLD");
+                exchange.getIn().setHeader(DdbConstants.ITEM, attributeMap);
+            }
+        });
+
+        assertNotNull(exchange.getIn().getHeader(DdbConstants.ITEMS, List.class));
+    }
+
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                        .to("aws-ddb://TestTable?accessKey=xxx&secretKey=yyy");
+            }
+        };
+    }
+}

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/integration/DdbComponentIntegrationTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: camel/trunk/components/camel-aws/src/test/java/org/apache/camel/component/aws/ddb/integration/DdbComponentIntegrationTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: camel/trunk/platforms/karaf/features/pom.xml
URL: http://svn.apache.org/viewvc/camel/trunk/platforms/karaf/features/pom.xml?rev=1240737&r1=1240736&r2=1240737&view=diff
==============================================================================
--- camel/trunk/platforms/karaf/features/pom.xml (original)
+++ camel/trunk/platforms/karaf/features/pom.xml Sun Feb  5 14:04:10 2012
@@ -38,7 +38,7 @@
       <antlr-bundle-version>2.7.7_2</antlr-bundle-version>
       <aopalliance-bundle-version>1.0_5</aopalliance-bundle-version>
       <asm2-bundle-version>2.2.3_4</asm2-bundle-version>
-      <aws-java-sdk-bundle-version>1.2.12_1</aws-java-sdk-bundle-version>
+      <aws-java-sdk-bundle-version>1.3.0_1</aws-java-sdk-bundle-version>
       <bcel-bundle-version>5.2_4</bcel-bundle-version>
       <bcpg-jdk16-bundle-version>1.46_1</bcpg-jdk16-bundle-version>
       <cglib-version>2.1_3_6</cglib-version>



Mime
View raw message