You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by cm...@apache.org on 2011/12/19 15:20:08 UTC

svn commit: r1220761 [2/3] - in /camel/branches/camel-2.8.x: components/camel-aws/src/main/java/org/apache/camel/component/aws/sdb/ components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/ components/camel-aws/src/test/java/org/apache/cam...

Added: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/ListDomainsCommandTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/ListDomainsCommandTest.java?rev=1220761&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/ListDomainsCommandTest.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/ListDomainsCommandTest.java Mon Dec 19 14:20:07 2011
@@ -0,0 +1,73 @@
+/**
+ * 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.sdb;
+
+import java.util.List;
+
+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;
+import static org.junit.Assert.assertTrue;
+
+public class ListDomainsCommandTest {
+
+    private ListDomainsCommand command;
+    private AmazonSDBClientMock sdbClient;
+    private SdbConfiguration configuration;
+    private Exchange exchange;
+    
+    @Before
+    public void setUp() {
+        sdbClient = new AmazonSDBClientMock();
+        configuration = new SdbConfiguration();
+        configuration.setDomainName("DOMAIN1");
+        configuration.setMaxNumberOfDomains(new Integer(5));
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        
+        command = new ListDomainsCommand(sdbClient, configuration, exchange);
+    }
+
+    @SuppressWarnings({ "unchecked" })
+    @Test
+    public void execute() {
+        exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1");
+        
+        command.execute();
+        
+        assertEquals(new Integer(5), sdbClient.listDomainsRequest.getMaxNumberOfDomains());
+        assertEquals("TOKEN1", sdbClient.listDomainsRequest.getNextToken());
+        
+        List<String> domains = exchange.getIn().getHeader(SdbConstants.DOMAIN_NAMES, List.class);
+        assertEquals("TOKEN2", exchange.getIn().getHeader(SdbConstants.NEXT_TOKEN));
+        assertEquals(2, domains.size());
+        assertTrue(domains.contains("DOMAIN1"));
+        assertTrue(domains.contains("DOMAIN2"));
+    }
+
+    @Test
+    public void determineMaxNumberOfDomains() {
+        assertEquals(new Integer(5), this.command.determineMaxNumberOfDomains());
+
+        exchange.getIn().setHeader(SdbConstants.MAX_NUMBER_OF_DOMAINS, new Integer(10));
+
+        assertEquals(new Integer(10), this.command.determineMaxNumberOfDomains());
+    }
+}
\ No newline at end of file

Added: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/PutAttributesCommandTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/PutAttributesCommandTest.java?rev=1220761&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/PutAttributesCommandTest.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/PutAttributesCommandTest.java Mon Dec 19 14:20:07 2011
@@ -0,0 +1,89 @@
+/**
+ * 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.sdb;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import com.amazonaws.services.simpledb.model.ReplaceableAttribute;
+import com.amazonaws.services.simpledb.model.UpdateCondition;
+
+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;
+import static org.junit.Assert.assertNull;
+
+public class PutAttributesCommandTest {
+
+    private PutAttributesCommand command;
+    private AmazonSDBClientMock sdbClient;
+    private SdbConfiguration configuration;
+    private Exchange exchange;
+    
+    @Before
+    public void setUp() {
+        sdbClient = new AmazonSDBClientMock();
+        configuration = new SdbConfiguration();
+        configuration.setDomainName("DOMAIN1");
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        
+        command = new PutAttributesCommand(sdbClient, configuration, exchange);
+    }
+
+    @Test
+    public void execute() {
+        List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>();
+        replaceableAttributes.add(new ReplaceableAttribute("NAME1", "VALUE1", true));
+        exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
+        exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+        UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
+        exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
+        
+        command.execute();
+        
+        assertEquals("DOMAIN1", sdbClient.putAttributesRequest.getDomainName());
+        assertEquals("ITEM1", sdbClient.putAttributesRequest.getItemName());
+        assertEquals(updateCondition, sdbClient.putAttributesRequest.getExpected());
+        assertEquals(replaceableAttributes, sdbClient.putAttributesRequest.getAttributes());
+    }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void executeWithoutItemName() {
+        List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>();
+        replaceableAttributes.add(new ReplaceableAttribute("NAME1", "VALUE1", true));
+        exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
+        UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
+        exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
+        
+        command.execute();
+    }
+
+    @Test
+    public void determineReplaceableAttributes() {
+        assertNull(this.command.determineReplaceableAttributes());
+
+        List<ReplaceableAttribute> replaceableAttributes = new ArrayList<ReplaceableAttribute>();
+        replaceableAttributes.add(new ReplaceableAttribute("NAME1", "VALUE1", true));
+        exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
+
+        assertEquals(replaceableAttributes, this.command.determineReplaceableAttributes());
+    }
+}
\ No newline at end of file

Added: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentConfigurationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentConfigurationTest.java?rev=1220761&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentConfigurationTest.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentConfigurationTest.java Mon Dec 19 14:20:07 2011
@@ -0,0 +1,103 @@
+/**
+ * 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.sdb;
+
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.impl.PropertyPlaceholderDelegateRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
+public class SdbComponentConfigurationTest extends CamelTestSupport {
+    
+    @Test
+    public void createEndpointWithMinimalConfiguration() throws Exception {
+        SdbComponent component = new SdbComponent(context);
+        SdbEndpoint endpoint = (SdbEndpoint) component.createEndpoint(
+                "aws-sdb://TestDomain?accessKey=xxx&secretKey=yyy");
+        
+        assertEquals("TestDomain", endpoint.getConfiguration().getDomainName());
+        assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
+        assertEquals("yyy", endpoint.getConfiguration().getSecretKey());
+        assertNull(endpoint.getConfiguration().getAmazonSDBClient());
+        assertEquals(SdbOperations.PutAttributes, endpoint.getConfiguration().getOperation());
+        assertNull(endpoint.getConfiguration().getAmazonSdbEndpoint());
+        assertNull(endpoint.getConfiguration().getConsistentRead());
+        assertNull(endpoint.getConfiguration().getMaxNumberOfDomains());
+    }
+    
+    @Test
+    public void createEndpointWithMinimalConfigurationAndProvidedClient() throws Exception {
+        AmazonSDBClientMock mock = new AmazonSDBClientMock();
+        
+        ((JndiRegistry) ((PropertyPlaceholderDelegateRegistry) context.getRegistry()).getRegistry())
+            .bind("amazonSDBClient", mock);
+        
+        SdbComponent component = new SdbComponent(context);
+        SdbEndpoint endpoint = (SdbEndpoint) component.createEndpoint("aws-sdb://TestDomain?"
+                + "amazonSDBClient=#amazonSDBClient");
+        
+        assertEquals("TestDomain", endpoint.getConfiguration().getDomainName());
+        assertNull(endpoint.getConfiguration().getAccessKey());
+        assertNull(endpoint.getConfiguration().getSecretKey());
+        assertSame(mock, endpoint.getConfiguration().getAmazonSDBClient());
+        assertEquals(SdbOperations.PutAttributes, endpoint.getConfiguration().getOperation());
+        assertNull(endpoint.getConfiguration().getAmazonSdbEndpoint());
+        assertNull(endpoint.getConfiguration().getConsistentRead());
+        assertNull(endpoint.getConfiguration().getMaxNumberOfDomains());
+    }
+
+    @Test
+    public void createEndpointWithMaximalConfiguration() throws Exception {
+        SdbComponent component = new SdbComponent(context);
+        SdbEndpoint endpoint = (SdbEndpoint) component.createEndpoint(
+                "aws-sdb://TestDomain?accessKey=xxx&secretKey=yyy&operation=DeleteAttributes&consistentRead=true"
+                + "&maxNumberOfDomains=5");
+        
+        assertEquals("TestDomain", endpoint.getConfiguration().getDomainName());
+        assertEquals("xxx", endpoint.getConfiguration().getAccessKey());
+        assertEquals("yyy", endpoint.getConfiguration().getSecretKey());
+        assertNull(endpoint.getConfiguration().getAmazonSDBClient());
+        assertEquals(SdbOperations.DeleteAttributes, endpoint.getConfiguration().getOperation());
+        assertNull(endpoint.getConfiguration().getAmazonSdbEndpoint());
+        assertTrue(endpoint.getConfiguration().getConsistentRead());
+        assertEquals(new Integer(5), endpoint.getConfiguration().getMaxNumberOfDomains());
+    }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void createEndpointWithoutDomainName() throws Exception {
+        SdbComponent component = new SdbComponent(context);
+        component.createEndpoint("aws-sdb:// ");
+    }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void createEndpointWithoutAmazonSDBClientConfiguration() throws Exception {
+        SdbComponent component = new SdbComponent(context);
+        component.createEndpoint("aws-sdb://TestDomain");
+    }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void createEndpointWithoutAccessKeyConfiguration() throws Exception {
+        SdbComponent component = new SdbComponent(context);
+        component.createEndpoint("aws-sdb://TestDomain?secretKey=yyy");
+    }
+    
+    @Test(expected = IllegalArgumentException.class)
+    public void createEndpointWithoutSecretKeyConfiguration() throws Exception {
+        SdbComponent component = new SdbComponent(context);
+        component.createEndpoint("aws-sdb://TestDomain?accessKey=xxx");
+    }
+}
\ No newline at end of file

Added: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentSpringTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentSpringTest.java?rev=1220761&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentSpringTest.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentSpringTest.java Mon Dec 19 14:20:07 2011
@@ -0,0 +1,295 @@
+/**
+ * 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.sdb;
+
+import java.util.Arrays;
+import java.util.List;
+
+import com.amazonaws.services.simpledb.model.Attribute;
+import com.amazonaws.services.simpledb.model.DeletableItem;
+import com.amazonaws.services.simpledb.model.Item;
+import com.amazonaws.services.simpledb.model.ReplaceableAttribute;
+import com.amazonaws.services.simpledb.model.ReplaceableItem;
+import com.amazonaws.services.simpledb.model.UpdateCondition;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.DefaultProducerTemplate;
+import org.apache.camel.test.junit4.CamelSpringTestSupport;
+import org.junit.Before;
+import org.junit.Test;
+import org.springframework.context.support.AbstractApplicationContext;
+import org.springframework.context.support.ClassPathXmlApplicationContext;
+
+public class SdbComponentSpringTest extends CamelSpringTestSupport {
+    
+    private AmazonSDBClientMock amazonSDBClient;
+    
+    @Override
+    @Before
+    public void setUp() throws Exception {
+        super.setUp();
+        
+        amazonSDBClient = context.getRegistry().lookup("amazonSDBClient", AmazonSDBClientMock.class);
+    }
+    
+    @Test
+    public void doesntCreateDomainOnStartIfExists() throws Exception {
+        assertNull(amazonSDBClient.createDomainRequest);
+    }
+    
+    @Test
+    public void createDomainOnStartIfNotExists() throws Exception {
+        DefaultProducerTemplate.newInstance(context, "aws-sdb://NonExistingDomain?amazonSDBClient=#amazonSDBClient&operation=GetAttributes");
+        
+        assertEquals("NonExistingDomain", amazonSDBClient.createDomainRequest.getDomainName());
+    }
+    
+    @Test
+    public void batchDeleteAttributes() {
+        final List<DeletableItem> deletableItems = Arrays.asList(new DeletableItem[] {
+            new DeletableItem("ITEM1", null),
+            new DeletableItem("ITEM2", null)});
+        
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchDeleteAttributes);
+                exchange.getIn().setHeader(SdbConstants.DELETABLE_ITEMS, deletableItems);
+            }
+        });
+        
+        assertEquals("TestDomain", amazonSDBClient.batchDeleteAttributesRequest.getDomainName());
+        assertEquals(deletableItems, amazonSDBClient.batchDeleteAttributesRequest.getItems());
+    }
+    
+    @Test
+    public void batchPutAttributes() {
+        final List<ReplaceableItem> replaceableItems = Arrays.asList(new ReplaceableItem[] {
+            new ReplaceableItem("ITEM1")});
+        
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchPutAttributes);
+                exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ITEMS, replaceableItems);
+            }
+        });
+        
+        assertEquals("TestDomain", amazonSDBClient.batchPutAttributesRequest.getDomainName());
+        assertEquals(replaceableItems, amazonSDBClient.batchPutAttributesRequest.getItems());
+    }
+    
+    @Test
+    public void deleteAttributes() {
+        final List<Attribute> attributes = Arrays.asList(new Attribute[] {
+            new Attribute("NAME1", "VALUE1")});
+        final UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
+        
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteAttributes);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
+            }
+        });
+        
+        assertEquals("TestDomain", amazonSDBClient.deleteAttributesRequest.getDomainName());
+        assertEquals("ITEM1", amazonSDBClient.deleteAttributesRequest.getItemName());
+        assertEquals(condition, amazonSDBClient.deleteAttributesRequest.getExpected());
+        assertEquals(attributes, amazonSDBClient.deleteAttributesRequest.getAttributes());
+    }
+    
+    @Test
+    public void deleteAttributesItemNameIsRequired() {
+        final List<Attribute> attributes = Arrays.asList(new Attribute[] {
+            new Attribute("NAME1", "VALUE1")});
+        final UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
+        
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteAttributes);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
+            }
+        });
+        
+        Exception exception = exchange.getException();
+        assertTrue(exception instanceof IllegalArgumentException);
+    }
+    
+    @Test
+    public void deleteDomain() {
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteDomain);
+            }
+        });
+        
+        assertEquals("TestDomain", amazonSDBClient.deleteDomainRequest.getDomainName());
+    }
+    
+    @Test
+    public void domainMetadata() {
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DomainMetadata);
+            }
+        });
+        
+        assertEquals("TestDomain", amazonSDBClient.domainMetadataRequest.getDomainName());
+        
+        assertEquals(new Integer(10), exchange.getIn().getHeader(SdbConstants.TIMESTAMP));
+        assertEquals(new Integer(11), exchange.getIn().getHeader(SdbConstants.ITEM_COUNT));
+        assertEquals(new Integer(12), exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_NAME_COUNT));
+        assertEquals(new Integer(13), exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_VALUE_COUNT));
+        assertEquals(new Long(1000000), exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_NAME_SIZE));
+        assertEquals(new Long(2000000), exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_VALUE_SIZE));
+        assertEquals(new Long(3000000), exchange.getIn().getHeader(SdbConstants.ITEM_NAME_SIZE));
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void getAttributes() {
+        final List<String> attributeNames = Arrays.asList(new String[] {"ATTRIBUTE1"});
+        
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.GetAttributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_NAMES, attributeNames);
+            }
+        });
+        
+        assertEquals("TestDomain", amazonSDBClient.getAttributesRequest.getDomainName());
+        assertEquals("ITEM1", amazonSDBClient.getAttributesRequest.getItemName());
+        assertEquals(Boolean.TRUE, amazonSDBClient.getAttributesRequest.getConsistentRead());
+        assertEquals(attributeNames, amazonSDBClient.getAttributesRequest.getAttributeNames());
+        
+        List<Attribute> attributes = exchange.getIn().getHeader(SdbConstants.ATTRIBUTES, List.class);
+        assertEquals(2, attributes.size());
+        assertEquals("AttributeOne", attributes.get(0).getName());
+        assertEquals("Value One", attributes.get(0).getValue());
+        assertEquals("AttributeTwo", attributes.get(1).getName());
+        assertEquals("Value Two", attributes.get(1).getValue());
+    }
+    
+    @Test
+    public void getAttributesItemNameIsRequired() {
+        final List<String> attributeNames = Arrays.asList(new String[] {"ATTRIBUTE1"});
+        
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.GetAttributes);
+                exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_NAMES, attributeNames);
+            }
+        });
+        
+        Exception exception = exchange.getException();
+        assertTrue(exception instanceof IllegalArgumentException);
+    }
+    
+    @SuppressWarnings({ "unchecked" })
+    @Test
+    public void listDomains() {
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.ListDomains);
+                exchange.getIn().setHeader(SdbConstants.MAX_NUMBER_OF_DOMAINS, new Integer(5));
+                exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1");
+            }
+        });
+        
+        assertEquals(new Integer(5), amazonSDBClient.listDomainsRequest.getMaxNumberOfDomains());
+        assertEquals("TOKEN1", amazonSDBClient.listDomainsRequest.getNextToken());
+        
+        List<String> domains = exchange.getIn().getHeader(SdbConstants.DOMAIN_NAMES, List.class);
+        assertEquals("TOKEN2", exchange.getIn().getHeader(SdbConstants.NEXT_TOKEN));
+        assertEquals(2, domains.size());
+        assertTrue(domains.contains("DOMAIN1"));
+        assertTrue(domains.contains("DOMAIN2"));
+    }
+    
+    @Test
+    public void putAttributes() {
+        final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] {
+            new ReplaceableAttribute("NAME1", "VALUE1", true)});
+        final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
+        
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
+                exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
+            }
+        });
+        
+        assertEquals("TestDomain", amazonSDBClient.putAttributesRequest.getDomainName());
+        assertEquals("ITEM1", amazonSDBClient.putAttributesRequest.getItemName());
+        assertEquals(updateCondition, amazonSDBClient.putAttributesRequest.getExpected());
+        assertEquals(replaceableAttributes, amazonSDBClient.putAttributesRequest.getAttributes());
+    }
+    
+    @Test
+    public void putAttributesItemNameIsRequired() {
+        final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] {
+            new ReplaceableAttribute("NAME1", "VALUE1", true)});
+        final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
+        
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
+                exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
+            }
+        });
+        
+        Exception exception = exchange.getException();
+        assertTrue(exception instanceof IllegalArgumentException);
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void select() {
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.Select);
+                exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1");
+                exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE);
+                exchange.getIn().setHeader(SdbConstants.SELECT_EXPRESSION, "SELECT NAME1 FROM DOMAIN1 WHERE NAME1 LIKE 'VALUE1'");
+            }
+        });
+        
+        assertEquals(Boolean.TRUE, amazonSDBClient.selectRequest.getConsistentRead());
+        assertEquals("TOKEN1", amazonSDBClient.selectRequest.getNextToken());
+        assertEquals("SELECT NAME1 FROM DOMAIN1 WHERE NAME1 LIKE 'VALUE1'", amazonSDBClient.selectRequest.getSelectExpression());
+        
+        List<Item> items = exchange.getIn().getHeader(SdbConstants.ITEMS, List.class);
+        assertEquals("TOKEN2", exchange.getIn().getHeader(SdbConstants.NEXT_TOKEN));
+        assertEquals(2, items.size());
+        assertEquals("ITEM1", items.get(0).getName());
+        assertEquals("ITEM2", items.get(1).getName());
+    }
+
+    @Override
+    protected AbstractApplicationContext createApplicationContext() {
+        return new ClassPathXmlApplicationContext(
+                "org/apache/camel/component/aws/sdb/SDBComponentSpringTest-context.xml");
+    }
+}
\ No newline at end of file

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentTest.java?rev=1220761&r1=1220760&r2=1220761&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbComponentTest.java Mon Dec 19 14:20:07 2011
@@ -16,125 +16,275 @@
  */
 package org.apache.camel.component.aws.sdb;
 
