You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2014/12/23 12:25:01 UTC

[1/5] camel git commit: CAMEL-2939: Camel Cassandra 3 CQL3 first edition

Repository: camel
Updated Branches:
  refs/heads/master dade39629 -> bf4ddfe8b


http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
new file mode 100644
index 0000000..5cc42e6
--- /dev/null
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
@@ -0,0 +1,87 @@
+package org.apache.camel.component.cassandra;
+
+import com.datastax.driver.core.Cluster;
+import org.apache.camel.component.cassandra.CassandraEndpoint;
+import org.apache.camel.component.cassandra.CassandraConstants;
+import com.datastax.driver.core.ConsistencyLevel;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+import java.util.Arrays;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.cassandraunit.CassandraCQLUnit;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class CassandraComponentProducerTest extends CamelTestSupport {
+    @Rule
+    public CassandraCQLUnit cassandra=CassandraUnitUtils.cassandraCQLUnit();
+    @Produce(uri = "direct:input")
+    ProducerTemplate producerTemplate;
+    @Produce(uri = "direct:inputNotConsistent")
+    ProducerTemplate notConsistentProducerTemplate;
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        CassandraUnitUtils.startEmbeddedCassandra();
+    }
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+        CassandraUnitUtils.cleanEmbeddedCassandra();
+    }
+    private static final String CQL = "insert into camel_user(login, first_name, last_name) values (?, ?, ?)";
+    private static final String NOT_CONSISTENT_URI="cql://localhost/camel_ks?cql="+CQL+"&consistencyLevel=ANY";
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {
+                
+                from("direct:input")
+                  .to("cql://localhost/camel_ks?cql="+CQL);
+                from("direct:inputNotConsistent")
+                  .to(NOT_CONSISTENT_URI);
+            }
+        };
+    }
+    @Test
+    public void testRequest_UriCql() throws Exception {
+        Object response = producerTemplate.requestBody(Arrays.asList("w_jiang","Willem","Jiang"));
+        
+        Cluster cluster = CassandraUnitUtils.cassandraCluster();
+        Session session = cluster.connect(CassandraUnitUtils.KEYSPACE);
+        ResultSet resultSet = session.execute("select login, first_name, last_name from camel_user where login = ?", "w_jiang");
+        Row row = resultSet.one();
+        assertNotNull(row);
+        assertEquals("Willem", row.getString("first_name"));
+        assertEquals("Jiang", row.getString("last_name"));
+        session.close();
+        cluster.close();
+    }
+    @Test
+    public void testRequest_MessageCql() throws Exception {
+        Object response = producerTemplate.requestBodyAndHeader(new Object[]{"Claus 2","Ibsen 2", "c_ibsen"}, CassandraConstants.CQL_QUERY, "update camel_user set first_name=?, last_name=? where login=?");
+        
+        Cluster cluster = CassandraUnitUtils.cassandraCluster();
+        Session session = cluster.connect(CassandraUnitUtils.KEYSPACE);
+        ResultSet resultSet = session.execute("select login, first_name, last_name from camel_user where login = ?", "c_ibsen");
+        Row row = resultSet.one();
+        assertNotNull(row);
+        assertEquals("Claus 2", row.getString("first_name"));
+        assertEquals("Ibsen 2", row.getString("last_name"));
+        session.close();
+        cluster.close();
+    }
+
+    @Test
+    public void testRequest_NotConsistent() throws Exception {
+        
+        CassandraEndpoint endpoint = getMandatoryEndpoint(NOT_CONSISTENT_URI, CassandraEndpoint.class);
+        assertEquals(ConsistencyLevel.ANY, endpoint.getConsistencyLevel());
+        
+        Object response = notConsistentProducerTemplate.requestBody(Arrays.asList("j_anstey","Jonathan","Anstey"));
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraUnitUtils.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraUnitUtils.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraUnitUtils.java
new file mode 100644
index 0000000..4bbcab0
--- /dev/null
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraUnitUtils.java
@@ -0,0 +1,77 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.cassandra;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+import org.cassandraunit.CQLDataLoader;
+import org.cassandraunit.CassandraCQLUnit;
+import org.cassandraunit.dataset.CQLDataSet;
+import org.cassandraunit.dataset.cql.ClassPathCQLDataSet;
+import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
+
+/**
+ * Util methods to manage Cassandra in Unit tests
+ */
+public class CassandraUnitUtils {
+    public static final String HOST = "127.0.0.1";
+    public static final String KEYSPACE = "camel_ks";
+
+    private static CassandraCQLUnit cassandraCQLUnit;
+    /**
+     * Create Cassandra JUnit Rule.
+     */
+    public static CassandraCQLUnit cassandraCQLUnit() {
+        if (cassandraCQLUnit == null) {
+            cassandraCQLUnit = cassandraCQLUnit("BasicDataSet.cql");
+        }
+        return cassandraCQLUnit;
+    }
+    public static CassandraCQLUnit cassandraCQLUnit(String dataSetCql) {
+        return cassandraCQLUnit(cqlDataSet(dataSetCql));
+    }
+
+    public static CQLDataSet cqlDataSet(String dataSetCql) {
+        return new ClassPathCQLDataSet(dataSetCql, KEYSPACE);
+    }
+    public static void loadCQLDataSet(Session session, String dataSetCql) {
+        CQLDataLoader loader = new CQLDataLoader(session);
+        loader.load(cqlDataSet(dataSetCql));
+    }
+
+    public static CassandraCQLUnit cassandraCQLUnit(CQLDataSet dataset) {
+        return new CassandraCQLUnit(dataset, "/camel-cassandra.yaml", HOST, 9042);
+    }
+    /**
+     * Start embedded Cassandra.
+     */
+    public static void startEmbeddedCassandra() throws Exception {
+        EmbeddedCassandraServerHelper.startEmbeddedCassandra("/camel-cassandra.yaml", "target/camel-cassandra");
+    }
+
+    /**
+     * Clean embedded Cassandra.
+     */
+    public static void cleanEmbeddedCassandra() throws Exception {
+        EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
+    }
+    public static Cluster cassandraCluster() {
+        return Cluster.builder()
+                .addContactPoint(HOST)
+                .withClusterName("camel-cluster")
+                .build();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/ResultSetConversionStrategiesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/ResultSetConversionStrategiesTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/ResultSetConversionStrategiesTest.java
new file mode 100644
index 0000000..fbb5393
--- /dev/null
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/ResultSetConversionStrategiesTest.java
@@ -0,0 +1,73 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.cassandra;
+
+import org.apache.camel.component.cassandra.ResultSetConversionStrategy;
+import org.apache.camel.component.cassandra.ResultSetConversionStrategies;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import java.util.Collections;
+import java.util.List;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.*;
+import static org.junit.matchers.JUnitMatchers.*;
+
+/**
+ * Unit test for {@link ResultSetConversionStrategy} implementations
+ */
+public class ResultSetConversionStrategiesTest {
+    
+    public ResultSetConversionStrategiesTest() {
+    }
+
+    @Test
+    public void testAll() {
+        ResultSetConversionStrategy strategy = ResultSetConversionStrategies.fromName("ALL");
+        ResultSet resultSet = mock(ResultSet.class);
+        List<Row> rows = Collections.nCopies(20, mock(Row.class));
+        when(resultSet.all()).thenReturn(rows);
+        
+        Object body = strategy.getBody(resultSet);
+        assertTrue(body instanceof List);
+        assertSame(rows, body);        
+    }
+    
+    @Test
+    public void testOne() {
+        ResultSetConversionStrategy strategy = ResultSetConversionStrategies.fromName("ONE");
+        ResultSet resultSet = mock(ResultSet.class);
+        Row row = mock(Row.class);
+        when(resultSet.one()).thenReturn(row);
+        
+        Object body = strategy.getBody(resultSet);
+        assertTrue(body instanceof Row);
+        assertSame(row, body);        
+    }
+
+    @Test
+    public void testLimit() {
+        ResultSetConversionStrategy strategy = ResultSetConversionStrategies.fromName("LIMIT_10");
+        ResultSet resultSet = mock(ResultSet.class);
+        List<Row> rows = Collections.nCopies(20, mock(Row.class));
+        when(resultSet.iterator()).thenReturn(rows.iterator());
+        
+        Object body = strategy.getBody(resultSet);
+        assertTrue(body instanceof List);
+        assertEquals(10, ((List) body).size());        
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
new file mode 100644
index 0000000..9f906b6
--- /dev/null
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
@@ -0,0 +1,182 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.processor.aggregate.cassandra;
+
+import org.apache.camel.processor.aggregate.cassandra.CassandraAggregationRepository;
+import org.apache.camel.processor.aggregate.cassandra.NamedCassandraAggregationRepository;
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.cassandra.CassandraUnitUtils;
+import org.apache.camel.impl.DefaultCamelContext;
+import org.apache.camel.impl.DefaultExchange;
+import org.cassandraunit.CassandraCQLUnit;
+import org.junit.After;
+import org.junit.AfterClass;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import java.util.Set;
+/**
+ * Unite test for {@link CassandraAggregationRepository}
+ */
+public class CassandraAggregationRepositoryTest {
+    private Cluster cluster;
+    private Session session;
+    private CassandraAggregationRepository aggregationRepository;
+    private CamelContext camelContext;
+    @Rule
+    public CassandraCQLUnit cassandraRule = CassandraUnitUtils.cassandraCQLUnit("AggregationDataSet.cql");
+    
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        CassandraUnitUtils.startEmbeddedCassandra();
+    }
+    @Before
+    public void setUp() throws Exception {
+        camelContext =new DefaultCamelContext();
+        cluster = CassandraUnitUtils.cassandraCluster();
+        session = cluster.connect(CassandraUnitUtils.KEYSPACE);
+        aggregationRepository = new NamedCassandraAggregationRepository(session, "ID");
+        aggregationRepository.start();
+    }
+    @After
+    public void tearDown() throws Exception {
+        aggregationRepository.stop();
+        session.close();
+        cluster.close();
+    }
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+        CassandraUnitUtils.cleanEmbeddedCassandra();
+    }
+    private boolean exists(String key) {
+        return session.execute(
+                "select KEY from CAMEL_AGGREGATION where NAME=? and KEY=?", "ID", key)
+                .one()!=null;
+    }
+    @Test
+    public void testAdd() {
+        // Given
+        String key="Add";
+        assertFalse(exists(key));
+        Exchange exchange = new DefaultExchange(camelContext);
+        // When
+        aggregationRepository.add(camelContext, key, exchange);
+        // Then
+        assertTrue(exists(key));        
+    }
+    @Test
+    public void testGet_Exists() {
+        // Given
+        String key="Get_Exists";
+        Exchange exchange = new DefaultExchange(camelContext);
+        aggregationRepository.add(camelContext, key, exchange);
+        assertTrue(exists(key));
+        // When
+        Exchange exchange2=aggregationRepository.get(camelContext, key);
+        // Then
+        assertNotNull(exchange2);
+        assertEquals(exchange.getExchangeId(), exchange2.getExchangeId());        
+    }
+    @Test
+    public void testGet_NotExists() {
+        // Given
+        String key="Get_NotExists";
+        assertFalse(exists(key));
+        // When
+        Exchange exchange2=aggregationRepository.get(camelContext, key);
+        // Then
+        assertNull(exchange2);
+    }
+    @Test
+    public void testRemove_Exists() {
+        // Given
+        String key="Remove_Exists";
+        Exchange exchange = new DefaultExchange(camelContext);
+        aggregationRepository.add(camelContext, key, exchange);
+        assertTrue(exists(key));
+        // When
+        aggregationRepository.remove(camelContext, key, exchange);
+        // Then
+        assertFalse(exists(key));
+    }
+    @Test
+    public void testRemove_NotExists() {
+        // Given
+        String key="Remove_NotExists";
+        Exchange exchange = new DefaultExchange(camelContext);
+        assertFalse(exists(key));
+        // When
+        aggregationRepository.remove(camelContext, key, exchange);
+        // Then
+        assertFalse(exists(key));
+    }
+    @Test
+    public void testGetKeys() {
+        // Given
+        String[] keys={"GetKeys1", "GetKeys2"};
+        for(String key: keys) {
+            Exchange exchange = new DefaultExchange(camelContext);
+            aggregationRepository.add(camelContext, key, exchange);
+        }
+        // When
+        Set<String> keySet=aggregationRepository.getKeys();
+        // Then
+        for(String key: keys) {
+            assertTrue(keySet.contains(key));
+        }
+    }
+    @Test
+    public void testConfirm_Exist() {
+        // Given
+        for(int i=1;i<4;i++) {
+            String key="Confirm_"+i;
+            Exchange exchange = new DefaultExchange(camelContext);
+            exchange.setExchangeId("Exchange_"+i);
+            aggregationRepository.add(camelContext, key, exchange);
+            assertTrue(exists(key));
+        }
+        // When
+        aggregationRepository.confirm(camelContext, "Exchange_2");
+        // Then
+        assertTrue(exists("Confirm_1"));
+        assertFalse(exists("Confirm_2"));
+        assertTrue(exists("Confirm_3"));
+    }
+    @Test
+    public void testConfirm_NotExist() {
+        // Given
+        for(int i=1;i<4;i++) {
+            String key="Confirm_"+i;
+            Exchange exchange = new DefaultExchange(camelContext);
+            exchange.setExchangeId("Exchange_"+i);
+            aggregationRepository.add(camelContext, key, exchange);
+            assertTrue(exists(key));
+        }
+        // When
+        aggregationRepository.confirm(camelContext, "Exchange_5");
+        // Then
+        for(int i=1;i<4;i++) {
+            assertTrue(exists("Confirm_"+i));
+        }
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
new file mode 100644
index 0000000..381c53e
--- /dev/null
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
@@ -0,0 +1,104 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.processor.aggregate.cassandra;
+
+import org.apache.camel.processor.aggregate.cassandra.CassandraAggregationRepository;
+import org.apache.camel.processor.aggregate.cassandra.NamedCassandraAggregationRepository;
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+import java.lang.reflect.Method;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.cassandra.CassandraUnitUtils;
+import org.junit.Test;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.processor.aggregate.AggregationStrategy;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.camel.utils.cassandra.CassandraUtils;
+import org.cassandraunit.CassandraCQLUnit;
+/**
+ * Unite test for {@link CassandraAggregationRepository}
+ */
+public class CassandraAggregationTest extends CamelTestSupport {
+    private Cluster cluster;
+    private CassandraAggregationRepository aggregationRepository;
+    
+    @Override
+    protected void doPreSetup() throws Exception {
+        CassandraUnitUtils.startEmbeddedCassandra();
+        cluster = CassandraUnitUtils.cassandraCluster();        
+        Session rootSession=cluster.connect();
+        CassandraUnitUtils.loadCQLDataSet(rootSession, "AggregationDataSet.cql");
+        rootSession.close();
+        aggregationRepository = new NamedCassandraAggregationRepository(cluster, CassandraUnitUtils.KEYSPACE, "ID");
+        aggregationRepository.start();
+        super.doPreSetup();
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        aggregationRepository.stop();
+        cluster.close();
+        CassandraUnitUtils.cleanEmbeddedCassandra();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                AggregationStrategy aggregationStrategy = new AggregationStrategy() {
+                    @Override
+                    public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
+                        if (oldExchange == null) {
+                            return newExchange;
+                        }
+                        String oldBody = oldExchange.getIn().getBody(String.class);
+                        String newBody = newExchange.getIn().getBody(String.class);
+                        oldExchange.getIn().setBody(oldBody+","+newBody);
+                        return oldExchange;
+                    }
+                };
+                from("direct:input")
+                        .aggregate(header("aggregationId"), aggregationStrategy)
+                            .completionSize(3).completionTimeout(3000L)
+                            .aggregationRepository(aggregationRepository)
+                        .to("mock:output");
+            }
+        };
+    }
+    private void send(String aggregationId, String body) {
+        super.template.sendBodyAndHeader("direct:input", body, "aggregationId", aggregationId);
+    }
+    @Test
+    public void testAggregationRoute() throws Exception {
+        // Given
+        MockEndpoint mockOutput = getMockEndpoint("mock:output");
+        mockOutput.expectedMessageCount(2);
+        mockOutput.expectedBodiesReceivedInAnyOrder("A,C,E","B,D");
+        // When
+        send("1", "A");
+        send("2", "B");
+        send("1", "C");
+        send("2", "D");
+        send("1", "E");
+        // Then
+        mockOutput.assertIsSatisfied(4000L);
+        
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
new file mode 100644
index 0000000..83c2513
--- /dev/null
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
@@ -0,0 +1,129 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.processor.idempotent.cassandra;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+import org.apache.camel.component.cassandra.CassandraUnitUtils;
+import org.cassandraunit.CassandraCQLUnit;
+import org.junit.After;
+import org.junit.AfterClass;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+
+/**
+ * Unit test for {@link CassandraIdempotentRepository}
+ */
+public class CassandraIdempotentRepositoryTest {
+    private Cluster cluster;
+    private Session session;
+    private CassandraIdempotentRepository<String> idempotentRepository;
+    @Rule
+    public CassandraCQLUnit cassandraRule = CassandraUnitUtils.cassandraCQLUnit("IdempotentDataSet.cql");
+    
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        CassandraUnitUtils.startEmbeddedCassandra();
+    }
+    @Before
+    public void setUp() throws Exception {
+        cluster = CassandraUnitUtils.cassandraCluster();
+        session = cluster.connect(CassandraUnitUtils.KEYSPACE);
+        idempotentRepository = new NamedCassandraIdempotentRepository<String>(session, "ID");
+        idempotentRepository.start();
+    }
+    @After
+    public void tearDown() throws Exception {
+        idempotentRepository.stop();
+        session.close();
+        cluster.close();
+    }
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+        CassandraUnitUtils.cleanEmbeddedCassandra();
+    }
+    private boolean exists(String key) {
+        return session.execute(
+                "select KEY from CAMEL_IDEMPOTENT where NAME=? and KEY=?","ID", key)
+                .one()!=null;
+    }
+    @Test
+    public void testAdd_NotExists() {
+        // Given
+        String key="Add_NotExists";
+        assertFalse(exists(key));
+        // When
+        boolean result=idempotentRepository.add(key);
+        // Then
+        assertTrue(result);
+        assertTrue(exists(key));        
+    }
+    @Test
+    public void testAdd_Exists() {
+        // Given
+        String key="Add_Exists";
+        assertTrue(exists(key));
+        // When
+        boolean result=idempotentRepository.add(key);
+        // Then
+        assertFalse(result);
+        assertTrue(exists(key));        
+    }
+    @Test
+    public void testContains_NotExists() {
+        // Given
+        String key="Contains_NotExists";
+        assertFalse(exists(key));
+        // When
+        boolean result=idempotentRepository.contains(key);
+        // Then
+        assertFalse(result);
+    }
+    @Test
+    public void testContains_Exists() {
+        // Given
+        String key="Contains_Exists";
+        assertTrue(exists(key));
+        // When
+        boolean result=idempotentRepository.contains(key);
+        // Then
+        assertTrue(result);
+    }
+    @Test
+    public void testRemove_NotExists() {
+        // Given
+        String key="Remove_NotExists";
+        assertFalse(exists(key));
+        // When
+        boolean result=idempotentRepository.contains(key);
+        // Then
+        // assertFalse(result);
+    }
+    @Test
+    public void testRemove_Exists() {
+        // Given
+        String key="Remove_Exists";
+        assertTrue(exists(key));
+        // When
+        boolean result=idempotentRepository.remove(key);
+        // Then
+        assertTrue(result);
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
new file mode 100644
index 0000000..7ac6386
--- /dev/null
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.processor.idempotent.cassandra;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+import org.apache.camel.component.cassandra.CassandraUnitUtils;
+import org.junit.Test;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+/**
+ * Unite test for {@link CassandraIdempotentRepository}
+ */
+public class CassandraIdempotentTest extends CamelTestSupport {
+    private Cluster cluster;
+    private CassandraIdempotentRepository idempotentRepository;
+    
+    @Override
+    protected void doPreSetup() throws Exception {
+        CassandraUnitUtils.startEmbeddedCassandra();
+        cluster = CassandraUnitUtils.cassandraCluster();        
+        Session rootSession=cluster.connect();
+        CassandraUnitUtils.loadCQLDataSet(rootSession, "IdempotentDataSet.cql");
+        rootSession.close();
+        idempotentRepository = new NamedCassandraIdempotentRepository(cluster, CassandraUnitUtils.KEYSPACE, "ID");
+        idempotentRepository.start();
+        super.doPreSetup();
+    }
+
+    @Override
+    public void tearDown() throws Exception {
+        super.tearDown();
+        idempotentRepository.stop();
+        CassandraUnitUtils.cleanEmbeddedCassandra();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:input")
+                        .idempotentConsumer(header("idempotentId"), idempotentRepository)
+                        .to("mock:output");
+            }
+        };
+    }
+    private void send(String idempotentId, String body) {
+        super.template.sendBodyAndHeader("direct:input", body, "idempotentId", idempotentId);
+    }
+    @Test
+    public void testIdempotentRoute() throws Exception {
+        // Given
+        MockEndpoint mockOutput = getMockEndpoint("mock:output");
+        mockOutput.expectedMessageCount(2);
+        mockOutput.expectedBodiesReceivedInAnyOrder("A","B");
+        // When
+        send("1", "A");
+        send("2", "B");
+        send("1", "A");
+        send("2", "B");
+        send("1", "A");
+        // Then
+        mockOutput.assertIsSatisfied();
+        
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/resources/AggregationDataSet.cql
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/resources/AggregationDataSet.cql b/components/camel-cassandraql/src/test/resources/AggregationDataSet.cql
new file mode 100644
index 0000000..aa6699a
--- /dev/null
+++ b/components/camel-cassandraql/src/test/resources/AggregationDataSet.cql
@@ -0,0 +1,7 @@
+CREATE TABLE CAMEL_AGGREGATION (
+  NAME varchar,
+  KEY varchar,
+  EXCHANGE_ID varchar,
+  EXCHANGE blob,
+  PRIMARY KEY (NAME, KEY)
+);

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/resources/BasicDataSet.cql
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/resources/BasicDataSet.cql b/components/camel-cassandraql/src/test/resources/BasicDataSet.cql
new file mode 100644
index 0000000..a47d42d
--- /dev/null
+++ b/components/camel-cassandraql/src/test/resources/BasicDataSet.cql
@@ -0,0 +1,9 @@
+CREATE TABLE camel_user (
+  login varchar PRIMARY KEY,
+  first_name varchar,
+  last_name varchar
+);
+INSERT INTO camel_user(login, first_name, last_name)
+    VALUES('j_strachan','James','Strachan');
+INSERT INTO camel_user(login, first_name, last_name)
+    VALUES('c_ibsen','Claus','Ibsen');

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/resources/IdempotentDataSet.cql
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/resources/IdempotentDataSet.cql b/components/camel-cassandraql/src/test/resources/IdempotentDataSet.cql
new file mode 100644
index 0000000..430e920
--- /dev/null
+++ b/components/camel-cassandraql/src/test/resources/IdempotentDataSet.cql
@@ -0,0 +1,11 @@
+CREATE TABLE CAMEL_IDEMPOTENT (
+  NAME varchar,
+  KEY varchar,
+  PRIMARY KEY (NAME, KEY)
+);
+INSERT INTO CAMEL_IDEMPOTENT(NAME, KEY)
+    VALUES('ID','Add_Exists');
+INSERT INTO CAMEL_IDEMPOTENT(NAME, KEY)
+    VALUES('ID','Contains_Exists');
+INSERT INTO CAMEL_IDEMPOTENT(NAME, KEY)
+    VALUES('ID','Remove_Exists');

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/resources/camel-cassandra.yaml
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/resources/camel-cassandra.yaml b/components/camel-cassandraql/src/test/resources/camel-cassandra.yaml
new file mode 100644
index 0000000..2a2a3a3
--- /dev/null
+++ b/components/camel-cassandraql/src/test/resources/camel-cassandra.yaml
@@ -0,0 +1,762 @@
+# Cassandra storage config YAML 
+
+# NOTE:
+#   See http://wiki.apache.org/cassandra/StorageConfiguration for
+#   full explanations of configuration directives
+# /NOTE
+
+# The name of the cluster. This is mainly used to prevent machines in
+# one logical cluster from joining another.
+cluster_name: 'camel-cluster'
+
+# This defines the number of tokens randomly assigned to this node on the ring
+# The more tokens, relative to other nodes, the larger the proportion of data
+# that this node will store. You probably want all nodes to have the same number
+# of tokens assuming they have equal hardware capability.
+#
+# If you leave this unspecified, Cassandra will use the default of 1 token for legacy compatibility,
+# and will use the initial_token as described below.
+#
+# Specifying initial_token will override this setting on the node's initial start,
+# on subsequent starts, this setting will apply even if initial token is set.
+#
+# If you already have a cluster with 1 token per node, and wish to migrate to 
+# multiple tokens per node, see http://wiki.apache.org/cassandra/Operations
+num_tokens: 256
+
+# initial_token allows you to specify tokens manually.  While you can use # it with
+# vnodes (num_tokens > 1, above) -- in which case you should provide a 
+# comma-separated list -- it's primarily used when adding nodes # to legacy clusters 
+# that do not have vnodes enabled.
+# initial_token:
+
+# See http://wiki.apache.org/cassandra/HintedHandoff
+# May either be "true" or "false" to enable globally, or contain a list
+# of data centers to enable per-datacenter.
+# hinted_handoff_enabled: DC1,DC2
+hinted_handoff_enabled: true
+# this defines the maximum amount of time a dead host will have hints
+# generated.  After it has been dead this long, new hints for it will not be
+# created until it has been seen alive and gone down again.
+max_hint_window_in_ms: 10800000 # 3 hours
+# Maximum throttle in KBs per second, per delivery thread.  This will be
+# reduced proportionally to the number of nodes in the cluster.  (If there
+# are two nodes in the cluster, each delivery thread will use the maximum
+# rate; if there are three, each will throttle to half of the maximum,
+# since we expect two nodes to be delivering hints simultaneously.)
+hinted_handoff_throttle_in_kb: 1024
+# Number of threads with which to deliver hints;
+# Consider increasing this number when you have multi-dc deployments, since
+# cross-dc handoff tends to be slower
+max_hints_delivery_threads: 2
+
+# Maximum throttle in KBs per second, total. This will be
+# reduced proportionally to the number of nodes in the cluster.
+batchlog_replay_throttle_in_kb: 1024
+
+# Authentication backend, implementing IAuthenticator; used to identify users
+# Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthenticator,
+# PasswordAuthenticator}.
+#
+# - AllowAllAuthenticator performs no checks - set it to disable authentication.
+# - PasswordAuthenticator relies on username/password pairs to authenticate
+#   users. It keeps usernames and hashed passwords in system_auth.credentials table.
+#   Please increase system_auth keyspace replication factor if you use this authenticator.
+authenticator: AllowAllAuthenticator
+
+# Authorization backend, implementing IAuthorizer; used to limit access/provide permissions
+# Out of the box, Cassandra provides org.apache.cassandra.auth.{AllowAllAuthorizer,
+# CassandraAuthorizer}.
+#
+# - AllowAllAuthorizer allows any action to any user - set it to disable authorization.
+# - CassandraAuthorizer stores permissions in system_auth.permissions table. Please
+#   increase system_auth keyspace replication factor if you use this authorizer.
+authorizer: AllowAllAuthorizer
+
+# Validity period for permissions cache (fetching permissions can be an
+# expensive operation depending on the authorizer, CassandraAuthorizer is
+# one example). Defaults to 2000, set to 0 to disable.
+# Will be disabled automatically for AllowAllAuthorizer.
+permissions_validity_in_ms: 2000
+
+# The partitioner is responsible for distributing groups of rows (by
+# partition key) across nodes in the cluster.  You should leave this
+# alone for new clusters.  The partitioner can NOT be changed without
+# reloading all data, so when upgrading you should set this to the
+# same partitioner you were already using.
+#
+# Besides Murmur3Partitioner, partitioners included for backwards
+# compatibility include RandomPartitioner, ByteOrderedPartitioner, and
+# OrderPreservingPartitioner.
+#
+partitioner: org.apache.cassandra.dht.Murmur3Partitioner
+
+# Directories where Cassandra should store data on disk.  Cassandra
+# will spread data evenly across them, subject to the granularity of
+# the configured compaction strategy.
+# If not set, the default directory is $CASSANDRA_HOME/data/data.
+# data_file_directories:
+#     - /var/lib/cassandra/data
+data_file_directories: 
+    - target/camel-cassandra/data
+
+# commit log.  when running on magnetic HDD, this should be a
+# separate spindle than the data directories.
+# If not set, the default directory is $CASSANDRA_HOME/data/commitlog.
+# commitlog_directory: /var/lib/cassandra/commitlog
+commitlog_directory: target/camel-cassandra/commitlog
+
+# policy for data disk failures:
+# stop_paranoid: shut down gossip and Thrift even for single-sstable errors.
+# stop: shut down gossip and Thrift, leaving the node effectively dead, but
+#       can still be inspected via JMX.
+# best_effort: stop using the failed disk and respond to requests based on
+#              remaining available sstables.  This means you WILL see obsolete
+#              data at CL.ONE!
+# ignore: ignore fatal errors and let requests fail, as in pre-1.2 Cassandra
+disk_failure_policy: stop
+
+# policy for commit disk failures:
+# stop: shut down gossip and Thrift, leaving the node effectively dead, but
+#       can still be inspected via JMX.
+# stop_commit: shutdown the commit log, letting writes collect but 
+#              continuing to service reads, as in pre-2.0.5 Cassandra
+# ignore: ignore fatal errors and let the batches fail
+commit_failure_policy: stop
+
+# Maximum size of the key cache in memory.
+#
+# Each key cache hit saves 1 seek and each row cache hit saves 2 seeks at the
+# minimum, sometimes more. The key cache is fairly tiny for the amount of
+# time it saves, so it's worthwhile to use it at large numbers.
+# The row cache saves even more time, but must contain the entire row,
+# so it is extremely space-intensive. It's best to only use the
+# row cache if you have hot rows or static rows.
+#
+# NOTE: if you reduce the size, you may not get you hottest keys loaded on startup.
+#
+# Default value is empty to make it "auto" (min(5% of Heap (in MB), 100MB)). Set to 0 to disable key cache.
+key_cache_size_in_mb:
+
+# Duration in seconds after which Cassandra should
+# save the key cache. Caches are saved to saved_caches_directory as
+# specified in this configuration file.
+#
+# Saved caches greatly improve cold-start speeds, and is relatively cheap in
+# terms of I/O for the key cache. Row cache saving is much more expensive and
+# has limited use.
+#
+# Default is 14400 or 4 hours.
+key_cache_save_period: 14400
+
+# Number of keys from the key cache to save
+# Disabled by default, meaning all keys are going to be saved
+# key_cache_keys_to_save: 100
+
+# Maximum size of the row cache in memory.
+# NOTE: if you reduce the size, you may not get you hottest keys loaded on startup.
+#
+# Default value is 0, to disable row caching.
+row_cache_size_in_mb: 0
+
+# Duration in seconds after which Cassandra should
+# save the row cache. Caches are saved to saved_caches_directory as specified
+# in this configuration file.
+#
+# Saved caches greatly improve cold-start speeds, and is relatively cheap in
+# terms of I/O for the key cache. Row cache saving is much more expensive and
+# has limited use.
+#
+# Default is 0 to disable saving the row cache.
+row_cache_save_period: 0
+
+# Number of keys from the row cache to save
+# Disabled by default, meaning all keys are going to be saved
+# row_cache_keys_to_save: 100
+
+# Maximum size of the counter cache in memory.
+#
+# Counter cache helps to reduce counter locks' contention for hot counter cells.
+# In case of RF = 1 a counter cache hit will cause Cassandra to skip the read before
+# write entirely. With RF > 1 a counter cache hit will still help to reduce the duration
+# of the lock hold, helping with hot counter cell updates, but will not allow skipping
+# the read entirely. Only the local (clock, count) tuple of a counter cell is kept
+# in memory, not the whole counter, so it's relatively cheap.
+#
+# NOTE: if you reduce the size, you may not get you hottest keys loaded on startup.
+#
+# Default value is empty to make it "auto" (min(2.5% of Heap (in MB), 50MB)). Set to 0 to disable counter cache.
+# NOTE: if you perform counter deletes and rely on low gcgs, you should disable the counter cache.
+counter_cache_size_in_mb:
+
+# Duration in seconds after which Cassandra should
+# save the counter cache (keys only). Caches are saved to saved_caches_directory as
+# specified in this configuration file.
+#
+# Default is 7200 or 2 hours.
+counter_cache_save_period: 7200
+
+# Number of keys from the counter cache to save
+# Disabled by default, meaning all keys are going to be saved
+# counter_cache_keys_to_save: 100
+
+# The off-heap memory allocator.  Affects storage engine metadata as
+# well as caches.  Experiments show that JEMAlloc saves some memory
+# than the native GCC allocator (i.e., JEMalloc is more
+# fragmentation-resistant).
+# 
+# Supported values are: NativeAllocator, JEMallocAllocator
+#
+# If you intend to use JEMallocAllocator you have to install JEMalloc as library and
+# modify cassandra-env.sh as directed in the file.
+#
+# Defaults to NativeAllocator
+# memory_allocator: NativeAllocator
+
+# saved caches
+# If not set, the default directory is $CASSANDRA_HOME/data/saved_caches.
+# saved_caches_directory: /var/lib/cassandra/saved_caches
+saved_caches_directory: target/camel-cassandra/saved_caches
+
+# commitlog_sync may be either "periodic" or "batch." 
+# When in batch mode, Cassandra won't ack writes until the commit log
+# has been fsynced to disk.  It will wait up to
+# commitlog_sync_batch_window_in_ms milliseconds for other writes, before
+# performing the sync.
+#
+# commitlog_sync: batch
+# commitlog_sync_batch_window_in_ms: 50
+#
+# the other option is "periodic" where writes may be acked immediately
+# and the CommitLog is simply synced every commitlog_sync_period_in_ms
+# milliseconds.  commitlog_periodic_queue_size allows 1024*(CPU cores) pending
+# entries on the commitlog queue by default.  If you are writing very large
+# blobs, you should reduce that; 16*cores works reasonably well for 1MB blobs.
+# It should be at least as large as the concurrent_writes setting.
+commitlog_sync: periodic
+commitlog_sync_period_in_ms: 10000
+# commitlog_periodic_queue_size:
+
+# The size of the individual commitlog file segments.  A commitlog
+# segment may be archived, deleted, or recycled once all the data
+# in it (potentially from each columnfamily in the system) has been
+# flushed to sstables.  
+#
+# The default size is 32, which is almost always fine, but if you are
+# archiving commitlog segments (see commitlog_archiving.properties),
+# then you probably want a finer granularity of archiving; 8 or 16 MB
+# is reasonable.
+commitlog_segment_size_in_mb: 32
+
+# any class that implements the SeedProvider interface and has a
+# constructor that takes a Map<String, String> of parameters will do.
+seed_provider:
+    # Addresses of hosts that are deemed contact points. 
+    # Cassandra nodes use this list of hosts to find each other and learn
+    # the topology of the ring.  You must change this if you are running
+    # multiple nodes!
+    - class_name: org.apache.cassandra.locator.SimpleSeedProvider
+      parameters:
+          # seeds is actually a comma-delimited list of addresses.
+          # Ex: "<ip1>,<ip2>,<ip3>"
+          - seeds: "127.0.0.1"
+
+# For workloads with more data than can fit in memory, Cassandra's
+# bottleneck will be reads that need to fetch data from
+# disk. "concurrent_reads" should be set to (16 * number_of_drives) in
+# order to allow the operations to enqueue low enough in the stack
+# that the OS and drives can reorder them. Same applies to
+# "concurrent_counter_writes", since counter writes read the current
+# values before incrementing and writing them back.
+#
+# On the other hand, since writes are almost never IO bound, the ideal
+# number of "concurrent_writes" is dependent on the number of cores in
+# your system; (8 * number_of_cores) is a good rule of thumb.
+concurrent_reads: 32
+concurrent_writes: 32
+concurrent_counter_writes: 32
+
+# Total memory to use for sstable-reading buffers.  Defaults to
+# the smaller of 1/4 of heap or 512MB.
+# file_cache_size_in_mb: 512
+
+# Total memory to use for memtables.  Cassandra will flush the largest
+# memtable when this much memory is used.
+# If omitted, Cassandra will set it to 1/4 of the heap.
+# memtable_total_space_in_mb: 2048
+
+# Ratio of occupied non-flushing memtable size to total permitted size
+# that will trigger a flush of the largest memtable.  Lager mct will
+# mean larger flushes and hence less compaction, but also less concurrent
+# flush activity which can make it difficult to keep your disks fed
+# under heavy write load.
+#
+# memtable_cleanup_threshold defaults to 1 / (memtable_flush_writers + 1)
+#memtable_cleanup_threshold: 0.11
+
+# Specify the way Cassandra allocates and manages memtable memory.
+# Options are:
+#   heap_buffers:    on heap nio buffers
+#   offheap_buffers: off heap (direct) nio buffers
+#   offheap_objects: native memory, eliminating nio buffer heap overhead
+memtable_allocation_type: heap_buffers
+
+# Total space to use for commitlogs.  Since commitlog segments are
+# mmapped, and hence use up address space, the default size is 32
+# on 32-bit JVMs, and 8192 on 64-bit JVMs.
+#
+# If space gets above this value (it will round up to the next nearest
+# segment multiple), Cassandra will flush every dirty CF in the oldest
+# segment and remove it.  So a small total commitlog space will tend
+# to cause more flush activity on less-active columnfamilies.
+# commitlog_total_space_in_mb: 8192
+
+# This sets the amount of memtable flush writer threads.  These will
+# be blocked by disk io, and each one will hold a memtable in memory
+# while blocked. 
+#
+# memtable_flush_writers defaults to the smaller of (number of disks,
+# number of cores), with a minimum of 2 and a maximum of 8.
+# 
+# If your data directories are backed by SSD, you should increase this
+# to the number of cores.
+#memtable_flush_writers: 8
+
+# A fixed memory pool size in MB for for SSTable index summaries. If left
+# empty, this will default to 5% of the heap size. If the memory usage of
+# all index summaries exceeds this limit, SSTables with low read rates will
+# shrink their index summaries in order to meet this limit.  However, this
+# is a best-effort process. In extreme conditions Cassandra may need to use
+# more than this amount of memory.
+index_summary_capacity_in_mb:
+
+# How frequently index summaries should be resampled.  This is done
+# periodically to redistribute memory from the fixed-size pool to sstables
+# proportional their recent read rates.  Setting to -1 will disable this
+# process, leaving existing index summaries at their current sampling level.
+index_summary_resize_interval_in_minutes: 60
+
+# Whether to, when doing sequential writing, fsync() at intervals in
+# order to force the operating system to flush the dirty
+# buffers. Enable this to avoid sudden dirty buffer flushing from
+# impacting read latencies. Almost always a good idea on SSDs; not
+# necessarily on platters.
+trickle_fsync: false
+trickle_fsync_interval_in_kb: 10240
+
+# TCP port, for commands and data
+storage_port: 7000
+
+# SSL port, for encrypted communication.  Unused unless enabled in
+# encryption_options
+ssl_storage_port: 7001
+
+# Address or interface to bind to and tell other Cassandra nodes to connect to.
+# You _must_ change this if you want multiple nodes to be able to communicate!
+#
+# Set listen_address OR listen_interface, not both. Interfaces must correspond
+# to a single address, IP aliasing is not supported.
+#
+# Leaving it blank leaves it up to InetAddress.getLocalHost(). This
+# will always do the Right Thing _if_ the node is properly configured
+# (hostname, name resolution, etc), and the Right Thing is to use the
+# address associated with the hostname (it might not be).
+#
+# Setting listen_address to 0.0.0.0 is always wrong.
+listen_address: localhost
+# listen_interface: eth0
+
+# Address to broadcast to other Cassandra nodes
+# Leaving this blank will set it to the same value as listen_address
+# broadcast_address: 1.2.3.4
+
+# Internode authentication backend, implementing IInternodeAuthenticator;
+# used to allow/disallow connections from peer nodes.
+# internode_authenticator: org.apache.cassandra.auth.AllowAllInternodeAuthenticator
+
+# Whether to start the native transport server.
+# Please note that the address on which the native transport is bound is the
+# same as the rpc_address. The port however is different and specified below.
+start_native_transport: true
+# port for the CQL native transport to listen for clients on
+native_transport_port: 9042
+# The maximum threads for handling requests when the native transport is used.
+# This is similar to rpc_max_threads though the default differs slightly (and
+# there is no native_transport_min_threads, idle threads will always be stopped
+# after 30 seconds).
+# native_transport_max_threads: 128
+#
+# The maximum size of allowed frame. Frame (requests) larger than this will
+# be rejected as invalid. The default is 256MB.
+# native_transport_max_frame_size_in_mb: 256
+
+# Whether to start the thrift rpc server.
+start_rpc: true
+
+# The address or interface to bind the Thrift RPC service and native transport
+# server to.
+#
+# Set rpc_address OR rpc_interface, not both. Interfaces must correspond
+# to a single address, IP aliasing is not supported.
+#
+# Leaving rpc_address blank has the same effect as on listen_address
+# (i.e. it will be based on the configured hostname of the node).
+#
+# Note that unlike listen_address, you can specify 0.0.0.0, but you must also
+# set broadcast_rpc_address to a value other than 0.0.0.0.
+rpc_address: localhost
+# rpc_interface: eth1
+
+# port for Thrift to listen for clients on
+rpc_port: 9160
+
+# RPC address to broadcast to drivers and other Cassandra nodes. This cannot
+# be set to 0.0.0.0. If left blank, this will be set to the value of
+# rpc_address. If rpc_address is set to 0.0.0.0, broadcast_rpc_address must
+# be set.
+# broadcast_rpc_address: 1.2.3.4
+
+# enable or disable keepalive on rpc/native connections
+rpc_keepalive: true
+
+# Cassandra provides two out-of-the-box options for the RPC Server:
+#
+# sync  -> One thread per thrift connection. For a very large number of clients, memory
+#          will be your limiting factor. On a 64 bit JVM, 180KB is the minimum stack size
+#          per thread, and that will correspond to your use of virtual memory (but physical memory
+#          may be limited depending on use of stack space).
+#
+# hsha  -> Stands for "half synchronous, half asynchronous." All thrift clients are handled
+#          asynchronously using a small number of threads that does not vary with the amount
+#          of thrift clients (and thus scales well to many clients). The rpc requests are still
+#          synchronous (one thread per active request).
+#
+# The default is sync because on Windows hsha is about 30% slower.  On Linux,
+# sync/hsha performance is about the same, with hsha of course using less memory.
+#
+# Alternatively,  can provide your own RPC server by providing the fully-qualified class name
+# of an o.a.c.t.TServerFactory that can create an instance of it.
+rpc_server_type: sync
+
+# Uncomment rpc_min|max_thread to set request pool size limits.
+#
+# Regardless of your choice of RPC server (see above), the number of maximum requests in the
+# RPC thread pool dictates how many concurrent requests are possible (but if you are using the sync
+# RPC server, it also dictates the number of clients that can be connected at all).
+#
+# The default is unlimited and thus provides no protection against clients overwhelming the server. You are
+# encouraged to set a maximum that makes sense for you in production, but do keep in mind that
+# rpc_max_threads represents the maximum number of client requests this server may execute concurrently.
+#
+# rpc_min_threads: 16
+# rpc_max_threads: 2048
+
+# uncomment to set socket buffer sizes on rpc connections
+# rpc_send_buff_size_in_bytes:
+# rpc_recv_buff_size_in_bytes:
+
+# Uncomment to set socket buffer size for internode communication
+# Note that when setting this, the buffer size is limited by net.core.wmem_max
+# and when not setting it it is defined by net.ipv4.tcp_wmem
+# See:
+# /proc/sys/net/core/wmem_max
+# /proc/sys/net/core/rmem_max
+# /proc/sys/net/ipv4/tcp_wmem
+# /proc/sys/net/ipv4/tcp_wmem
+# and: man tcp
+# internode_send_buff_size_in_bytes:
+# internode_recv_buff_size_in_bytes:
+
+# Frame size for thrift (maximum message length).
+thrift_framed_transport_size_in_mb: 15
+
+# Set to true to have Cassandra create a hard link to each sstable
+# flushed or streamed locally in a backups/ subdirectory of the
+# keyspace data.  Removing these links is the operator's
+# responsibility.
+incremental_backups: false
+
+# Whether or not to take a snapshot before each compaction.  Be
+# careful using this option, since Cassandra won't clean up the
+# snapshots for you.  Mostly useful if you're paranoid when there
+# is a data format change.
+snapshot_before_compaction: false
+
+# Whether or not a snapshot is taken of the data before keyspace truncation
+# or dropping of column families. The STRONGLY advised default of true 
+# should be used to provide data safety. If you set this flag to false, you will
+# lose data on truncation or drop.
+auto_snapshot: true
+
+# When executing a scan, within or across a partition, we need to keep the
+# tombstones seen in memory so we can return them to the coordinator, which
+# will use them to make sure other replicas also know about the deleted rows.
+# With workloads that generate a lot of tombstones, this can cause performance
+# problems and even exaust the server heap.
+# (http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets)
+# Adjust the thresholds here if you understand the dangers and want to
+# scan more tombstones anyway.  These thresholds may also be adjusted at runtime
+# using the StorageService mbean.
+tombstone_warn_threshold: 1000
+tombstone_failure_threshold: 100000
+
+# Granularity of the collation index of rows within a partition.
+# Increase if your rows are large, or if you have a very large
+# number of rows per partition.  The competing goals are these:
+#   1) a smaller granularity means more index entries are generated
+#      and looking up rows withing the partition by collation column
+#      is faster
+#   2) but, Cassandra will keep the collation index in memory for hot
+#      rows (as part of the key cache), so a larger granularity means
+#      you can cache more hot rows
+column_index_size_in_kb: 64
+
+
+# Log WARN on any batch size exceeding this value. 5kb per batch by default.
+# Caution should be taken on increasing the size of this threshold as it can lead to node instability.
+batch_size_warn_threshold_in_kb: 5
+
+# Number of simultaneous compactions to allow, NOT including
+# validation "compactions" for anti-entropy repair.  Simultaneous
+# compactions can help preserve read performance in a mixed read/write
+# workload, by mitigating the tendency of small sstables to accumulate
+# during a single long running compactions. The default is usually
+# fine and if you experience problems with compaction running too
+# slowly or too fast, you should look at
+# compaction_throughput_mb_per_sec first.
+#
+# concurrent_compactors defaults to the smaller of (number of disks,
+# number of cores), with a minimum of 2 and a maximum of 8.
+# 
+# If your data directories are backed by SSD, you should increase this
+# to the number of cores.
+#concurrent_compactors: 1
+
+# Throttles compaction to the given total throughput across the entire
+# system. The faster you insert data, the faster you need to compact in
+# order to keep the sstable count down, but in general, setting this to
+# 16 to 32 times the rate you are inserting data is more than sufficient.
+# Setting this to 0 disables throttling. Note that this account for all types
+# of compaction, including validation compaction.
+compaction_throughput_mb_per_sec: 16
+
+# When compacting, the replacement sstable(s) can be opened before they
+# are completely written, and used in place of the prior sstables for
+# any range that has been written. This helps to smoothly transfer reads 
+# between the sstables, reducing page cache churn and keeping hot rows hot
+sstable_preemptive_open_interval_in_mb: 50
+
+# Throttles all outbound streaming file transfers on this node to the
+# given total throughput in Mbps. This is necessary because Cassandra does
+# mostly sequential IO when streaming data during bootstrap or repair, which
+# can lead to saturating the network connection and degrading rpc performance.
+# When unset, the default is 200 Mbps or 25 MB/s.
+# stream_throughput_outbound_megabits_per_sec: 200
+
+# Throttles all streaming file transfer between the datacenters,
+# this setting allows users to throttle inter dc stream throughput in addition
+# to throttling all network stream traffic as configured with
+# stream_throughput_outbound_megabits_per_sec
+# inter_dc_stream_throughput_outbound_megabits_per_sec:
+
+# How long the coordinator should wait for read operations to complete
+read_request_timeout_in_ms: 5000
+# How long the coordinator should wait for seq or index scans to complete
+range_request_timeout_in_ms: 10000
+# How long the coordinator should wait for writes to complete
+write_request_timeout_in_ms: 2000
+# How long the coordinator should wait for counter writes to complete
+counter_write_request_timeout_in_ms: 5000
+# How long a coordinator should continue to retry a CAS operation
+# that contends with other proposals for the same row
+cas_contention_timeout_in_ms: 1000
+# How long the coordinator should wait for truncates to complete
+# (This can be much longer, because unless auto_snapshot is disabled
+# we need to flush first so we can snapshot before removing the data.)
+truncate_request_timeout_in_ms: 60000
+# The default timeout for other, miscellaneous operations
+request_timeout_in_ms: 10000
+
+# Enable operation timeout information exchange between nodes to accurately
+# measure request timeouts.  If disabled, replicas will assume that requests
+# were forwarded to them instantly by the coordinator, which means that
+# under overload conditions we will waste that much extra time processing 
+# already-timed-out requests.
+#
+# Warning: before enabling this property make sure to ntp is installed
+# and the times are synchronized between the nodes.
+cross_node_timeout: false
+
+# Enable socket timeout for streaming operation.
+# When a timeout occurs during streaming, streaming is retried from the start
+# of the current file. This _can_ involve re-streaming an important amount of
+# data, so you should avoid setting the value too low.
+# Default value is 0, which never timeout streams.
+# streaming_socket_timeout_in_ms: 0
+
+# phi value that must be reached for a host to be marked down.
+# most users should never need to adjust this.
+# phi_convict_threshold: 8
+
+# endpoint_snitch -- Set this to a class that implements
+# IEndpointSnitch.  The snitch has two functions:
+# - it teaches Cassandra enough about your network topology to route
+#   requests efficiently
+# - it allows Cassandra to spread replicas around your cluster to avoid
+#   correlated failures. It does this by grouping machines into
+#   "datacenters" and "racks."  Cassandra will do its best not to have
+#   more than one replica on the same "rack" (which may not actually
+#   be a physical location)
+#
+# IF YOU CHANGE THE SNITCH AFTER DATA IS INSERTED INTO THE CLUSTER,
+# YOU MUST RUN A FULL REPAIR, SINCE THE SNITCH AFFECTS WHERE REPLICAS
+# ARE PLACED.
+#
+# Out of the box, Cassandra provides
+#  - SimpleSnitch:
+#    Treats Strategy order as proximity. This can improve cache
+#    locality when disabling read repair.  Only appropriate for
+#    single-datacenter deployments.
+#  - GossipingPropertyFileSnitch
+#    This should be your go-to snitch for production use.  The rack
+#    and datacenter for the local node are defined in
+#    cassandra-rackdc.properties and propagated to other nodes via
+#    gossip.  If cassandra-topology.properties exists, it is used as a
+#    fallback, allowing migration from the PropertyFileSnitch.
+#  - PropertyFileSnitch:
+#    Proximity is determined by rack and data center, which are
+#    explicitly configured in cassandra-topology.properties.
+#  - Ec2Snitch:
+#    Appropriate for EC2 deployments in a single Region. Loads Region
+#    and Availability Zone information from the EC2 API. The Region is
+#    treated as the datacenter, and the Availability Zone as the rack.
+#    Only private IPs are used, so this will not work across multiple
+#    Regions.
+#  - Ec2MultiRegionSnitch:
+#    Uses public IPs as broadcast_address to allow cross-region
+#    connectivity.  (Thus, you should set seed addresses to the public
+#    IP as well.) You will need to open the storage_port or
+#    ssl_storage_port on the public IP firewall.  (For intra-Region
+#    traffic, Cassandra will switch to the private IP after
+#    establishing a connection.)
+#  - RackInferringSnitch:
+#    Proximity is determined by rack and data center, which are
+#    assumed to correspond to the 3rd and 2nd octet of each node's IP
+#    address, respectively.  Unless this happens to match your
+#    deployment conventions, this is best used as an example of
+#    writing a custom Snitch class and is provided in that spirit.
+#
+# You can use a custom Snitch by setting this to the full class name
+# of the snitch, which will be assumed to be on your classpath.
+endpoint_snitch: SimpleSnitch
+
+# controls how often to perform the more expensive part of host score
+# calculation
+dynamic_snitch_update_interval_in_ms: 100 
+# controls how often to reset all host scores, allowing a bad host to
+# possibly recover
+dynamic_snitch_reset_interval_in_ms: 600000
+# if set greater than zero and read_repair_chance is < 1.0, this will allow
+# 'pinning' of replicas to hosts in order to increase cache capacity.
+# The badness threshold will control how much worse the pinned host has to be
+# before the dynamic snitch will prefer other replicas over it.  This is
+# expressed as a double which represents a percentage.  Thus, a value of
+# 0.2 means Cassandra would continue to prefer the static snitch values
+# until the pinned host was 20% worse than the fastest.
+dynamic_snitch_badness_threshold: 0.1
+
+# request_scheduler -- Set this to a class that implements
+# RequestScheduler, which will schedule incoming client requests
+# according to the specific policy. This is useful for multi-tenancy
+# with a single Cassandra cluster.
+# NOTE: This is specifically for requests from the client and does
+# not affect inter node communication.
+# org.apache.cassandra.scheduler.NoScheduler - No scheduling takes place
+# org.apache.cassandra.scheduler.RoundRobinScheduler - Round robin of
+# client requests to a node with a separate queue for each
+# request_scheduler_id. The scheduler is further customized by
+# request_scheduler_options as described below.
+request_scheduler: org.apache.cassandra.scheduler.NoScheduler
+
+# Scheduler Options vary based on the type of scheduler
+# NoScheduler - Has no options
+# RoundRobin
+#  - throttle_limit -- The throttle_limit is the number of in-flight
+#                      requests per client.  Requests beyond 
+#                      that limit are queued up until
+#                      running requests can complete.
+#                      The value of 80 here is twice the number of
+#                      concurrent_reads + concurrent_writes.
+#  - default_weight -- default_weight is optional and allows for
+#                      overriding the default which is 1.
+#  - weights -- Weights are optional and will default to 1 or the
+#               overridden default_weight. The weight translates into how
+#               many requests are handled during each turn of the
+#               RoundRobin, based on the scheduler id.
+#
+# request_scheduler_options:
+#    throttle_limit: 80
+#    default_weight: 5
+#    weights:
+#      Keyspace1: 1
+#      Keyspace2: 5
+
+# request_scheduler_id -- An identifier based on which to perform
+# the request scheduling. Currently the only valid option is keyspace.
+# request_scheduler_id: keyspace
+
+# Enable or disable inter-node encryption
+# Default settings are TLS v1, RSA 1024-bit keys (it is imperative that
+# users generate their own keys) TLS_RSA_WITH_AES_128_CBC_SHA as the cipher
+# suite for authentication, key exchange and encryption of the actual data transfers.
+# Use the DHE/ECDHE ciphers if running in FIPS 140 compliant mode.
+# NOTE: No custom encryption options are enabled at the moment
+# The available internode options are : all, none, dc, rack
+#
+# If set to dc cassandra will encrypt the traffic between the DCs
+# If set to rack cassandra will encrypt the traffic between the racks
+#
+# The passwords used in these options must match the passwords used when generating
+# the keystore and truststore.  For instructions on generating these files, see:
+# http://download.oracle.com/javase/6/docs/technotes/guides/security/jsse/JSSERefGuide.html#CreateKeystore
+#
+server_encryption_options:
+    internode_encryption: none
+    keystore: conf/.keystore
+    keystore_password: cassandra
+    truststore: conf/.truststore
+    truststore_password: cassandra
+    # More advanced defaults below:
+    # protocol: TLS
+    # algorithm: SunX509
+    # store_type: JKS
+    # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA]
+    # require_client_auth: false
+
+# enable or disable client/server encryption.
+client_encryption_options:
+    enabled: false
+    keystore: conf/.keystore
+    keystore_password: cassandra
+    # require_client_auth: false
+    # Set trustore and truststore_password if require_client_auth is true
+    # truststore: conf/.truststore
+    # truststore_password: cassandra
+    # More advanced defaults below:
+    # protocol: TLS
+    # algorithm: SunX509
+    # store_type: JKS
+    # cipher_suites: [TLS_RSA_WITH_AES_128_CBC_SHA,TLS_RSA_WITH_AES_256_CBC_SHA,TLS_DHE_RSA_WITH_AES_128_CBC_SHA,TLS_DHE_RSA_WITH_AES_256_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA,TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA]
+
+# internode_compression controls whether traffic between nodes is
+# compressed.
+# can be:  all  - all traffic is compressed
+#          dc   - traffic between different datacenters is compressed
+#          none - nothing is compressed.
+internode_compression: all
+
+# Enable or disable tcp_nodelay for inter-dc communication.
+# Disabling it will result in larger (but fewer) network packets being sent,
+# reducing overhead from the TCP protocol itself, at the cost of increasing
+# latency if you block for cross-datacenter responses.
+inter_dc_tcp_nodelay: false

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/resources/log4j.properties b/components/camel-cassandraql/src/test/resources/log4j.properties
new file mode 100644
index 0000000..3476f4b
--- /dev/null
+++ b/components/camel-cassandraql/src/test/resources/log4j.properties
@@ -0,0 +1,17 @@
+#
+# The logging properties used
+#
+log4j.rootLogger=INFO, out
+
+# uncomment the following line to turn on Camel debugging
+#log4j.logger.org.apache.camel=DEBUG
+log4j.logger.org.apache.camel.processor.idempotent.cassandra=INFO
+log4j.logger.org.apache.camel.processor.aggregate.cassandra=INFO
+log4j.logger.org.apache.cassandra=WARN
+log4j.logger.com.datastax=WARN
+# CONSOLE appender not used by default
+log4j.appender.out=org.apache.log4j.ConsoleAppender
+log4j.appender.out.layout=org.apache.log4j.PatternLayout
+log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
+#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/pom.xml
----------------------------------------------------------------------
diff --git a/components/pom.xml b/components/pom.xml
index 7cabf32..f427d0c 100644
--- a/components/pom.xml
+++ b/components/pom.xml
@@ -71,6 +71,7 @@
     <module>camel-bindy</module>
     <module>camel-box</module>
     <module>camel-cache</module>
+    <module>camel-cassandraql</module>
     <module>camel-castor</module>
     <module>camel-cdi</module>
     <module>camel-chunk</module>


[4/5] camel git commit: CAMEL-2939: Fixed CS

Posted by da...@apache.org.
CAMEL-2939: Fixed CS


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/e0b14cd4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/e0b14cd4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/e0b14cd4

Branch: refs/heads/master
Commit: e0b14cd4fa4875a17b899bfedb334a97e7c4eaf9
Parents: 7be546a
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Dec 23 11:40:45 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Dec 23 11:40:45 2014 +0100

----------------------------------------------------------------------
 .../component/cassandra/CassandraComponent.java |  31 ++-
 .../component/cassandra/CassandraConstants.java |  20 +-
 .../component/cassandra/CassandraConsumer.java  |  18 +-
 .../component/cassandra/CassandraEndpoint.java  |  25 ++-
 .../component/cassandra/CassandraProducer.java  |  36 +++-
 .../ResultSetConversionStrategies.java          |  53 +++--
 .../cassandra/ResultSetConversionStrategy.java  |  14 +-
 .../CassandraAggregationException.java          |  16 +-
 .../CassandraAggregationRepository.java         |  83 +++++---
 .../cassandra/CassandraCamelCodec.java          |  22 +-
 .../NamedCassandraAggregationRepository.java    |  19 +-
 .../CassandraIdempotentRepository.java          |  36 ++--
 .../NamedCassandraIdempotentRepository.java     |  22 +-
 .../utils/cassandra/CassandraSessionHolder.java |  19 +-
 .../camel/utils/cassandra/CassandraUtils.java   |  42 ++--
 .../src/main/resources/META-INF/LICENSE.txt     | 203 +++++++++++++++++++
 .../src/main/resources/META-INF/NOTICE.txt      |  11 +
 .../services/org/apache/camel/component/cql     |  17 ++
 .../CassandraComponentBeanRefTest.java          |  49 +++--
 .../CassandraComponentClusterBuilderTest.java   |  59 +++---
 .../CassandraComponentConsumerTest.java         |  52 +++--
 .../CassandraComponentProducerTest.java         |  63 ++++--
 .../component/cassandra/CassandraUnitUtils.java |  23 ++-
 .../ResultSetConversionStrategiesTest.java      |  46 +++--
 .../CassandraAggregationRepositoryTest.java     | 104 ++++++----
 .../cassandra/CassandraAggregationTest.java     |  42 ++--
 .../CassandraIdempotentRepositoryTest.java      |  82 ++++----
 .../cassandra/CassandraIdempotentTest.java      |  31 +--
 .../src/test/resources/log4j.properties         |  44 +++-
 29 files changed, 889 insertions(+), 393 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraComponent.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraComponent.java
index 761a5d7..9a1dac6 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraComponent.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraComponent.java
@@ -1,11 +1,27 @@
+/**
+ * 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.cassandra;
 
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.Session;
 import java.util.Map;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
 import org.apache.camel.Endpoint;
 import org.apache.camel.impl.DefaultComponent;
 import org.apache.camel.util.EndpointHelper;
@@ -13,7 +29,7 @@ import org.apache.camel.util.EndpointHelper;
 /**
  * Represents the component that manages {@link CassandraEndpoint}. This
  * component is based on Datastax Java Driver for Cassandra.
- *
+ * <p/>
  * URI examples:
  * <ul>
  * <li>cql:localhost/keyspace</li>
@@ -46,8 +62,8 @@ public class CassandraComponent extends DefaultComponent {
      */
     private static final Pattern HOSTS_PORT_KEYSPACE_PATTERN = Pattern.compile(
             "^(" + HOSTS_PATTERN + ")?" // Hosts
-            + "(?::(" + PORT_PATTERN + "))?" // Port
-            + "(?:/(" + KEYSPACE_PATTERN + "))?$"); // Keyspace
+                    + "(?::(" + PORT_PATTERN + "))?" // Port
+                    + "(?:/(" + KEYSPACE_PATTERN + "))?$"); // Keyspace
     /**
      * Regular expression for parsing URI bean:sessionRef
      */
@@ -64,7 +80,7 @@ public class CassandraComponent extends DefaultComponent {
         if (beanRefMatcher.matches()) {
             String beanRefName = beanRefMatcher.group(1);
             keyspace = beanRefMatcher.group(2);
-            Object bean = EndpointHelper.resolveParameter(getCamelContext(), "#"+beanRefName, Object.class);
+            Object bean = EndpointHelper.resolveParameter(getCamelContext(), "#" + beanRefName, Object.class);
             if (bean instanceof Session) {
                 session = (Session) bean;
                 cluster = session.getCluster();
@@ -86,6 +102,7 @@ public class CassandraComponent extends DefaultComponent {
         setProperties(endpoint, parameters);
         return endpoint;
     }
+
     /**
      * Parse URI of the form cql://host1,host2:9042/keyspace and create a
      * {@link Cluster.Builder}
@@ -123,7 +140,7 @@ public class CassandraComponent extends DefaultComponent {
         // Username and password
         String username = getAndRemoveOrResolveReferenceParameter(parameters, "username", String.class);
         String password = getAndRemoveOrResolveReferenceParameter(parameters, "password", String.class);
-        if (username != null && !username.isEmpty() && password!=null) {
+        if (username != null && !username.isEmpty() && password != null) {
             clusterBuilder.withCredentials(username, password);
         }
         return clusterBuilder;

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConstants.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConstants.java
index 1c7722f..2abd513 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConstants.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConstants.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,16 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.cassandra;
 
 /**
  * Cassandra QL Endpoint constants
  */
-public class CassandraConstants {
+public final class CassandraConstants {
+
     /**
      * In Message header: CQL Query
      */
     public static final String CQL_QUERY = "CamelCqlQuery";
 
+    private CassandraConstants() {
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConsumer.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConsumer.java
index 20b0812..952eae3 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConsumer.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConsumer.java
@@ -1,3 +1,19 @@
+/**
+ * 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.cassandra;
 
 import com.datastax.driver.core.PreparedStatement;
@@ -35,7 +51,7 @@ public class CassandraConsumer extends ScheduledPollConsumer {
             preparedStatement = getEndpoint().prepareStatement();
         }
         ResultSet resultSet = session.execute(preparedStatement.bind());
-        
+
         // Create message from ResultSet
         Exchange exchange = getEndpoint().createExchange();
         Message message = exchange.getIn();

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraEndpoint.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraEndpoint.java
index c7f7b11..49d3a71 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraEndpoint.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraEndpoint.java
@@ -1,3 +1,19 @@
+/**
+ * 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.cassandra;
 
 import com.datastax.driver.core.Cluster;
@@ -34,14 +50,15 @@ public class CassandraEndpoint extends DefaultEndpoint {
      * How many rows should be retrieved in message body
      */
     private ResultSetConversionStrategy resultSetConversionStrategy = ResultSetConversionStrategies.all();
+
     /**
      * Cassandra URI
      *
      * @param uri
      * @param component Parent component
-     * @param cluster Cluster (required)
-     * @param session Session (optional)
-     * @param keyspace Keyspace (optional)
+     * @param cluster   Cluster (required)
+     * @param session   Session (optional)
+     * @param keyspace  Keyspace (optional)
      */
     public CassandraEndpoint(String uri, CassandraComponent component, Cluster cluster, Session session, String keyspace) {
         super(uri, component);
@@ -122,12 +139,14 @@ public class CassandraEndpoint extends DefaultEndpoint {
         }
         return preparedStatement;
     }
+
     /**
      * Create and configure a Prepared CQL statement
      */
     protected PreparedStatement prepareStatement() {
         return prepareStatement(cql);
     }
+
     /**
      * Copy ResultSet into Message.
      */

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraProducer.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraProducer.java
index ac429e0..9921191 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraProducer.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraProducer.java
@@ -1,10 +1,26 @@
+/**
+ * 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.cassandra;
 
-import com.datastax.driver.core.ConsistencyLevel;
+import java.util.Collection;
+
 import com.datastax.driver.core.PreparedStatement;
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Session;
-import java.util.Collection;
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.impl.DefaultProducer;
@@ -14,16 +30,17 @@ import org.slf4j.LoggerFactory;
 /**
  * Cassandra 2 CQL3 producer.
  * <dl>
- *  <dt>In Message</dt>
- *  <dd>Bound parameters: Collection of Objects, Array of Objects, Simple Object<dd>
- *  <dt>Out Message</dt>
- *  <dd>List of all Rows<dd>
+ * <dt>In Message</dt>
+ * <dd>Bound parameters: Collection of Objects, Array of Objects, Simple Object<dd>
+ * <dt>Out Message</dt>
+ * <dd>List of all Rows<dd>
  * <dl>
  */
 public class CassandraProducer extends DefaultProducer {
 
     private static final Logger LOG = LoggerFactory.getLogger(CassandraProducer.class);
     private PreparedStatement preparedStatement;
+
     public CassandraProducer(CassandraEndpoint endpoint) {
         super(endpoint);
     }
@@ -47,14 +64,15 @@ public class CassandraProducer extends DefaultProducer {
         }
         return cqlParams;
     }
+
     /**
      * Execute CQL query using incoming message body has statement parameters.
      */
     private ResultSet execute(Message message) {
         String messageCql = message.getHeader(CassandraConstants.CQL_QUERY, String.class);
         Object[] cqlParams = getCqlParams(message);
-        
-        ResultSet resultSet;  
+
+        ResultSet resultSet;
         PreparedStatement lPreparedStatement;
         if (messageCql == null || messageCql.isEmpty()) {
             // URI CQL
@@ -71,7 +89,7 @@ public class CassandraProducer extends DefaultProducer {
             resultSet = session.execute(lPreparedStatement.bind());
         } else {
             resultSet = session.execute(lPreparedStatement.bind(cqlParams));
-        }            
+        }
         return resultSet;
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java
index 51ed9c4..29aa7a2 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,27 +14,41 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.cassandra;
 
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
 import java.util.ArrayList;
 import java.util.Iterator;
 import java.util.List;
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+
 /**
  * Implementations of {@link ResultSetConversionStrategy}
  */
-public class ResultSetConversionStrategies {
+public final class ResultSetConversionStrategies {
+
+    private static final Pattern LIMIT_NAME_PATTERN = Pattern.compile("^LIMIT_(\\d+)$");
+
     private static final ResultSetConversionStrategy ALL = new ResultSetConversionStrategy() {
         @Override
         public Object getBody(ResultSet resultSet) {
             return resultSet.all();
         }
     };
+
+    private static final ResultSetConversionStrategy ONE = new ResultSetConversionStrategy() {
+        @Override
+        public Object getBody(ResultSet resultSet) {
+            return resultSet.one();
+        }
+    };
+
+    private ResultSetConversionStrategies() {
+    }
+
     /**
      * Retrieve all rows.
      * Message body contains a big list of {@link Row}s
@@ -41,12 +56,7 @@ public class ResultSetConversionStrategies {
     public static ResultSetConversionStrategy all() {
         return ALL;
     }
-    private static final ResultSetConversionStrategy ONE = new ResultSetConversionStrategy() {
-        @Override
-        public Object getBody(ResultSet resultSet) {
-            return resultSet.one();
-        }
-    };
+
     /**
      * Retrieve a single row.
      * Message body contains a single {@link Row}
@@ -54,8 +64,10 @@ public class ResultSetConversionStrategies {
     public static ResultSetConversionStrategy one() {
         return ONE;
     }
+
     private static class LimitResultSetConversionStrategy implements ResultSetConversionStrategy {
         private final int rowMax;
+
         public LimitResultSetConversionStrategy(int rowMax) {
             this.rowMax = rowMax;
         }
@@ -65,13 +77,14 @@ public class ResultSetConversionStrategies {
             List<Row> rows = new ArrayList<Row>(rowMax);
             int rowCount = 0;
             Iterator<Row> rowIter = resultSet.iterator();
-            while(rowIter.hasNext() && rowCount<rowMax) {
+            while (rowIter.hasNext() && rowCount < rowMax) {
                 rows.add(rowIter.next());
                 rowCount++;
             }
             return rows;
-        }        
+        }
     }
+
     /**
      * Retrieve a limited list of rows.
      * Message body contains a list of {@link Row} containing at most rowMax rows.
@@ -79,7 +92,7 @@ public class ResultSetConversionStrategies {
     public static ResultSetConversionStrategy limit(int rowMax) {
         return new LimitResultSetConversionStrategy(rowMax);
     }
-    private static final Pattern LIMIT_NAME_PATTERN=Pattern.compile("^LIMIT_(\\d+)$");
+
     /**
      * Get {@link ResultSetConversionStrategy} from String
      */
@@ -98,6 +111,6 @@ public class ResultSetConversionStrategies {
             int limit = Integer.parseInt(matcher.group(1));
             return limit(limit);
         }
-        throw new IllegalArgumentException("Unknown conversion strategy "+name);
+        throw new IllegalArgumentException("Unknown conversion strategy " + name);
     }
 }
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategy.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategy.java
index 5874d5a..0bf8366 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategy.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategy.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.cassandra;
 
 import com.datastax.driver.core.ResultSet;

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationException.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationException.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationException.java
index cfc0049..459bafe 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationException.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationException.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.processor.aggregate.cassandra;
 
 import org.apache.camel.CamelExecutionException;
@@ -22,7 +22,7 @@ import org.apache.camel.Exchange;
 /**
  * Error occurred in Cassandra Aggregation repository
  */
-public class CassandraAggregationException extends CamelExecutionException{
+public class CassandraAggregationException extends CamelExecutionException {
 
     public CassandraAggregationException(String message, Exchange exchange, Throwable cause) {
         super(message, exchange, cause);

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepository.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepository.java
index db900ef..d075e59 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepository.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepository.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,19 +14,19 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.processor.aggregate.cassandra;
 
-import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ConsistencyLevel;
-import com.datastax.driver.core.PreparedStatement;
-import com.datastax.driver.core.Row;
-import com.datastax.driver.core.Session;
 import java.io.IOException;
 import java.nio.ByteBuffer;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Set;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ConsistencyLevel;
+import com.datastax.driver.core.PreparedStatement;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
 import org.apache.camel.CamelContext;
 import org.apache.camel.Exchange;
 import org.apache.camel.spi.AggregationRepository;
@@ -33,14 +34,20 @@ import org.apache.camel.support.ServiceSupport;
 import org.apache.camel.utils.cassandra.CassandraSessionHolder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import static org.apache.camel.utils.cassandra.CassandraUtils.*;
+
+import static org.apache.camel.utils.cassandra.CassandraUtils.append;
+import static org.apache.camel.utils.cassandra.CassandraUtils.applyConsistencyLevel;
+import static org.apache.camel.utils.cassandra.CassandraUtils.concat;
+import static org.apache.camel.utils.cassandra.CassandraUtils.generateDelete;
+import static org.apache.camel.utils.cassandra.CassandraUtils.generateInsert;
+import static org.apache.camel.utils.cassandra.CassandraUtils.generateSelect;
 
 /**
  * Implementation of {@link AggregationRepository} using Cassandra table to store
  * exchanges.
  * Advice: use LeveledCompaction for this table and tune read/write consistency levels.
  * Warning: Cassandra is not the best tool for queuing use cases
- * @see http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets
+ * See: http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets
  */
 public abstract class CassandraAggregationRepository extends ServiceSupport implements AggregationRepository {
     /**
@@ -58,11 +65,11 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
     /**
      * Exchange Id column name
      */
-    private String exchangeIdColumn="EXCHANGE_ID";
+    private String exchangeIdColumn = "EXCHANGE_ID";
     /**
      * Exchange column name
      */
-    private String exchangeColumn="EXCHANGE";
+    private String exchangeColumn = "EXCHANGE";
     /**
      * Primary key columns
      */
@@ -83,7 +90,7 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
      * Read consistency level
      */
     private ConsistencyLevel readConsistencyLevel;
-    
+
     private PreparedStatement insertStatement;
     private PreparedStatement selectStatement;
     private PreparedStatement deleteStatement;
@@ -102,31 +109,36 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
     public CassandraAggregationRepository(Session session) {
         this.sessionHolder = new CassandraSessionHolder(session);
     }
+
     public CassandraAggregationRepository(Cluster cluster, String keyspace) {
         this.sessionHolder = new CassandraSessionHolder(cluster, keyspace);
     }
+
     /**
      * Get fixed primary key values.
      */
     protected abstract Object[] getPKValues();
+
     /**
      * Generate primary key values: fixed + aggregation key.
      */
     protected Object[] getPKValues(String key) {
         return append(getPKValues(), key);
     }
+
     /**
      * Get aggregation key colum name.
      */
     private String getKeyColumn() {
-        return pkColumns[pkColumns.length-1];
+        return pkColumns[pkColumns.length - 1];
     }
+
     private String[] getAllColumns() {
         return append(pkColumns, exchangeIdColumn, exchangeColumn);
     }
     //--------------------------------------------------------------------------
     // Service support
-    
+
     @Override
     protected void doStart() throws Exception {
         sessionHolder.start();
@@ -146,12 +158,13 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
     // Add exchange to repository
 
     private void initInsertStatement() {
-        String cql = generateInsert(table, 
-                getAllColumns(), 
+        String cql = generateInsert(table,
+                getAllColumns(),
                 false, ttl).toString();
         LOGGER.debug("Generated Insert {}", cql);
         insertStatement = applyConsistencyLevel(getSession().prepare(cql), writeConsistencyLevel);
     }
+
     /**
      * Insert or update exchange in aggregation table.
      */
@@ -173,12 +186,13 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
     // Get exchange from repository
 
     protected void initSelectStatement() {
-        String cql = generateSelect(table, 
-                getAllColumns(), 
+        String cql = generateSelect(table,
+                getAllColumns(),
                 pkColumns).toString();
         LOGGER.debug("Generated Select {}", cql);
         selectStatement = applyConsistencyLevel(getSession().prepare(cql), readConsistencyLevel);
     }
+
     /**
      * Get exchange from aggregation table by aggregation key.
      */
@@ -188,7 +202,7 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
         LOGGER.debug("Selecting key {} ", pkValues);
         Row row = getSession().execute(selectStatement.bind(pkValues)).one();
         Exchange exchange = null;
-        if (row!=null) {
+        if (row != null) {
             try {
                 exchange = exchangeCodec.unmarshallExchange(camelContext, row.getBytes(exchangeColumn));
             } catch (IOException iOException) {
@@ -216,10 +230,10 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
     @Override
     public void confirm(CamelContext camelContext, String exchangeId) {
         Object[] pkValues = getPKValues();
-        String keyColumn= getKeyColumn();
+        String keyColumn = getKeyColumn();
         LOGGER.debug("Selecting Ids {} ", pkValues);
         List<Row> rows = selectKeyIds();
-        for(Row row:rows) {
+        for (Row row : rows) {
             if (row.getString(exchangeIdColumn).equals(exchangeId)) {
                 String key = row.getString(keyColumn);
                 Object[] cqlParams = append(pkValues, key, exchangeId);
@@ -247,11 +261,12 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
         LOGGER.debug("Deleting key {}", (Object) idValues);
         getSession().execute(deleteStatement.bind(idValues));
     }
+
     // -------------------------------------------------------------------------
-    private void initSelectKeyIdStatement() { 
-        String cql = generateSelect(table, 
+    private void initSelectKeyIdStatement() {
+        String cql = generateSelect(table,
                 new String[]{getKeyColumn(), exchangeIdColumn}, // Key + Exchange Id columns
-                pkColumns, pkColumns.length-1).toString(); // Where fixed PK columns
+                pkColumns, pkColumns.length - 1).toString(); // Where fixed PK columns
         LOGGER.debug("Generated Select keys {}", cql);
         selectKeyIdStatement = applyConsistencyLevel(getSession().prepare(cql), readConsistencyLevel);
     }
@@ -270,7 +285,7 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
         List<Row> rows = selectKeyIds();
         Set<String> keys = new HashSet<String>(rows.size());
         String keyColumnName = getPKColumns()[1];
-        for(Row row:rows) {
+        for (Row row : rows) {
             keys.add(row.getString(keyColumnName));
         }
         return keys;
@@ -295,10 +310,12 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
     public void setTable(String table) {
         this.table = table;
     }
+
     public String[] getPKColumns() {
         return pkColumns;
     }
-    public void setPKColumns(String ... pkColumns) {
+
+    public void setPKColumns(String... pkColumns) {
         this.pkColumns = pkColumns;
     }
 
@@ -325,7 +342,7 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
     public void setReadConsistencyLevel(ConsistencyLevel readConsistencyLevel) {
         this.readConsistencyLevel = readConsistencyLevel;
     }
-    
+
     public String getExchangeColumn() {
         return exchangeColumn;
     }
@@ -341,5 +358,5 @@ public abstract class CassandraAggregationRepository extends ServiceSupport impl
     public void setTtl(Integer ttl) {
         this.ttl = ttl;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraCamelCodec.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraCamelCodec.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraCamelCodec.java
index e060678..af5b2e5 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraCamelCodec.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraCamelCodec.java
@@ -1,18 +1,18 @@
 /**
  * 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
+ * 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
+ *      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.
+ * 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.processor.aggregate.cassandra;
 
@@ -31,7 +31,7 @@ import org.apache.camel.impl.DefaultExchangeHolder;
 
 /**
  * Marshall/unmarshall Exchange to/from a ByteBuffer.
- * Inspired from JdbcCamelCodec. TODO Find how to share code
+ * Inspired from JdbcCamelCodec.
  */
 public class CassandraCamelCodec {
 

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepository.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepository.java
index 5448207..347ed75 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepository.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepository.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,14 +14,13 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.processor.aggregate.cassandra;
 
 import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.Session;
 
 /**
- * Concrete implementation of {@link  CassandraAggregationRepository} using 2 
+ * Concrete implementation of {@link  CassandraAggregationRepository} using 2
  * columns as primary key: name (partition key) and key (clustering key).
  */
 public class NamedCassandraAggregationRepository extends CassandraAggregationRepository {
@@ -28,14 +28,17 @@ public class NamedCassandraAggregationRepository extends CassandraAggregationRep
      * Aggregation repository name
      */
     private String name;
+
     public NamedCassandraAggregationRepository() {
         setPKColumns("NAME", "KEY");
     }
+
     public NamedCassandraAggregationRepository(Session session, String name) {
         super(session);
         this.name = name;
         setPKColumns("NAME", "KEY");
     }
+
     public NamedCassandraAggregationRepository(Cluster cluster, String keyspace, String name) {
         super(cluster, keyspace);
         this.name = name;

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
index 4bdf496..ddb7168 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -26,14 +27,19 @@ import org.apache.camel.support.ServiceSupport;
 import org.apache.camel.utils.cassandra.CassandraSessionHolder;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
-import static org.apache.camel.utils.cassandra.CassandraUtils.*;
+
+import static org.apache.camel.utils.cassandra.CassandraUtils.applyConsistencyLevel;
+import static org.apache.camel.utils.cassandra.CassandraUtils.generateDelete;
+import static org.apache.camel.utils.cassandra.CassandraUtils.generateInsert;
+import static org.apache.camel.utils.cassandra.CassandraUtils.generateSelect;
 
 /**
  * Implementation of {@link IdempotentRepository} using Cassandra table to store
  * message ids.
  * Advice: use LeveledCompaction for this table and tune read/write consistency levels.
  * Warning: Cassandra is not the best tool for queuing use cases
- * @see http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets
+ * See http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets
+ *
  * @param <K> Message Id
  */
 public abstract class CassandraIdempotentRepository<K> extends ServiceSupport implements IdempotentRepository<K> {
@@ -75,20 +81,22 @@ public abstract class CassandraIdempotentRepository<K> extends ServiceSupport im
     public CassandraIdempotentRepository(Session session) {
         this.sessionHolder = new CassandraSessionHolder(session);
     }
+
     public CassandraIdempotentRepository(Cluster cluster, String keyspace) {
         this.sessionHolder = new CassandraSessionHolder(cluster, keyspace);
     }
 
     private boolean isKey(ResultSet resultSet) {
-        Row row = resultSet.one(); 
-        if (row==null) {
+        Row row = resultSet.one();
+        if (row == null) {
             LOGGER.debug("No row to check key");
             return false;
         } else {
-            LOGGER.debug("Row with {} columns to check key", row.getColumnDefinitions());            
-            return row.getColumnDefinitions().size()>1;
+            LOGGER.debug("Row with {} columns to check key", row.getColumnDefinitions());
+            return row.getColumnDefinitions().size() > 1;
         }
     }
+
     protected abstract Object[] getPKValues(K key);
     // -------------------------------------------------------------------------
     // Lifecycle methods
@@ -182,7 +190,7 @@ public abstract class CassandraIdempotentRepository<K> extends ServiceSupport im
     }
 
     public void setPKColumns(String... pkColumns) {
-        this.pkColumns=pkColumns;
+        this.pkColumns = pkColumns;
     }
 
     public Integer getTtl() {
@@ -208,5 +216,5 @@ public abstract class CassandraIdempotentRepository<K> extends ServiceSupport im
     public void setReadConsistencyLevel(ConsistencyLevel readConsistencyLevel) {
         this.readConsistencyLevel = readConsistencyLevel;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java
index 03d73ec..73219fc 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,17 +14,16 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.processor.idempotent.cassandra;
 
 import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.Session;
 
 /**
- * Concrete implementation of {@link  CassandraIdempotentRepository} using 2 
+ * Concrete implementation of {@link  CassandraIdempotentRepository} using 2
  * columns as primary key: name (partition key) and key (clustering key).
  */
-public class NamedCassandraIdempotentRepository<K> extends CassandraIdempotentRepository<K>{
+public class NamedCassandraIdempotentRepository<K> extends CassandraIdempotentRepository<K> {
     /**
      * Idempotent repository name
      */
@@ -32,17 +32,19 @@ public class NamedCassandraIdempotentRepository<K> extends CassandraIdempotentRe
     public NamedCassandraIdempotentRepository() {
         setPKColumns("NAME", "KEY");
     }
+
     public NamedCassandraIdempotentRepository(Session session, String name) {
         super(session);
         this.name = name;
         setPKColumns("NAME", "KEY");
     }
+
     public NamedCassandraIdempotentRepository(Cluster cluster, String keyspace, String name) {
         super(cluster, keyspace);
         this.name = name;
         setPKColumns("NAME", "KEY");
     }
-    
+
     @Override
     protected Object[] getPKValues(K key) {
         return new Object[]{name, key};

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraSessionHolder.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraSessionHolder.java b/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraSessionHolder.java
index 82a7a72..d16c3fa 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraSessionHolder.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraSessionHolder.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.utils.cassandra;
 
 import com.datastax.driver.core.Cluster;
@@ -52,6 +52,7 @@ public class CassandraSessionHolder {
         this.keyspace = session.getLoggedKeyspace();
         this.managedSession = false;
     }
+
     public void start() {
         if (managedSession) {
             if (keyspace == null) {
@@ -61,12 +62,14 @@ public class CassandraSessionHolder {
             }
         }
     }
+
     public void stop() {
         if (!managedSession) {
             session.close();
             session = null;
         }
     }
+
     public Session getSession() {
         return session;
     }
@@ -78,5 +81,5 @@ public class CassandraSessionHolder {
     public String getKeyspace() {
         return keyspace;
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraUtils.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraUtils.java b/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraUtils.java
index 4b18d8c..defc169 100644
--- a/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraUtils.java
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraUtils.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,7 +14,6 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.utils.cassandra;
 
 import com.datastax.driver.core.ConsistencyLevel;
@@ -27,41 +27,46 @@ public class CassandraUtils {
      * Apply consistency level if provided, else leave default.
      */
     public static PreparedStatement applyConsistencyLevel(PreparedStatement statement, ConsistencyLevel consistencyLevel) {
-        if (consistencyLevel!=null) {
+        if (consistencyLevel != null) {
             statement.setConsistencyLevel(consistencyLevel);
         }
         return statement;
     }
+
     /**
      * Concatenate 2 arrays.
      */
     public static Object[] concat(Object[] array1, Object[] array2) {
-        Object[] array = new Object[array1.length+array2.length];
+        Object[] array = new Object[array1.length + array2.length];
         System.arraycopy(array1, 0, array, 0, array1.length);
         System.arraycopy(array2, 0, array, array1.length, array2.length);
         return array;
     }
+
     /**
      * Concatenate 2 arrays.
      */
     public static String[] concat(String[] array1, String[] array2) {
-        String[] array = new String[array1.length+array2.length];
+        String[] array = new String[array1.length + array2.length];
         System.arraycopy(array1, 0, array, 0, array1.length);
         System.arraycopy(array2, 0, array, array1.length, array2.length);
         return array;
     }
+
     /**
      * Append values to given array.
      */
-    public static Object[] append(Object[] array1, Object ... array2) {
+    public static Object[] append(Object[] array1, Object... array2) {
         return concat(array1, array2);
     }
+
     /**
      * Append values to given array.
      */
-    public static String[] append(String[] array1, String ... array2) {
+    public static String[] append(String[] array1, String... array2) {
         return concat(array1, array2);
     }
+
     /**
      * Append columns to CQL.
      */
@@ -77,7 +82,7 @@ public class CassandraUtils {
     /**
      * Append columns to CQL.
      */
-    public static  void appendColumns(StringBuilder cqlBuilder, String[] columns, String sep) {
+    public static void appendColumns(StringBuilder cqlBuilder, String[] columns, String sep) {
         appendColumns(cqlBuilder, columns, sep, columns.length);
     }
 
@@ -89,12 +94,14 @@ public class CassandraUtils {
         appendColumns(cqlBuilder, columns, "=? and ", maxColumnIndex);
         cqlBuilder.append("=?");
     }
+
     /**
      * Append where columns = ? to CQL.
      */
     public void appendWhere(StringBuilder cqlBuilder, String[] columns) {
         appendWhere(cqlBuilder, columns, columns.length);
     }
+
     /**
      * Append ?,? to CQL.
      */
@@ -120,11 +127,12 @@ public class CassandraUtils {
         if (ifNotExists) {
             cqlBuilder.append(" if not exists");
         }
-        if (ttl!=null) {
+        if (ttl != null) {
             cqlBuilder.append(" using ttl=").append(ttl);
         }
-        return cqlBuilder;        
+        return cqlBuilder;
     }
+
     /**
      * Generate select where columns = ? CQL.
      */
@@ -142,18 +150,20 @@ public class CassandraUtils {
         appendWhere(cqlBuilder, whereColumns, whereColumnsMaxIndex);
         return cqlBuilder;
     }
+
     /**
      * Generate delete where columns = ? CQL.
      */
     public static StringBuilder generateDelete(String table, String[] whereColumns, boolean ifExists) {
         return generateDelete(table, whereColumns, whereColumns.length, ifExists);
     }
+
     /**
      * Generate delete where columns = ? CQL.
      */
     public static StringBuilder generateDelete(String table, String[] whereColumns, int whereColumnsMaxIndex, boolean ifExists) {
         StringBuilder cqlBuilder = new StringBuilder("delete from ")
-            .append(table);
+                .append(table);
         appendWhere(cqlBuilder, whereColumns, whereColumnsMaxIndex);
         if (ifExists) {
             cqlBuilder.append(" if exists");

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/resources/META-INF/LICENSE.txt b/components/camel-cassandraql/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-cassandraql/src/main/resources/META-INF/LICENSE.txt
@@ -0,0 +1,203 @@
+
+                                 Apache License
+                           Version 2.0, January 2004
+                        http://www.apache.org/licenses/
+
+   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+   1. Definitions.
+
+      "License" shall mean the terms and conditions for use, reproduction,
+      and distribution as defined by Sections 1 through 9 of this document.
+
+      "Licensor" shall mean the copyright owner or entity authorized by
+      the copyright owner that is granting the License.
+
+      "Legal Entity" shall mean the union of the acting entity and all
+      other entities that control, are controlled by, or are under common
+      control with that entity. For the purposes of this definition,
+      "control" means (i) the power, direct or indirect, to cause the
+      direction or management of such entity, whether by contract or
+      otherwise, or (ii) ownership of fifty percent (50%) or more of the
+      outstanding shares, or (iii) beneficial ownership of such entity.
+
+      "You" (or "Your") shall mean an individual or Legal Entity
+      exercising permissions granted by this License.
+
+      "Source" form shall mean the preferred form for making modifications,
+      including but not limited to software source code, documentation
+      source, and configuration files.
+
+      "Object" form shall mean any form resulting from mechanical
+      transformation or translation of a Source form, including but
+      not limited to compiled object code, generated documentation,
+      and conversions to other media types.
+
+      "Work" shall mean the work of authorship, whether in Source or
+      Object form, made available under the License, as indicated by a
+      copyright notice that is included in or attached to the work
+      (an example is provided in the Appendix below).
+
+      "Derivative Works" shall mean any work, whether in Source or Object
+      form, that is based on (or derived from) the Work and for which the
+      editorial revisions, annotations, elaborations, or other modifications
+      represent, as a whole, an original work of authorship. For the purposes
+      of this License, Derivative Works shall not include works that remain
+      separable from, or merely link (or bind by name) to the interfaces of,
+      the Work and Derivative Works thereof.
+
+      "Contribution" shall mean any work of authorship, including
+      the original version of the Work and any modifications or additions
+      to that Work or Derivative Works thereof, that is intentionally
+      submitted to Licensor for inclusion in the Work by the copyright owner
+      or by an individual or Legal Entity authorized to submit on behalf of
+      the copyright owner. For the purposes of this definition, "submitted"
+      means any form of electronic, verbal, or written communication sent
+      to the Licensor or its representatives, including but not limited to
+      communication on electronic mailing lists, source code control systems,
+      and issue tracking systems that are managed by, or on behalf of, the
+      Licensor for the purpose of discussing and improving the Work, but
+      excluding communication that is conspicuously marked or otherwise
+      designated in writing by the copyright owner as "Not a Contribution."
+
+      "Contributor" shall mean Licensor and any individual or Legal Entity
+      on behalf of whom a Contribution has been received by Licensor and
+      subsequently incorporated within the Work.
+
+   2. Grant of Copyright License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      copyright license to reproduce, prepare Derivative Works of,
+      publicly display, publicly perform, sublicense, and distribute the
+      Work and such Derivative Works in Source or Object form.
+
+   3. Grant of Patent License. Subject to the terms and conditions of
+      this License, each Contributor hereby grants to You a perpetual,
+      worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+      (except as stated in this section) patent license to make, have made,
+      use, offer to sell, sell, import, and otherwise transfer the Work,
+      where such license applies only to those patent claims licensable
+      by such Contributor that are necessarily infringed by their
+      Contribution(s) alone or by combination of their Contribution(s)
+      with the Work to which such Contribution(s) was submitted. If You
+      institute patent litigation against any entity (including a
+      cross-claim or counterclaim in a lawsuit) alleging that the Work
+      or a Contribution incorporated within the Work constitutes direct
+      or contributory patent infringement, then any patent licenses
+      granted to You under this License for that Work shall terminate
+      as of the date such litigation is filed.
+
+   4. Redistribution. You may reproduce and distribute copies of the
+      Work or Derivative Works thereof in any medium, with or without
+      modifications, and in Source or Object form, provided that You
+      meet the following conditions:
+
+      (a) You must give any other recipients of the Work or
+          Derivative Works a copy of this License; and
+
+      (b) You must cause any modified files to carry prominent notices
+          stating that You changed the files; and
+
+      (c) You must retain, in the Source form of any Derivative Works
+          that You distribute, all copyright, patent, trademark, and
+          attribution notices from the Source form of the Work,
+          excluding those notices that do not pertain to any part of
+          the Derivative Works; and
+
+      (d) If the Work includes a "NOTICE" text file as part of its
+          distribution, then any Derivative Works that You distribute must
+          include a readable copy of the attribution notices contained
+          within such NOTICE file, excluding those notices that do not
+          pertain to any part of the Derivative Works, in at least one
+          of the following places: within a NOTICE text file distributed
+          as part of the Derivative Works; within the Source form or
+          documentation, if provided along with the Derivative Works; or,
+          within a display generated by the Derivative Works, if and
+          wherever such third-party notices normally appear. The contents
+          of the NOTICE file are for informational purposes only and
+          do not modify the License. You may add Your own attribution
+          notices within Derivative Works that You distribute, alongside
+          or as an addendum to the NOTICE text from the Work, provided
+          that such additional attribution notices cannot be construed
+          as modifying the License.
+
+      You may add Your own copyright statement to Your modifications and
+      may provide additional or different license terms and conditions
+      for use, reproduction, or distribution of Your modifications, or
+      for any such Derivative Works as a whole, provided Your use,
+      reproduction, and distribution of the Work otherwise complies with
+      the conditions stated in this License.
+
+   5. Submission of Contributions. Unless You explicitly state otherwise,
+      any Contribution intentionally submitted for inclusion in the Work
+      by You to the Licensor shall be under the terms and conditions of
+      this License, without any additional terms or conditions.
+      Notwithstanding the above, nothing herein shall supersede or modify
+      the terms of any separate license agreement you may have executed
+      with Licensor regarding such Contributions.
+
+   6. Trademarks. This License does not grant permission to use the trade
+      names, trademarks, service marks, or product names of the Licensor,
+      except as required for reasonable and customary use in describing the
+      origin of the Work and reproducing the content of the NOTICE file.
+
+   7. Disclaimer of Warranty. Unless required by applicable law or
+      agreed to in writing, Licensor provides the Work (and each
+      Contributor provides its Contributions) on an "AS IS" BASIS,
+      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+      implied, including, without limitation, any warranties or conditions
+      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+      PARTICULAR PURPOSE. You are solely responsible for determining the
+      appropriateness of using or redistributing the Work and assume any
+      risks associated with Your exercise of permissions under this License.
+
+   8. Limitation of Liability. In no event and under no legal theory,
+      whether in tort (including negligence), contract, or otherwise,
+      unless required by applicable law (such as deliberate and grossly
+      negligent acts) or agreed to in writing, shall any Contributor be
+      liable to You for damages, including any direct, indirect, special,
+      incidental, or consequential damages of any character arising as a
+      result of this License or out of the use or inability to use the
+      Work (including but not limited to damages for loss of goodwill,
+      work stoppage, computer failure or malfunction, or any and all
+      other commercial damages or losses), even if such Contributor
+      has been advised of the possibility of such damages.
+
+   9. Accepting Warranty or Additional Liability. While redistributing
+      the Work or Derivative Works thereof, You may choose to offer,
+      and charge a fee for, acceptance of support, warranty, indemnity,
+      or other liability obligations and/or rights consistent with this
+      License. However, in accepting such obligations, You may act only
+      on Your own behalf and on Your sole responsibility, not on behalf
+      of any other Contributor, and only if You agree to indemnify,
+      defend, and hold each Contributor harmless for any liability
+      incurred by, or claims asserted against, such Contributor by reason
+      of your accepting any such warranty or additional liability.
+
+   END OF TERMS AND CONDITIONS
+
+   APPENDIX: How to apply the Apache License to your work.
+
+      To apply the Apache License to your work, attach the following
+      boilerplate notice, with the fields enclosed by brackets "[]"
+      replaced with your own identifying information. (Don't include
+      the brackets!)  The text should be enclosed in the appropriate
+      comment syntax for the file format. We also recommend that a
+      file or class name and description of purpose be included on the
+      same "printed page" as the copyright notice for easier
+      identification within third-party archives.
+
+   Copyright [yyyy] [name of copyright owner]
+
+   Licensed 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.
+

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/resources/META-INF/NOTICE.txt b/components/camel-cassandraql/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-cassandraql/src/main/resources/META-INF/NOTICE.txt
@@ -0,0 +1,11 @@
+   =========================================================================
+   ==  NOTICE file corresponding to the section 4 d of                    ==
+   ==  the Apache License, Version 2.0,                                   ==
+   ==  in this case for the Apache Camel distribution.                    ==
+   =========================================================================
+
+   This product includes software developed by
+   The Apache Software Foundation (http://www.apache.org/).
+
+   Please read the different LICENSE files present in the licenses directory of
+   this distribution.

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/main/resources/META-INF/services/org/apache/camel/component/cql
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/resources/META-INF/services/org/apache/camel/component/cql b/components/camel-cassandraql/src/main/resources/META-INF/services/org/apache/camel/component/cql
index 8d80a4f..66c5093 100644
--- a/components/camel-cassandraql/src/main/resources/META-INF/services/org/apache/camel/component/cql
+++ b/components/camel-cassandraql/src/main/resources/META-INF/services/org/apache/camel/component/cql
@@ -1 +1,18 @@
+#
+# 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.
+#
+
 class=org.apache.camel.component.cassandra.CassandraComponent

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
index f3efc27..a184401 100644
--- a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
@@ -1,18 +1,27 @@
+/**
+ * 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.cassandra;
 
-import org.apache.camel.component.cassandra.CassandraEndpoint;
 import com.datastax.driver.core.Cluster;
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
-import com.datastax.driver.core.Session;
-import java.net.URLEncoder;
-import java.util.Arrays;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
 import org.apache.camel.impl.JndiRegistry;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.http.client.utils.URLEncodedUtils;
 import org.cassandraunit.CassandraCQLUnit;
 import org.junit.AfterClass;
 import org.junit.BeforeClass;
@@ -20,14 +29,21 @@ import org.junit.Rule;
 import org.junit.Test;
 
 public class CassandraComponentBeanRefTest extends CamelTestSupport {
-    @Rule
-    public CassandraCQLUnit cassandra=CassandraUnitUtils.cassandraCQLUnit();
+    public static final String CQL = "insert into camel_user(login, first_name, last_name) values (?, ?, ?)";
+    public static final String SESSION_URI = "cql:bean:cassandraSession?cql=#insertCql";
+    public static final String CLUSTER_URI = "cql:bean:cassandraCluster/camel_ks?cql=#insertCql";
+
     @Produce(uri = "direct:input")
-    ProducerTemplate producerTemplate;
+    public ProducerTemplate producerTemplate;
+
+    @Rule
+    public CassandraCQLUnit cassandra = CassandraUnitUtils.cassandraCQLUnit();
+
     @BeforeClass
     public static void setUpClass() throws Exception {
         CassandraUnitUtils.startEmbeddedCassandra();
     }
+
     @AfterClass
     public static void tearDownClass() throws Exception {
         CassandraUnitUtils.cleanEmbeddedCassandra();
@@ -44,21 +60,19 @@ public class CassandraComponentBeanRefTest extends CamelTestSupport {
         registry.bind("insertCql", CQL);
         return registry;
     }
-    public static final String CQL = "insert into camel_user(login, first_name, last_name) values (?, ?, ?)";
-    public static final String SESSION_URI = "cql:bean:cassandraSession?cql=#insertCql";
-    public static final String CLUSTER_URI = "cql:bean:cassandraCluster/camel_ks?cql=#insertCql";
-    
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
-            public void configure() {                
+            public void configure() {
                 from("direct:inputSession")
-                  .to(SESSION_URI);
+                        .to(SESSION_URI);
                 from("direct:inputCluster")
-                  .to(CLUSTER_URI);
+                        .to(CLUSTER_URI);
             }
         };
     }
+
     @Test
     public void testSession() throws Exception {
         CassandraEndpoint endpoint = getMandatoryEndpoint(SESSION_URI, CassandraEndpoint.class);
@@ -66,6 +80,7 @@ public class CassandraComponentBeanRefTest extends CamelTestSupport {
         assertEquals("camel_ks", endpoint.getKeyspace());
         assertEquals(CQL, endpoint.getCql());
     }
+
     @Test
     public void testCluster() throws Exception {
         CassandraEndpoint endpoint = getMandatoryEndpoint(CLUSTER_URI, CassandraEndpoint.class);

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentClusterBuilderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentClusterBuilderTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentClusterBuilderTest.java
index 17753f7..826cd17 100644
--- a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentClusterBuilderTest.java
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentClusterBuilderTest.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,62 +14,68 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.cassandra;
 
-import org.apache.camel.component.cassandra.CassandraComponent;
+import java.util.HashMap;
+import java.util.Map;
+
 import com.datastax.driver.core.Cluster;
-import java.util.*;
 import org.apache.camel.impl.DefaultCamelContext;
-import static org.hamcrest.Matchers.*;
-import org.junit.Test;
-import static org.junit.Assert.*;
 import org.junit.Before;
+import org.junit.Test;
+
+import static org.hamcrest.Matchers.isOneOf;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertThat;
 
 /**
  * Unit test for {@link CassandraComponent}
  */
 public class CassandraComponentClusterBuilderTest {
     private final CassandraComponent component = new CassandraComponent();
+
     @Before
     public void setUp() {
         component.setCamelContext(new DefaultCamelContext());
     }
+
     @Test
-    public void testClusterBuilder_Basic() {
+    public void testClusterBuilderBasic() {
         Map<String, Object> params = new HashMap<String, Object>();
         params.put("clusterName", "cluster");
         Cluster.Builder clusterBuilder = component.clusterBuilder("127.0.0.1,127.0.0.2/keyspace", params);
-        
+
         assertEquals(2, clusterBuilder.getContactPoints().size());
-        assertThat(clusterBuilder.getContactPoints().get(0).getHostName(), isOneOf("127.0.0.1","localhost"));
-        assertThat(clusterBuilder.getContactPoints().get(1).getHostName(), isOneOf("127.0.0.2","localhost"));
+        assertThat(clusterBuilder.getContactPoints().get(0).getHostName(), isOneOf("127.0.0.1", "localhost"));
+        assertThat(clusterBuilder.getContactPoints().get(1).getHostName(), isOneOf("127.0.0.2", "localhost"));
         assertEquals("cluster", clusterBuilder.getClusterName());
-        assertEquals("keyspace",params.get("keyspace"));
+        assertEquals("keyspace", params.get("keyspace"));
     }
+
     @Test
-    public void testClusterBuilder_Port() {
+    public void testClusterBuilderPort() {
         Map<String, Object> params = new HashMap<String, Object>();
         params.put("clusterName", "cluster");
         Cluster.Builder clusterBuilder = component.clusterBuilder("127.0.0.1,127.0.0.2:1234/keyspace", params);
-        
+
         assertEquals(2, clusterBuilder.getContactPoints().size());
-        assertThat(clusterBuilder.getContactPoints().get(0).getHostName(), isOneOf("127.0.0.1","localhost"));
+        assertThat(clusterBuilder.getContactPoints().get(0).getHostName(), isOneOf("127.0.0.1", "localhost"));
         assertEquals(1234, clusterBuilder.getContactPoints().get(0).getPort());
-        assertThat(clusterBuilder.getContactPoints().get(1).getHostName(), isOneOf("127.0.0.2","localhost"));
+        assertThat(clusterBuilder.getContactPoints().get(1).getHostName(), isOneOf("127.0.0.2", "localhost"));
         assertEquals(1234, clusterBuilder.getConfiguration().getProtocolOptions().getPort());
         assertEquals("cluster", clusterBuilder.getClusterName());
-        assertEquals("keyspace",params.get("keyspace"));
+        assertEquals("keyspace", params.get("keyspace"));
     }
 
     @Test
-    public void testClusterBuilder_Simplest() {
+    public void testClusterBuilderSimplest() {
         Map<String, Object> params = new HashMap<String, Object>();
         Cluster.Builder clusterBuilder = component.clusterBuilder("127.0.0.1", params);
-        
+
         assertEquals(1, clusterBuilder.getContactPoints().size());
-        assertThat(clusterBuilder.getContactPoints().get(0).getHostName(), isOneOf("127.0.0.1","localhost"));
+        assertThat(clusterBuilder.getContactPoints().get(0).getHostName(), isOneOf("127.0.0.1", "localhost"));
         assertNull(params.get("keyspace"));
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
index 0b4f0ed..76d303d 100644
--- a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
@@ -1,8 +1,25 @@
+/**
+ * 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.cassandra;
 
-import com.datastax.driver.core.Row;
 import java.util.List;
 import java.util.concurrent.TimeUnit;
+
+import com.datastax.driver.core.Row;
 import org.apache.camel.Exchange;
 import org.apache.camel.Processor;
 import org.apache.camel.builder.RouteBuilder;
@@ -10,7 +27,6 @@ import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
 import org.cassandraunit.CassandraCQLUnit;
 import org.junit.AfterClass;
-import static org.junit.Assert.assertTrue;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
@@ -18,21 +34,26 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
 public class CassandraComponentConsumerTest extends CamelTestSupport {
+
+    private static final String CQL = "select login, first_name, last_name from camel_user";
+
     @Rule
-    public CassandraCQLUnit cassandra=CassandraUnitUtils.cassandraCQLUnit();
-    private final Logger logger = LoggerFactory.getLogger(getClass());
+    public CassandraCQLUnit cassandra = CassandraUnitUtils.cassandraCQLUnit();
+
     @BeforeClass
     public static void setUpClass() throws Exception {
         CassandraUnitUtils.startEmbeddedCassandra();
     }
+
     @AfterClass
     public static void tearDownClass() throws Exception {
         CassandraUnitUtils.cleanEmbeddedCassandra();
     }
+
     @Test
-    public void testConsume_All() throws Exception {
+    public void testConsumeAll() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:resultAll");
-        mock.expectedMinimumMessageCount(1);       
+        mock.expectedMinimumMessageCount(1);
         mock.whenAnyExchangeReceived(new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -43,10 +64,11 @@ public class CassandraComponentConsumerTest extends CamelTestSupport {
         mock.await(1, TimeUnit.SECONDS);
         assertMockEndpointsSatisfied();
     }
+
     @Test
-    public void testConsume_One() throws Exception {
+    public void testConsumeOne() throws Exception {
         MockEndpoint mock = getMockEndpoint("mock:resultOne");
-        mock.expectedMinimumMessageCount(1);       
+        mock.expectedMinimumMessageCount(1);
         mock.whenAnyExchangeReceived(new Processor() {
             @Override
             public void process(Exchange exchange) throws Exception {
@@ -55,18 +77,18 @@ public class CassandraComponentConsumerTest extends CamelTestSupport {
             }
         });
         mock.await(1, TimeUnit.SECONDS);
-        
+
         assertMockEndpointsSatisfied();
     }
-    private static final String CQL = "select login, first_name, last_name from camel_user";
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
-            public void configure() {                
-                from("cql://localhost/camel_ks?cql="+CQL)
-                  .to("mock:resultAll");
-                from("cql://localhost/camel_ks?cql="+CQL+"&resultSetConversionStrategy=ONE")
-                  .to("mock:resultOne");
+            public void configure() {
+                from("cql://localhost/camel_ks?cql=" + CQL)
+                        .to("mock:resultAll");
+                from("cql://localhost/camel_ks?cql=" + CQL + "&resultSetConversionStrategy=ONE")
+                        .to("mock:resultOne");
             }
         };
     }


[3/5] camel git commit: CAMEL-2939: Fixed CS

Posted by da...@apache.org.
http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
index 5cc42e6..1755612 100644
--- a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentProducerTest.java
@@ -1,13 +1,28 @@
+/**
+ * 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.cassandra;
 
+import java.util.Arrays;
+
 import com.datastax.driver.core.Cluster;
-import org.apache.camel.component.cassandra.CassandraEndpoint;
-import org.apache.camel.component.cassandra.CassandraConstants;
 import com.datastax.driver.core.ConsistencyLevel;
 import com.datastax.driver.core.ResultSet;
 import com.datastax.driver.core.Row;
 import com.datastax.driver.core.Session;
-import java.util.Arrays;
 import org.apache.camel.Produce;
 import org.apache.camel.ProducerTemplate;
 import org.apache.camel.builder.RouteBuilder;
@@ -19,38 +34,46 @@ import org.junit.Rule;
 import org.junit.Test;
 
 public class CassandraComponentProducerTest extends CamelTestSupport {
+
+    private static final String CQL = "insert into camel_user(login, first_name, last_name) values (?, ?, ?)";
+    private static final String NOT_CONSISTENT_URI = "cql://localhost/camel_ks?cql=" + CQL + "&consistencyLevel=ANY";
+
     @Rule
-    public CassandraCQLUnit cassandra=CassandraUnitUtils.cassandraCQLUnit();
+    public CassandraCQLUnit cassandra = CassandraUnitUtils.cassandraCQLUnit();
+
     @Produce(uri = "direct:input")
     ProducerTemplate producerTemplate;
+
     @Produce(uri = "direct:inputNotConsistent")
     ProducerTemplate notConsistentProducerTemplate;
+
     @BeforeClass
     public static void setUpClass() throws Exception {
         CassandraUnitUtils.startEmbeddedCassandra();
     }
+
     @AfterClass
     public static void tearDownClass() throws Exception {
         CassandraUnitUtils.cleanEmbeddedCassandra();
     }
-    private static final String CQL = "insert into camel_user(login, first_name, last_name) values (?, ?, ?)";
-    private static final String NOT_CONSISTENT_URI="cql://localhost/camel_ks?cql="+CQL+"&consistencyLevel=ANY";
+
     @Override
     protected RouteBuilder createRouteBuilder() throws Exception {
         return new RouteBuilder() {
             public void configure() {
-                
+
                 from("direct:input")
-                  .to("cql://localhost/camel_ks?cql="+CQL);
+                        .to("cql://localhost/camel_ks?cql=" + CQL);
                 from("direct:inputNotConsistent")
-                  .to(NOT_CONSISTENT_URI);
+                        .to(NOT_CONSISTENT_URI);
             }
         };
     }
+
     @Test
-    public void testRequest_UriCql() throws Exception {
-        Object response = producerTemplate.requestBody(Arrays.asList("w_jiang","Willem","Jiang"));
-        
+    public void testRequestUriCql() throws Exception {
+        Object response = producerTemplate.requestBody(Arrays.asList("w_jiang", "Willem", "Jiang"));
+
         Cluster cluster = CassandraUnitUtils.cassandraCluster();
         Session session = cluster.connect(CassandraUnitUtils.KEYSPACE);
         ResultSet resultSet = session.execute("select login, first_name, last_name from camel_user where login = ?", "w_jiang");
@@ -61,10 +84,12 @@ public class CassandraComponentProducerTest extends CamelTestSupport {
         session.close();
         cluster.close();
     }
+
     @Test
-    public void testRequest_MessageCql() throws Exception {
-        Object response = producerTemplate.requestBodyAndHeader(new Object[]{"Claus 2","Ibsen 2", "c_ibsen"}, CassandraConstants.CQL_QUERY, "update camel_user set first_name=?, last_name=? where login=?");
-        
+    public void testRequestMessageCql() throws Exception {
+        Object response = producerTemplate.requestBodyAndHeader(new Object[]{"Claus 2", "Ibsen 2", "c_ibsen"},
+                CassandraConstants.CQL_QUERY, "update camel_user set first_name=?, last_name=? where login=?");
+
         Cluster cluster = CassandraUnitUtils.cassandraCluster();
         Session session = cluster.connect(CassandraUnitUtils.KEYSPACE);
         ResultSet resultSet = session.execute("select login, first_name, last_name from camel_user where login = ?", "c_ibsen");
@@ -77,11 +102,11 @@ public class CassandraComponentProducerTest extends CamelTestSupport {
     }
 
     @Test
-    public void testRequest_NotConsistent() throws Exception {
-        
+    public void testRequestNotConsistent() throws Exception {
+
         CassandraEndpoint endpoint = getMandatoryEndpoint(NOT_CONSISTENT_URI, CassandraEndpoint.class);
         assertEquals(ConsistencyLevel.ANY, endpoint.getConsistencyLevel());
-        
-        Object response = notConsistentProducerTemplate.requestBody(Arrays.asList("j_anstey","Jonathan","Anstey"));
+
+        Object response = notConsistentProducerTemplate.requestBody(Arrays.asList("j_anstey", "Jonathan", "Anstey"));
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraUnitUtils.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraUnitUtils.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraUnitUtils.java
index 4bbcab0..30d6c43 100644
--- a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraUnitUtils.java
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraUnitUtils.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -26,11 +27,15 @@ import org.cassandraunit.utils.EmbeddedCassandraServerHelper;
 /**
  * Util methods to manage Cassandra in Unit tests
  */
-public class CassandraUnitUtils {
+public final class CassandraUnitUtils {
     public static final String HOST = "127.0.0.1";
     public static final String KEYSPACE = "camel_ks";
 
     private static CassandraCQLUnit cassandraCQLUnit;
+
+    private CassandraUnitUtils() {
+    }
+
     /**
      * Create Cassandra JUnit Rule.
      */
@@ -40,6 +45,7 @@ public class CassandraUnitUtils {
         }
         return cassandraCQLUnit;
     }
+
     public static CassandraCQLUnit cassandraCQLUnit(String dataSetCql) {
         return cassandraCQLUnit(cqlDataSet(dataSetCql));
     }
@@ -47,6 +53,7 @@ public class CassandraUnitUtils {
     public static CQLDataSet cqlDataSet(String dataSetCql) {
         return new ClassPathCQLDataSet(dataSetCql, KEYSPACE);
     }
+
     public static void loadCQLDataSet(Session session, String dataSetCql) {
         CQLDataLoader loader = new CQLDataLoader(session);
         loader.load(cqlDataSet(dataSetCql));
@@ -55,6 +62,7 @@ public class CassandraUnitUtils {
     public static CassandraCQLUnit cassandraCQLUnit(CQLDataSet dataset) {
         return new CassandraCQLUnit(dataset, "/camel-cassandra.yaml", HOST, 9042);
     }
+
     /**
      * Start embedded Cassandra.
      */
@@ -68,6 +76,7 @@ public class CassandraUnitUtils {
     public static void cleanEmbeddedCassandra() throws Exception {
         EmbeddedCassandraServerHelper.cleanEmbeddedCassandra();
     }
+
     public static Cluster cassandraCluster() {
         return Cluster.builder()
                 .addContactPoint(HOST)

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/ResultSetConversionStrategiesTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/ResultSetConversionStrategiesTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/ResultSetConversionStrategiesTest.java
index fbb5393..f5887f2 100644
--- a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/ResultSetConversionStrategiesTest.java
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/ResultSetConversionStrategiesTest.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,25 +14,26 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.component.cassandra;
 
-import org.apache.camel.component.cassandra.ResultSetConversionStrategy;
-import org.apache.camel.component.cassandra.ResultSetConversionStrategies;
-import com.datastax.driver.core.ResultSet;
-import com.datastax.driver.core.Row;
 import java.util.Collections;
 import java.util.List;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
 import org.junit.Test;
-import static org.junit.Assert.*;
-import static org.mockito.Mockito.*;
-import static org.junit.matchers.JUnitMatchers.*;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertSame;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
 
 /**
  * Unit test for {@link ResultSetConversionStrategy} implementations
  */
 public class ResultSetConversionStrategiesTest {
-    
+
     public ResultSetConversionStrategiesTest() {
     }
 
@@ -41,22 +43,22 @@ public class ResultSetConversionStrategiesTest {
         ResultSet resultSet = mock(ResultSet.class);
         List<Row> rows = Collections.nCopies(20, mock(Row.class));
         when(resultSet.all()).thenReturn(rows);
-        
+
         Object body = strategy.getBody(resultSet);
         assertTrue(body instanceof List);
-        assertSame(rows, body);        
+        assertSame(rows, body);
     }
-    
+
     @Test
     public void testOne() {
         ResultSetConversionStrategy strategy = ResultSetConversionStrategies.fromName("ONE");
         ResultSet resultSet = mock(ResultSet.class);
         Row row = mock(Row.class);
         when(resultSet.one()).thenReturn(row);
-        
+
         Object body = strategy.getBody(resultSet);
         assertTrue(body instanceof Row);
-        assertSame(row, body);        
+        assertSame(row, body);
     }
 
     @Test
@@ -65,9 +67,9 @@ public class ResultSetConversionStrategiesTest {
         ResultSet resultSet = mock(ResultSet.class);
         List<Row> rows = Collections.nCopies(20, mock(Row.class));
         when(resultSet.iterator()).thenReturn(rows.iterator());
-        
+
         Object body = strategy.getBody(resultSet);
         assertTrue(body instanceof List);
-        assertEquals(10, ((List) body).size());        
+        assertEquals(10, ((List) body).size());
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
index 9f906b6..1011212 100644
--- a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepositoryTest.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,11 +14,10 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.processor.aggregate.cassandra;
 
-import org.apache.camel.processor.aggregate.cassandra.CassandraAggregationRepository;
-import org.apache.camel.processor.aggregate.cassandra.NamedCassandraAggregationRepository;
+import java.util.Set;
+
 import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.Session;
 import org.apache.camel.CamelContext;
@@ -28,88 +28,102 @@ import org.apache.camel.impl.DefaultExchange;
 import org.cassandraunit.CassandraCQLUnit;
 import org.junit.After;
 import org.junit.AfterClass;
-import static org.junit.Assert.*;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Rule;
 import org.junit.Test;
-import java.util.Set;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+
 /**
  * Unite test for {@link CassandraAggregationRepository}
  */
 public class CassandraAggregationRepositoryTest {
+    @Rule
+    public CassandraCQLUnit cassandraRule = CassandraUnitUtils.cassandraCQLUnit("AggregationDataSet.cql");
+
     private Cluster cluster;
     private Session session;
     private CassandraAggregationRepository aggregationRepository;
     private CamelContext camelContext;
-    @Rule
-    public CassandraCQLUnit cassandraRule = CassandraUnitUtils.cassandraCQLUnit("AggregationDataSet.cql");
-    
+
     @BeforeClass
     public static void setUpClass() throws Exception {
         CassandraUnitUtils.startEmbeddedCassandra();
     }
+
     @Before
     public void setUp() throws Exception {
-        camelContext =new DefaultCamelContext();
+        camelContext = new DefaultCamelContext();
         cluster = CassandraUnitUtils.cassandraCluster();
         session = cluster.connect(CassandraUnitUtils.KEYSPACE);
         aggregationRepository = new NamedCassandraAggregationRepository(session, "ID");
         aggregationRepository.start();
     }
+
     @After
     public void tearDown() throws Exception {
         aggregationRepository.stop();
         session.close();
         cluster.close();
     }
+
     @AfterClass
     public static void tearDownClass() throws Exception {
         CassandraUnitUtils.cleanEmbeddedCassandra();
     }
+
     private boolean exists(String key) {
         return session.execute(
                 "select KEY from CAMEL_AGGREGATION where NAME=? and KEY=?", "ID", key)
-                .one()!=null;
+                .one() != null;
     }
+
     @Test
     public void testAdd() {
         // Given
-        String key="Add";
+        String key = "Add";
         assertFalse(exists(key));
         Exchange exchange = new DefaultExchange(camelContext);
         // When
         aggregationRepository.add(camelContext, key, exchange);
         // Then
-        assertTrue(exists(key));        
+        assertTrue(exists(key));
     }
+
     @Test
-    public void testGet_Exists() {
+    public void testGetExists() {
         // Given
-        String key="Get_Exists";
+        String key = "Get_Exists";
         Exchange exchange = new DefaultExchange(camelContext);
         aggregationRepository.add(camelContext, key, exchange);
         assertTrue(exists(key));
         // When
-        Exchange exchange2=aggregationRepository.get(camelContext, key);
+        Exchange exchange2 = aggregationRepository.get(camelContext, key);
         // Then
         assertNotNull(exchange2);
-        assertEquals(exchange.getExchangeId(), exchange2.getExchangeId());        
+        assertEquals(exchange.getExchangeId(), exchange2.getExchangeId());
     }
+
     @Test
-    public void testGet_NotExists() {
+    public void testGetNotExists() {
         // Given
-        String key="Get_NotExists";
+        String key = "Get_NotExists";
         assertFalse(exists(key));
         // When
-        Exchange exchange2=aggregationRepository.get(camelContext, key);
+        Exchange exchange2 = aggregationRepository.get(camelContext, key);
         // Then
         assertNull(exchange2);
     }
+
     @Test
-    public void testRemove_Exists() {
+    public void testRemoveExists() {
         // Given
-        String key="Remove_Exists";
+        String key = "Remove_Exists";
         Exchange exchange = new DefaultExchange(camelContext);
         aggregationRepository.add(camelContext, key, exchange);
         assertTrue(exists(key));
@@ -118,10 +132,11 @@ public class CassandraAggregationRepositoryTest {
         // Then
         assertFalse(exists(key));
     }
+
     @Test
-    public void testRemove_NotExists() {
+    public void testRemoveNotExists() {
         // Given
-        String key="Remove_NotExists";
+        String key = "RemoveNotExists";
         Exchange exchange = new DefaultExchange(camelContext);
         assertFalse(exists(key));
         // When
@@ -129,28 +144,30 @@ public class CassandraAggregationRepositoryTest {
         // Then
         assertFalse(exists(key));
     }
+
     @Test
     public void testGetKeys() {
         // Given
-        String[] keys={"GetKeys1", "GetKeys2"};
-        for(String key: keys) {
+        String[] keys = {"GetKeys1", "GetKeys2"};
+        for (String key : keys) {
             Exchange exchange = new DefaultExchange(camelContext);
             aggregationRepository.add(camelContext, key, exchange);
         }
         // When
-        Set<String> keySet=aggregationRepository.getKeys();
+        Set<String> keySet = aggregationRepository.getKeys();
         // Then
-        for(String key: keys) {
+        for (String key : keys) {
             assertTrue(keySet.contains(key));
         }
     }
+
     @Test
-    public void testConfirm_Exist() {
+    public void testConfirmExist() {
         // Given
-        for(int i=1;i<4;i++) {
-            String key="Confirm_"+i;
+        for (int i = 1; i < 4; i++) {
+            String key = "Confirm_" + i;
             Exchange exchange = new DefaultExchange(camelContext);
-            exchange.setExchangeId("Exchange_"+i);
+            exchange.setExchangeId("Exchange_" + i);
             aggregationRepository.add(camelContext, key, exchange);
             assertTrue(exists(key));
         }
@@ -161,21 +178,22 @@ public class CassandraAggregationRepositoryTest {
         assertFalse(exists("Confirm_2"));
         assertTrue(exists("Confirm_3"));
     }
+
     @Test
-    public void testConfirm_NotExist() {
+    public void testConfirmNotExist() {
         // Given
-        for(int i=1;i<4;i++) {
-            String key="Confirm_"+i;
+        for (int i = 1; i < 4; i++) {
+            String key = "Confirm_" + i;
             Exchange exchange = new DefaultExchange(camelContext);
-            exchange.setExchangeId("Exchange_"+i);
+            exchange.setExchangeId("Exchange_" + i);
             aggregationRepository.add(camelContext, key, exchange);
             assertTrue(exists(key));
         }
         // When
         aggregationRepository.confirm(camelContext, "Exchange_5");
         // Then
-        for(int i=1;i<4;i++) {
-            assertTrue(exists("Confirm_"+i));
+        for (int i = 1; i < 4; i++) {
+            assertTrue(exists("Confirm_" + i));
         }
     }
 

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
index 381c53e..0302663 100644
--- a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationTest.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,35 +14,30 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.processor.aggregate.cassandra;
 
-import org.apache.camel.processor.aggregate.cassandra.CassandraAggregationRepository;
-import org.apache.camel.processor.aggregate.cassandra.NamedCassandraAggregationRepository;
 import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.Session;
-import java.lang.reflect.Method;
 import org.apache.camel.Exchange;
-import org.apache.camel.component.cassandra.CassandraUnitUtils;
-import org.junit.Test;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.cassandra.CassandraUnitUtils;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.processor.aggregate.AggregationStrategy;
 import org.apache.camel.test.junit4.CamelTestSupport;
-import org.apache.camel.utils.cassandra.CassandraUtils;
-import org.cassandraunit.CassandraCQLUnit;
+import org.junit.Test;
+
 /**
  * Unite test for {@link CassandraAggregationRepository}
  */
 public class CassandraAggregationTest extends CamelTestSupport {
     private Cluster cluster;
     private CassandraAggregationRepository aggregationRepository;
-    
+
     @Override
     protected void doPreSetup() throws Exception {
         CassandraUnitUtils.startEmbeddedCassandra();
-        cluster = CassandraUnitUtils.cassandraCluster();        
-        Session rootSession=cluster.connect();
+        cluster = CassandraUnitUtils.cassandraCluster();
+        Session rootSession = cluster.connect();
         CassandraUnitUtils.loadCQLDataSet(rootSession, "AggregationDataSet.cql");
         rootSession.close();
         aggregationRepository = new NamedCassandraAggregationRepository(cluster, CassandraUnitUtils.KEYSPACE, "ID");
@@ -70,27 +66,29 @@ public class CassandraAggregationTest extends CamelTestSupport {
                         }
                         String oldBody = oldExchange.getIn().getBody(String.class);
                         String newBody = newExchange.getIn().getBody(String.class);
-                        oldExchange.getIn().setBody(oldBody+","+newBody);
+                        oldExchange.getIn().setBody(oldBody + "," + newBody);
                         return oldExchange;
                     }
                 };
                 from("direct:input")
                         .aggregate(header("aggregationId"), aggregationStrategy)
-                            .completionSize(3).completionTimeout(3000L)
-                            .aggregationRepository(aggregationRepository)
+                        .completionSize(3).completionTimeout(3000L)
+                        .aggregationRepository(aggregationRepository)
                         .to("mock:output");
             }
         };
     }
+
     private void send(String aggregationId, String body) {
         super.template.sendBodyAndHeader("direct:input", body, "aggregationId", aggregationId);
     }
+
     @Test
     public void testAggregationRoute() throws Exception {
         // Given
         MockEndpoint mockOutput = getMockEndpoint("mock:output");
         mockOutput.expectedMessageCount(2);
-        mockOutput.expectedBodiesReceivedInAnyOrder("A,C,E","B,D");
+        mockOutput.expectedBodiesReceivedInAnyOrder("A,C,E", "B,D");
         // When
         send("1", "A");
         send("2", "B");
@@ -99,6 +97,6 @@ public class CassandraAggregationTest extends CamelTestSupport {
         send("1", "E");
         // Then
         mockOutput.assertIsSatisfied(4000L);
-        
+
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
index 83c2513..89a73b4 100644
--- a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepositoryTest.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -21,26 +22,30 @@ import org.apache.camel.component.cassandra.CassandraUnitUtils;
 import org.cassandraunit.CassandraCQLUnit;
 import org.junit.After;
 import org.junit.AfterClass;
-import org.junit.Test;
-import static org.junit.Assert.*;
 import org.junit.Before;
 import org.junit.BeforeClass;
 import org.junit.Rule;
+import org.junit.Test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
 /**
  * Unit test for {@link CassandraIdempotentRepository}
  */
 public class CassandraIdempotentRepositoryTest {
+    @Rule
+    public CassandraCQLUnit cassandraRule = CassandraUnitUtils.cassandraCQLUnit("IdempotentDataSet.cql");
+
     private Cluster cluster;
     private Session session;
     private CassandraIdempotentRepository<String> idempotentRepository;
-    @Rule
-    public CassandraCQLUnit cassandraRule = CassandraUnitUtils.cassandraCQLUnit("IdempotentDataSet.cql");
-    
+
     @BeforeClass
     public static void setUpClass() throws Exception {
         CassandraUnitUtils.startEmbeddedCassandra();
     }
+
     @Before
     public void setUp() throws Exception {
         cluster = CassandraUnitUtils.cassandraCluster();
@@ -48,82 +53,91 @@ public class CassandraIdempotentRepositoryTest {
         idempotentRepository = new NamedCassandraIdempotentRepository<String>(session, "ID");
         idempotentRepository.start();
     }
+
     @After
     public void tearDown() throws Exception {
         idempotentRepository.stop();
         session.close();
         cluster.close();
     }
+
     @AfterClass
     public static void tearDownClass() throws Exception {
         CassandraUnitUtils.cleanEmbeddedCassandra();
     }
+
     private boolean exists(String key) {
         return session.execute(
-                "select KEY from CAMEL_IDEMPOTENT where NAME=? and KEY=?","ID", key)
-                .one()!=null;
+                "select KEY from CAMEL_IDEMPOTENT where NAME=? and KEY=?", "ID", key)
+                .one() != null;
     }
+
     @Test
-    public void testAdd_NotExists() {
+    public void testAddNotExists() {
         // Given
-        String key="Add_NotExists";
+        String key = "Add_NotExists";
         assertFalse(exists(key));
         // When
-        boolean result=idempotentRepository.add(key);
+        boolean result = idempotentRepository.add(key);
         // Then
         assertTrue(result);
-        assertTrue(exists(key));        
+        assertTrue(exists(key));
     }
+
     @Test
-    public void testAdd_Exists() {
+    public void testAddExists() {
         // Given
-        String key="Add_Exists";
+        String key = "Add_Exists";
         assertTrue(exists(key));
         // When
-        boolean result=idempotentRepository.add(key);
+        boolean result = idempotentRepository.add(key);
         // Then
         assertFalse(result);
-        assertTrue(exists(key));        
+        assertTrue(exists(key));
     }
+
     @Test
-    public void testContains_NotExists() {
+    public void testContainsNotExists() {
         // Given
-        String key="Contains_NotExists";
+        String key = "Contains_NotExists";
         assertFalse(exists(key));
         // When
-        boolean result=idempotentRepository.contains(key);
+        boolean result = idempotentRepository.contains(key);
         // Then
         assertFalse(result);
     }
+
     @Test
-    public void testContains_Exists() {
+    public void testContainsExists() {
         // Given
-        String key="Contains_Exists";
+        String key = "Contains_Exists";
         assertTrue(exists(key));
         // When
-        boolean result=idempotentRepository.contains(key);
+        boolean result = idempotentRepository.contains(key);
         // Then
         assertTrue(result);
     }
+
     @Test
-    public void testRemove_NotExists() {
+    public void testRemoveNotExists() {
         // Given
-        String key="Remove_NotExists";
+        String key = "Remove_NotExists";
         assertFalse(exists(key));
         // When
-        boolean result=idempotentRepository.contains(key);
+        boolean result = idempotentRepository.contains(key);
         // Then
         // assertFalse(result);
     }
+
     @Test
-    public void testRemove_Exists() {
+    public void testRemoveExists() {
         // Given
-        String key="Remove_Exists";
+        String key = "Remove_Exists";
         assertTrue(exists(key));
         // When
-        boolean result=idempotentRepository.remove(key);
+        boolean result = idempotentRepository.remove(key);
         // Then
         assertTrue(result);
     }
-    
+
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
index 7ac6386..1380bf9 100644
--- a/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentTest.java
@@ -1,9 +1,10 @@
-/*
- * Copyright 2014 The Apache Software Foundation.
- *
- * Licensed 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
+/**
+ * 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
  *
@@ -13,28 +14,28 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-
 package org.apache.camel.processor.idempotent.cassandra;
 
 import com.datastax.driver.core.Cluster;
 import com.datastax.driver.core.Session;
-import org.apache.camel.component.cassandra.CassandraUnitUtils;
-import org.junit.Test;
 import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.cassandra.CassandraUnitUtils;
 import org.apache.camel.component.mock.MockEndpoint;
 import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Test;
+
 /**
  * Unite test for {@link CassandraIdempotentRepository}
  */
 public class CassandraIdempotentTest extends CamelTestSupport {
     private Cluster cluster;
     private CassandraIdempotentRepository idempotentRepository;
-    
+
     @Override
     protected void doPreSetup() throws Exception {
         CassandraUnitUtils.startEmbeddedCassandra();
-        cluster = CassandraUnitUtils.cassandraCluster();        
-        Session rootSession=cluster.connect();
+        cluster = CassandraUnitUtils.cassandraCluster();
+        Session rootSession = cluster.connect();
         CassandraUnitUtils.loadCQLDataSet(rootSession, "IdempotentDataSet.cql");
         rootSession.close();
         idempotentRepository = new NamedCassandraIdempotentRepository(cluster, CassandraUnitUtils.KEYSPACE, "ID");
@@ -60,15 +61,17 @@ public class CassandraIdempotentTest extends CamelTestSupport {
             }
         };
     }
+
     private void send(String idempotentId, String body) {
         super.template.sendBodyAndHeader("direct:input", body, "idempotentId", idempotentId);
     }
+
     @Test
     public void testIdempotentRoute() throws Exception {
         // Given
         MockEndpoint mockOutput = getMockEndpoint("mock:output");
         mockOutput.expectedMessageCount(2);
-        mockOutput.expectedBodiesReceivedInAnyOrder("A","B");
+        mockOutput.expectedBodiesReceivedInAnyOrder("A", "B");
         // When
         send("1", "A");
         send("2", "B");
@@ -77,6 +80,6 @@ public class CassandraIdempotentTest extends CamelTestSupport {
         send("1", "A");
         // Then
         mockOutput.assertIsSatisfied();
-        
+
     }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/e0b14cd4/components/camel-cassandraql/src/test/resources/log4j.properties
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/resources/log4j.properties b/components/camel-cassandraql/src/test/resources/log4j.properties
index 3476f4b..792dd13 100644
--- a/components/camel-cassandraql/src/test/resources/log4j.properties
+++ b/components/camel-cassandraql/src/test/resources/log4j.properties
@@ -1,17 +1,39 @@
+## ---------------------------------------------------------------------------
+## 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.
+## ---------------------------------------------------------------------------
+
 #
-# The logging properties used
+# The logging properties used during tests
 #
-log4j.rootLogger=INFO, out
+log4j.rootLogger=INFO, file
 
-# uncomment the following line to turn on Camel debugging
+# uncomment this to turn on debug of camel
 #log4j.logger.org.apache.camel=DEBUG
-log4j.logger.org.apache.camel.processor.idempotent.cassandra=INFO
-log4j.logger.org.apache.camel.processor.aggregate.cassandra=INFO
-log4j.logger.org.apache.cassandra=WARN
-log4j.logger.com.datastax=WARN
+#log4j.logger.org.apache.camel.component.cassandra=TRACE
+#log4j.logger.org.apache.cassandra=DEBUG
+
 # CONSOLE appender not used by default
-log4j.appender.out=org.apache.log4j.ConsoleAppender
-log4j.appender.out.layout=org.apache.log4j.PatternLayout
-log4j.appender.out.layout.ConversionPattern=[%30.30t] %-30.30c{1} %-5p %m%n
-#log4j.appender.out.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.stdout=org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+
+# File appender
+log4j.appender.file=org.apache.log4j.FileAppender
+log4j.appender.file.layout=org.apache.log4j.PatternLayout
+log4j.appender.file.layout.ConversionPattern=%d [%-15.15t] %-5p %-30.30c{1} - %m%n
+log4j.appender.file.file=target/camel-cassandraql-test.log
+log4j.appender.file.append=true
 


[5/5] camel git commit: CAMEL-2939: Added to kit

Posted by da...@apache.org.
CAMEL-2939: Added to kit


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/bf4ddfe8
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/bf4ddfe8
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/bf4ddfe8

Branch: refs/heads/master
Commit: bf4ddfe8bb689f726089ef4db894f796fc9eaf85
Parents: e0b14cd
Author: Claus Ibsen <da...@apache.org>
Authored: Tue Dec 23 12:22:39 2014 +0100
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Dec 23 12:22:39 2014 +0100

----------------------------------------------------------------------
 apache-camel/pom.xml                            |  4 +++
 .../src/main/descriptors/common-bin.xml         |  1 +
 components/camel-cassandraql/pom.xml            | 36 +++++++++++---------
 parent/pom.xml                                  |  9 +++++
 4 files changed, 34 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/bf4ddfe8/apache-camel/pom.xml
----------------------------------------------------------------------
diff --git a/apache-camel/pom.xml b/apache-camel/pom.xml
index c0ca486..0e4dcfb 100644
--- a/apache-camel/pom.xml
+++ b/apache-camel/pom.xml
@@ -125,6 +125,10 @@
     </dependency>
     <dependency>
       <groupId>org.apache.camel</groupId>
+      <artifactId>camel-cassandraql</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
       <artifactId>camel-castor</artifactId>
     </dependency>
     <dependency>

http://git-wip-us.apache.org/repos/asf/camel/blob/bf4ddfe8/apache-camel/src/main/descriptors/common-bin.xml
----------------------------------------------------------------------
diff --git a/apache-camel/src/main/descriptors/common-bin.xml b/apache-camel/src/main/descriptors/common-bin.xml
index d5d2e1b..ee5bcbf 100644
--- a/apache-camel/src/main/descriptors/common-bin.xml
+++ b/apache-camel/src/main/descriptors/common-bin.xml
@@ -42,6 +42,7 @@
         <include>org.apache.camel:camel-box</include>
         <include>org.apache.camel:camel-blueprint</include>
         <include>org.apache.camel:camel-cache</include>
+        <include>org.apache.camel:camel-cassandraql</include>
         <include>org.apache.camel:camel-castor</include>
         <include>org.apache.camel:camel-cdi</include>
         <include>org.apache.camel:camel-chunk</include>

http://git-wip-us.apache.org/repos/asf/camel/blob/bf4ddfe8/components/camel-cassandraql/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/pom.xml b/components/camel-cassandraql/pom.xml
index 88d6e84..de6cd4e 100644
--- a/components/camel-cassandraql/pom.xml
+++ b/components/camel-cassandraql/pom.xml
@@ -17,17 +17,28 @@
   
   <properties>
     <camel.osgi.export.pkg>
-      org.apache.camel.component.cassandraql.*
+      org.apache.camel.component.cassandra.*,
+      org.apache.camel.processor.aggregate.cassandra,
+      org.apache.camel.processor.idempotent.cassandra,
+      org.apache.camel.utils.cassandra
     </camel.osgi.export.pkg>
     <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=cql</camel.osgi.export.service>
   </properties>
 
   <dependencies>
+
     <dependency>
       <groupId>org.apache.camel</groupId>
       <artifactId>camel-core</artifactId>
     </dependency>
 
+    <!-- cassandra -->
+    <dependency>
+      <groupId>com.datastax.cassandra</groupId>
+      <artifactId>cassandra-driver-core</artifactId>
+      <version>${cassandra-driver-version}</version>
+    </dependency>
+
     <!-- logging -->
     <dependency>
       <groupId>org.slf4j</groupId>
@@ -51,21 +62,9 @@
       <scope>test</scope>
     </dependency>
     <dependency>
-      <groupId>org.mockito</groupId>
-      <artifactId>mockito-core</artifactId>
-      <scope>test</scope>
-    </dependency>
-    
-    <!-- cassandra -->
-    <dependency>
-      <groupId>com.datastax.cassandra</groupId>
-      <artifactId>cassandra-driver-core</artifactId>
-      <version>2.1.2</version>
-    </dependency>
-    <dependency>
       <groupId>org.cassandraunit</groupId>
       <artifactId>cassandra-unit</artifactId>
-      <version>2.0.2.2</version>
+      <version>${cassandra-unit-version}</version>
       <scope>test</scope>
       <exclusions>
         <exclusion>
@@ -77,13 +76,18 @@
     <dependency>
       <groupId>org.apache.cassandra</groupId>
       <artifactId>cassandra-all</artifactId>
-      <version>2.1.2</version>
+      <version>${cassandra-version}</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
       <scope>test</scope>
     </dependency>
     <dependency>
       <groupId>org.yaml</groupId>
       <artifactId>snakeyaml</artifactId>
-      <version>1.14</version>
+      <version>${snakeyaml-version}</version>
       <scope>test</scope>
     </dependency>
   </dependencies>

http://git-wip-us.apache.org/repos/asf/camel/blob/bf4ddfe8/parent/pom.xml
----------------------------------------------------------------------
diff --git a/parent/pom.xml b/parent/pom.xml
index 1ea6515..23e02b2 100644
--- a/parent/pom.xml
+++ b/parent/pom.xml
@@ -75,6 +75,9 @@
     <build-helper-maven-plugin-version>1.8</build-helper-maven-plugin-version>
     <c3p0-version>0.9.1.2</c3p0-version>
     <camel-test-spring-artifactId>camel-test-spring</camel-test-spring-artifactId>
+    <cassandra-driver-version>2.1.2</cassandra-driver-version>
+    <cassandra-version>2.1.2</cassandra-version>
+    <cassandra-unit-version>2.0.2.2</cassandra-unit-version>
     <castor-bundle-version>1.3.2_2</castor-bundle-version>
     <cdi-api-version>1.2</cdi-api-version>
     <cglib-bundle-version>2.1_3_7</cglib-bundle-version>
@@ -400,6 +403,7 @@
     <slf4j-version>1.7.7</slf4j-version>
     <smack-bundle-version>3.2.1_1</smack-bundle-version>
     <smack-version>3.2.1</smack-version>
+    <snakeyaml-version>1.14</snakeyaml-version>
     <snappy-version>1.1.0.1</snappy-version>
     <snmp4j-version>2.3.0_1</snmp4j-version>
     <solr-bundle-version>4.9.0_1</solr-bundle-version>
@@ -645,6 +649,11 @@
       </dependency>
       <dependency>
         <groupId>org.apache.camel</groupId>
+        <artifactId>camel-cassandraql</artifactId>
+        <version>${project.version}</version>
+      </dependency>
+      <dependency>
+        <groupId>org.apache.camel</groupId>
         <artifactId>camel-castor</artifactId>
         <version>${project.version}</version>
       </dependency>


[2/5] camel git commit: CAMEL-2939: Camel Cassandra 3 CQL3 first edition

Posted by da...@apache.org.
CAMEL-2939: Camel Cassandra 3 CQL3 first edition

Handle Cassandra authentication

Improve ResultSet to message body conversion

Added ReadMe.md

Update ReadMe.md

Rename package

Upgrade dependencies

Implement IdempotentRepository using Cassandra

Implement AggregationRepository using Cassandra

Renamed CassandraQl into Cassandra

Refactored CQL generation

Removed PKHelper in favour of generateInsert, generateDelete... methods


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/7be546af
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/7be546af
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/7be546af

Branch: refs/heads/master
Commit: 7be546af5c889b0fd7afbfdc2ef52c4a60d9879c
Parents: dade396
Author: Gerald Quintana <ge...@gmail.com>
Authored: Sat Sep 20 21:08:01 2014 +0200
Committer: Claus Ibsen <da...@apache.org>
Committed: Tue Dec 23 11:21:05 2014 +0100

----------------------------------------------------------------------
 components/camel-cassandraql/ReadMe.md          |  43 ++
 components/camel-cassandraql/pom.xml            |  90 +++
 .../component/cassandra/CassandraComponent.java | 131 ++++
 .../component/cassandra/CassandraConstants.java |  28 +
 .../component/cassandra/CassandraConsumer.java  |  55 ++
 .../component/cassandra/CassandraEndpoint.java  | 138 ++++
 .../component/cassandra/CassandraProducer.java  |  83 ++
 .../ResultSetConversionStrategies.java          | 103 +++
 .../cassandra/ResultSetConversionStrategy.java  |  26 +
 .../CassandraAggregationException.java          |  31 +
 .../CassandraAggregationRepository.java         | 345 +++++++++
 .../cassandra/CassandraCamelCodec.java          | 111 +++
 .../NamedCassandraAggregationRepository.java    |  58 ++
 .../CassandraIdempotentRepository.java          | 212 ++++++
 .../NamedCassandraIdempotentRepository.java     |  59 ++
 .../utils/cassandra/CassandraSessionHolder.java |  82 ++
 .../camel/utils/cassandra/CassandraUtils.java   | 163 ++++
 .../services/org/apache/camel/component/cql     |   1 +
 .../CassandraComponentBeanRefTest.java          |  77 ++
 .../CassandraComponentClusterBuilderTest.java   |  74 ++
 .../CassandraComponentConsumerTest.java         |  73 ++
 .../CassandraComponentProducerTest.java         |  87 +++
 .../component/cassandra/CassandraUnitUtils.java |  77 ++
 .../ResultSetConversionStrategiesTest.java      |  73 ++
 .../CassandraAggregationRepositoryTest.java     | 182 +++++
 .../cassandra/CassandraAggregationTest.java     | 104 +++
 .../CassandraIdempotentRepositoryTest.java      | 129 ++++
 .../cassandra/CassandraIdempotentTest.java      |  82 ++
 .../src/test/resources/AggregationDataSet.cql   |   7 +
 .../src/test/resources/BasicDataSet.cql         |   9 +
 .../src/test/resources/IdempotentDataSet.cql    |  11 +
 .../src/test/resources/camel-cassandra.yaml     | 762 +++++++++++++++++++
 .../src/test/resources/log4j.properties         |  17 +
 components/pom.xml                              |   1 +
 34 files changed, 3524 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/ReadMe.md
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/ReadMe.md b/components/camel-cassandraql/ReadMe.md
new file mode 100644
index 0000000..f149384
--- /dev/null
+++ b/components/camel-cassandraql/ReadMe.md
@@ -0,0 +1,43 @@
+# Camel Cassandra Component
+
+This component aims at integrating Cassandra 2.0+ using the CQL3 API (not the Thrift API).
+It's based on [Cassandra Java Driver](https://github.com/datastax/java-driver) provided by DataStax.
+
+## URI
+
+### Examples
+
+| URI                              | Description
+|----------------------------------|----------------------------------
+|`cql:localhost/keyspace`          | single host, default port, usual for testing
+|`cql:host1,host2/keyspace`        | multi host, default port
+|`cql:host1:host2:9042/keyspace`   |
+|`cql:host1:host2`                 | default port and keyspace
+|`cql:bean:sessionRef`             | provided Session reference
+|`cql:bean:clusterRef/keyspace`    | provided Cluster reference
+
+### Options
+
+| Option                           | Description
+|----------------------------------|----------------------------------
+|`clusterName`                     | cluster name
+|`username and password`           | session authentication
+|`cql`                             | CQL query
+|`consistencyLevel`                | `ANY`, `ONE`, `TWO`, `QUORUM`, `LOCAL_QUORUM`...
+|`resultSetConversionStrategy`     | how is ResultSet converted transformed into message body `ALL`, `ONE`, `LIMIT_10`, `LIMIT_100`...
+
+## Message
+
+### Incoming
+
+Headers:
+* `CamelCqlQuery` (optional, String): CQL query
+
+Body
+* (`Object[]` or `Collection<Object>`): CQL query parameters to be bound
+
+### Outgoing
+
+Body
+* `List<Row>` if resultSetConversionStrategy is ALL or LIMIT_10
+* `Row` if resultSetConversionStrategy is ONE

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/pom.xml b/components/camel-cassandraql/pom.xml
new file mode 100644
index 0000000..88d6e84
--- /dev/null
+++ b/components/camel-cassandraql/pom.xml
@@ -0,0 +1,90 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.camel</groupId>
+    <artifactId>components</artifactId>
+    <version>2.15-SNAPSHOT</version>
+  </parent>
+  
+  <artifactId>camel-cassandraql</artifactId>
+  <packaging>bundle</packaging>
+
+  <name>Camel :: Cassandra CQL</name>
+  <description>Cassandra CQL3 support</description>
+  
+  <properties>
+    <camel.osgi.export.pkg>
+      org.apache.camel.component.cassandraql.*
+    </camel.osgi.export.pkg>
+    <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=cql</camel.osgi.export.service>
+  </properties>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-core</artifactId>
+    </dependency>
+
+    <!-- logging -->
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-api</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.slf4j</groupId>
+      <artifactId>slf4j-log4j12</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>log4j</groupId>
+      <artifactId>log4j</artifactId>
+      <scope>test</scope>
+    </dependency>
+
+    <!-- testing -->
+    <dependency>
+      <groupId>org.apache.camel</groupId>
+      <artifactId>camel-test</artifactId>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.mockito</groupId>
+      <artifactId>mockito-core</artifactId>
+      <scope>test</scope>
+    </dependency>
+    
+    <!-- cassandra -->
+    <dependency>
+      <groupId>com.datastax.cassandra</groupId>
+      <artifactId>cassandra-driver-core</artifactId>
+      <version>2.1.2</version>
+    </dependency>
+    <dependency>
+      <groupId>org.cassandraunit</groupId>
+      <artifactId>cassandra-unit</artifactId>
+      <version>2.0.2.2</version>
+      <scope>test</scope>
+      <exclusions>
+        <exclusion>
+          <artifactId>org.apache.cassandra</artifactId>
+          <groupId>cassandra-all</groupId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.cassandra</groupId>
+      <artifactId>cassandra-all</artifactId>
+      <version>2.1.2</version>
+      <scope>test</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.yaml</groupId>
+      <artifactId>snakeyaml</artifactId>
+      <version>1.14</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+</project>

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraComponent.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraComponent.java
new file mode 100644
index 0000000..761a5d7
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraComponent.java
@@ -0,0 +1,131 @@
+package org.apache.camel.component.cassandra;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+import org.apache.camel.util.EndpointHelper;
+
+/**
+ * Represents the component that manages {@link CassandraEndpoint}. This
+ * component is based on Datastax Java Driver for Cassandra.
+ *
+ * URI examples:
+ * <ul>
+ * <li>cql:localhost/keyspace</li>
+ * <li>cql:host1,host2/keyspace</li>
+ * <li>cql:host1:host2:9042/keyspace</li>
+ * <li>cql:host1:host2</li>
+ * <li>cql:bean:sessionRef</li>
+ * <li>cql:bean:clusterRef/keyspace</li>
+ * </ul>
+ */
+public class CassandraComponent extends DefaultComponent {
+    /**
+     * Regular expression for parsing host name
+     */
+    private static final String HOST_PATTERN = "[\\w.\\-]+";
+    /**
+     * Regular expression for parsing several hosts name
+     */
+    private static final String HOSTS_PATTERN = HOST_PATTERN + "(?:," + HOST_PATTERN + ")*";
+    /**
+     * Regular expression for parsing port
+     */
+    private static final String PORT_PATTERN = "\\d+";
+    /**
+     * Regular expression for parsing keyspace
+     */
+    private static final String KEYSPACE_PATTERN = "\\w+";
+    /**
+     * Regular expression for parsing URI host1,host2:9042/keyspace
+     */
+    private static final Pattern HOSTS_PORT_KEYSPACE_PATTERN = Pattern.compile(
+            "^(" + HOSTS_PATTERN + ")?" // Hosts
+            + "(?::(" + PORT_PATTERN + "))?" // Port
+            + "(?:/(" + KEYSPACE_PATTERN + "))?$"); // Keyspace
+    /**
+     * Regular expression for parsing URI bean:sessionRef
+     */
+    private static final Pattern BEAN_REF_PATTERN = Pattern.compile(
+            "^bean:([\\w.\\-]+)(?:/(" + KEYSPACE_PATTERN + "))?$"); // Keyspace
+
+    @Override
+    protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
+        Cluster cluster;
+        Session session;
+        String keyspace;
+        // Try URI of type cql:bean:session or 
+        Matcher beanRefMatcher = BEAN_REF_PATTERN.matcher(remaining);
+        if (beanRefMatcher.matches()) {
+            String beanRefName = beanRefMatcher.group(1);
+            keyspace = beanRefMatcher.group(2);
+            Object bean = EndpointHelper.resolveParameter(getCamelContext(), "#"+beanRefName, Object.class);
+            if (bean instanceof Session) {
+                session = (Session) bean;
+                cluster = session.getCluster();
+                keyspace = session.getLoggedKeyspace();
+            } else if (bean instanceof Cluster) {
+                cluster = (Cluster) bean;
+                session = null;
+            } else {
+                throw new IllegalArgumentException("CQL Bean type should be of type Session or Cluster but was " + bean);
+            }
+        } else {
+            // Try URI of type cql:host1,host2:9042/keyspace
+            cluster = clusterBuilder(remaining, parameters).build();
+            session = null;
+            keyspace = getAndRemoveParameter(parameters, "keyspace", String.class);
+        }
+
+        Endpoint endpoint = new CassandraEndpoint(uri, this, cluster, session, keyspace);
+        setProperties(endpoint, parameters);
+        return endpoint;
+    }
+    /**
+     * Parse URI of the form cql://host1,host2:9042/keyspace and create a
+     * {@link Cluster.Builder}
+     */
+    protected Cluster.Builder clusterBuilder(String remaining, Map<String, Object> parameters) throws NumberFormatException {
+        Cluster.Builder clusterBuilder = Cluster.builder();
+        Matcher matcher = HOSTS_PORT_KEYSPACE_PATTERN.matcher(remaining);
+        if (matcher.matches()) {
+            // Parse hosts
+            String hostsGroup = matcher.group(1);
+            if (hostsGroup != null && !hostsGroup.isEmpty()) {
+                String[] hosts = hostsGroup.split(",");
+                clusterBuilder = clusterBuilder.addContactPoints(hosts);
+            }
+            // Parse port
+            String portGroup = matcher.group(2);
+            if (portGroup != null) {
+                Integer port = Integer.valueOf(portGroup);
+                clusterBuilder = clusterBuilder.withPort(port);
+            }
+            // Parse keyspace
+            String keyspaceGroup = matcher.group(3);
+            if (keyspaceGroup != null && !keyspaceGroup.isEmpty()) {
+                String keyspace = keyspaceGroup;
+                parameters.put("keyspace", keyspace);
+            }
+        } else {
+            throw new IllegalArgumentException("Invalid CQL URI");
+        }
+        // Cluster name parameter
+        String clusterName = getAndRemoveParameter(parameters, "clusterName", String.class);
+        if (clusterName != null) {
+            clusterBuilder = clusterBuilder.withClusterName(clusterName);
+        }
+        // Username and password
+        String username = getAndRemoveOrResolveReferenceParameter(parameters, "username", String.class);
+        String password = getAndRemoveOrResolveReferenceParameter(parameters, "password", String.class);
+        if (username != null && !username.isEmpty() && password!=null) {
+            clusterBuilder.withCredentials(username, password);
+        }
+        return clusterBuilder;
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConstants.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConstants.java
new file mode 100644
index 0000000..1c7722f
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConstants.java
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.cassandra;
+
+/**
+ * Cassandra QL Endpoint constants
+ */
+public class CassandraConstants {
+    /**
+     * In Message header: CQL Query
+     */
+    public static final String CQL_QUERY = "CamelCqlQuery";
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConsumer.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConsumer.java
new file mode 100644
index 0000000..20b0812
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraConsumer.java
@@ -0,0 +1,55 @@
+package org.apache.camel.component.cassandra;
+
+import com.datastax.driver.core.PreparedStatement;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Session;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.impl.ScheduledPollConsumer;
+
+/**
+ * Cassandra 2 CQL3 consumer.
+ */
+public class CassandraConsumer extends ScheduledPollConsumer {
+
+    /**
+     * Prepared statement used for polling
+     */
+    private PreparedStatement preparedStatement;
+
+    public CassandraConsumer(CassandraEndpoint endpoint, Processor processor) {
+        super(endpoint, processor);
+    }
+
+    @Override
+    public CassandraEndpoint getEndpoint() {
+        return (CassandraEndpoint) super.getEndpoint();
+    }
+
+    @Override
+    protected int poll() throws Exception {
+        // Execute CQL Query
+        Session session = getEndpoint().getSession();
+        if (preparedStatement == null) {
+            preparedStatement = getEndpoint().prepareStatement();
+        }
+        ResultSet resultSet = session.execute(preparedStatement.bind());
+        
+        // Create message from ResultSet
+        Exchange exchange = getEndpoint().createExchange();
+        Message message = exchange.getIn();
+        getEndpoint().fillMessage(resultSet, message);
+
+        try {
+            // send message to next processor in the route
+            getProcessor().process(exchange);
+            return 1; // number of messages polled
+        } finally {
+            // log exception if an exception occurred and was not handled
+            if (exchange.getException() != null) {
+                getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
+            }
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraEndpoint.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraEndpoint.java
new file mode 100644
index 0000000..c7f7b11
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraEndpoint.java
@@ -0,0 +1,138 @@
+package org.apache.camel.component.cassandra;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ConsistencyLevel;
+import com.datastax.driver.core.PreparedStatement;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Session;
+import org.apache.camel.Consumer;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.camel.spi.UriParam;
+import org.apache.camel.utils.cassandra.CassandraSessionHolder;
+
+/**
+ * Cassandra 2 CQL3 endpoint
+ */
+public class CassandraEndpoint extends DefaultEndpoint {
+    /**
+     * Session holder
+     */
+    private CassandraSessionHolder sessionHolder;
+    /**
+     * CQL query
+     */
+    private String cql;
+    /**
+     * Consistency level: ONE, TWO, QUORUM, LOCAL_QUORUM, ALL...
+     */
+    @UriParam
+    private ConsistencyLevel consistencyLevel;
+    /**
+     * How many rows should be retrieved in message body
+     */
+    private ResultSetConversionStrategy resultSetConversionStrategy = ResultSetConversionStrategies.all();
+    /**
+     * Cassandra URI
+     *
+     * @param uri
+     * @param component Parent component
+     * @param cluster Cluster (required)
+     * @param session Session (optional)
+     * @param keyspace Keyspace (optional)
+     */
+    public CassandraEndpoint(String uri, CassandraComponent component, Cluster cluster, Session session, String keyspace) {
+        super(uri, component);
+        if (session == null) {
+            sessionHolder = new CassandraSessionHolder(cluster, keyspace);
+        } else {
+            sessionHolder = new CassandraSessionHolder(session);
+        }
+    }
+
+    @Override
+    protected void doStart() throws Exception {
+        super.doStart();
+        sessionHolder.start();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        sessionHolder.stop();
+        super.doStop();
+    }
+
+    public Producer createProducer() throws Exception {
+        return new CassandraProducer(this);
+    }
+
+    public Consumer createConsumer(Processor processor) throws Exception {
+        return new CassandraConsumer(this, processor);
+    }
+
+    public boolean isSingleton() {
+        return true;
+    }
+
+    public Session getSession() {
+        return sessionHolder.getSession();
+    }
+
+    public String getCql() {
+        return cql;
+    }
+
+    public void setCql(String cql) {
+        this.cql = cql;
+    }
+
+    public String getKeyspace() {
+        return sessionHolder.getKeyspace();
+    }
+
+    public ConsistencyLevel getConsistencyLevel() {
+        return consistencyLevel;
+    }
+
+    public void setConsistencyLevel(ConsistencyLevel consistencyLevel) {
+        this.consistencyLevel = consistencyLevel;
+    }
+
+    public ResultSetConversionStrategy getResultSetConversionStrategy() {
+        return resultSetConversionStrategy;
+    }
+
+    public void setResultSetConversionStrategy(ResultSetConversionStrategy resultSetConversionStrategy) {
+        this.resultSetConversionStrategy = resultSetConversionStrategy;
+    }
+
+    public void setResultSetConversionStrategy(String converter) {
+        this.resultSetConversionStrategy = ResultSetConversionStrategies.fromName(converter);
+    }
+
+    /**
+     * Create and configure a Prepared CQL statement
+     */
+    protected PreparedStatement prepareStatement(String cql) {
+        PreparedStatement preparedStatement = getSession().prepare(cql);
+        if (consistencyLevel != null) {
+            preparedStatement.setConsistencyLevel(consistencyLevel);
+        }
+        return preparedStatement;
+    }
+    /**
+     * Create and configure a Prepared CQL statement
+     */
+    protected PreparedStatement prepareStatement() {
+        return prepareStatement(cql);
+    }
+    /**
+     * Copy ResultSet into Message.
+     */
+    protected void fillMessage(ResultSet resultSet, Message message) {
+        message.setBody(resultSetConversionStrategy.getBody(resultSet));
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraProducer.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraProducer.java
new file mode 100644
index 0000000..ac429e0
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/CassandraProducer.java
@@ -0,0 +1,83 @@
+package org.apache.camel.component.cassandra;
+
+import com.datastax.driver.core.ConsistencyLevel;
+import com.datastax.driver.core.PreparedStatement;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Session;
+import java.util.Collection;
+import org.apache.camel.Exchange;
+import org.apache.camel.Message;
+import org.apache.camel.impl.DefaultProducer;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Cassandra 2 CQL3 producer.
+ * <dl>
+ *  <dt>In Message</dt>
+ *  <dd>Bound parameters: Collection of Objects, Array of Objects, Simple Object<dd>
+ *  <dt>Out Message</dt>
+ *  <dd>List of all Rows<dd>
+ * <dl>
+ */
+public class CassandraProducer extends DefaultProducer {
+
+    private static final Logger LOG = LoggerFactory.getLogger(CassandraProducer.class);
+    private PreparedStatement preparedStatement;
+    public CassandraProducer(CassandraEndpoint endpoint) {
+        super(endpoint);
+    }
+
+    @Override
+    public CassandraEndpoint getEndpoint() {
+        return (CassandraEndpoint) super.getEndpoint();
+    }
+
+    private Object[] getCqlParams(Message message) {
+        Object cqlParamsObj = message.getBody(Object.class);
+        Object[] cqlParams;
+        final Class<Object[]> objectArrayClazz = Object[].class;
+        if (objectArrayClazz.isInstance(cqlParamsObj)) {
+            cqlParams = objectArrayClazz.cast(cqlParamsObj);
+        } else if (cqlParamsObj instanceof Collection) {
+            final Collection cqlParamsColl = (Collection) cqlParamsObj;
+            cqlParams = cqlParamsColl.toArray();
+        } else {
+            cqlParams = new Object[]{cqlParamsObj};
+        }
+        return cqlParams;
+    }
+    /**
+     * Execute CQL query using incoming message body has statement parameters.
+     */
+    private ResultSet execute(Message message) {
+        String messageCql = message.getHeader(CassandraConstants.CQL_QUERY, String.class);
+        Object[] cqlParams = getCqlParams(message);
+        
+        ResultSet resultSet;  
+        PreparedStatement lPreparedStatement;
+        if (messageCql == null || messageCql.isEmpty()) {
+            // URI CQL
+            if (preparedStatement == null) {
+                this.preparedStatement = getEndpoint().prepareStatement();
+            }
+            lPreparedStatement = this.preparedStatement;
+        } else {
+            // Message CQL
+            lPreparedStatement = getEndpoint().prepareStatement(messageCql);
+        }
+        Session session = getEndpoint().getSession();
+        if (cqlParams == null) {
+            resultSet = session.execute(lPreparedStatement.bind());
+        } else {
+            resultSet = session.execute(lPreparedStatement.bind(cqlParams));
+        }            
+        return resultSet;
+    }
+
+    public void process(Exchange exchange) throws Exception {
+        ResultSet resultSet = execute(exchange.getIn());
+        getEndpoint().fillMessage(resultSet, exchange.getOut());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java
new file mode 100644
index 0000000..51ed9c4
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategies.java
@@ -0,0 +1,103 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.cassandra;
+
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+/**
+ * Implementations of {@link ResultSetConversionStrategy}
+ */
+public class ResultSetConversionStrategies {
+    private static final ResultSetConversionStrategy ALL = new ResultSetConversionStrategy() {
+        @Override
+        public Object getBody(ResultSet resultSet) {
+            return resultSet.all();
+        }
+    };
+    /**
+     * Retrieve all rows.
+     * Message body contains a big list of {@link Row}s
+     */
+    public static ResultSetConversionStrategy all() {
+        return ALL;
+    }
+    private static final ResultSetConversionStrategy ONE = new ResultSetConversionStrategy() {
+        @Override
+        public Object getBody(ResultSet resultSet) {
+            return resultSet.one();
+        }
+    };
+    /**
+     * Retrieve a single row.
+     * Message body contains a single {@link Row}
+     */
+    public static ResultSetConversionStrategy one() {
+        return ONE;
+    }
+    private static class LimitResultSetConversionStrategy implements ResultSetConversionStrategy {
+        private final int rowMax;
+        public LimitResultSetConversionStrategy(int rowMax) {
+            this.rowMax = rowMax;
+        }
+
+        @Override
+        public Object getBody(ResultSet resultSet) {
+            List<Row> rows = new ArrayList<Row>(rowMax);
+            int rowCount = 0;
+            Iterator<Row> rowIter = resultSet.iterator();
+            while(rowIter.hasNext() && rowCount<rowMax) {
+                rows.add(rowIter.next());
+                rowCount++;
+            }
+            return rows;
+        }        
+    }
+    /**
+     * Retrieve a limited list of rows.
+     * Message body contains a list of {@link Row} containing at most rowMax rows.
+     */
+    public static ResultSetConversionStrategy limit(int rowMax) {
+        return new LimitResultSetConversionStrategy(rowMax);
+    }
+    private static final Pattern LIMIT_NAME_PATTERN=Pattern.compile("^LIMIT_(\\d+)$");
+    /**
+     * Get {@link ResultSetConversionStrategy} from String
+     */
+    public static ResultSetConversionStrategy fromName(String name) {
+        if (name == null) {
+            return null;
+        }
+        if (name.equals("ALL")) {
+            return ResultSetConversionStrategies.all();
+        }
+        if (name.equals("ONE")) {
+            return ResultSetConversionStrategies.one();
+        }
+        Matcher matcher = LIMIT_NAME_PATTERN.matcher(name);
+        if (matcher.matches()) {
+            int limit = Integer.parseInt(matcher.group(1));
+            return limit(limit);
+        }
+        throw new IllegalArgumentException("Unknown conversion strategy "+name);
+    }
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategy.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategy.java b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategy.java
new file mode 100644
index 0000000..5874d5a
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/component/cassandra/ResultSetConversionStrategy.java
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.cassandra;
+
+import com.datastax.driver.core.ResultSet;
+
+/**
+ * Strategy to convert {@link ResultSet} into message body
+ */
+public interface ResultSetConversionStrategy {
+    Object getBody(ResultSet resultSet);
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationException.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationException.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationException.java
new file mode 100644
index 0000000..cfc0049
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationException.java
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.processor.aggregate.cassandra;
+
+import org.apache.camel.CamelExecutionException;
+import org.apache.camel.Exchange;
+
+/**
+ * Error occurred in Cassandra Aggregation repository
+ */
+public class CassandraAggregationException extends CamelExecutionException{
+
+    public CassandraAggregationException(String message, Exchange exchange, Throwable cause) {
+        super(message, exchange, cause);
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepository.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepository.java
new file mode 100644
index 0000000..db900ef
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraAggregationRepository.java
@@ -0,0 +1,345 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.processor.aggregate.cassandra;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ConsistencyLevel;
+import com.datastax.driver.core.PreparedStatement;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import org.apache.camel.CamelContext;
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.AggregationRepository;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.utils.cassandra.CassandraSessionHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.apache.camel.utils.cassandra.CassandraUtils.*;
+
+/**
+ * Implementation of {@link AggregationRepository} using Cassandra table to store
+ * exchanges.
+ * Advice: use LeveledCompaction for this table and tune read/write consistency levels.
+ * Warning: Cassandra is not the best tool for queuing use cases
+ * @see http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets
+ */
+public abstract class CassandraAggregationRepository extends ServiceSupport implements AggregationRepository {
+    /**
+     * Logger
+     */
+    private static final Logger LOGGER = LoggerFactory.getLogger(CassandraAggregationRepository.class);
+    /**
+     * Session holder
+     */
+    private CassandraSessionHolder sessionHolder;
+    /**
+     * Table name
+     */
+    private String table = "CAMEL_AGGREGATION";
+    /**
+     * Exchange Id column name
+     */
+    private String exchangeIdColumn="EXCHANGE_ID";
+    /**
+     * Exchange column name
+     */
+    private String exchangeColumn="EXCHANGE";
+    /**
+     * Primary key columns
+     */
+    private String[] pkColumns;
+    /**
+     * Exchange marshaller/unmarshaller
+     */
+    private final CassandraCamelCodec exchangeCodec = new CassandraCamelCodec();
+    /**
+     * Time to live in seconds used for inserts
+     */
+    private Integer ttl;
+    /**
+     * Writeconsistency level
+     */
+    private ConsistencyLevel writeConsistencyLevel;
+    /**
+     * Read consistency level
+     */
+    private ConsistencyLevel readConsistencyLevel;
+    
+    private PreparedStatement insertStatement;
+    private PreparedStatement selectStatement;
+    private PreparedStatement deleteStatement;
+    /**
+     * Prepared statement used to get keys and exchange ids
+     */
+    private PreparedStatement selectKeyIdStatement;
+    /**
+     * Prepared statement used to delete with key and exchange id
+     */
+    private PreparedStatement deleteIfIdStatement;
+
+    public CassandraAggregationRepository() {
+    }
+
+    public CassandraAggregationRepository(Session session) {
+        this.sessionHolder = new CassandraSessionHolder(session);
+    }
+    public CassandraAggregationRepository(Cluster cluster, String keyspace) {
+        this.sessionHolder = new CassandraSessionHolder(cluster, keyspace);
+    }
+    /**
+     * Get fixed primary key values.
+     */
+    protected abstract Object[] getPKValues();
+    /**
+     * Generate primary key values: fixed + aggregation key.
+     */
+    protected Object[] getPKValues(String key) {
+        return append(getPKValues(), key);
+    }
+    /**
+     * Get aggregation key colum name.
+     */
+    private String getKeyColumn() {
+        return pkColumns[pkColumns.length-1];
+    }
+    private String[] getAllColumns() {
+        return append(pkColumns, exchangeIdColumn, exchangeColumn);
+    }
+    //--------------------------------------------------------------------------
+    // Service support
+    
+    @Override
+    protected void doStart() throws Exception {
+        sessionHolder.start();
+        initInsertStatement();
+        initSelectStatement();
+        initDeleteStatement();
+        initSelectKeyIdStatement();
+        initDeleteIfIdStatement();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        sessionHolder.stop();
+    }
+
+    // -------------------------------------------------------------------------
+    // Add exchange to repository
+
+    private void initInsertStatement() {
+        String cql = generateInsert(table, 
+                getAllColumns(), 
+                false, ttl).toString();
+        LOGGER.debug("Generated Insert {}", cql);
+        insertStatement = applyConsistencyLevel(getSession().prepare(cql), writeConsistencyLevel);
+    }
+    /**
+     * Insert or update exchange in aggregation table.
+     */
+    @Override
+    public Exchange add(CamelContext camelContext, String key, Exchange exchange) {
+        final Object[] idValues = getPKValues(key);
+        LOGGER.debug("Inserting key {} exchange {}", idValues, exchange);
+        try {
+            ByteBuffer marshalledExchange = exchangeCodec.marshallExchange(camelContext, exchange);
+            Object[] cqlParams = concat(idValues, new Object[]{exchange.getExchangeId(), marshalledExchange});
+            getSession().execute(insertStatement.bind(cqlParams));
+            return exchange;
+        } catch (IOException iOException) {
+            throw new CassandraAggregationException("Failed to write exchange", exchange, iOException);
+        }
+    }
+
+    // -------------------------------------------------------------------------
+    // Get exchange from repository
+
+    protected void initSelectStatement() {
+        String cql = generateSelect(table, 
+                getAllColumns(), 
+                pkColumns).toString();
+        LOGGER.debug("Generated Select {}", cql);
+        selectStatement = applyConsistencyLevel(getSession().prepare(cql), readConsistencyLevel);
+    }
+    /**
+     * Get exchange from aggregation table by aggregation key.
+     */
+    @Override
+    public Exchange get(CamelContext camelContext, String key) {
+        Object[] pkValues = getPKValues(key);
+        LOGGER.debug("Selecting key {} ", pkValues);
+        Row row = getSession().execute(selectStatement.bind(pkValues)).one();
+        Exchange exchange = null;
+        if (row!=null) {
+            try {
+                exchange = exchangeCodec.unmarshallExchange(camelContext, row.getBytes(exchangeColumn));
+            } catch (IOException iOException) {
+                throw new CassandraAggregationException("Failed to read exchange", exchange, iOException);
+            } catch (ClassNotFoundException classNotFoundException) {
+                throw new CassandraAggregationException("Failed to read exchange", exchange, classNotFoundException);
+            }
+        }
+        return exchange;
+    }
+
+    // -------------------------------------------------------------------------
+    // Confirm exchange in repository
+    private void initDeleteIfIdStatement() {
+        StringBuilder cqlBuilder = generateDelete(table, pkColumns, false);
+        cqlBuilder.append(" if ").append(exchangeIdColumn).append("=?");
+        String cql = cqlBuilder.toString();
+        LOGGER.debug("Generated Delete If Id {}", cql);
+        deleteIfIdStatement = applyConsistencyLevel(getSession().prepare(cql), writeConsistencyLevel);
+    }
+
+    /**
+     * Remove exchange by Id from aggregation table.
+     */
+    @Override
+    public void confirm(CamelContext camelContext, String exchangeId) {
+        Object[] pkValues = getPKValues();
+        String keyColumn= getKeyColumn();
+        LOGGER.debug("Selecting Ids {} ", pkValues);
+        List<Row> rows = selectKeyIds();
+        for(Row row:rows) {
+            if (row.getString(exchangeIdColumn).equals(exchangeId)) {
+                String key = row.getString(keyColumn);
+                Object[] cqlParams = append(pkValues, key, exchangeId);
+                LOGGER.debug("Deleting If Id {} ", cqlParams);
+                getSession().execute(deleteIfIdStatement.bind(cqlParams));
+            }
+        }
+    }
+
+    // -------------------------------------------------------------------------
+    // Remove exchange from repository
+
+    private void initDeleteStatement() {
+        String cql = generateDelete(table, pkColumns, false).toString();
+        LOGGER.debug("Generated Delete {}", cql);
+        deleteStatement = applyConsistencyLevel(getSession().prepare(cql), writeConsistencyLevel);
+    }
+
+    /**
+     * Remove exchange by aggregation key from aggregation table.
+     */
+    @Override
+    public void remove(CamelContext camelContext, String key, Exchange exchange) {
+        Object[] idValues = getPKValues(key);
+        LOGGER.debug("Deleting key {}", (Object) idValues);
+        getSession().execute(deleteStatement.bind(idValues));
+    }
+    // -------------------------------------------------------------------------
+    private void initSelectKeyIdStatement() { 
+        String cql = generateSelect(table, 
+                new String[]{getKeyColumn(), exchangeIdColumn}, // Key + Exchange Id columns
+                pkColumns, pkColumns.length-1).toString(); // Where fixed PK columns
+        LOGGER.debug("Generated Select keys {}", cql);
+        selectKeyIdStatement = applyConsistencyLevel(getSession().prepare(cql), readConsistencyLevel);
+    }
+
+    private List<Row> selectKeyIds() {
+        Object[] pkValues = getPKValues();
+        LOGGER.debug("Selecting keys {}", pkValues);
+        return getSession().execute(selectKeyIdStatement.bind(pkValues)).all();
+    }
+
+    /**
+     * Get aggregation keys from aggregation table.
+     */
+    @Override
+    public Set<String> getKeys() {
+        List<Row> rows = selectKeyIds();
+        Set<String> keys = new HashSet<String>(rows.size());
+        String keyColumnName = getPKColumns()[1];
+        for(Row row:rows) {
+            keys.add(row.getString(keyColumnName));
+        }
+        return keys;
+    }
+
+
+    // -------------------------------------------------------------------------
+    // Getters and Setters
+
+    public Session getSession() {
+        return sessionHolder.getSession();
+    }
+
+    public void setSession(Session session) {
+        this.sessionHolder = new CassandraSessionHolder(session);
+    }
+
+    public String getTable() {
+        return table;
+    }
+
+    public void setTable(String table) {
+        this.table = table;
+    }
+    public String[] getPKColumns() {
+        return pkColumns;
+    }
+    public void setPKColumns(String ... pkColumns) {
+        this.pkColumns = pkColumns;
+    }
+
+    public String getExchangeIdColumn() {
+        return exchangeIdColumn;
+    }
+
+    public void setExchangeIdColumn(String exchangeIdColumn) {
+        this.exchangeIdColumn = exchangeIdColumn;
+    }
+
+    public ConsistencyLevel getWriteConsistencyLevel() {
+        return writeConsistencyLevel;
+    }
+
+    public void setWriteConsistencyLevel(ConsistencyLevel writeConsistencyLevel) {
+        this.writeConsistencyLevel = writeConsistencyLevel;
+    }
+
+    public ConsistencyLevel getReadConsistencyLevel() {
+        return readConsistencyLevel;
+    }
+
+    public void setReadConsistencyLevel(ConsistencyLevel readConsistencyLevel) {
+        this.readConsistencyLevel = readConsistencyLevel;
+    }
+    
+    public String getExchangeColumn() {
+        return exchangeColumn;
+    }
+
+    public void setExchangeColumn(String exchangeColumnName) {
+        this.exchangeColumn = exchangeColumnName;
+    }
+
+    public Integer getTtl() {
+        return ttl;
+    }
+
+    public void setTtl(Integer ttl) {
+        this.ttl = ttl;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraCamelCodec.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraCamelCodec.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraCamelCodec.java
new file mode 100644
index 0000000..e060678
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/CassandraCamelCodec.java
@@ -0,0 +1,111 @@
+/**
+ * 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.processor.aggregate.cassandra;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.nio.ByteBuffer;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.impl.DefaultExchange;
+import org.apache.camel.impl.DefaultExchangeHolder;
+
+/**
+ * Marshall/unmarshall Exchange to/from a ByteBuffer.
+ * Inspired from JdbcCamelCodec. TODO Find how to share code
+ */
+public class CassandraCamelCodec {
+
+    public ByteBuffer marshallExchange(CamelContext camelContext, Exchange exchange) throws IOException {
+        // use DefaultExchangeHolder to marshal to a serialized object
+        DefaultExchangeHolder pe = DefaultExchangeHolder.marshal(exchange, false);
+        // add the aggregated size and timeout property as the only properties we want to retain
+        DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_SIZE, exchange.getProperty(Exchange.AGGREGATED_SIZE, Integer.class));
+        DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_TIMEOUT, exchange.getProperty(Exchange.AGGREGATED_TIMEOUT, Long.class));
+        // add the aggregated completed by property to retain
+        DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_COMPLETED_BY, exchange.getProperty(Exchange.AGGREGATED_COMPLETED_BY, String.class));
+        // add the aggregated correlation key property to retain
+        DefaultExchangeHolder.addProperty(pe, Exchange.AGGREGATED_CORRELATION_KEY, exchange.getProperty(Exchange.AGGREGATED_CORRELATION_KEY, String.class));
+        // persist the from endpoint as well
+        if (exchange.getFromEndpoint() != null) {
+            DefaultExchangeHolder.addProperty(pe, "CamelAggregatedFromEndpoint", exchange.getFromEndpoint().getEndpointUri());
+        }
+        return ByteBuffer.wrap(serialize(pe));
+    }
+
+    public Exchange unmarshallExchange(CamelContext camelContext, ByteBuffer buffer) throws IOException, ClassNotFoundException {
+        DefaultExchangeHolder pe = (DefaultExchangeHolder) deserialize(new ByteBufferInputStream(buffer));
+        Exchange answer = new DefaultExchange(camelContext);
+        DefaultExchangeHolder.unmarshal(answer, pe);
+        // restore the from endpoint
+        String fromEndpointUri = (String) answer.removeProperty("CamelAggregatedFromEndpoint");
+        if (fromEndpointUri != null) {
+            Endpoint fromEndpoint = camelContext.hasEndpoint(fromEndpointUri);
+            if (fromEndpoint != null) {
+                answer.setFromEndpoint(fromEndpoint);
+            }
+        }
+        return answer;
+    }
+
+    private byte[] serialize(Object object) throws IOException {
+        ByteArrayOutputStream bytesOut = new ByteArrayOutputStream();
+        ObjectOutputStream objectOut = new ObjectOutputStream(bytesOut);
+        objectOut.writeObject(object);
+        objectOut.close();
+        return bytesOut.toByteArray();
+    }
+
+    private Object deserialize(InputStream bytes) throws IOException, ClassNotFoundException {
+        ObjectInputStream objectIn = new ObjectInputStream(bytes);
+        Object object = objectIn.readObject();
+        objectIn.close();
+        return object;
+    }
+
+    private static class ByteBufferInputStream extends InputStream {
+
+        private final ByteBuffer buffer;
+
+        public ByteBufferInputStream(ByteBuffer buffer) {
+            this.buffer = buffer;
+        }
+
+        @Override
+        public int read() throws IOException {
+            if (!buffer.hasRemaining()) {
+                return -1;
+            }
+            return buffer.get();
+        }
+
+        @Override
+        public int read(byte[] bytes, int off, int len) throws IOException {
+            if (!buffer.hasRemaining()) {
+                return -1;
+            }
+            len = Math.min(len, buffer.remaining());
+            buffer.get(bytes, off, len);
+            return len;
+        }
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepository.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepository.java
new file mode 100644
index 0000000..5448207
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/aggregate/cassandra/NamedCassandraAggregationRepository.java
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.processor.aggregate.cassandra;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+
+/**
+ * Concrete implementation of {@link  CassandraAggregationRepository} using 2 
+ * columns as primary key: name (partition key) and key (clustering key).
+ */
+public class NamedCassandraAggregationRepository extends CassandraAggregationRepository {
+    /**
+     * Aggregation repository name
+     */
+    private String name;
+    public NamedCassandraAggregationRepository() {
+        setPKColumns("NAME", "KEY");
+    }
+    public NamedCassandraAggregationRepository(Session session, String name) {
+        super(session);
+        this.name = name;
+        setPKColumns("NAME", "KEY");
+    }
+    public NamedCassandraAggregationRepository(Cluster cluster, String keyspace, String name) {
+        super(cluster, keyspace);
+        this.name = name;
+        setPKColumns("NAME", "KEY");
+    }
+
+    @Override
+    protected Object[] getPKValues() {
+        return new Object[]{name};
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
new file mode 100644
index 0000000..4bdf496
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/CassandraIdempotentRepository.java
@@ -0,0 +1,212 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.processor.idempotent.cassandra;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ConsistencyLevel;
+import com.datastax.driver.core.PreparedStatement;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+import org.apache.camel.spi.IdempotentRepository;
+import org.apache.camel.support.ServiceSupport;
+import org.apache.camel.utils.cassandra.CassandraSessionHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import static org.apache.camel.utils.cassandra.CassandraUtils.*;
+
+/**
+ * Implementation of {@link IdempotentRepository} using Cassandra table to store
+ * message ids.
+ * Advice: use LeveledCompaction for this table and tune read/write consistency levels.
+ * Warning: Cassandra is not the best tool for queuing use cases
+ * @see http://www.datastax.com/dev/blog/cassandra-anti-patterns-queues-and-queue-like-datasets
+ * @param <K> Message Id
+ */
+public abstract class CassandraIdempotentRepository<K> extends ServiceSupport implements IdempotentRepository<K> {
+    /**
+     * Logger
+     */
+    private static final Logger LOGGER = LoggerFactory.getLogger(CassandraIdempotentRepository.class);
+    /**
+     * Session holder
+     */
+    private CassandraSessionHolder sessionHolder;
+    /**
+     * Table name
+     */
+    private String table = "CAMEL_IDEMPOTENT";
+    /**
+     * Primary key columns
+     */
+    private String[] pkColumns;
+    /**
+     * Time to live in seconds used for inserts
+     */
+    private Integer ttl;
+    /**
+     * Write consistency level
+     */
+    private ConsistencyLevel writeConsistencyLevel;
+    /**
+     * Read consistency level
+     */
+    private ConsistencyLevel readConsistencyLevel;
+    private PreparedStatement insertStatement;
+    private PreparedStatement selectStatement;
+    private PreparedStatement deleteStatement;
+
+    public CassandraIdempotentRepository() {
+    }
+
+    public CassandraIdempotentRepository(Session session) {
+        this.sessionHolder = new CassandraSessionHolder(session);
+    }
+    public CassandraIdempotentRepository(Cluster cluster, String keyspace) {
+        this.sessionHolder = new CassandraSessionHolder(cluster, keyspace);
+    }
+
+    private boolean isKey(ResultSet resultSet) {
+        Row row = resultSet.one(); 
+        if (row==null) {
+            LOGGER.debug("No row to check key");
+            return false;
+        } else {
+            LOGGER.debug("Row with {} columns to check key", row.getColumnDefinitions());            
+            return row.getColumnDefinitions().size()>1;
+        }
+    }
+    protected abstract Object[] getPKValues(K key);
+    // -------------------------------------------------------------------------
+    // Lifecycle methods
+
+    @Override
+    protected void doStart() throws Exception {
+        sessionHolder.start();
+        initInsertStatement();
+        initSelectStatement();
+        initDeleteStatement();
+    }
+
+    @Override
+    protected void doStop() throws Exception {
+        sessionHolder.stop();
+    }
+    // -------------------------------------------------------------------------
+    // Add key to repository
+
+    protected void initInsertStatement() {
+        String cql = generateInsert(table, pkColumns, true, ttl).toString();
+        LOGGER.debug("Generated Insert {}", cql);
+        insertStatement = applyConsistencyLevel(getSession().prepare(cql), writeConsistencyLevel);
+    }
+
+    @Override
+    public boolean add(K key) {
+        Object[] idValues = getPKValues(key);
+        LOGGER.debug("Inserting key {}", (Object) idValues);
+        return !isKey(getSession().execute(insertStatement.bind(idValues)));
+    }
+
+    // -------------------------------------------------------------------------
+    // Check if key is in repository
+
+    protected void initSelectStatement() {
+        String cql = generateSelect(table, pkColumns, pkColumns).toString();
+        LOGGER.debug("Generated Select {}", cql);
+        selectStatement = applyConsistencyLevel(getSession().prepare(cql), readConsistencyLevel);
+    }
+
+    @Override
+    public boolean contains(K key) {
+        Object[] idValues = getPKValues(key);
+        LOGGER.debug("Checking key {}", (Object) idValues);
+        return isKey(getSession().execute(selectStatement.bind(idValues)));
+    }
+
+    @Override
+    public boolean confirm(K key) {
+        return true;
+    }
+
+    // -------------------------------------------------------------------------
+    // Remove key from repository
+
+    protected void initDeleteStatement() {
+        String cql = generateDelete(table, pkColumns, true).toString();
+        LOGGER.debug("Generated Delete {}", cql);
+        deleteStatement = applyConsistencyLevel(getSession().prepare(cql), writeConsistencyLevel);
+    }
+
+    @Override
+    public boolean remove(K key) {
+        Object[] idValues = getPKValues(key);
+        LOGGER.debug("Deleting key {}", (Object) idValues);
+        getSession().execute(deleteStatement.bind(idValues));
+        return true;
+    }
+    // -------------------------------------------------------------------------
+    // Getters & Setters
+
+    public Session getSession() {
+        return sessionHolder.getSession();
+    }
+
+    public void setSession(Session session) {
+        this.sessionHolder = new CassandraSessionHolder(session);
+    }
+
+    public String getTable() {
+        return table;
+    }
+
+    public void setTable(String table) {
+        this.table = table;
+    }
+
+    public String[] getPKColumns() {
+        return pkColumns;
+    }
+
+    public void setPKColumns(String... pkColumns) {
+        this.pkColumns=pkColumns;
+    }
+
+    public Integer getTtl() {
+        return ttl;
+    }
+
+    public void setTtl(Integer ttl) {
+        this.ttl = ttl;
+    }
+
+    public ConsistencyLevel getWriteConsistencyLevel() {
+        return writeConsistencyLevel;
+    }
+
+    public void setWriteConsistencyLevel(ConsistencyLevel writeConsistencyLevel) {
+        this.writeConsistencyLevel = writeConsistencyLevel;
+    }
+
+    public ConsistencyLevel getReadConsistencyLevel() {
+        return readConsistencyLevel;
+    }
+
+    public void setReadConsistencyLevel(ConsistencyLevel readConsistencyLevel) {
+        this.readConsistencyLevel = readConsistencyLevel;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java
new file mode 100644
index 0000000..03d73ec
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/processor/idempotent/cassandra/NamedCassandraIdempotentRepository.java
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.processor.idempotent.cassandra;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+
+/**
+ * Concrete implementation of {@link  CassandraIdempotentRepository} using 2 
+ * columns as primary key: name (partition key) and key (clustering key).
+ */
+public class NamedCassandraIdempotentRepository<K> extends CassandraIdempotentRepository<K>{
+    /**
+     * Idempotent repository name
+     */
+    private String name;
+
+    public NamedCassandraIdempotentRepository() {
+        setPKColumns("NAME", "KEY");
+    }
+    public NamedCassandraIdempotentRepository(Session session, String name) {
+        super(session);
+        this.name = name;
+        setPKColumns("NAME", "KEY");
+    }
+    public NamedCassandraIdempotentRepository(Cluster cluster, String keyspace, String name) {
+        super(cluster, keyspace);
+        this.name = name;
+        setPKColumns("NAME", "KEY");
+    }
+    
+    @Override
+    protected Object[] getPKValues(K key) {
+        return new Object[]{name, key};
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public void setName(String name) {
+        this.name = name;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraSessionHolder.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraSessionHolder.java b/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraSessionHolder.java
new file mode 100644
index 0000000..82a7a72
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraSessionHolder.java
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.utils.cassandra;
+
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.Session;
+
+/**
+ * Holds a Cassandra Session and manages its lifecycle
+ */
+public class CassandraSessionHolder {
+    /**
+     * Cluster
+     */
+    private final Cluster cluster;
+    /**
+     * Session
+     */
+    private Session session;
+    /**
+     * Keyspace name
+     */
+    private String keyspace;
+    /**
+     * Indicates whether Session is externally managed
+     */
+    private final boolean managedSession;
+
+    public CassandraSessionHolder(Cluster cluster, String keyspace) {
+        this.cluster = cluster;
+        this.keyspace = keyspace;
+        this.managedSession = true;
+    }
+
+    public CassandraSessionHolder(Session session) {
+        this.cluster = session.getCluster();
+        this.session = session;
+        this.keyspace = session.getLoggedKeyspace();
+        this.managedSession = false;
+    }
+    public void start() {
+        if (managedSession) {
+            if (keyspace == null) {
+                this.session = cluster.connect();
+            } else {
+                this.session = cluster.connect(keyspace);
+            }
+        }
+    }
+    public void stop() {
+        if (!managedSession) {
+            session.close();
+            session = null;
+        }
+    }
+    public Session getSession() {
+        return session;
+    }
+
+    public Cluster getCluster() {
+        return cluster;
+    }
+
+    public String getKeyspace() {
+        return keyspace;
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraUtils.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraUtils.java b/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraUtils.java
new file mode 100644
index 0000000..4b18d8c
--- /dev/null
+++ b/components/camel-cassandraql/src/main/java/org/apache/camel/utils/cassandra/CassandraUtils.java
@@ -0,0 +1,163 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.utils.cassandra;
+
+import com.datastax.driver.core.ConsistencyLevel;
+import com.datastax.driver.core.PreparedStatement;
+
+/**
+ *
+ */
+public class CassandraUtils {
+    /**
+     * Apply consistency level if provided, else leave default.
+     */
+    public static PreparedStatement applyConsistencyLevel(PreparedStatement statement, ConsistencyLevel consistencyLevel) {
+        if (consistencyLevel!=null) {
+            statement.setConsistencyLevel(consistencyLevel);
+        }
+        return statement;
+    }
+    /**
+     * Concatenate 2 arrays.
+     */
+    public static Object[] concat(Object[] array1, Object[] array2) {
+        Object[] array = new Object[array1.length+array2.length];
+        System.arraycopy(array1, 0, array, 0, array1.length);
+        System.arraycopy(array2, 0, array, array1.length, array2.length);
+        return array;
+    }
+    /**
+     * Concatenate 2 arrays.
+     */
+    public static String[] concat(String[] array1, String[] array2) {
+        String[] array = new String[array1.length+array2.length];
+        System.arraycopy(array1, 0, array, 0, array1.length);
+        System.arraycopy(array2, 0, array, array1.length, array2.length);
+        return array;
+    }
+    /**
+     * Append values to given array.
+     */
+    public static Object[] append(Object[] array1, Object ... array2) {
+        return concat(array1, array2);
+    }
+    /**
+     * Append values to given array.
+     */
+    public static String[] append(String[] array1, String ... array2) {
+        return concat(array1, array2);
+    }
+    /**
+     * Append columns to CQL.
+     */
+    public static void appendColumns(StringBuilder cqlBuilder, String[] columns, String sep, int maxColumnIndex) {
+        for (int i = 0; i < maxColumnIndex; i++) {
+            if (i > 0) {
+                cqlBuilder.append(sep);
+            }
+            cqlBuilder.append(columns[i]);
+        }
+    }
+
+    /**
+     * Append columns to CQL.
+     */
+    public static  void appendColumns(StringBuilder cqlBuilder, String[] columns, String sep) {
+        appendColumns(cqlBuilder, columns, sep, columns.length);
+    }
+
+    /**
+     * Append where columns = ? to CQL.
+     */
+    public static void appendWhere(StringBuilder cqlBuilder, String[] columns, int maxColumnIndex) {
+        cqlBuilder.append(" where ");
+        appendColumns(cqlBuilder, columns, "=? and ", maxColumnIndex);
+        cqlBuilder.append("=?");
+    }
+    /**
+     * Append where columns = ? to CQL.
+     */
+    public void appendWhere(StringBuilder cqlBuilder, String[] columns) {
+        appendWhere(cqlBuilder, columns, columns.length);
+    }
+    /**
+     * Append ?,? to CQL.
+     */
+    public static void appendPlaceholders(StringBuilder cqlBuilder, int columnCount) {
+        for (int i = 0; i < columnCount; i++) {
+            if (i > 0) {
+                cqlBuilder.append(",");
+            }
+            cqlBuilder.append("?");
+        }
+    }
+
+    /**
+     * Generate Insert CQL.
+     */
+    public static StringBuilder generateInsert(String table, String[] columns, boolean ifNotExists, Integer ttl) {
+        StringBuilder cqlBuilder = new StringBuilder("insert into ")
+                .append(table).append("(");
+        appendColumns(cqlBuilder, columns, ",");
+        cqlBuilder.append(") values (");
+        appendPlaceholders(cqlBuilder, columns.length);
+        cqlBuilder.append(")");
+        if (ifNotExists) {
+            cqlBuilder.append(" if not exists");
+        }
+        if (ttl!=null) {
+            cqlBuilder.append(" using ttl=").append(ttl);
+        }
+        return cqlBuilder;        
+    }
+    /**
+     * Generate select where columns = ? CQL.
+     */
+    public static StringBuilder generateSelect(String table, String[] selectColumns, String[] whereColumns) {
+        return generateSelect(table, selectColumns, whereColumns, whereColumns.length);
+    }
+
+    /**
+     * Generate select where columns = ? CQL.
+     */
+    public static StringBuilder generateSelect(String table, String[] selectColumns, String[] whereColumns, int whereColumnsMaxIndex) {
+        StringBuilder cqlBuilder = new StringBuilder("select ");
+        appendColumns(cqlBuilder, selectColumns, ",");
+        cqlBuilder.append(" from ").append(table);
+        appendWhere(cqlBuilder, whereColumns, whereColumnsMaxIndex);
+        return cqlBuilder;
+    }
+    /**
+     * Generate delete where columns = ? CQL.
+     */
+    public static StringBuilder generateDelete(String table, String[] whereColumns, boolean ifExists) {
+        return generateDelete(table, whereColumns, whereColumns.length, ifExists);
+    }
+    /**
+     * Generate delete where columns = ? CQL.
+     */
+    public static StringBuilder generateDelete(String table, String[] whereColumns, int whereColumnsMaxIndex, boolean ifExists) {
+        StringBuilder cqlBuilder = new StringBuilder("delete from ")
+            .append(table);
+        appendWhere(cqlBuilder, whereColumns, whereColumnsMaxIndex);
+        if (ifExists) {
+            cqlBuilder.append(" if exists");
+        }
+        return cqlBuilder;
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/main/resources/META-INF/services/org/apache/camel/component/cql
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/main/resources/META-INF/services/org/apache/camel/component/cql b/components/camel-cassandraql/src/main/resources/META-INF/services/org/apache/camel/component/cql
new file mode 100644
index 0000000..8d80a4f
--- /dev/null
+++ b/components/camel-cassandraql/src/main/resources/META-INF/services/org/apache/camel/component/cql
@@ -0,0 +1 @@
+class=org.apache.camel.component.cassandra.CassandraComponent

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
new file mode 100644
index 0000000..f3efc27
--- /dev/null
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentBeanRefTest.java
@@ -0,0 +1,77 @@
+package org.apache.camel.component.cassandra;
+
+import org.apache.camel.component.cassandra.CassandraEndpoint;
+import com.datastax.driver.core.Cluster;
+import com.datastax.driver.core.ResultSet;
+import com.datastax.driver.core.Row;
+import com.datastax.driver.core.Session;
+import java.net.URLEncoder;
+import java.util.Arrays;
+import org.apache.camel.Produce;
+import org.apache.camel.ProducerTemplate;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.impl.JndiRegistry;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.apache.http.client.utils.URLEncodedUtils;
+import org.cassandraunit.CassandraCQLUnit;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+
+public class CassandraComponentBeanRefTest extends CamelTestSupport {
+    @Rule
+    public CassandraCQLUnit cassandra=CassandraUnitUtils.cassandraCQLUnit();
+    @Produce(uri = "direct:input")
+    ProducerTemplate producerTemplate;
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        CassandraUnitUtils.startEmbeddedCassandra();
+    }
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+        CassandraUnitUtils.cleanEmbeddedCassandra();
+    }
+
+    @Override
+    protected JndiRegistry createRegistry() throws Exception {
+        JndiRegistry registry = super.createRegistry();
+        Cluster cluster = Cluster.builder()
+                .addContactPoint("localhost")
+                .build();
+        registry.bind("cassandraCluster", cluster);
+        registry.bind("cassandraSession", cluster.connect("camel_ks"));
+        registry.bind("insertCql", CQL);
+        return registry;
+    }
+    public static final String CQL = "insert into camel_user(login, first_name, last_name) values (?, ?, ?)";
+    public static final String SESSION_URI = "cql:bean:cassandraSession?cql=#insertCql";
+    public static final String CLUSTER_URI = "cql:bean:cassandraCluster/camel_ks?cql=#insertCql";
+    
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {                
+                from("direct:inputSession")
+                  .to(SESSION_URI);
+                from("direct:inputCluster")
+                  .to(CLUSTER_URI);
+            }
+        };
+    }
+    @Test
+    public void testSession() throws Exception {
+        CassandraEndpoint endpoint = getMandatoryEndpoint(SESSION_URI, CassandraEndpoint.class);
+
+        assertEquals("camel_ks", endpoint.getKeyspace());
+        assertEquals(CQL, endpoint.getCql());
+    }
+    @Test
+    public void testCluster() throws Exception {
+        CassandraEndpoint endpoint = getMandatoryEndpoint(CLUSTER_URI, CassandraEndpoint.class);
+
+        assertEquals("camel_ks", endpoint.getKeyspace());
+        assertEquals(CQL, endpoint.getCql());
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentClusterBuilderTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentClusterBuilderTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentClusterBuilderTest.java
new file mode 100644
index 0000000..17753f7
--- /dev/null
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentClusterBuilderTest.java
@@ -0,0 +1,74 @@
+/*
+ * Copyright 2014 The Apache Software Foundation.
+ *
+ * Licensed 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.cassandra;
+
+import org.apache.camel.component.cassandra.CassandraComponent;
+import com.datastax.driver.core.Cluster;
+import java.util.*;
+import org.apache.camel.impl.DefaultCamelContext;
+import static org.hamcrest.Matchers.*;
+import org.junit.Test;
+import static org.junit.Assert.*;
+import org.junit.Before;
+
+/**
+ * Unit test for {@link CassandraComponent}
+ */
+public class CassandraComponentClusterBuilderTest {
+    private final CassandraComponent component = new CassandraComponent();
+    @Before
+    public void setUp() {
+        component.setCamelContext(new DefaultCamelContext());
+    }
+    @Test
+    public void testClusterBuilder_Basic() {
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put("clusterName", "cluster");
+        Cluster.Builder clusterBuilder = component.clusterBuilder("127.0.0.1,127.0.0.2/keyspace", params);
+        
+        assertEquals(2, clusterBuilder.getContactPoints().size());
+        assertThat(clusterBuilder.getContactPoints().get(0).getHostName(), isOneOf("127.0.0.1","localhost"));
+        assertThat(clusterBuilder.getContactPoints().get(1).getHostName(), isOneOf("127.0.0.2","localhost"));
+        assertEquals("cluster", clusterBuilder.getClusterName());
+        assertEquals("keyspace",params.get("keyspace"));
+    }
+    @Test
+    public void testClusterBuilder_Port() {
+        Map<String, Object> params = new HashMap<String, Object>();
+        params.put("clusterName", "cluster");
+        Cluster.Builder clusterBuilder = component.clusterBuilder("127.0.0.1,127.0.0.2:1234/keyspace", params);
+        
+        assertEquals(2, clusterBuilder.getContactPoints().size());
+        assertThat(clusterBuilder.getContactPoints().get(0).getHostName(), isOneOf("127.0.0.1","localhost"));
+        assertEquals(1234, clusterBuilder.getContactPoints().get(0).getPort());
+        assertThat(clusterBuilder.getContactPoints().get(1).getHostName(), isOneOf("127.0.0.2","localhost"));
+        assertEquals(1234, clusterBuilder.getConfiguration().getProtocolOptions().getPort());
+        assertEquals("cluster", clusterBuilder.getClusterName());
+        assertEquals("keyspace",params.get("keyspace"));
+    }
+
+    @Test
+    public void testClusterBuilder_Simplest() {
+        Map<String, Object> params = new HashMap<String, Object>();
+        Cluster.Builder clusterBuilder = component.clusterBuilder("127.0.0.1", params);
+        
+        assertEquals(1, clusterBuilder.getContactPoints().size());
+        assertThat(clusterBuilder.getContactPoints().get(0).getHostName(), isOneOf("127.0.0.1","localhost"));
+        assertNull(params.get("keyspace"));
+    }
+    
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/7be546af/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
new file mode 100644
index 0000000..0b4f0ed
--- /dev/null
+++ b/components/camel-cassandraql/src/test/java/org/apache/camel/component/cassandra/CassandraComponentConsumerTest.java
@@ -0,0 +1,73 @@
+package org.apache.camel.component.cassandra;
+
+import com.datastax.driver.core.Row;
+import java.util.List;
+import java.util.concurrent.TimeUnit;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.cassandraunit.CassandraCQLUnit;
+import org.junit.AfterClass;
+import static org.junit.Assert.assertTrue;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.Test;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class CassandraComponentConsumerTest extends CamelTestSupport {
+    @Rule
+    public CassandraCQLUnit cassandra=CassandraUnitUtils.cassandraCQLUnit();
+    private final Logger logger = LoggerFactory.getLogger(getClass());
+    @BeforeClass
+    public static void setUpClass() throws Exception {
+        CassandraUnitUtils.startEmbeddedCassandra();
+    }
+    @AfterClass
+    public static void tearDownClass() throws Exception {
+        CassandraUnitUtils.cleanEmbeddedCassandra();
+    }
+    @Test
+    public void testConsume_All() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:resultAll");
+        mock.expectedMinimumMessageCount(1);       
+        mock.whenAnyExchangeReceived(new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                Object body = exchange.getIn().getBody();
+                assertTrue(body instanceof List);
+            }
+        });
+        mock.await(1, TimeUnit.SECONDS);
+        assertMockEndpointsSatisfied();
+    }
+    @Test
+    public void testConsume_One() throws Exception {
+        MockEndpoint mock = getMockEndpoint("mock:resultOne");
+        mock.expectedMinimumMessageCount(1);       
+        mock.whenAnyExchangeReceived(new Processor() {
+            @Override
+            public void process(Exchange exchange) throws Exception {
+                Object body = exchange.getIn().getBody();
+                assertTrue(body instanceof Row);
+            }
+        });
+        mock.await(1, TimeUnit.SECONDS);
+        
+        assertMockEndpointsSatisfied();
+    }
+    private static final String CQL = "select login, first_name, last_name from camel_user";
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            public void configure() {                
+                from("cql://localhost/camel_ks?cql="+CQL)
+                  .to("mock:resultAll");
+                from("cql://localhost/camel_ks?cql="+CQL+"&resultSetConversionStrategy=ONE")
+                  .to("mock:resultOne");
+            }
+        };
+    }
+}