You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2013/12/09 03:11:51 UTC
[47/50] [abbrv] git commit: CAMEL-4817 Added camel-gora component
with thanks to Ioannis
CAMEL-4817 Added camel-gora component with thanks to Ioannis
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8ad60f0f
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8ad60f0f
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8ad60f0f
Branch: refs/heads/camel-gora
Commit: 8ad60f0fd59049985fba3a025e7fa8d0384cc8d5
Parents: f68954c
Author: Willem Jiang <wi...@gmail.com>
Authored: Tue Nov 19 14:34:04 2013 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Mon Dec 9 10:07:07 2013 +0800
----------------------------------------------------------------------
components/camel-gora/pom.xml | 208 ++++++++
.../camel/component/gora/GoraAttribute.java | 106 +++++
.../camel/component/gora/GoraComponent.java | 109 +++++
.../camel/component/gora/GoraConfiguration.java | 476 +++++++++++++++++++
.../camel/component/gora/GoraConstants.java | 39 ++
.../camel/component/gora/GoraConsumer.java | 132 +++++
.../camel/component/gora/GoraEndpoint.java | 105 ++++
.../camel/component/gora/GoraOperation.java | 85 ++++
.../camel/component/gora/GoraProducer.java | 131 +++++
.../camel/component/gora/utils/GoraUtils.java | 326 +++++++++++++
.../src/main/resources/META-INF/LICENSE.txt | 203 ++++++++
.../src/main/resources/META-INF/NOTICE.txt | 11 +
.../services/org/apache/camel/component/gora | 18 +
.../component/gora/GoraConfigurationTest.java | 78 +++
.../camel/component/gora/GoraConsumerTest.java | 103 ++++
.../camel/component/gora/GoraProducerTest.java | 314 ++++++++++++
.../camel/component/gora/GoraTestSupport.java | 29 ++
.../component/gora/utils/GoraUtilsTest.java | 56 +++
18 files changed, 2529 insertions(+)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/pom.xml
----------------------------------------------------------------------
diff --git a/components/camel-gora/pom.xml b/components/camel-gora/pom.xml
new file mode 100644
index 0000000..f2318ff
--- /dev/null
+++ b/components/camel-gora/pom.xml
@@ -0,0 +1,208 @@
+<!--
+ Copyright 2011 Ioannis Polyzos
+
+ 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.
+ -->
+<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.12-SNAPSHOT</version>
+ </parent>
+
+ <artifactId>camel-gora</artifactId>
+ <packaging>bundle</packaging>
+ <name>Camel :: Gora</name>
+
+ <description>
+ Gora Component for Apache Camel.
+ </description>
+
+ <properties>
+ <!--
+ General
+ -->
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+
+ <!--
+ OSGi
+ -->
+ <camel.osgi.export.pkg>
+ org.apache.camel.component.gora.*
+ </camel.osgi.export.pkg>
+ <camel.osgi.import.before.defaults>
+ org.apache.camel.*
+ com.google.common.base;version="[11,14)",
+ org.apache.hadoop.conf;version="[1,2)"
+ </camel.osgi.import.before.defaults>
+ <camel.osgi.export.pkg>org.apache.camel.component.gora.*</camel.osgi.export.pkg>
+ <camel.osgi.export.service>org.apache.camel.spi.ComponentResolver;component=gora</camel.osgi.export.service>
+
+ <!--
+ Libraries versions
+ -->
+
+ <!-- apache gora -->
+ <apache-gora.version>0.4-SNAPSHOT</apache-gora.version>
+
+ <mockito.version>1.9.0</mockito.version>
+ <powermock.version>1.4.11</powermock.version>
+
+ <hadoop.version>1.1.1_1</hadoop.version>
+ <avro.version>1.6.1_1</avro.version>
+ <jackson.version>1.6.9</jackson.version>
+
+ <jdom.version>1.1.2_1</jdom.version>
+ <guava.version>11.0.2_2</guava.version>
+ <commons-beanutils.version>1.8.3</commons-beanutils.version>
+
+ </properties>
+
+ <build>
+ <defaultGoal>install</defaultGoal>
+ <resources>
+ <resource>
+ <directory>src/main/resources</directory>
+ <filtering>true</filtering>
+ </resource>
+ </resources>
+ <testResources>
+ <testResource>
+ <directory>src/test/resources</directory>
+ <filtering>true</filtering>
+ </testResource>
+ </testResources>
+ </build>
+
+ <dependencies>
+ <!-- logging -->
+ <dependency>
+ <groupId>log4j</groupId>
+ <artifactId>log4j</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ </dependency>
+
+ <!-- testing -->
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.mockito</groupId>
+ <artifactId>mockito-all</artifactId>
+ <version>${mockito.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-core</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-module-junit4</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.powermock</groupId>
+ <artifactId>powermock-api-mockito</artifactId>
+ <version>${powermock.version}</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-test-spring</artifactId>
+ <scope>test</scope>
+ </dependency>
+
+ <!-- apache camel -->
+ <dependency>
+ <groupId>org.apache.camel</groupId>
+ <artifactId>camel-core</artifactId>
+ </dependency>
+
+ <!-- apache gora -->
+ <dependency>
+ <groupId>org.apache.gora</groupId>
+ <artifactId>gora-core</artifactId>
+ <version>${apache-gora.version}</version>
+ </dependency>
+
+ <!-- hadoop -->
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.hadoop-core</artifactId>
+ <version>${hadoop.version}</version>
+ </dependency>
+
+ <!-- Avro -->
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.avro</artifactId>
+ <version>${avro.version}</version>
+ </dependency>
+
+ <!-- other -->
+ <!-- Avro needs this version of jackson -->
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-core-asl</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.jackson</groupId>
+ <artifactId>jackson-mapper-asl</artifactId>
+ <version>${jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.jdom</artifactId>
+ <version>${jdom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.servicemix.bundles</groupId>
+ <artifactId>org.apache.servicemix.bundles.guava</artifactId>
+ <version>${guava.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-beanutils</groupId>
+ <artifactId>commons-beanutils</artifactId>
+ <version>${commons-beanutils.version}</version>
+ </dependency>
+ </dependencies>
+
+ <licenses>
+ <license>
+ <name>Apache 2.0 License</name>
+ <url>http://www.apache.org/licenses/LICENSE-2.0</url>
+ </license>
+ </licenses>
+
+</project>
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraAttribute.java
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraAttribute.java b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraAttribute.java
new file mode 100644
index 0000000..aeab95f
--- /dev/null
+++ b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraAttribute.java
@@ -0,0 +1,106 @@
+/**
+ * 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.gora;
+
+/**
+ * Camel-Gora attributes
+ *
+ * @author ipolyzos
+ */
+public enum GoraAttribute {
+
+ /**
+ * Gora KEY attribute
+ */
+ GORA_KEY("goraKey"),
+
+ /**
+ * Gora operation header name
+ */
+ GORA_OPERATION("goraOperation"),
+
+ /**
+ * Gora Query Start Time attribute
+ */
+ GORA_QUERY_START_TIME("startTime"),
+
+ /**
+ * Gora Query End Time attribute
+ */
+ GORA_QUERY_END_TIME("endTime"),
+
+ /**
+ * Gora Query Start Key attribute
+ */
+ GORA_QUERY_START_KEY("startKey"),
+
+ /**
+ * Gora Query End Key attribute
+ */
+ GORA_QUERY_END_KEY("endKey"),
+
+ /**
+ * Gora Query Key Range From attribute
+ */
+ GORA_QUERY_KEY_RANGE_FROM("keyRangeFrom"),
+
+ /**
+ * Gora Query Key Range To attribute
+ */
+ GORA_QUERY_KEY_RANGE_TO("keyRangeTo"),
+
+ /**
+ * Gora Query Time Range From attribute
+ */
+ GORA_QUERY_TIME_RANGE_FROM("timeRangeFrom"),
+
+ /**
+ * Gora Query Key Range To attribute
+ */
+ GORA_QUERY_TIME_RANGE_TO("timeRangeTo"),
+
+ /**
+ * Gora Query Limit attribute
+ */
+ GORA_QUERY_LIMIT("limit"),
+
+ /**
+ * Gora Query Timestamp attribute
+ */
+ GORA_QUERY_TIMESTAMP("timestamp"),
+
+ /**
+ * Gora Query Fields attribute
+ */
+ GORA_QUERY_FIELDS("fields");
+ /**
+ * Enum value
+ */
+ public final String value;
+
+ /**
+ * Enum constructor
+ *
+ * @param str Operation Value
+ */
+ private GoraAttribute(final String str) {
+
+ value = str;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraComponent.java b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraComponent.java
new file mode 100644
index 0000000..03f2573
--- /dev/null
+++ b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraComponent.java
@@ -0,0 +1,109 @@
+/**
+ * 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.gora;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.Endpoint;
+import org.apache.camel.impl.DefaultComponent;
+
+import org.apache.gora.persistency.Persistent;
+import org.apache.gora.store.DataStore;
+import org.apache.gora.store.DataStoreFactory;
+import org.apache.hadoop.conf.Configuration;
+
+import java.io.IOException;
+import java.util.Map;
+import java.util.Properties;
+
+import static org.apache.camel.component.gora.GoraConstants.GORA_DEFAULT_DATASTORE_KEY;
+
+
+/**
+ * Camel-Gora {@link Endpoint}.
+ *
+ * @author ipolyzos
+ */
+public class GoraComponent extends DefaultComponent {
+
+ /**
+ * GORA datastore
+ */
+ private DataStore<Object,? extends Persistent> dataStore;
+
+ /**
+ * GORA properties
+ */
+ private Properties goraProperties;
+
+ /**
+ * Hadoop configuration
+ */
+ private Configuration configuration;
+
+ /**
+ *
+ * Initialize class and create DataStore instance
+ *
+ * @param config component configuration
+ * @throws IOException
+ */
+ private void init(final GoraConfiguration config) throws IOException {
+
+ this.configuration = new Configuration();
+ this.goraProperties = DataStoreFactory.createProps();
+
+ this.dataStore = DataStoreFactory.getDataStore(goraProperties.getProperty(GORA_DEFAULT_DATASTORE_KEY,
+ config.getDataStoreClass()),
+ config.getKeyClass(),
+ config.getValueClass(),
+ this.configuration);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected Endpoint createEndpoint(final String uri,
+ final String remaining,
+ final Map<String, Object> parameters) throws Exception {
+
+ final GoraConfiguration config = new GoraConfiguration();
+ setProperties(config, parameters);
+
+ try {
+
+ init(config);
+ } catch (IOException ex) {
+
+ throw new RuntimeException(ex);
+ }
+
+ return new GoraEndpoint(uri, this, config, dataStore);
+ }
+
+ /**
+ * Get DataStore
+ *
+ * @return DataStore
+ */
+ public DataStore getDataStore() {
+
+ return dataStore;
+ }
+
+}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConfiguration.java b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConfiguration.java
new file mode 100644
index 0000000..3deabee
--- /dev/null
+++ b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConfiguration.java
@@ -0,0 +1,476 @@
+/**
+ * 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.gora;
+
+import com.google.common.base.Strings;
+import org.apache.hadoop.conf.Configuration;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+import static com.google.common.base.Strings.isNullOrEmpty;
+
+
+/**
+ * Gora Configuration.
+ *
+ * @author ipolyzos
+ */
+public class GoraConfiguration {
+
+ /**
+ * key type
+ */
+ private String keyClass;
+
+ /**
+ * configuration
+ */
+ private Configuration hadoopConfiguration;
+
+ /**
+ * value type
+ */
+ private String valueClass;
+
+ /**
+ * dataStore type
+ */
+ private String dataStoreClass;
+
+ /** Consumer only properties! */
+
+ /**
+ * Gora Query Start Time attribute
+ */
+ private long startTime;
+
+ /**
+ * Gora Query End Time attribute
+ */
+ private long endTime;
+
+ /**
+ * Gora Query Time Range From attribute
+ */
+ private long timeRangeFrom;
+
+ /**
+ * Gora Query Key Range To attribute
+ */
+ private long timeRangeTo;
+
+ /**
+ * Gora Query Limit attribute
+ */
+ private long limit;
+
+ /**
+ * Gora Query Timestamp attribute
+ */
+ private long timestamp;
+
+ /**
+ * Gora Query Start Key attribute
+ */
+ private Object startKey;
+
+ /**
+ * Gora Query End Key attribute
+ */
+ private Object endKey;
+
+ /**
+ * Gora Query Key Range From attribute
+ */
+ private Object keyRangeFrom;
+
+ /**
+ * Gora Query Key Range To attribute
+ */
+ private Object keyRangeTo;
+
+
+ /**
+ * Gora Query Fields attribute
+ */
+ private Strings fields;
+
+ /**
+ * Concurrent Consumers
+ *
+ * <b>NOTE:<b/> used only by consumer
+ */
+ private int concurrentConsumers = 1;
+
+ /**
+ * Flush on every operation
+ *
+ * <b>NOTE:<b/> used only by producer
+ */
+ private boolean flushOnEveryOperation = true;
+
+ /**
+ * Default Constructor
+ */
+ public GoraConfiguration() {
+
+ this.hadoopConfiguration = new Configuration();
+ }
+
+ /**
+ * Get type of the key (i.e clients)
+ *
+ * @return key class
+ */
+ public String getKeyClass() {
+
+ return keyClass;
+ }
+
+ /**
+ * Set type class of the key
+ *
+ * @param keyClass
+ */
+ public void setKeyClass(final String keyClass) {
+
+ if (isNullOrEmpty(keyClass)){
+
+ throw new IllegalArgumentException("Key class could not be null or empty!");
+ }
+
+ this.keyClass = keyClass;
+ }
+
+ /**
+ * Get type of the value
+ *
+ * @return
+ */
+ public String getValueClass() {
+
+ return valueClass;
+ }
+
+ /**
+ * Set type of the value
+ *
+ * @param valueClass
+ */
+ public void setValueClass(final String valueClass) {
+
+ if (isNullOrEmpty(valueClass)){
+
+ throw new IllegalArgumentException("Value class could not be null or empty!");
+ }
+
+ this.valueClass = valueClass;
+ }
+
+ /**
+ * Get type of the dataStore
+ *
+ * @return DataStore class
+ */
+ public String getDataStoreClass() {
+
+ return dataStoreClass;
+ }
+
+ /**
+ * Set type of the dataStore
+ *
+ * @param dataStoreClass
+ */
+ public void setDataStoreClass(String dataStoreClass) {
+
+
+ if (isNullOrEmpty(dataStoreClass)){
+
+ throw new IllegalArgumentException("DataStore class could not be null or empty!");
+ }
+
+ this.dataStoreClass = dataStoreClass;
+ }
+
+ /**
+ * Get Hadoop Configuration
+ *
+ * @return
+ */
+ public Configuration getHadoopConfiguration() {
+
+ return hadoopConfiguration;
+ }
+
+ /**
+ * Get Start Time
+ *
+ * @return
+ */
+ public long getStartTime() {
+
+ return startTime;
+ }
+
+ /**
+ * Set Start Time
+ *
+ * @return
+ */
+ public void setStartTime(long startTime) {
+
+ this.startTime = startTime;
+ }
+
+ /**
+ * Get End Time
+ *
+ * @return
+ */
+ public long getEndTime() {
+
+ return endTime;
+ }
+
+ /**
+ * Set End Time
+ *
+ * @return
+ */
+ public void setEndTime(long endTime) {
+
+ this.endTime = endTime;
+ }
+
+ /**
+ * Get Time Range From
+ *
+ * @return
+ */
+ public long getTimeRangeFrom() {
+
+ return timeRangeFrom;
+ }
+
+ /**
+ * Set Time Range From
+ *
+ * @return
+ */
+ public void setTimeRangeFrom(long timeRangeFrom) {
+
+ this.timeRangeFrom = timeRangeFrom;
+ }
+
+ /**
+ * Get Time Range To
+ *
+ * @return
+ */
+ public long getTimeRangeTo() {
+
+ return timeRangeTo;
+ }
+
+ /**
+ * Set Time Range To
+ *
+ * @return
+ */
+ public void setTimeRangeTo(long timeRangeTo) {
+
+ this.timeRangeTo = timeRangeTo;
+ }
+
+ /**
+ * Get Limit
+ *
+ * @return
+ */
+ public long getLimit() {
+
+ return limit;
+ }
+
+ /**
+ * Set Limit
+ *
+ * @param limit
+ */
+ public void setLimit(long limit) {
+ this.limit = limit;
+ }
+
+ /**
+ * Get Timestamp
+ *
+ * @return
+ */
+ public long getTimestamp() {
+
+ return timestamp;
+ }
+
+ /**
+ * Set Timestamp
+ *
+ * @param timestamp
+ */
+ public void setTimestamp(long timestamp) {
+
+ this.timestamp = timestamp;
+ }
+
+ /**
+ * Get Start Key
+ *
+ * @return
+ */
+ public Object getStartKey() {
+ return startKey;
+ }
+
+ /**
+ * Set Start Key
+ *
+ * @param startKey
+ */
+ public void setStartKey(Object startKey) {
+ this.startKey = startKey;
+ }
+
+ /**
+ * Get End Key
+ *
+ * @return
+ */
+ public Object getEndKey() {
+ return endKey;
+ }
+
+ /**
+ * Set End Key
+ *
+ * @param endKey
+ */
+ public void setEndKey(Object endKey) {
+ this.endKey = endKey;
+ }
+
+ /**
+ * Get Key Range From
+ * @return
+ */
+ public Object getKeyRangeFrom() {
+ return keyRangeFrom;
+ }
+
+ /**
+ * Set Key Range From
+ *
+ * @param keyRangeFrom
+ */
+ public void setKeyRangeFrom(Object keyRangeFrom) {
+ this.keyRangeFrom = keyRangeFrom;
+ }
+
+ /**
+ * Get Key Range To
+ * @return
+ */
+ public Object getKeyRangeTo() {
+ return keyRangeTo;
+ }
+
+ /**
+ * Set Key Range To
+ *
+ * @param keyRangeTo
+ */
+ public void setKeyRangeTo(Object keyRangeTo) {
+ this.keyRangeTo = keyRangeTo;
+ }
+
+ /**
+ * Get Fields
+ *
+ * @return
+ */
+ public Strings getFields() {
+
+ return fields;
+ }
+
+ /**
+ * Set Fields
+ *
+ * @param fields
+ */
+ public void setFields(Strings fields) {
+
+ this.fields = fields;
+ }
+
+ /**
+ * Get Concurrent Consumers
+ * @return
+ */
+ public int getConcurrentConsumers() {
+
+ return concurrentConsumers;
+ }
+
+ /**
+ * Set Concurrent Consumers
+ *
+ * @param concurrentConsumers
+ */
+ public void setConcurrentConsumers(int concurrentConsumers) {
+
+ this.concurrentConsumers = concurrentConsumers;
+ }
+
+ /**
+ * Get flush on every operation
+ *
+ * @return
+ */
+ public boolean isFlushOnEveryOperation() {
+ return flushOnEveryOperation;
+ }
+
+ /**
+ * Set flush on every operation
+ *
+ * @param flushOnEveryOperation
+ */
+ public void setFlushOnEveryOperation(boolean flushOnEveryOperation) {
+ this.flushOnEveryOperation = flushOnEveryOperation;
+ }
+
+ /**
+ * Set Hadoop Configuration
+ *
+ * @param hadoopConfiguration
+ */
+ public void setHadoopConfiguration(Configuration hadoopConfiguration) {
+
+ checkNotNull(hadoopConfiguration,"Hadoop Configuration could not be null!");
+ this.hadoopConfiguration = hadoopConfiguration;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConstants.java
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConstants.java b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConstants.java
new file mode 100644
index 0000000..de08fb7
--- /dev/null
+++ b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConstants.java
@@ -0,0 +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.
+ */
+
+package org.apache.camel.component.gora;
+
+/**
+ * Camel Gora component constants
+ *
+ * @author ipolyzos
+ */
+public final class GoraConstants {
+
+ /**
+ * default DataStore key
+ */
+ public static final String GORA_DEFAULT_DATASTORE_KEY = "gora.datastore.default";
+
+ /**
+ * Private constructor
+ */
+ private GoraConstants() {
+ // prevent instantiation
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConsumer.java b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConsumer.java
new file mode 100644
index 0000000..51983a4
--- /dev/null
+++ b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraConsumer.java
@@ -0,0 +1,132 @@
+/**
+ * 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.gora;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.Processor;
+import org.apache.camel.component.gora.utils.GoraUtils;
+import org.apache.camel.impl.ScheduledPollConsumer;
+import org.apache.camel.util.ObjectHelper;
+import org.apache.gora.query.Query;
+import org.apache.gora.query.Result;
+import org.apache.gora.store.DataStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Date;
+import java.util.concurrent.ExecutorService;
+
+/**
+ * Implementation of Camel-Gora {@link Consumer}.
+ *
+ * @author ipolyzos
+ */
+public class GoraConsumer extends ScheduledPollConsumer {
+
+ /**
+ * logger
+ */
+ private static final Logger LOG = LoggerFactory.getLogger(GoraConsumer.class);
+
+ /**
+ * GORA datastore
+ */
+ private final DataStore dataStore;
+
+ /**
+ * Camel-Gora endpoint configuration
+ */
+ private final GoraConfiguration configuration;
+
+ /**
+ * Camel Gora Query
+ */
+ private Query query;
+
+ /**
+ * executor service
+ */
+ private ExecutorService executor;
+
+ /**
+ * Poll run
+ */
+ private boolean firstRun;
+
+
+ /**
+ * Consumer Constructor
+ *
+ * @param endpoint Reference to the Camel-Gora endpoint
+ * @param processor Reference to Consumer Processor
+ * @param configuration Reference to Camel-Gora endpoint configuration
+ * @param dataStore Reference to the datastore
+ */
+ public GoraConsumer(final Endpoint endpoint,
+ final Processor processor,
+ final GoraConfiguration configuration,
+ final DataStore dataStore) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException {
+
+ super(endpoint, processor);
+
+ this.configuration = configuration;
+ this.dataStore = dataStore;
+
+ this.query = GoraUtils.constractQueryFromConfiguration(this.dataStore, this.configuration);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected int poll() throws Exception {
+
+ final Exchange exchange = this.getEndpoint().createExchange();
+
+ // compute time (aprox) since last update
+ if(firstRun){
+
+ this.query.setStartTime(System.currentTimeMillis());
+ }else{
+
+ this.query.setStartTime(System.currentTimeMillis() - getDelay());
+ }
+
+ //proceed with query
+ final Result result = query.execute();
+
+ LOG.trace("Processing exchange [{}]...", exchange);
+
+ try {
+
+ getProcessor().process(exchange);
+ } finally {
+
+ if (exchange.getException() != null) {
+
+ getExceptionHandler().handleException("Error processing exchange", exchange, exchange.getException());
+ }
+ }
+
+ return Long.valueOf(result.getOffset()).intValue();
+ }
+}
+
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraEndpoint.java
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraEndpoint.java b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraEndpoint.java
new file mode 100644
index 0000000..2674013
--- /dev/null
+++ b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraEndpoint.java
@@ -0,0 +1,105 @@
+/**
+ * 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.gora;
+
+import org.apache.camel.Consumer;
+import org.apache.camel.Processor;
+import org.apache.camel.Producer;
+import org.apache.camel.impl.DefaultEndpoint;
+import org.apache.gora.store.DataStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * Gora endpoint
+ *
+ * @author ipolyzos
+ */
+public class GoraEndpoint extends DefaultEndpoint {
+
+ /**
+ * logger
+ */
+ private static final Logger LOG = LoggerFactory.getLogger(GoraEndpoint.class);
+
+ /**
+ * Gora DataStore
+ */
+ private final DataStore dataStore;
+
+ /**
+ * Camel-Gora Endpoint Configuratopn
+ */
+ private GoraConfiguration configuration;
+
+ /**
+ * GORA endpoint default constructor
+ *
+ * @param uri Endpoint URI
+ * @param goraComponent Reference to the Camel-Gora component
+ * @param config Reference to Camel-Gora endpoint configuration
+ * @param dataStore Reference to Gora DataStore
+ */
+ public GoraEndpoint(final String uri,
+ final GoraComponent goraComponent,
+ final GoraConfiguration config,
+ final DataStore dataStore) {
+
+ super(uri, goraComponent);
+ this.configuration = config;
+ this.dataStore = dataStore;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Producer createProducer() throws Exception {
+
+ return new GoraProducer(this, this.configuration, this.dataStore);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Consumer createConsumer(final Processor processor) throws Exception {
+
+ //throw new UnsupportedOperationException("Not supported");
+ return new GoraConsumer(this,processor ,this.configuration, this.dataStore);
+ }
+
+ /**
+ * Get Configutation
+ *
+ * @return
+ */
+ public GoraConfiguration getConfiguration() {
+ return configuration;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isSingleton() {
+
+ return true;
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraOperation.java
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraOperation.java b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraOperation.java
new file mode 100644
index 0000000..3fd4284
--- /dev/null
+++ b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraOperation.java
@@ -0,0 +1,85 @@
+/**
+ * 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.gora;
+
+/**
+ * Camel-Gora Operations.
+ *
+ * @author ipolyzos
+ */
+public enum GoraOperation {
+
+ /**
+ * Gora "put" operation
+ */
+ PUT("put"),
+
+ /**
+ * Gora fetch/"get" operation
+ */
+ GET("get"),
+
+ /**
+ * Gora "delete" operation
+ */
+ DELETE("delete"),
+
+ /**
+ * Gora "get schema name" operation
+ */
+ GET_SCHEMA_NAME("getSchemaName"),
+
+ /**
+ * Gora "delete schema" operation
+ */
+ DELETE_SCHEMA("deleteSchema"),
+
+ /**
+ * Gora "create schema" operation
+ */
+ CREATE_SCHEMA("createSchema"),
+
+ /**
+ * Gora "query" operation
+ */
+ QUERY("query"),
+
+ /**
+ * Gora "deleteByQuery" operation
+ */
+ DELETE_BY_QUERY("deleteByQuery"),
+
+ /**
+ * Gora "schemaExists" operation
+ */
+ SCHEMA_EXIST("schemaExists");
+
+ /**
+ * Enum value
+ */
+ public final String value;
+
+ /**
+ * Enum constructor
+ *
+ * @param str Operation Value
+ */
+ private GoraOperation(final String str) {
+
+ value = str;
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraProducer.java b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraProducer.java
new file mode 100644
index 0000000..d395fc6
--- /dev/null
+++ b/components/camel-gora/src/main/java/org/apache/camel/component/gora/GoraProducer.java
@@ -0,0 +1,131 @@
+/**
+ * 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.gora;
+
+import org.apache.camel.Endpoint;
+import org.apache.camel.Exchange;
+import org.apache.camel.ServicePoolAware;
+import org.apache.camel.impl.DefaultProducer;
+import org.apache.gora.store.DataStore;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import java.util.Map;
+
+import static org.apache.camel.component.gora.utils.GoraUtils.*;
+
+/**
+ * Camel-Gora {@link DefaultProducer}.
+ *
+ * @author ipolyzos
+ */
+public class GoraProducer extends DefaultProducer implements ServicePoolAware {
+
+ /**
+ * logger
+ */
+ private static final Logger LOG = LoggerFactory.getLogger(GoraProducer.class);
+
+ /**
+ * Camel-Gora endpoint configuration
+ */
+ private final GoraConfiguration configuration;
+
+ /**
+ * GORA datastore
+ */
+ private final DataStore dataStore;
+
+ /**
+ * Constructor
+ *
+ * @param endpoint Reference to the Camel-Gora endpoint
+ * @param configuration Reference to Camel-Gora endpoint configuration
+ * @param dataStore Reference to the datastore
+ */
+ public GoraProducer(final Endpoint endpoint,
+ final GoraConfiguration configuration,
+ final DataStore dataStore) {
+
+ super(endpoint);
+ this.dataStore = dataStore;
+ this.configuration = configuration;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void process(final Exchange exchange) throws Exception {
+
+ final String operation = (String) exchange.getIn().getHeader(GoraAttribute.GORA_OPERATION.value);
+
+ if (operation == null || operation.isEmpty()) {
+
+ throw new RuntimeException("Gora operation is null or empty!");
+ }
+
+ Object result = 0; // 0 used as default response in order to avoid null body exception
+
+ if (GoraOperation.PUT.value.equalsIgnoreCase(operation)) {
+
+ dataStore.put(getKeyFromExchange(exchange), getValueFromExchange(exchange));
+ } else if (GoraOperation.GET.value.equalsIgnoreCase(operation)) {
+
+ result = dataStore.get(getKeyFromExchange(exchange));
+ } else if (GoraOperation.DELETE.value.equalsIgnoreCase(operation)) {
+
+ result = dataStore.delete(getKeyFromExchange(exchange));
+ } else if (GoraOperation.QUERY.value.equalsIgnoreCase(operation)) {
+
+ final Map<String,Object> props = exchange.getIn().getHeaders();
+ result = constractQueryFromPropertiesMap(props,dataStore,this.configuration).execute();
+ } else if (GoraOperation.DELETE_BY_QUERY.value.equalsIgnoreCase(operation)) {
+
+ final Map<String,Object> props = exchange.getIn().getHeaders();
+ result = dataStore.deleteByQuery(constractQueryFromPropertiesMap(props,dataStore,this.configuration));
+ } else if (GoraOperation.GET_SCHEMA_NAME.value.equalsIgnoreCase(operation)) {
+
+ result = dataStore.getSchemaName();
+ } else if (GoraOperation.DELETE_SCHEMA.value.equalsIgnoreCase(operation)) {
+
+ dataStore.deleteSchema();
+ } else if (GoraOperation.CREATE_SCHEMA.value.equalsIgnoreCase(operation)) {
+
+ dataStore.createSchema();
+ } else if (GoraOperation.SCHEMA_EXIST.value.equalsIgnoreCase(operation)) {
+
+ result = dataStore.schemaExists();
+ }else {
+
+ throw new RuntimeException("Unknown operation!");
+ }
+
+ /*
+ from the tests auto-flush seems not to work always
+ therefore a temporary solution is calling flush
+ on every action
+ */
+ if (configuration.isFlushOnEveryOperation()){
+ dataStore.flush();
+ }
+
+ exchange.getOut().setBody(result);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/main/java/org/apache/camel/component/gora/utils/GoraUtils.java
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/java/org/apache/camel/component/gora/utils/GoraUtils.java b/components/camel-gora/src/main/java/org/apache/camel/component/gora/utils/GoraUtils.java
new file mode 100644
index 0000000..bec9de4
--- /dev/null
+++ b/components/camel-gora/src/main/java/org/apache/camel/component/gora/utils/GoraUtils.java
@@ -0,0 +1,326 @@
+/**
+ * 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.gora.utils;
+
+import com.google.common.base.Objects;
+import org.apache.camel.Exchange;
+import org.apache.camel.component.gora.GoraAttribute;
+import org.apache.camel.component.gora.GoraConfiguration;
+import org.apache.commons.beanutils.PropertyUtils;
+import org.apache.gora.persistency.Persistent;
+import org.apache.gora.query.Query;
+import org.apache.gora.store.DataStore;
+import org.apache.gora.store.DataStoreFactory;
+import org.apache.gora.util.GoraException;
+import org.apache.gora.util.IOUtils;
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.Map;
+
+import static com.google.common.base.Preconditions.*;
+
+/**
+ * GoraUtil class contain utility methods for the
+ * camel component.
+ *
+ * @author ipolyzos
+ */
+public class GoraUtils {
+
+
+
+ /**
+ * Private Constructor to prevent
+ * instantiation of the class.
+ */
+ private GoraUtils() {
+
+ // utility Class
+ }
+
+ /**
+ * Utility method to construct a new query from the exchange
+ *
+ * <b>NOTE:</b> values used in order construct the query
+ * should be stored in the "in" message headers.
+ *
+ * @param dataStore
+ * @param conf
+ * @return
+ * @throws ClassNotFoundException
+ * @throws IllegalAccessException
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ */
+ public static Query<?, ? extends Persistent> constractQueryFromConfiguration(final DataStore dataStore,
+ final GoraConfiguration conf) throws ClassNotFoundException, IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
+
+ final Query query = dataStore.newQuery();
+
+ if (configurationExist(GoraAttribute.GORA_QUERY_START_TIME, conf)) {
+ query.setStartTime(getAttributeAsLong(GoraAttribute.GORA_QUERY_START_TIME, conf));
+ }
+
+ if (configurationExist(GoraAttribute.GORA_QUERY_END_TIME, conf)) {
+ query.setEndTime(getAttributeAsLong(GoraAttribute.GORA_QUERY_END_TIME, conf));
+ }
+
+ if (configurationExist(GoraAttribute.GORA_QUERY_LIMIT, conf)) {
+ query.setLimit(getAttributeAsLong(GoraAttribute.GORA_QUERY_LIMIT, conf));
+ }
+
+ if (configurationExist(GoraAttribute.GORA_QUERY_TIME_RANGE_FROM, conf)
+ && configurationExist(GoraAttribute.GORA_QUERY_TIME_RANGE_TO, conf)) {
+ query.setTimeRange(getAttributeAsLong(GoraAttribute.GORA_QUERY_TIME_RANGE_FROM, conf),
+ getAttributeAsLong(GoraAttribute.GORA_QUERY_TIME_RANGE_TO, conf));
+ }
+
+ if (configurationExist(GoraAttribute.GORA_QUERY_TIMESTAMP, conf)) {
+ query.setTimestamp(getAttributeAsLong(GoraAttribute.GORA_QUERY_TIMESTAMP, conf));
+ }
+
+ if (configurationExist(GoraAttribute.GORA_QUERY_START_KEY, conf)) {
+ query.setStartKey(getAttribute(GoraAttribute.GORA_QUERY_START_KEY, conf));
+ }
+
+ if (configurationExist(GoraAttribute.GORA_QUERY_END_KEY, conf)) {
+ query.setEndKey(getAttribute(GoraAttribute.GORA_QUERY_END_KEY, conf));
+ }
+
+ if (configurationExist(GoraAttribute.GORA_QUERY_KEY_RANGE_FROM, conf)
+ && configurationExist(GoraAttribute.GORA_QUERY_KEY_RANGE_TO, conf)) {
+ query.setKeyRange(getAttribute(GoraAttribute.GORA_QUERY_KEY_RANGE_FROM, conf),
+ getAttribute(GoraAttribute.GORA_QUERY_KEY_RANGE_TO, conf));
+ }
+
+ return query;
+ }
+
+ /**
+ * Utility method to construct a new query from the exchange
+ *
+ * <b>NOTE:</b> values used in order construct the query
+ * should be stored in the "in" message headers.
+ *
+ * @param propertiesMap
+ * @param dataStore
+ * @param conf
+ * @return
+ * @throws ClassNotFoundException
+ */
+ public static Query<?, ? extends Persistent> constractQueryFromPropertiesMap(final Map<String, ?> propertiesMap,
+ final DataStore dataStore,
+ final GoraConfiguration conf) throws ClassNotFoundException {
+
+
+ final Query query = dataStore.newQuery();
+
+ if (propertyExist(GoraAttribute.GORA_QUERY_START_TIME, propertiesMap)) {
+ query.setStartTime(getPropertyAsLong(GoraAttribute.GORA_QUERY_START_TIME, propertiesMap));
+ }
+
+ if (propertyExist(GoraAttribute.GORA_QUERY_END_TIME, propertiesMap)) {
+ query.setEndTime(getPropertyAsLong(GoraAttribute.GORA_QUERY_END_TIME, propertiesMap));
+ }
+
+ if (propertyExist(GoraAttribute.GORA_QUERY_LIMIT, propertiesMap)) {
+ query.setLimit(getPropertyAsLong(GoraAttribute.GORA_QUERY_LIMIT, propertiesMap));
+ }
+
+ if (propertyExist(GoraAttribute.GORA_QUERY_TIME_RANGE_FROM, propertiesMap)
+ && propertyExist(GoraAttribute.GORA_QUERY_TIME_RANGE_TO, propertiesMap)) {
+ query.setTimeRange(getPropertyAsLong(GoraAttribute.GORA_QUERY_TIME_RANGE_FROM, propertiesMap),
+ getPropertyAsLong(GoraAttribute.GORA_QUERY_TIME_RANGE_TO, propertiesMap));
+ }
+
+ if (propertyExist(GoraAttribute.GORA_QUERY_TIMESTAMP, propertiesMap)) {
+ query.setTimestamp(getPropertyAsLong(GoraAttribute.GORA_QUERY_TIMESTAMP, propertiesMap));
+ }
+
+ if (propertyExist(GoraAttribute.GORA_QUERY_START_KEY, propertiesMap)) {
+ query.setStartKey(getProperty(GoraAttribute.GORA_QUERY_START_KEY, propertiesMap));
+ }
+
+ if (propertyExist(GoraAttribute.GORA_QUERY_END_KEY, propertiesMap)) {
+ query.setStartKey(getProperty(GoraAttribute.GORA_QUERY_END_KEY, propertiesMap));
+ }
+
+ if (propertyExist(GoraAttribute.GORA_QUERY_KEY_RANGE_FROM, propertiesMap)
+ && propertyExist(GoraAttribute.GORA_QUERY_KEY_RANGE_TO, propertiesMap)) {
+ query.setKeyRange(getProperty(GoraAttribute.GORA_QUERY_KEY_RANGE_FROM, propertiesMap),
+ getProperty(GoraAttribute.GORA_QUERY_KEY_RANGE_TO, propertiesMap));
+ }
+
+ return query;
+ }
+
+ /**
+ * Utility method to check if a value exist in the configuration class
+ *
+ * <b>NOTE:</>
+ * Checks only if is not null
+ *
+ * @param attr
+ * @param conf
+ * @return
+ * @throws IllegalAccessException
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ */
+ protected static boolean configurationExist(final GoraAttribute attr,
+ final GoraConfiguration conf) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
+ return (PropertyUtils.getSimpleProperty(conf, attr.value) != null);
+ }
+
+ /**
+ * Utility method to check if a value exist in the properties map
+ *
+ * @param attr
+ * @param propertiesMap
+ * @return
+ */
+ protected static boolean propertyExist(final GoraAttribute attr,
+ final Map<String, ?> propertiesMap) {
+
+ return propertiesMap.containsKey(attr.value);
+ }
+
+
+ /**
+ * Utility method to extract value from configuration
+ *
+ * @param attr
+ * @param conf
+ * @return
+ * @throws IllegalAccessException
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ */
+ protected static Object getAttribute(final GoraAttribute attr,
+ final GoraConfiguration conf) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
+ return PropertyUtils.getSimpleProperty(conf, attr.value);
+ }
+
+ /**
+ * Utility method to extract value from configuration as String
+ *
+ * @param attr
+ * @param conf
+ * @return
+ * @throws IllegalAccessException
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ */
+ protected static String getAttributeAsString(final GoraAttribute attr,
+ final GoraConfiguration conf) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
+ return String.valueOf(getAttribute(attr, conf));
+ }
+
+
+ /**
+ * Utility method to extract value from configuration as Long
+ *
+ * @param attr
+ * @param conf
+ * @return
+ * @throws IllegalAccessException
+ * @throws NoSuchMethodException
+ * @throws InvocationTargetException
+ */
+ protected static Long getAttributeAsLong(final GoraAttribute attr,
+ final GoraConfiguration conf) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException {
+
+ return Long.parseLong(getAttributeAsString(attr,conf));
+ }
+
+ /**
+ * Utility method to extract value of a map
+ *
+ * @param attr
+ * @param propertiesMap
+ * @return
+ */
+ protected static Object getProperty(final GoraAttribute attr,
+ final Map<String, ?> propertiesMap) {
+
+ return propertiesMap.get(attr.value);
+ }
+
+ /**
+ * Utility method to extract value of a map as String
+ *
+ * @param attr
+ * @param propertiesMap
+ * @return
+ */
+ protected static String getPropertyAsString(final GoraAttribute attr,
+ final Map<String, ?> propertiesMap) {
+
+ return String.valueOf(getProperty(attr, propertiesMap));
+ }
+
+ /**
+ * Utility method to extract value of a map as long
+ *
+ * @param attr
+ * @param propertiesMap
+ * @return
+ */
+ protected static Long getPropertyAsLong(final GoraAttribute attr,
+ final Map<String, ?> propertiesMap) {
+
+ return Long.parseLong(getPropertyAsString(attr, propertiesMap));
+ }
+
+
+ /**
+ * Utility method to extract GORA key from the exchange
+ *
+ * <b>NOTE:</b> key value expected to be stored
+ * in the "in" message headers.
+ *
+ * @param exchange The Camel Exchange
+ * @return The key
+ */
+ public static Object getKeyFromExchange(Exchange exchange) {
+
+ final Object key = exchange.getIn().getHeader(GoraAttribute.GORA_KEY.value);
+
+ checkNotNull(key, "Key should not be null!");
+ return key;
+ }
+
+ /**
+ * Utility method to extract the value from the exchange
+ *
+ * <b>NOTE:</b> the value expected to be instance
+ * of persistent type.
+ *
+ * @param exchange The Camel Exchange
+ * @return The value
+ */
+ public static Persistent getValueFromExchange(Exchange exchange) {
+
+ return exchange.getIn().getBody(Persistent.class);
+ }
+
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/main/resources/META-INF/LICENSE.txt
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/resources/META-INF/LICENSE.txt b/components/camel-gora/src/main/resources/META-INF/LICENSE.txt
new file mode 100644
index 0000000..6b0b127
--- /dev/null
+++ b/components/camel-gora/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/8ad60f0f/components/camel-gora/src/main/resources/META-INF/NOTICE.txt
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/resources/META-INF/NOTICE.txt b/components/camel-gora/src/main/resources/META-INF/NOTICE.txt
new file mode 100644
index 0000000..2e215bf
--- /dev/null
+++ b/components/camel-gora/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/8ad60f0f/components/camel-gora/src/main/resources/META-INF/services/org/apache/camel/component/gora
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/main/resources/META-INF/services/org/apache/camel/component/gora b/components/camel-gora/src/main/resources/META-INF/services/org/apache/camel/component/gora
new file mode 100644
index 0000000..4cb9abb
--- /dev/null
+++ b/components/camel-gora/src/main/resources/META-INF/services/org/apache/camel/component/gora
@@ -0,0 +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.gora.GoraComponent
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraConfigurationTest.java
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraConfigurationTest.java b/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraConfigurationTest.java
new file mode 100644
index 0000000..dcfd548
--- /dev/null
+++ b/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraConfigurationTest.java
@@ -0,0 +1,78 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.gora;
+
+import org.junit.Test;
+
+/**
+ * GORA Configuration Tests
+ *
+ * @author ipolyzos
+ */
+public class GoraConfigurationTest {
+
+
+ @Test(expected = IllegalArgumentException.class)
+ public void setKeyClassClassShouldThrowExceptionIfNull(){
+
+ final GoraConfiguration conf = new GoraConfiguration();
+ conf.setValueClass(null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void setKeyClassShouldThrowExceptionIfEmpty(){
+
+ final GoraConfiguration conf = new GoraConfiguration();
+ conf.setValueClass("");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void setValueClassClassShouldThrowExceptionIfNull(){
+
+ final GoraConfiguration conf = new GoraConfiguration();
+ conf.setValueClass(null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void setValueClassClassShouldThrowExceptionIfEmpty(){
+
+ final GoraConfiguration conf = new GoraConfiguration();
+ conf.setValueClass("");
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void setDataStoreClassShouldThrowExceptionIfNull(){
+
+ final GoraConfiguration conf = new GoraConfiguration();
+ conf.setDataStoreClass(null);
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void setDataStoreClassShouldThrowExceptionIfEmpty(){
+
+ final GoraConfiguration conf = new GoraConfiguration();
+ conf.setDataStoreClass("");
+ }
+
+ @Test(expected = NullPointerException.class)
+ public void setHadoopConfigurationShouldThrowExceptionIfNull(){
+
+ final GoraConfiguration conf = new GoraConfiguration();
+ conf.setHadoopConfiguration(null);
+ }
+}
http://git-wip-us.apache.org/repos/asf/camel/blob/8ad60f0f/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraConsumerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraConsumerTest.java b/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraConsumerTest.java
new file mode 100644
index 0000000..605591c
--- /dev/null
+++ b/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraConsumerTest.java
@@ -0,0 +1,103 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.camel.component.gora;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.ExchangePattern;
+import org.apache.camel.Message;
+import org.apache.camel.Processor;
+import org.apache.camel.component.gora.utils.GoraUtils;
+import org.apache.gora.query.Query;
+import org.apache.gora.store.DataStore;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.lang.reflect.InvocationTargetException;
+
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+/**
+ * GORA Consumer Tests
+ *
+ * @author ipolyzos
+ */
+public class GoraConsumerTest extends GoraTestSupport {
+
+ /**
+ * Mock CamelExchange
+ */
+ private Exchange mockCamelExchange;
+
+ /**
+ * Mock Gora Endpoint
+ */
+ private GoraEndpoint mockGoraEndpoint;
+
+ /**
+ * Mock Gora Configuration
+ */
+ private GoraConfiguration mockGoraConfiguration;
+
+ /**
+ * Mock Camel Message
+ */
+ private Message mockCamelMessage;
+
+ /**
+ * Mock Gora DataStore
+ */
+ private DataStore mockDatastore;
+
+ /**
+ * Mock Processor
+ */
+ private Processor mockGoraProcessor;
+
+ /**
+ * Mock GoraUtils
+ */
+ private GoraUtils mockGoraUtils;
+
+ @Before
+ public void setUp() {
+
+ //setup mocks
+ mockCamelExchange = mock(Exchange.class);
+ mockGoraEndpoint = mock(GoraEndpoint.class);
+ mockGoraConfiguration = mock(GoraConfiguration.class);
+ mockCamelMessage = mock(Message.class);
+ mockDatastore = mock(DataStore.class);
+ mockGoraUtils = mock(GoraUtils.class);
+
+ //setup default conditions
+ when(mockCamelExchange.getIn()).thenReturn(mockCamelMessage);
+ when(mockCamelExchange.getPattern()).thenReturn(ExchangePattern.InOnly);
+ }
+
+
+ @Test
+ public void consumerInstantiationWithMocksShouldSucceed() throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException {
+
+
+ final Query mockQuery = mock(Query.class);
+ when(mockDatastore.newQuery()).thenReturn(mockQuery);
+ GoraConsumer goraConsumer = new GoraConsumer(mockGoraEndpoint, mockGoraProcessor, mockGoraConfiguration, mockDatastore);
+ }
+
+}