+import java.util.Arrays;
 import java.util.List;
 
-import com.amazonaws.services.simpledb.model.NoSuchDomainException;
+import com.amazonaws.services.simpledb.model.Attribute;
+import com.amazonaws.services.simpledb.model.DeletableItem;
+import com.amazonaws.services.simpledb.model.Item;
 import com.amazonaws.services.simpledb.model.ReplaceableAttribute;
+import com.amazonaws.services.simpledb.model.ReplaceableItem;
+import com.amazonaws.services.simpledb.model.UpdateCondition;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.DefaultProducerTemplate;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.junit.Test;
 
 public class SdbComponentTest extends CamelTestSupport {
-    private AmazonSDBClientMock amazonSdbClient;
-
+    
+    private AmazonSDBClientMock amazonSDBClient;
+    
     @Test
-    public void domainCreatedOnStart() throws Exception {
-        assertEquals("TestDomain", amazonSdbClient.getDomainNameToCreate());
+    public void doesntCreateDomainOnStartIfExists() throws Exception {
+        assertNull(amazonSDBClient.createDomainRequest);
     }
-
+    
+    @Test
+    public void createDomainOnStartIfNotExists() throws Exception {
+        DefaultProducerTemplate.newInstance(context, "aws-sdb://NonExistingDomain?amazonSDBClient=#amazonSDBClient&operation=GetAttributes");
+        
+        assertEquals("NonExistingDomain", amazonSDBClient.createDomainRequest.getDomainName());
+    }
+    
     @Test
-    public void putItemFromMessageHeaders() throws Exception {
+    public void batchDeleteAttributes() {
+        final List<DeletableItem> deletableItems = Arrays.asList(new DeletableItem[] {
+            new DeletableItem("ITEM1", null),
+            new DeletableItem("ITEM2", null)});
+        
         template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbConstants.OPERATION_PUT);
-                exchange.getIn().setHeader(SdbConstants.ITEM_KEY, "ItemOne");
-                exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_PREFIX + "AttributeOne", "Value One");
-                exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_PREFIX + "AttributeTwo", "Value Two");
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchDeleteAttributes);
+                exchange.getIn().setHeader(SdbConstants.DELETABLE_ITEMS, deletableItems);
             }
         });
