Return-Path: X-Original-To: apmail-camel-commits-archive@www.apache.org Delivered-To: apmail-camel-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id EF0FF1086C for ; Tue, 27 May 2014 08:30:30 +0000 (UTC) Received: (qmail 57683 invoked by uid 500); 27 May 2014 08:30:30 -0000 Delivered-To: apmail-camel-commits-archive@camel.apache.org Received: (qmail 57539 invoked by uid 500); 27 May 2014 08:30:30 -0000 Mailing-List: contact commits-help@camel.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@camel.apache.org Delivered-To: mailing list commits@camel.apache.org Received: (qmail 57510 invoked by uid 99); 27 May 2014 08:30:30 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Tue, 27 May 2014 08:30:30 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 82CEB9A663A; Tue, 27 May 2014 08:30:30 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: ningjiang@apache.org To: commits@camel.apache.org Date: Tue, 27 May 2014 08:30:32 -0000 Message-Id: <8b9a88807dd240eea0181f9d06aff647@git.apache.org> In-Reply-To: <28312df0c0b64fb0a178147a51cac306@git.apache.org> References: <28312df0c0b64fb0a178147a51cac306@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [3/8] git commit: Fixed the CS errors of camel-gora Fixed the CS errors of camel-gora Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/481fce9a Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/481fce9a Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/481fce9a Branch: refs/heads/master Commit: 481fce9aa7877f1019821558e4e3646f4c817083 Parents: 5836ac0 Author: Willem Jiang Authored: Tue Nov 19 14:35:45 2013 +0800 Committer: Willem Jiang Committed: Tue May 27 16:11:33 2014 +0800 ---------------------------------------------------------------------- components/camel-gora/pom.xml | 2 +- .../camel/component/gora/GoraComponent.java | 20 ++++------ .../camel/component/gora/GoraConfiguration.java | 12 ++---- .../camel/component/gora/GoraConsumer.java | 20 ++++------ .../camel/component/gora/GoraEndpoint.java | 10 ++--- .../camel/component/gora/GoraProducer.java | 25 ++++++------ .../camel/component/gora/utils/GoraUtils.java | 40 ++++++++----------- .../component/gora/GoraConfigurationTest.java | 15 ++++--- .../camel/component/gora/GoraConsumerTest.java | 14 ++----- .../camel/component/gora/GoraProducerTest.java | 41 ++++++++------------ .../camel/component/gora/GoraTestSupport.java | 1 - .../component/gora/utils/GoraUtilsTest.java | 8 ++-- 12 files changed, 86 insertions(+), 122 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/components/camel-gora/pom.xml ---------------------------------------------------------------------- diff --git a/components/camel-gora/pom.xml b/components/camel-gora/pom.xml index f2318ff..0f9aef1 100644 --- a/components/camel-gora/pom.xml +++ b/components/camel-gora/pom.xml @@ -23,7 +23,7 @@ org.apache.camel components - 2.12-SNAPSHOT + 2.13-SNAPSHOT camel-gora http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/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 index 03f2573..0a162fd 100644 --- 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 @@ -17,33 +17,29 @@ package org.apache.camel.component.gora; -import org.apache.camel.CamelContext; +import java.io.IOException; +import java.util.Map; +import java.util.Properties; + 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 dataStore; + private DataStore dataStore; /** * GORA properties @@ -87,10 +83,10 @@ public class GoraComponent extends DefaultComponent { try { - init(config); + init(config); } catch (IOException ex) { - throw new RuntimeException(ex); + throw new RuntimeException(ex); } return new GoraEndpoint(uri, this, config, dataStore); @@ -101,7 +97,7 @@ public class GoraComponent extends DefaultComponent { * * @return DataStore */ - public DataStore getDataStore() { + public DataStore getDataStore() { return dataStore; } http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/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 index 3deabee..5456522 100644 --- 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 @@ -27,7 +27,6 @@ import static com.google.common.base.Strings.isNullOrEmpty; /** * Gora Configuration. * - * @author ipolyzos */ public class GoraConfiguration { @@ -148,8 +147,7 @@ public class GoraConfiguration { */ public void setKeyClass(final String keyClass) { - if (isNullOrEmpty(keyClass)){ - + if (isNullOrEmpty(keyClass)) { throw new IllegalArgumentException("Key class could not be null or empty!"); } @@ -173,8 +171,7 @@ public class GoraConfiguration { */ public void setValueClass(final String valueClass) { - if (isNullOrEmpty(valueClass)){ - + if (isNullOrEmpty(valueClass)) { throw new IllegalArgumentException("Value class could not be null or empty!"); } @@ -199,8 +196,7 @@ public class GoraConfiguration { public void setDataStoreClass(String dataStoreClass) { - if (isNullOrEmpty(dataStoreClass)){ - + if (isNullOrEmpty(dataStoreClass)) { throw new IllegalArgumentException("DataStore class could not be null or empty!"); } @@ -470,7 +466,7 @@ public class GoraConfiguration { */ public void setHadoopConfiguration(Configuration hadoopConfiguration) { - checkNotNull(hadoopConfiguration,"Hadoop Configuration could not be null!"); + checkNotNull(hadoopConfiguration, "Hadoop Configuration could not be null!"); this.hadoopConfiguration = hadoopConfiguration; } } http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/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 index 51983a4..24c2e22 100644 --- 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 @@ -17,27 +17,25 @@ package org.apache.camel.component.gora; +import java.lang.reflect.InvocationTargetException; +import java.util.concurrent.ExecutorService; + 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.persistency.Persistent; 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 { @@ -49,7 +47,7 @@ public class GoraConsumer extends ScheduledPollConsumer { /** * GORA datastore */ - private final DataStore dataStore; + private final DataStore dataStore; /** * Camel-Gora endpoint configuration @@ -83,7 +81,7 @@ public class GoraConsumer extends ScheduledPollConsumer { public GoraConsumer(final Endpoint endpoint, final Processor processor, final GoraConfiguration configuration, - final DataStore dataStore) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { + final DataStore dataStore) throws ClassNotFoundException, NoSuchMethodException, InvocationTargetException, IllegalAccessException { super(endpoint, processor); @@ -102,11 +100,9 @@ public class GoraConsumer extends ScheduledPollConsumer { final Exchange exchange = this.getEndpoint().createExchange(); // compute time (aprox) since last update - if(firstRun){ - + if (firstRun) { this.query.setStartTime(System.currentTimeMillis()); - }else{ - + } else { this.query.setStartTime(System.currentTimeMillis() - getDelay()); } http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/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 index 2674013..df5c628 100644 --- 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 @@ -21,6 +21,7 @@ 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.persistency.Persistent; import org.apache.gora.store.DataStore; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -40,7 +41,7 @@ public class GoraEndpoint extends DefaultEndpoint { /** * Gora DataStore */ - private final DataStore dataStore; + private final DataStore dataStore; /** * Camel-Gora Endpoint Configuratopn @@ -58,7 +59,7 @@ public class GoraEndpoint extends DefaultEndpoint { public GoraEndpoint(final String uri, final GoraComponent goraComponent, final GoraConfiguration config, - final DataStore dataStore) { + final DataStore dataStore) { super(uri, goraComponent); this.configuration = config; @@ -79,9 +80,8 @@ public class GoraEndpoint extends DefaultEndpoint { */ @Override public Consumer createConsumer(final Processor processor) throws Exception { - - //throw new UnsupportedOperationException("Not supported"); - return new GoraConsumer(this,processor ,this.configuration, this.dataStore); + + return new GoraConsumer(this, processor, this.configuration, this.dataStore); } /** http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/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 index d395fc6..7e25fd5 100644 --- 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 @@ -17,22 +17,25 @@ package org.apache.camel.component.gora; +import java.util.Map; + 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.persistency.Persistent; 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.constractQueryFromPropertiesMap; +import static org.apache.camel.component.gora.utils.GoraUtils.getKeyFromExchange; +import static org.apache.camel.component.gora.utils.GoraUtils.getValueFromExchange; -import static org.apache.camel.component.gora.utils.GoraUtils.*; /** * Camel-Gora {@link DefaultProducer}. * - * @author ipolyzos */ public class GoraProducer extends DefaultProducer implements ServicePoolAware { @@ -49,7 +52,7 @@ public class GoraProducer extends DefaultProducer implements ServicePoolAware { /** * GORA datastore */ - private final DataStore dataStore; + private final DataStore dataStore; /** * Constructor @@ -60,7 +63,7 @@ public class GoraProducer extends DefaultProducer implements ServicePoolAware { */ public GoraProducer(final Endpoint endpoint, final GoraConfiguration configuration, - final DataStore dataStore) { + final DataStore dataStore) { super(endpoint); this.dataStore = dataStore; @@ -93,12 +96,12 @@ public class GoraProducer extends DefaultProducer implements ServicePoolAware { result = dataStore.delete(getKeyFromExchange(exchange)); } else if (GoraOperation.QUERY.value.equalsIgnoreCase(operation)) { - final Map props = exchange.getIn().getHeaders(); - result = constractQueryFromPropertiesMap(props,dataStore,this.configuration).execute(); + final Map props = exchange.getIn().getHeaders(); + result = constractQueryFromPropertiesMap(props, dataStore, this.configuration).execute(); } else if (GoraOperation.DELETE_BY_QUERY.value.equalsIgnoreCase(operation)) { - final Map props = exchange.getIn().getHeaders(); - result = dataStore.deleteByQuery(constractQueryFromPropertiesMap(props,dataStore,this.configuration)); + final Map props = exchange.getIn().getHeaders(); + result = dataStore.deleteByQuery(constractQueryFromPropertiesMap(props, dataStore, this.configuration)); } else if (GoraOperation.GET_SCHEMA_NAME.value.equalsIgnoreCase(operation)) { result = dataStore.getSchemaName(); @@ -111,7 +114,7 @@ public class GoraProducer extends DefaultProducer implements ServicePoolAware { } else if (GoraOperation.SCHEMA_EXIST.value.equalsIgnoreCase(operation)) { result = dataStore.schemaExists(); - }else { + } else { throw new RuntimeException("Unknown operation!"); } @@ -121,7 +124,7 @@ public class GoraProducer extends DefaultProducer implements ServicePoolAware { therefore a temporary solution is calling flush on every action */ - if (configuration.isFlushOnEveryOperation()){ + if (configuration.isFlushOnEveryOperation()) { dataStore.flush(); } http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/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 index bec9de4..58c4cf6 100644 --- 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 @@ -17,7 +17,9 @@ package org.apache.camel.component.gora.utils; -import com.google.common.base.Objects; +import java.lang.reflect.InvocationTargetException; +import java.util.Map; + import org.apache.camel.Exchange; import org.apache.camel.component.gora.GoraAttribute; import org.apache.camel.component.gora.GoraConfiguration; @@ -25,25 +27,16 @@ 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.*; +import static com.google.common.base.Preconditions.checkNotNull; /** * GoraUtil class contain utility methods for the * camel component. * - * @author ipolyzos */ -public class GoraUtils { - - - +public final class GoraUtils { + /** * Private Constructor to prevent * instantiation of the class. @@ -67,11 +60,10 @@ public class GoraUtils { * @throws NoSuchMethodException * @throws InvocationTargetException */ - public static Query constractQueryFromConfiguration(final DataStore dataStore, - final GoraConfiguration conf) throws ClassNotFoundException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { - + public static Query constractQueryFromConfiguration(final DataStore dataStore, final GoraConfiguration conf) + throws ClassNotFoundException, IllegalAccessException, NoSuchMethodException, InvocationTargetException { - final Query query = dataStore.newQuery(); + final Query query = dataStore.newQuery(); if (configurationExist(GoraAttribute.GORA_QUERY_START_TIME, conf)) { query.setStartTime(getAttributeAsLong(GoraAttribute.GORA_QUERY_START_TIME, conf)); @@ -124,12 +116,12 @@ public class GoraUtils { * @return * @throws ClassNotFoundException */ - public static Query constractQueryFromPropertiesMap(final Map propertiesMap, - final DataStore dataStore, + public static Query constractQueryFromPropertiesMap(final Map propertiesMap, + final DataStore dataStore, final GoraConfiguration conf) throws ClassNotFoundException { - final Query query = dataStore.newQuery(); + final Query query = dataStore.newQuery(); if (propertyExist(GoraAttribute.GORA_QUERY_START_TIME, propertiesMap)) { query.setStartTime(getPropertyAsLong(GoraAttribute.GORA_QUERY_START_TIME, propertiesMap)); @@ -145,8 +137,8 @@ public class GoraUtils { 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)); + 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)) { @@ -186,7 +178,7 @@ public class GoraUtils { protected static boolean configurationExist(final GoraAttribute attr, final GoraConfiguration conf) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { - return (PropertyUtils.getSimpleProperty(conf, attr.value) != null); + return PropertyUtils.getSimpleProperty(conf, attr.value) != null; } /** @@ -249,7 +241,7 @@ public class GoraUtils { protected static Long getAttributeAsLong(final GoraAttribute attr, final GoraConfiguration conf) throws IllegalAccessException, NoSuchMethodException, InvocationTargetException { - return Long.parseLong(getAttributeAsString(attr,conf)); + return Long.parseLong(getAttributeAsString(attr, conf)); } /** http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/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 index dcfd548..ef20e31 100644 --- 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 @@ -22,55 +22,54 @@ import org.junit.Test; /** * GORA Configuration Tests * - * @author ipolyzos */ public class GoraConfigurationTest { @Test(expected = IllegalArgumentException.class) - public void setKeyClassClassShouldThrowExceptionIfNull(){ + public void setKeyClassClassShouldThrowExceptionIfNull() { final GoraConfiguration conf = new GoraConfiguration(); conf.setValueClass(null); } @Test(expected = IllegalArgumentException.class) - public void setKeyClassShouldThrowExceptionIfEmpty(){ + public void setKeyClassShouldThrowExceptionIfEmpty() { final GoraConfiguration conf = new GoraConfiguration(); conf.setValueClass(""); } @Test(expected = IllegalArgumentException.class) - public void setValueClassClassShouldThrowExceptionIfNull(){ + public void setValueClassClassShouldThrowExceptionIfNull() { final GoraConfiguration conf = new GoraConfiguration(); conf.setValueClass(null); } @Test(expected = IllegalArgumentException.class) - public void setValueClassClassShouldThrowExceptionIfEmpty(){ + public void setValueClassClassShouldThrowExceptionIfEmpty() { final GoraConfiguration conf = new GoraConfiguration(); conf.setValueClass(""); } @Test(expected = IllegalArgumentException.class) - public void setDataStoreClassShouldThrowExceptionIfNull(){ + public void setDataStoreClassShouldThrowExceptionIfNull() { final GoraConfiguration conf = new GoraConfiguration(); conf.setDataStoreClass(null); } @Test(expected = IllegalArgumentException.class) - public void setDataStoreClassShouldThrowExceptionIfEmpty(){ + public void setDataStoreClassShouldThrowExceptionIfEmpty() { final GoraConfiguration conf = new GoraConfiguration(); conf.setDataStoreClass(""); } @Test(expected = NullPointerException.class) - public void setHadoopConfigurationShouldThrowExceptionIfNull(){ + public void setHadoopConfigurationShouldThrowExceptionIfNull() { final GoraConfiguration conf = new GoraConfiguration(); conf.setHadoopConfiguration(null); http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/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 index 605591c..f2d22b0 100644 --- 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 @@ -17,25 +17,23 @@ package org.apache.camel.component.gora; +import java.lang.reflect.InvocationTargetException; + 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 { @@ -68,11 +66,7 @@ public class GoraConsumerTest extends GoraTestSupport { * Mock Processor */ private Processor mockGoraProcessor; - - /** - * Mock GoraUtils - */ - private GoraUtils mockGoraUtils; + @Before public void setUp() { @@ -83,7 +77,7 @@ public class GoraConsumerTest extends GoraTestSupport { mockGoraConfiguration = mock(GoraConfiguration.class); mockCamelMessage = mock(Message.class); mockDatastore = mock(DataStore.class); - mockGoraUtils = mock(GoraUtils.class); + //setup default conditions when(mockCamelExchange.getIn()).thenReturn(mockCamelMessage); http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraProducerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraProducerTest.java b/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraProducerTest.java index 1bf4df8..4012e82 100644 --- a/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraProducerTest.java +++ b/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraProducerTest.java @@ -17,45 +17,36 @@ package org.apache.camel.component.gora; +import java.util.Map; + import org.apache.camel.Exchange; import org.apache.camel.ExchangePattern; import org.apache.camel.Message; import org.apache.camel.component.gora.utils.GoraUtils; import org.apache.gora.persistency.Persistent; -import org.apache.gora.persistency.StateManager; import org.apache.gora.query.Query; import org.apache.gora.query.impl.QueryBase; import org.apache.gora.store.DataStore; import org.junit.Before; -import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.internal.verification.VerificationModeFactory; -import org.mockito.stubbing.OngoingStubbing; -import org.mockito.verification.VerificationMode; -import org.powermock.api.mockito.PowerMockito; import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.modules.junit4.PowerMockRunner; -import java.util.*; - - import static org.mockito.Mockito.atLeastOnce; import static org.mockito.Mockito.atMost; import static org.mockito.Mockito.verify; import static org.mockito.internal.verification.VerificationModeFactory.times; -import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.mock; -import static org.powermock.api.mockito.PowerMockito.when; +import static org.powermock.api.mockito.PowerMockito.mockStatic; import static org.powermock.api.mockito.PowerMockito.verifyStatic; +import static org.powermock.api.mockito.PowerMockito.when; /** * GORA Producer Tests * * TODO: NOTE: Query methods does not yet has tests * - * @author ipolyzos */ @RunWith(PowerMockRunner.class) @PrepareForTest(GoraUtils.class) @@ -104,7 +95,7 @@ public class GoraProducerTest extends GoraTestSupport { @Test(expected = RuntimeException.class) public void processShouldThrowExceptionIfOperationIsNull() throws Exception { - final GoraProducer producer = new GoraProducer(mockGoraEndpoint,mockGoraConfiguration,mockDatastore); + final GoraProducer producer = new GoraProducer(mockGoraEndpoint, mockGoraConfiguration, mockDatastore); producer.process(mockCamelExchange); } @@ -115,7 +106,7 @@ public class GoraProducerTest extends GoraTestSupport { when(mockCamelExchange.getIn()).thenReturn(mockCamelMessage); when(mockCamelMessage.getHeader(GoraAttribute.GORA_OPERATION.value)).thenReturn("dah"); - final GoraProducer producer = new GoraProducer(mockGoraEndpoint,mockGoraConfiguration,mockDatastore); + final GoraProducer producer = new GoraProducer(mockGoraEndpoint, mockGoraConfiguration, mockDatastore); producer.process(mockCamelExchange); verify(mockCamelExchange, atMost(1)).getIn(); @@ -137,14 +128,14 @@ public class GoraProducerTest extends GoraTestSupport { final Message outMessage = mock(Message.class); when(mockCamelExchange.getOut()).thenReturn(outMessage); - final GoraProducer producer = new GoraProducer(mockGoraEndpoint,mockGoraConfiguration,mockDatastore); + final GoraProducer producer = new GoraProducer(mockGoraEndpoint, mockGoraConfiguration, mockDatastore); producer.process(mockCamelExchange); verify(mockCamelExchange, atLeastOnce()).getIn(); verify(mockCamelMessage, atLeastOnce()).getHeader(GoraAttribute.GORA_OPERATION.value); verify(mockCamelMessage, atLeastOnce()).getHeader(GoraAttribute.GORA_KEY.value); verify(mockCamelMessage, atLeastOnce()).getBody(Persistent.class); - verify(mockDatastore, atMost(1)).put(sampleKey,sampleValue); + verify(mockDatastore, atMost(1)).put(sampleKey, sampleValue); } @Test @@ -159,7 +150,7 @@ public class GoraProducerTest extends GoraTestSupport { final Message outMessage = mock(Message.class); when(mockCamelExchange.getOut()).thenReturn(outMessage); - final GoraProducer producer = new GoraProducer(mockGoraEndpoint,mockGoraConfiguration,mockDatastore); + final GoraProducer producer = new GoraProducer(mockGoraEndpoint, mockGoraConfiguration, mockDatastore); producer.process(mockCamelExchange); verify(mockCamelExchange, atLeastOnce()).getIn(); @@ -180,7 +171,7 @@ public class GoraProducerTest extends GoraTestSupport { final Message outMessage = mock(Message.class); when(mockCamelExchange.getOut()).thenReturn(outMessage); - final GoraProducer producer = new GoraProducer(mockGoraEndpoint,mockGoraConfiguration,mockDatastore); + final GoraProducer producer = new GoraProducer(mockGoraEndpoint, mockGoraConfiguration, mockDatastore); producer.process(mockCamelExchange); verify(mockCamelExchange, atLeastOnce()).getIn(); @@ -198,7 +189,7 @@ public class GoraProducerTest extends GoraTestSupport { final Message outMessage = mock(Message.class); when(mockCamelExchange.getOut()).thenReturn(outMessage); - final GoraProducer producer = new GoraProducer(mockGoraEndpoint,mockGoraConfiguration,mockDatastore); + final GoraProducer producer = new GoraProducer(mockGoraEndpoint, mockGoraConfiguration, mockDatastore); producer.process(mockCamelExchange); verify(mockCamelExchange, atLeastOnce()).getIn(); @@ -215,7 +206,7 @@ public class GoraProducerTest extends GoraTestSupport { final Message outMessage = mock(Message.class); when(mockCamelExchange.getOut()).thenReturn(outMessage); - final GoraProducer producer = new GoraProducer(mockGoraEndpoint,mockGoraConfiguration,mockDatastore); + final GoraProducer producer = new GoraProducer(mockGoraEndpoint, mockGoraConfiguration, mockDatastore); producer.process(mockCamelExchange); verify(mockCamelExchange, atLeastOnce()).getIn(); @@ -233,7 +224,7 @@ public class GoraProducerTest extends GoraTestSupport { final Message outMessage = mock(Message.class); when(mockCamelExchange.getOut()).thenReturn(outMessage); - final GoraProducer producer = new GoraProducer(mockGoraEndpoint,mockGoraConfiguration,mockDatastore); + final GoraProducer producer = new GoraProducer(mockGoraEndpoint, mockGoraConfiguration, mockDatastore); producer.process(mockCamelExchange); verify(mockCamelExchange, atLeastOnce()).getIn(); @@ -251,7 +242,7 @@ public class GoraProducerTest extends GoraTestSupport { final Message outMessage = mock(Message.class); when(mockCamelExchange.getOut()).thenReturn(outMessage); - final GoraProducer producer = new GoraProducer(mockGoraEndpoint,mockGoraConfiguration,mockDatastore); + final GoraProducer producer = new GoraProducer(mockGoraEndpoint, mockGoraConfiguration, mockDatastore); producer.process(mockCamelExchange); verify(mockCamelExchange, atLeastOnce()).getIn(); @@ -276,7 +267,7 @@ public class GoraProducerTest extends GoraTestSupport { final Query mockQuery = mock(QueryBase.class); when(GoraUtils.constractQueryFromPropertiesMap(mockProperties, mockDatastore, mockGoraConfiguration)).thenReturn(mockQuery); - final GoraProducer producer = new GoraProducer(mockGoraEndpoint,mockGoraConfiguration,mockDatastore); + final GoraProducer producer = new GoraProducer(mockGoraEndpoint, mockGoraConfiguration, mockDatastore); producer.process(mockCamelExchange); verify(mockCamelExchange, atLeastOnce()).getIn(); @@ -302,7 +293,7 @@ public class GoraProducerTest extends GoraTestSupport { final Query mockQuery = mock(QueryBase.class); when(GoraUtils.constractQueryFromPropertiesMap(mockProperties, mockDatastore, mockGoraConfiguration)).thenReturn(mockQuery); - final GoraProducer producer = new GoraProducer(mockGoraEndpoint,mockGoraConfiguration,mockDatastore); + final GoraProducer producer = new GoraProducer(mockGoraEndpoint, mockGoraConfiguration, mockDatastore); producer.process(mockCamelExchange); verify(mockCamelExchange, atLeastOnce()).getIn(); http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraTestSupport.java ---------------------------------------------------------------------- diff --git a/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraTestSupport.java b/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraTestSupport.java index 939763d..3d11e80 100644 --- a/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraTestSupport.java +++ b/components/camel-gora/src/test/java/org/apache/camel/component/gora/GoraTestSupport.java @@ -22,7 +22,6 @@ import org.apache.camel.test.junit4.CamelTestSupport; /** * GORA Test Support * - * @author ipolyzos */ public class GoraTestSupport extends CamelTestSupport { //TODO http://git-wip-us.apache.org/repos/asf/camel/blob/481fce9a/components/camel-gora/src/test/java/org/apache/camel/component/gora/utils/GoraUtilsTest.java ---------------------------------------------------------------------- diff --git a/components/camel-gora/src/test/java/org/apache/camel/component/gora/utils/GoraUtilsTest.java b/components/camel-gora/src/test/java/org/apache/camel/component/gora/utils/GoraUtilsTest.java index c2c4ecef..56ecfb4 100644 --- a/components/camel-gora/src/test/java/org/apache/camel/component/gora/utils/GoraUtilsTest.java +++ b/components/camel-gora/src/test/java/org/apache/camel/component/gora/utils/GoraUtilsTest.java @@ -22,28 +22,26 @@ import org.apache.camel.component.gora.GoraConfiguration; import org.junit.Test; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; /** * GORA Utils Tests * - * @author ipolyzos */ public class GoraUtilsTest { @Test public void configurationExistShouldSucceedtIfMethodExist() throws Exception { - final GoraConfiguration conf = new GoraConfiguration(); - assertTrue(GoraUtils.configurationExist(GoraAttribute.GORA_QUERY_LIMIT,conf)); + final GoraConfiguration conf = new GoraConfiguration(); + assertTrue(GoraUtils.configurationExist(GoraAttribute.GORA_QUERY_LIMIT, conf)); } @Test(expected = NoSuchMethodException.class) public void configurationExistShouldThrowExceptionIfMethodDoesNotExist() throws Exception { final GoraConfiguration conf = new GoraConfiguration(); - GoraUtils.configurationExist(GoraAttribute.GORA_KEY,conf); + GoraUtils.configurationExist(GoraAttribute.GORA_KEY, conf); } @Test