-
-        assertEquals("TestDomain", domainNameToBeCreated());
-        assertEquals("ItemOne", itemNameToBeCreated());
-        assertEquals("Value One", getAttributeValueFor("AttributeOne"));
-        assertEquals("Value Two", getAttributeValueFor("AttributeTwo"));
-        assertEquals(2, getAttributesSize());
+        
+        assertEquals("TestDomain", amazonSDBClient.batchDeleteAttributesRequest.getDomainName());
+        assertEquals(deletableItems, amazonSDBClient.batchDeleteAttributesRequest.getItems());
     }
-
+    
     @Test
-    public void deleteItemByKey() throws Exception {
+    public void batchPutAttributes() {
+        final List<ReplaceableItem> replaceableItems = Arrays.asList(new ReplaceableItem[] {
+            new ReplaceableItem("ITEM1")});
+        
         template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbConstants.OPERATION_DELETE);
-                exchange.getIn().setHeader(SdbConstants.ITEM_KEY, "ItemOne");
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchPutAttributes);
+                exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ITEMS, replaceableItems);
             }
         });
-
-        assertEquals("ItemOne", amazonSdbClient.getItemNameToDelete());
+        
+        assertEquals("TestDomain", amazonSDBClient.batchPutAttributesRequest.getDomainName());
+        assertEquals(replaceableItems, amazonSDBClient.batchPutAttributesRequest.getItems());
     }
-
+    
     @Test
-    public void getItemByKey() throws Exception {
-        Exchange exchange = template.send("direct:start", new Processor() {
+    public void deleteAttributes() {
+        final List<Attribute> attributes = Arrays.asList(new Attribute[] {
+            new Attribute("NAME1", "VALUE1")});
+        final UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
+        
+        template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbConstants.OPERATION_GET);
-                exchange.getIn().setHeader(SdbConstants.ITEM_KEY, "ItemOne");
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteAttributes);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
             }
         });
-
-        assertEquals("Value One", exchange.getIn().getHeader("AttributeOne"));
-        assertEquals("Value Two", exchange.getIn().getHeader("AttributeTwo"));
+        
+        assertEquals("TestDomain", amazonSDBClient.deleteAttributesRequest.getDomainName());
+        assertEquals("ITEM1", amazonSDBClient.deleteAttributesRequest.getItemName());
+        assertEquals(condition, amazonSDBClient.deleteAttributesRequest.getExpected());
+        assertEquals(attributes, amazonSDBClient.deleteAttributesRequest.getAttributes());
     }
-
+    
     @Test
-    public void deletingItemOnNonExistingDomainCauseException() throws Exception {
+    public void deleteAttributesItemNameIsRequired() {
+        final List<Attribute> attributes = Arrays.asList(new Attribute[] {
+            new Attribute("NAME1", "VALUE1")});
+        final UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
+        
         Exchange exchange = template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(SdbConstants.DOMAIN_NAME, "MissingDomain");
-                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbConstants.OPERATION_DELETE);
-                exchange.getIn().setHeader(SdbConstants.ITEM_KEY, "ItemOne");
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteAttributes);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
             }
         });
-
+        
         Exception exception = exchange.getException();
-        assertNotNull("NoSuchDomainException is missing", exception);
-        assertTrue(exception instanceof NoSuchDomainException);
+        assertTrue(exception instanceof IllegalArgumentException);
     }
-
-
+    
+    @Test
+    public void deleteDomain() {
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteDomain);
+            }
+        });
+        
+        assertEquals("TestDomain", amazonSDBClient.deleteDomainRequest.getDomainName());
+    }
+    
     @Test
-    public void itemKeyHeaderIsAlwaysRequired() throws Exception {
+    public void domainMetadata() {
         Exchange exchange = template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbConstants.OPERATION_PUT);
-                exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_PREFIX + "AttributeOne", "Value One");
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DomainMetadata);
             }
         });
-
+        
+        assertEquals("TestDomain", amazonSDBClient.domainMetadataRequest.getDomainName());
+        
+        assertEquals(new Integer(10), exchange.getIn().getHeader(SdbConstants.TIMESTAMP));
+        assertEquals(new Integer(11), exchange.getIn().getHeader(SdbConstants.ITEM_COUNT));
+        assertEquals(new Integer(12), exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_NAME_COUNT));
+        assertEquals(new Integer(13), exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_VALUE_COUNT));
+        assertEquals(new Long(1000000), exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_NAME_SIZE));
+        assertEquals(new Long(2000000), exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_VALUE_SIZE));
+        assertEquals(new Long(3000000), exchange.getIn().getHeader(SdbConstants.ITEM_NAME_SIZE));
+    }
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void getAttributes() {
+        final List<String> attributeNames = Arrays.asList(new String[] {"ATTRIBUTE1"});
+        
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.GetAttributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_NAMES, attributeNames);
+            }
+        });
+        
+        assertEquals("TestDomain", amazonSDBClient.getAttributesRequest.getDomainName());
+        assertEquals("ITEM1", amazonSDBClient.getAttributesRequest.getItemName());
+        assertEquals(Boolean.TRUE, amazonSDBClient.getAttributesRequest.getConsistentRead());
+        assertEquals(attributeNames, amazonSDBClient.getAttributesRequest.getAttributeNames());
+        
+        List<Attribute> attributes = exchange.getIn().getHeader(SdbConstants.ATTRIBUTES, List.class);
+        assertEquals(2, attributes.size());
+        assertEquals("AttributeOne", attributes.get(0).getName());
+        assertEquals("Value One", attributes.get(0).getValue());
+        assertEquals("AttributeTwo", attributes.get(1).getName());
+        assertEquals("Value Two", attributes.get(1).getValue());
+    }
+    
+    @Test
+    public void getAttributesItemNameIsRequired() {
+        final List<String> attributeNames = Arrays.asList(new String[] {"ATTRIBUTE1"});
+        
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.GetAttributes);
+                exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_NAMES, attributeNames);
+            }
+        });
+        
         Exception exception = exchange.getException();
-        assertNotNull("IllegalArgumentException is missing", exception);
         assertTrue(exception instanceof IllegalArgumentException);
     }
-
-    private int getAttributesSize() {
-        return amazonSdbClient.getPutAttributesRequest().getAttributes().size();
+    
+    @SuppressWarnings({ "unchecked" })
+    @Test
+    public void listDomains() {
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.ListDomains);
+                exchange.getIn().setHeader(SdbConstants.MAX_NUMBER_OF_DOMAINS, new Integer(5));
+                exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1");
+            }
+        });
+        
+        assertEquals(new Integer(5), amazonSDBClient.listDomainsRequest.getMaxNumberOfDomains());
+        assertEquals("TOKEN1", amazonSDBClient.listDomainsRequest.getNextToken());
+        
+        List<String> domains = exchange.getIn().getHeader(SdbConstants.DOMAIN_NAMES, List.class);
+        assertEquals("TOKEN2", exchange.getIn().getHeader(SdbConstants.NEXT_TOKEN));
+        assertEquals(2, domains.size());
+        assertTrue(domains.contains("DOMAIN1"));
+        assertTrue(domains.contains("DOMAIN2"));
     }
-
-    private String getAttributeValueFor(String attributeName) {
-        List<ReplaceableAttribute> attributes = amazonSdbClient.getPutAttributesRequest().getAttributes();
-        for (ReplaceableAttribute attribute : attributes) {
-            if (attribute.getName().equals(attributeName)) {
-                return attribute.getValue();
+    
+    @Test
+    public void putAttributes() {
+        final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] {
+            new ReplaceableAttribute("NAME1", "VALUE1", true)});
+        final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
+        
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
+                exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
             }
-        }
-        return "Attribute Not Found" + attributeName;
+        });
+        
+        assertEquals("TestDomain", amazonSDBClient.putAttributesRequest.getDomainName());
+        assertEquals("ITEM1", amazonSDBClient.putAttributesRequest.getItemName());
+        assertEquals(updateCondition, amazonSDBClient.putAttributesRequest.getExpected());
+        assertEquals(replaceableAttributes, amazonSDBClient.putAttributesRequest.getAttributes());
     }
-
-    private String itemNameToBeCreated() {
-        return amazonSdbClient.getPutAttributesRequest().getItemName();
+    
+    @Test
+    public void putAttributesItemNameIsRequired() {
+        final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] {
+            new ReplaceableAttribute("NAME1", "VALUE1", true)});
+        final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
+        
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
+                exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
+            }
+        });
+        
+        Exception exception = exchange.getException();
+        assertTrue(exception instanceof IllegalArgumentException);
     }
-
-    private String domainNameToBeCreated() {
-        return amazonSdbClient.getPutAttributesRequest().getDomainName();
+    
+    @SuppressWarnings("unchecked")
+    @Test
+    public void select() {
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.Select);
+                exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1");
+                exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE);
+                exchange.getIn().setHeader(SdbConstants.SELECT_EXPRESSION, "SELECT NAME1 FROM DOMAIN1 WHERE NAME1 LIKE 'VALUE1'");
+            }
+        });
+        
+        assertEquals(Boolean.TRUE, amazonSDBClient.selectRequest.getConsistentRead());
+        assertEquals("TOKEN1", amazonSDBClient.selectRequest.getNextToken());
+        assertEquals("SELECT NAME1 FROM DOMAIN1 WHERE NAME1 LIKE 'VALUE1'", amazonSDBClient.selectRequest.getSelectExpression());
+        
+        List<Item> items = exchange.getIn().getHeader(SdbConstants.ITEMS, List.class);
+        assertEquals("TOKEN2", exchange.getIn().getHeader(SdbConstants.NEXT_TOKEN));
+        assertEquals(2, items.size());
+        assertEquals("ITEM1", items.get(0).getName());
+        assertEquals("ITEM2", items.get(1).getName());
     }
 
     @Override
     protected JndiRegistry createRegistry() throws Exception {
         JndiRegistry registry = super.createRegistry();
-        amazonSdbClient = new AmazonSDBClientMock();
-        registry.bind("amazonSdbClient", amazonSdbClient);
+        
+        amazonSDBClient = new AmazonSDBClientMock();
+        registry.bind("amazonSDBClient", amazonSDBClient);
+        
         return registry;
     }
 
@@ -144,8 +294,8 @@ public class SdbComponentTest extends Ca
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                        .to("aws-sdb://TestDomain?amazonSdbClient=#amazonSdbClient&operation=CamelAwsSdbGet");
+                        .to("aws-sdb://TestDomain?amazonSDBClient=#amazonSDBClient&operation=GetAttributes");
             }
         };
     }
-}
+}
\ No newline at end of file

Added: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbOperationsTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbOperationsTest.java?rev=1220761&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbOperationsTest.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SdbOperationsTest.java Mon Dec 19 14:20:07 2011
@@ -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.sdb;
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class SdbOperationsTest {
+
+    @Test
+    public void supportedOperationCount() {
+        assertEquals(9, SdbOperations.values().length);
+    }
+    
+    @Test
+    public void valueOf() {
+        assertEquals(SdbOperations.BatchDeleteAttributes, SdbOperations.valueOf("BatchDeleteAttributes"));
+        assertEquals(SdbOperations.BatchPutAttributes, SdbOperations.valueOf("BatchPutAttributes"));
+        assertEquals(SdbOperations.DeleteAttributes, SdbOperations.valueOf("DeleteAttributes"));
+        assertEquals(SdbOperations.DeleteDomain, SdbOperations.valueOf("DeleteDomain"));
+        assertEquals(SdbOperations.DomainMetadata, SdbOperations.valueOf("DomainMetadata"));
+        assertEquals(SdbOperations.GetAttributes, SdbOperations.valueOf("GetAttributes"));
+        assertEquals(SdbOperations.ListDomains, SdbOperations.valueOf("ListDomains"));
+        assertEquals(SdbOperations.PutAttributes, SdbOperations.valueOf("PutAttributes"));
+        assertEquals(SdbOperations.Select, SdbOperations.valueOf("Select"));
+    }
+    
+    @Test
+    public void testToString() {
+        assertEquals(SdbOperations.BatchDeleteAttributes.toString(), "BatchDeleteAttributes");
+        assertEquals(SdbOperations.BatchPutAttributes.toString(), "BatchPutAttributes");
+        assertEquals(SdbOperations.DeleteAttributes.toString(), "DeleteAttributes");
+        assertEquals(SdbOperations.DeleteDomain.toString(), "DeleteDomain");
+        assertEquals(SdbOperations.DomainMetadata.toString(), "DomainMetadata");
+        assertEquals(SdbOperations.GetAttributes.toString(), "GetAttributes");
+        assertEquals(SdbOperations.ListDomains.toString(), "ListDomains");
+        assertEquals(SdbOperations.PutAttributes.toString(), "PutAttributes");
+        assertEquals(SdbOperations.Select.toString(), "Select");
+    }
+}

Added: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SelectCommandTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SelectCommandTest.java?rev=1220761&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SelectCommandTest.java (added)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/SelectCommandTest.java Mon Dec 19 14:20:07 2011
@@ -0,0 +1,77 @@
+/**
+ * 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.sdb;
+
+import java.util.List;
+
+import com.amazonaws.services.simpledb.model.Item;
+
+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;
+import static org.junit.Assert.assertNull;
+
+public class SelectCommandTest {
+
+    private SelectCommand command;
+    private AmazonSDBClientMock sdbClient;
+    private SdbConfiguration configuration;
+    private Exchange exchange;
+    
+    @Before
+    public void setUp() {
+        sdbClient = new AmazonSDBClientMock();
+        configuration = new SdbConfiguration();
+        configuration.setDomainName("DOMAIN1");
+        configuration.setConsistentRead(Boolean.TRUE);
+        exchange = new DefaultExchange(new DefaultCamelContext());
+        
+        command = new SelectCommand(sdbClient, configuration, exchange);
+    }
+
+    @SuppressWarnings("unchecked")
+    @Test
+    public void execute() {
+        exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1");
+        exchange.getIn().setHeader(SdbConstants.SELECT_EXPRESSION, "SELECT NAME1 FROM DOMAIN1 WHERE NAME1 LIKE 'VALUE1'");
+        
+        command.execute();
+        
+        assertEquals(Boolean.TRUE, sdbClient.selectRequest.getConsistentRead());
+        assertEquals("TOKEN1", sdbClient.selectRequest.getNextToken());
+        assertEquals("SELECT NAME1 FROM DOMAIN1 WHERE NAME1 LIKE 'VALUE1'", sdbClient.selectRequest.getSelectExpression());
+        
+        List<Item> items = exchange.getIn().getHeader(SdbConstants.ITEMS, List.class);
+        assertEquals("TOKEN2", exchange.getIn().getHeader(SdbConstants.NEXT_TOKEN));
+        assertEquals(2, items.size());
+        assertEquals("ITEM1", items.get(0).getName());
+        assertEquals("ITEM2", items.get(1).getName());
+    }
+    
+    @Test
+    public void determineSelectExpression() {
+        assertNull(this.command.determineSelectExpression());
+
+        exchange.getIn().setHeader(SdbConstants.SELECT_EXPRESSION, "SELECT NAME1 FROM DOMAIN1 WHERE NAME1 LIKE 'VALUE1'");
+
+        assertEquals("SELECT NAME1 FROM DOMAIN1 WHERE NAME1 LIKE 'VALUE1'", this.command.determineSelectExpression());
+    }
+}
\ No newline at end of file

Modified: camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/integration/SdbComponentIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/integration/SdbComponentIntegrationTest.java?rev=1220761&r1=1220760&r2=1220761&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/integration/SdbComponentIntegrationTest.java (original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/java/org/apache/camel/component/aws/sdb/integration/SdbComponentIntegrationTest.java Mon Dec 19 14:20:07 2011
@@ -16,58 +16,163 @@
  */
 package org.apache.camel.component.aws.sdb.integration;
 
+import java.util.Arrays;
+import java.util.List;
+
+import com.amazonaws.services.simpledb.model.Attribute;
+import com.amazonaws.services.simpledb.model.DeletableItem;
+import com.amazonaws.services.simpledb.model.ReplaceableAttribute;
+import com.amazonaws.services.simpledb.model.ReplaceableItem;
+import com.amazonaws.services.simpledb.model.UpdateCondition;
+
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.component.aws.sdb.SdbConstants;
+import org.apache.camel.component.aws.sdb.SdbOperations;
 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 SdbComponentIntegrationTest extends CamelTestSupport {
-
+    
+    @Test
+    public void batchDeleteAttributes() {
+        final List<DeletableItem> deletableItems = Arrays.asList(new DeletableItem[] {
+            new DeletableItem("ITEM1", null),
+            new DeletableItem("ITEM2", null)});
+        
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchDeleteAttributes);
+                exchange.getIn().setHeader(SdbConstants.DELETABLE_ITEMS, deletableItems);
+            }
+        });
+    }
+    
+    @Test
+    public void batchPutAttributes() {
+        final List<ReplaceableItem> replaceableItems = Arrays.asList(new ReplaceableItem[] {
+            new ReplaceableItem("ITEM1")});
+        
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchPutAttributes);
+                exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ITEMS, replaceableItems);
+            }
+        });
+    }
+    
+    @Test
+    public void deleteAttributes() {
+        final List<Attribute> attributes = Arrays.asList(new Attribute[] {
+            new Attribute("NAME1", "VALUE1")});
+        final UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
+        
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteAttributes);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
+            }
+        });
+    }
+    
+    @Test
+    public void deleteDomain() {
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteDomain);
+            }
+        });
+    }
+    
     @Test
-    public void putItemFromMessageHeaders() throws Exception {
+    public void domainMetadata() {
         Exchange exchange = template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbConstants.OPERATION_PUT);
-                exchange.getIn().setHeader(SdbConstants.ITEM_KEY, "ItemOne");
-                exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_PREFIX + "AttributeOne", "Value One");
-                exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_PREFIX + "AttributeTwo", "Value Two");
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DomainMetadata);
             }
         });
-
-        assertNull("No exceptions during PUT operation", exchange.getException());
-
-        exchange = template.send("direct:start", new Processor() {
+        
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.TIMESTAMP));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ITEM_COUNT));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_NAME_COUNT));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_VALUE_COUNT));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_NAME_SIZE));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_VALUE_SIZE));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ITEM_NAME_SIZE));
+    }
+    
+    @Test
+    public void getAttributes() {
+        final List<String> attributeNames = Arrays.asList(new String[] {"ATTRIBUTE1"});
+        
+        Exchange exchange = template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbConstants.OPERATION_GET);
-                exchange.getIn().setHeader(SdbConstants.ITEM_KEY, "ItemOne");
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.GetAttributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_NAMES, attributeNames);
             }
         });
-
-        assertNull("No exceptions during GET operation", exchange.getException());
-        assertEquals("Value One", exchange.getIn().getHeader("AttributeOne"));
-        assertEquals("Value Two", exchange.getIn().getHeader("AttributeTwo"));
-
-        exchange = template.send("direct:start", new Processor() {
+        
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTES, List.class));
+    }
+    
+    @Test
+    public void listDomains() {
+        Exchange exchange = template.send("direct:start", new Processor() {
             public void process(Exchange exchange) throws Exception {
-                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbConstants.OPERATION_DELETE);
-                exchange.getIn().setHeader(SdbConstants.ITEM_KEY, "ItemOne");
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.ListDomains);
+                exchange.getIn().setHeader(SdbConstants.MAX_NUMBER_OF_DOMAINS, new Integer(5));
+                exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1");
             }
         });
-
-        assertNull("No exceptions during DELETE operation", exchange.getException());
+        
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.DOMAIN_NAMES, List.class));
+    }
+    
+    @Test
+    public void putAttributes() {
+        final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] {
+            new ReplaceableAttribute("NAME1", "VALUE1", true)});
+        final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
+        
+        template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
+                exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
+            }
+        });
+    }
+    
+    @Test
+    public void select() {
+        Exchange exchange = template.send("direct:start", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.Select);
+                exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1");
+                exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE);
+                exchange.getIn().setHeader(SdbConstants.SELECT_EXPRESSION, "SELECT NAME1 FROM DOMAIN1 WHERE NAME1 LIKE 'VALUE1'");
+            }
+        });
+        
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ITEMS, List.class));
     }
 
+    @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             @Override
             public void configure() throws Exception {
                 from("direct:start")
-                        .to("aws-sdb://TestDomain?accessKey=xxx&secretKey=yyy");
+                        .to("aws-sdb://TestDomain?accessKey=xxx&secretKey=yyy&operation=GetAttributes");
             }
         };
     }
-}
+}
\ No newline at end of file

Copied: camel/branches/camel-2.8.x/components/camel-aws/src/test/resources/org/apache/camel/component/aws/sdb/SDBComponentSpringTest-context.xml (from r1220717, camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml)
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/components/camel-aws/src/test/resources/org/apache/camel/component/aws/sdb/SDBComponentSpringTest-context.xml?p2=camel/branches/camel-2.8.x/components/camel-aws/src/test/resources/org/apache/camel/component/aws/sdb/SDBComponentSpringTest-context.xml&p1=camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml&r1=1220717&r2=1220761&rev=1220761&view=diff
==============================================================================
--- camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/resources/org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml (original)
+++ camel/branches/camel-2.8.x/components/camel-aws/src/test/resources/org/apache/camel/component/aws/sdb/SDBComponentSpringTest-context.xml Mon Dec 19 14:20:07 2011
@@ -23,32 +23,9 @@
     <camelContext id="camel" xmlns="http://camel.apache.org/schema/spring">
         <route>
             <from uri="direct:start"/>
-            <to uri="aws-sqs://MyQueue?accessKey=xxx&amp;secretKey=yyy"/>
-        </route>
-
-        <route>
-            <from uri="aws-sqs://MyQueue?accessKey=xxx&amp;secretKey=yyy"/>
-            <to uri="mock:result"/>
-        </route>
-        
-        <route>
-            <from uri="direct:start-sns"/>
-            <to uri="aws-sns://MyTopic?accessKey=xxx&amp;secretKey=yyy"/>
-        </route>
-        
-        <route>
-            <from uri="direct:start-s3"/>
-            <to uri="aws-s3://mycamelbucket?accessKey=xxx&amp;secretKey=yyy"/>
-        </route>
-        
-        <route>
-            <from uri="aws-s3://mycamelbucket?accessKey=xxx&amp;secretKey=yyy&amp;maxMessagesPerPoll=5"/>
-            <to uri="mock:result-s3"/>
-        </route>
-        
-        <route>
-            <from uri="direct:start-ses"/>
-            <to uri="aws-ses://from@example.com?accessKey=xxx&amp;secretKey=yyy"/>
+            <to uri="aws-sdb://TestDomain?amazonSDBClient=#amazonSDBClient&amp;operation=GetAttributes"/>
         </route>
     </camelContext>
+
+    <bean id="amazonSDBClient" class="org.apache.camel.component.aws.sdb.AmazonSDBClientMock"/>
 </beans>
\ No newline at end of file

Added: camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSDBClientMock.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSDBClientMock.java?rev=1220761&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSDBClientMock.java (added)
+++ camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AmazonSDBClientMock.java Mon Dec 19 14:20:07 2011
@@ -0,0 +1,142 @@
+/**
+ * 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.itest.osgi.aws;
+
+import com.amazonaws.AmazonClientException;
+import com.amazonaws.AmazonServiceException;
+import com.amazonaws.auth.BasicAWSCredentials;
+import com.amazonaws.services.simpledb.AmazonSimpleDBClient;
+import com.amazonaws.services.simpledb.model.Attribute;
+import com.amazonaws.services.simpledb.model.BatchDeleteAttributesRequest;
+import com.amazonaws.services.simpledb.model.BatchPutAttributesRequest;
+import com.amazonaws.services.simpledb.model.CreateDomainRequest;
+import com.amazonaws.services.simpledb.model.DeleteAttributesRequest;
+import com.amazonaws.services.simpledb.model.DeleteDomainRequest;
+import com.amazonaws.services.simpledb.model.DomainMetadataRequest;
+import com.amazonaws.services.simpledb.model.DomainMetadataResult;
+import com.amazonaws.services.simpledb.model.GetAttributesRequest;
+import com.amazonaws.services.simpledb.model.GetAttributesResult;
+import com.amazonaws.services.simpledb.model.Item;
+import com.amazonaws.services.simpledb.model.ListDomainsRequest;
+import com.amazonaws.services.simpledb.model.ListDomainsResult;
+import com.amazonaws.services.simpledb.model.NoSuchDomainException;
+import com.amazonaws.services.simpledb.model.PutAttributesRequest;
+import com.amazonaws.services.simpledb.model.SelectRequest;
+import com.amazonaws.services.simpledb.model.SelectResult;
+
+public class AmazonSDBClientMock extends AmazonSimpleDBClient {
+    
+    protected BatchDeleteAttributesRequest batchDeleteAttributesRequest;
+    protected BatchPutAttributesRequest batchPutAttributesRequest;
+    protected CreateDomainRequest createDomainRequest;
+    protected DeleteAttributesRequest deleteAttributesRequest;
+    protected DeleteDomainRequest deleteDomainRequest;
+    protected DomainMetadataRequest domainMetadataRequest;
+    protected GetAttributesRequest getAttributesRequest;
+    protected ListDomainsRequest listDomainsRequest;
+    protected PutAttributesRequest putAttributesRequest;
+    protected SelectRequest selectRequest;
+
+    public AmazonSDBClientMock() {
+        super(new BasicAWSCredentials("user", "secret"));
+    }
+    
+    @Override
+    public void batchDeleteAttributes(BatchDeleteAttributesRequest batchDeleteAttributesRequest) throws AmazonServiceException, AmazonClientException {
+        this.batchDeleteAttributesRequest = batchDeleteAttributesRequest;
+    }
+    
+    @Override
+    public void batchPutAttributes(BatchPutAttributesRequest batchPutAttributesRequest) throws AmazonServiceException, AmazonClientException {
+        this.batchPutAttributesRequest = batchPutAttributesRequest;
+    }
+    
+    @Override
+    public void createDomain(CreateDomainRequest createDomainRequest) throws AmazonServiceException, AmazonClientException {
+        this.createDomainRequest = createDomainRequest;
+    }
+    
+    @Override
+    public void deleteAttributes(DeleteAttributesRequest deleteAttributesRequest) throws AmazonServiceException, AmazonClientException {
+        this.deleteAttributesRequest = deleteAttributesRequest;
+        
+        String domainName = deleteAttributesRequest.getDomainName();
+        if ("MissingDomain".equals(domainName)) {
+            throw new NoSuchDomainException(domainName);
+        }
+    }
+    
+    @Override
+    public void deleteDomain(DeleteDomainRequest deleteDomainRequest) throws AmazonServiceException, AmazonClientException {
+        this.deleteDomainRequest = deleteDomainRequest;
+    }
+
+    @Override
+    public DomainMetadataResult domainMetadata(DomainMetadataRequest domainMetadataRequest) throws AmazonServiceException, AmazonClientException {
+        this.domainMetadataRequest = domainMetadataRequest;
+        
+        if ("NonExistingDomain".equals(domainMetadataRequest.getDomainName())) {
+            throw new NoSuchDomainException("Domain 'NonExistingDomain' doesn't exist.");
+        }
+        
+        DomainMetadataResult result = new DomainMetadataResult();
+        result.setTimestamp(new Integer(10));
+        result.setItemCount(new Integer(11));
+        result.setAttributeNameCount(new Integer(12));
+        result.setAttributeValueCount(new Integer(13));
+        result.setAttributeNamesSizeBytes(new Long(1000000));
+        result.setAttributeValuesSizeBytes(new Long(2000000));
+        result.setItemNamesSizeBytes(new Long(3000000));
+        return result;
+    }
+    
+    @Override
+    public GetAttributesResult getAttributes(GetAttributesRequest getAttributesRequest) throws AmazonServiceException, AmazonClientException {
+        this.getAttributesRequest = getAttributesRequest;
+        
+        return new GetAttributesResult()
+                .withAttributes(new Attribute("AttributeOne", "Value One"))
+                .withAttributes(new Attribute("AttributeTwo", "Value Two"));
+    }
+    
+    @Override
+    public ListDomainsResult listDomains(ListDomainsRequest listDomainsRequest) throws AmazonServiceException, AmazonClientException {
+        this.listDomainsRequest = listDomainsRequest;
+        
+        ListDomainsResult result = new ListDomainsResult();
+        result.getDomainNames().add("DOMAIN1");
+        result.getDomainNames().add("DOMAIN2");
+        result.setNextToken("TOKEN2");
+        return result;
+    }
+
+    @Override
+    public void putAttributes(PutAttributesRequest putAttributesRequest) throws AmazonServiceException, AmazonClientException {
+        this.putAttributesRequest = putAttributesRequest;
+    }
+    
+    @Override
+    public SelectResult select(SelectRequest selectRequest) throws AmazonServiceException, AmazonClientException {
+        this.selectRequest = selectRequest;
+        
+        SelectResult result = new SelectResult();
+        result.setNextToken("TOKEN2");
+        result.getItems().add(new Item("ITEM1", null));
+        result.getItems().add(new Item("ITEM2", null));
+        return result;
+    }
+}
\ No newline at end of file

Added: camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSdbIntegrationTest.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSdbIntegrationTest.java?rev=1220761&view=auto
==============================================================================
--- camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSdbIntegrationTest.java (added)
+++ camel/branches/camel-2.8.x/tests/camel-itest-osgi/src/test/java/org/apache/camel/itest/osgi/aws/AwsSdbIntegrationTest.java Mon Dec 19 14:20:07 2011
@@ -0,0 +1,175 @@
+/**
+ * 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.itest.osgi.aws;
+
+import java.util.Arrays;
+import java.util.List;
+
+import com.amazonaws.services.simpledb.model.Attribute;
+import com.amazonaws.services.simpledb.model.DeletableItem;
+import com.amazonaws.services.simpledb.model.ReplaceableAttribute;
+import com.amazonaws.services.simpledb.model.ReplaceableItem;
+import com.amazonaws.services.simpledb.model.UpdateCondition;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.aws.sdb.SdbConstants;
+import org.apache.camel.component.aws.sdb.SdbOperations;
+import org.junit.Ignore;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.junit.JUnit4TestRunner;
+import org.springframework.osgi.context.support.OsgiBundleXmlApplicationContext;
+
+@RunWith(JUnit4TestRunner.class)
+@Ignore("Must be manually tested. Provide your own accessKey and secretKey!")
+public class AwsSdbIntegrationTest extends AwsTestSupport {
+    
+    @Override
+    protected OsgiBundleXmlApplicationContext createApplicationContext() {
+        return new OsgiBundleXmlApplicationContext(
+                new String[]{"org/apache/camel/itest/osgi/aws/CamelIntegrationContext.xml"});
+    }
+    
+    @Test
+    public void batchDeleteAttributes() {
+        final List<DeletableItem> deletableItems = Arrays.asList(new DeletableItem[] {
+            new DeletableItem("ITEM1", null),
+            new DeletableItem("ITEM2", null)});
+        
+        template.send("direct:start-sdb", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchDeleteAttributes);
+                exchange.getIn().setHeader(SdbConstants.DELETABLE_ITEMS, deletableItems);
+            }
+        });
+    }
+    
+    @Test
+    public void batchPutAttributes() {
+        final List<ReplaceableItem> replaceableItems = Arrays.asList(new ReplaceableItem[] {
+            new ReplaceableItem("ITEM1")});
+        
+        template.send("direct:start-sdb", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.BatchPutAttributes);
+                exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ITEMS, replaceableItems);
+            }
+        });
+    }
+    
+    @Test
+    public void deleteAttributes() {
+        final List<Attribute> attributes = Arrays.asList(new Attribute[] {
+            new Attribute("NAME1", "VALUE1")});
+        final UpdateCondition condition = new UpdateCondition("Key1", "Value1", true);
+        
+        template.send("direct:start-sdb", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteAttributes);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTES, attributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, condition);
+            }
+        });
+    }
+    
+    @Test
+    public void deleteDomain() {
+        template.send("direct:start-sdb", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DeleteDomain);
+            }
+        });
+    }
+    
+    @Test
+    public void domainMetadata() {
+        Exchange exchange = template.send("direct:start-sdb", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.DomainMetadata);
+            }
+        });
+        
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.TIMESTAMP));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ITEM_COUNT));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_NAME_COUNT));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_VALUE_COUNT));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_NAME_SIZE));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTE_VALUE_SIZE));
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ITEM_NAME_SIZE));
+    }
+    
+    @Test
+    public void getAttributes() {
+        final List<String> attributeNames = Arrays.asList(new String[] {"ATTRIBUTE1"});
+        
+        Exchange exchange = template.send("direct:start-sdb", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.GetAttributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE);
+                exchange.getIn().setHeader(SdbConstants.ATTRIBUTE_NAMES, attributeNames);
+            }
+        });
+        
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ATTRIBUTES, List.class));
+    }
+    
+    @Test
+    public void listDomains() {
+        Exchange exchange = template.send("direct:start-sdb", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.ListDomains);
+                exchange.getIn().setHeader(SdbConstants.MAX_NUMBER_OF_DOMAINS, new Integer(5));
+                exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1");
+            }
+        });
+        
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.DOMAIN_NAMES, List.class));
+    }
+    
+    @Test
+    public void putAttributes() {
+        final List<ReplaceableAttribute> replaceableAttributes = Arrays.asList(new ReplaceableAttribute[] {
+            new ReplaceableAttribute("NAME1", "VALUE1", true)});
+        final UpdateCondition updateCondition = new UpdateCondition("NAME1", "VALUE1", true);
+        
+        template.send("direct:start-sdb", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.PutAttributes);
+                exchange.getIn().setHeader(SdbConstants.ITEM_NAME, "ITEM1");
+                exchange.getIn().setHeader(SdbConstants.UPDATE_CONDITION, updateCondition);
+                exchange.getIn().setHeader(SdbConstants.REPLACEABLE_ATTRIBUTES, replaceableAttributes);
+            }
+        });
+    }
+    
+    @Test
+    public void select() {
+        Exchange exchange = template.send("direct:start-sdb", new Processor() {
+            public void process(Exchange exchange) throws Exception {
+                exchange.getIn().setHeader(SdbConstants.OPERATION, SdbOperations.Select);
+                exchange.getIn().setHeader(SdbConstants.NEXT_TOKEN, "TOKEN1");
+                exchange.getIn().setHeader(SdbConstants.CONSISTENT_READ, Boolean.TRUE);
+                exchange.getIn().setHeader(SdbConstants.SELECT_EXPRESSION, "SELECT NAME1 FROM DOMAIN1 WHERE NAME1 LIKE 'VALUE1'");
+            }
+        });
+        
+        assertNotNull(exchange.getIn().getHeader(SdbConstants.ITEMS, List.class));
+    }
+}
\ No newline at end of file