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/07/29 07:54:26 UTC
[3/3] git commit: CAMEL-6575 Fixed the CS errors of camel-avro
CAMEL-6575 Fixed the CS errors of camel-avro
Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/0d090200
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/0d090200
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/0d090200
Branch: refs/heads/master
Commit: 0d0902001c13cbb85a5eec4538066a74036e30b9
Parents: 6783cea
Author: Willem Jiang <ni...@apache.org>
Authored: Mon Jul 29 13:52:48 2013 +0800
Committer: Willem Jiang <ni...@apache.org>
Committed: Mon Jul 29 13:53:27 2013 +0800
----------------------------------------------------------------------
.../camel/component/avro/AvroComponent.java | 57 ++++++-------
.../component/avro/AvroComponentException.java | 28 +++----
.../camel/component/avro/AvroConfiguration.java | 66 +++++++--------
.../camel/component/avro/AvroConsumer.java | 7 +-
.../camel/component/avro/AvroListener.java | 84 +++++++++++++-------
.../camel/component/avro/AvroProducer.java | 18 +++--
.../component/avro/AvroReflectRequestor.java | 12 +--
.../component/avro/AvroReflectResponder.java | 7 +-
.../org/apache/camel/avro/test/TestPojo.java | 14 ++--
.../apache/camel/avro/test/TestReflection.java | 30 +++----
.../camel/avro/test/TestReflectionImpl.java | 78 +++++++++---------
.../component/avro/AvroConsumerTestSupport.java | 10 +--
.../component/avro/AvroHttpProducerTest.java | 27 ++++---
.../camel/component/avro/AvroSettingsTest.java | 2 +-
.../camel/component/avro/AvroTestSupport.java | 4 +-
.../component/avro/processors/GetProcessor.java | 2 +-
.../processors/ReflectionInOnlyProcessor.java | 40 +++++-----
.../processors/ReflectionInOutProcessor.java | 20 ++---
18 files changed, 269 insertions(+), 237 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java
index db10421..f1f6fc6 100644
--- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java
+++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponent.java
@@ -86,17 +86,17 @@ public class AvroComponent extends DefaultComponent {
if (config.getProtocol() == null && config.getProtocolClassName() != null) {
Class<?> protocolClass = getCamelContext().getClassResolver().resolveClass(config.getProtocolClassName());
if (protocolClass != null) {
- try {
- Field f = protocolClass.getField("PROTOCOL");
- if (f != null) {
- Protocol protocol = (Protocol) f.get(null);
+ try {
+ Field f = protocolClass.getField("PROTOCOL");
+ if (f != null) {
+ Protocol protocol = (Protocol)f.get(null);
config.setProtocol(protocol);
}
- } catch(NoSuchFieldException e) {
- ReflectData reflectData = ReflectData.get();
- config.setProtocol(reflectData.getProtocol(protocolClass));
- config.setReflectionProtocol(true);
- }
+ } catch (NoSuchFieldException e) {
+ ReflectData reflectData = ReflectData.get();
+ config.setProtocol(reflectData.getProtocol(protocolClass));
+ config.setReflectionProtocol(true);
+ }
}
}
@@ -110,14 +110,14 @@ public class AvroComponent extends DefaultComponent {
if (config.isSingleParameter()) {
Map<String, Protocol.Message> messageMap = config.getProtocol().getMessages();
- Iterable<Protocol.Message> messagesToCheck = config.getMessageName() == null ?
- messageMap.values() :
- Collections.singleton(messageMap.get(config.getMessageName()));
+ Iterable<Protocol.Message> messagesToCheck = config.getMessageName() == null
+ ? messageMap.values()
+ : Collections.singleton(messageMap.get(config.getMessageName()));
for (Protocol.Message message: messagesToCheck) {
if (message.getRequest().getFields().size() != 1) {
throw new IllegalArgumentException("Single parameter option can't be used with message "
- + message.getName() + " because it has " + message.getRequest().getFields().size() +
- " parameters defined"
+ + message.getName() + " because it has " + message.getRequest().getFields().size()
+ + " parameters defined"
);
}
}
@@ -126,31 +126,34 @@ public class AvroComponent extends DefaultComponent {
/**
* Registers new responder with uri as key. Registers consumer in responder.
- * In case if responder is already registered by this uri then just registers consumer.
+ * In case if responder is already registered by this uri then just
+ * registers consumer.
*
- * @param uri URI of the endpoint without message name
- * @param messageName message name
- * @param consumer consumer that will be registered in providers` registry
+ * @param uri URI of the endpoint without message name
+ * @param messageName message name
+ * @param consumer consumer that will be registered in providers` registry
* @throws Exception
*/
public void register(String uri, String messageName, AvroConsumer consumer) throws Exception {
- AvroListener listener = listenerRegistry.get(uri);
- if(listener == null) {
- listener = new AvroListener(consumer.getEndpoint());
- listenerRegistry.put(uri, listener);
- }
- listener.register(messageName, consumer);
+ AvroListener listener = listenerRegistry.get(uri);
+ if (listener == null) {
+ listener = new AvroListener(consumer.getEndpoint());
+ listenerRegistry.put(uri, listener);
+ }
+ listener.register(messageName, consumer);
}
/**
* Calls unregister of consumer by appropriate message name.
* In case if all consumers are unregistered then it removes responder from the registry.
*
- * @param uri URI of the endpoint without message name
- * @param messageName message name
+ * @param uri URI of the endpoint without message name
+ * @param messageName message name
*/
public void unregister(String uri, String messageName) {
- if(listenerRegistry.get(uri).unregister(messageName)) listenerRegistry.remove(uri);
+ if (listenerRegistry.get(uri).unregister(messageName)) {
+ listenerRegistry.remove(uri);
+ }
}
public AvroConfiguration getConfiguration() {
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponentException.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponentException.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponentException.java
index 677259a..4f42a95 100644
--- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponentException.java
+++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroComponentException.java
@@ -18,22 +18,22 @@ package org.apache.camel.component.avro;
public class AvroComponentException extends Exception {
- private static final long serialVersionUID = 8915917806189741165L;
-
- public AvroComponentException() {
- super();
- }
+ private static final long serialVersionUID = 8915917806189741165L;
- public AvroComponentException(String message, Throwable cause) {
- super(message, cause);
- }
+ public AvroComponentException() {
+ super();
+ }
- public AvroComponentException(String message) {
- super(message);
- }
+ public AvroComponentException(String message, Throwable cause) {
+ super(message, cause);
+ }
- public AvroComponentException(Throwable cause) {
- super(cause);
- }
+ public AvroComponentException(String message) {
+ super(message);
+ }
+
+ public AvroComponentException(Throwable cause) {
+ super(cause);
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java
index ee138b3..6b5b24b 100644
--- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java
+++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConfiguration.java
@@ -38,9 +38,9 @@ public class AvroConfiguration implements Cloneable {
private boolean reflectionProtocol;
private boolean singleParameter;
- public AvroConfiguration copy() {
+ public AvroConfiguration copy() {
try {
- AvroConfiguration answer = (AvroConfiguration) clone();
+ AvroConfiguration answer = (AvroConfiguration)clone();
return answer;
} catch (CloneNotSupportedException e) {
throw new RuntimeCamelException(e);
@@ -57,10 +57,14 @@ public class AvroConfiguration implements Cloneable {
setHost(uri.getHost());
setPort(uri.getPort());
- if((uri.getPath() != null) && (StringUtils.indexOf(uri.getPath(), AVRO_MESSAGE_NAME_SEPARATOR) != -1)) {
- String path = StringUtils.substringAfter(uri.getPath(), AVRO_MESSAGE_NAME_SEPARATOR);
- if(!path.contains(AVRO_MESSAGE_NAME_SEPARATOR)) setMessageName(path);
- else throw new IllegalArgumentException("Unrecognized Avro message name: " + path + " for uri: " + uri);
+ if ((uri.getPath() != null)
+ && (StringUtils.indexOf(uri.getPath(), AVRO_MESSAGE_NAME_SEPARATOR) != -1)) {
+ String path = StringUtils.substringAfter(uri.getPath(), AVRO_MESSAGE_NAME_SEPARATOR);
+ if (!path.contains(AVRO_MESSAGE_NAME_SEPARATOR)) {
+ setMessageName(path);
+ } else {
+ throw new IllegalArgumentException("Unrecognized Avro message name: " + path + " for uri: " + uri);
+ }
}
setUriAuthority(uri.getAuthority());
@@ -114,35 +118,35 @@ public class AvroConfiguration implements Cloneable {
this.protocolClassName = protocolClassName;
}
- public String getMessageName() {
- return messageName;
- }
+ public String getMessageName() {
+ return messageName;
+ }
- public void setMessageName(String messageName) {
- this.messageName = messageName;
- }
+ public void setMessageName(String messageName) {
+ this.messageName = messageName;
+ }
- public String getUriAuthority() {
- return uriAuthority;
- }
+ public String getUriAuthority() {
+ return uriAuthority;
+ }
- public void setUriAuthority(String uriAuthority) {
- this.uriAuthority = uriAuthority;
- }
-
- public boolean isReflectionProtocol() {
- return reflectionProtocol;
- }
+ public void setUriAuthority(String uriAuthority) {
+ this.uriAuthority = uriAuthority;
+ }
- public void setReflectionProtocol(boolean isReflectionProtocol) {
- this.reflectionProtocol = isReflectionProtocol;
- }
+ public boolean isReflectionProtocol() {
+ return reflectionProtocol;
+ }
- public boolean isSingleParameter() {
- return singleParameter;
- }
+ public void setReflectionProtocol(boolean isReflectionProtocol) {
+ this.reflectionProtocol = isReflectionProtocol;
+ }
+
+ public boolean isSingleParameter() {
+ return singleParameter;
+ }
- public void setSingleParameter(boolean singleParameter) {
- this.singleParameter = singleParameter;
- }
+ public void setSingleParameter(boolean singleParameter) {
+ this.singleParameter = singleParameter;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConsumer.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConsumer.java
index 5375c2d..5c7116b 100644
--- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConsumer.java
+++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroConsumer.java
@@ -33,13 +33,14 @@ public class AvroConsumer extends DefaultConsumer {
@Override
protected void doStart() throws Exception {
- super.doStart();
- ((AvroComponent) getEndpoint().getComponent()).register(getEndpoint().getConfiguration().getUriAuthority(), getEndpoint().getConfiguration().getMessageName(), this);
+ super.doStart();
+ ((AvroComponent)getEndpoint().getComponent()).register(getEndpoint().getConfiguration()
+ .getUriAuthority(), getEndpoint().getConfiguration().getMessageName(), this);
}
@Override
protected void doStop() throws Exception {
- super.doStop();
((AvroComponent) getEndpoint().getComponent()).unregister(getEndpoint().getConfiguration().getUriAuthority(), getEndpoint().getConfiguration().getMessageName());
+ super.doStop();
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroListener.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroListener.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroListener.java
index 546e490..c593080 100644
--- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroListener.java
+++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroListener.java
@@ -1,5 +1,25 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
package org.apache.camel.component.avro;
+import java.net.InetSocketAddress;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
+
import org.apache.avro.Protocol;
import org.apache.avro.Schema;
import org.apache.avro.ipc.HttpServer;
@@ -12,13 +32,10 @@ import org.apache.camel.util.ExchangeHelper;
import org.apache.commons.lang.StringUtils;
import org.mortbay.log.Log;
-import java.net.InetSocketAddress;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.ConcurrentMap;
-
import static org.apache.camel.component.avro.AvroConstants.AVRO_HTTP_TRANSPORT;
import static org.apache.camel.component.avro.AvroConstants.AVRO_NETTY_TRANSPORT;
+
/**
* This class holds server that listen to given protocol:host:port combination and dispatches messages to
* different routes mapped.
@@ -40,26 +57,27 @@ public class AvroListener {
*
*
* @param configuration
- * @return Initialized and started server
+ * @return Initialized and started server
* @throws java.io.IOException
*/
private Server initAndStartServer(AvroConfiguration configuration) throws Exception {
SpecificResponder responder;
Server server;
- if(configuration.isReflectionProtocol()) {
+ if (configuration.isReflectionProtocol()) {
responder = new AvroReflectResponder(configuration.getProtocol(), this);
- }
- else {
+ } else {
responder = new AvroSpecificResponder(configuration.getProtocol(), this);
}
- if(AVRO_HTTP_TRANSPORT.equalsIgnoreCase(configuration.getTransport()))
+ if (AVRO_HTTP_TRANSPORT.equalsIgnoreCase(configuration.getTransport())) {
server = new HttpServer(responder, configuration.getPort());
- else if(AVRO_NETTY_TRANSPORT.equalsIgnoreCase(configuration.getTransport()))
+ } else if (AVRO_NETTY_TRANSPORT.equalsIgnoreCase(configuration.getTransport())) {
server = new NettyServer(responder, new InetSocketAddress(configuration.getHost(), configuration.getPort()));
- else throw new IllegalArgumentException("Unknown transport " + configuration.getTransport());
+ } else {
+ throw new IllegalArgumentException("Unknown transport " + configuration.getTransport());
+ }
server.start();
@@ -69,14 +87,15 @@ public class AvroListener {
/**
* Registers consumer by appropriate message name as key in registry.
*
- * @param messageName message name
- * @param consumer avro consumer
+ * @param messageName message name
+ * @param consumer avro consumer
* @throws AvroComponentException
*/
public void register(String messageName, AvroConsumer consumer) throws AvroComponentException {
if (messageName == null) {
- if(this.defaultConsumer != null)
+ if (this.defaultConsumer != null) {
throw new AvroComponentException("Default consumer already registered for uri: " + consumer.getEndpoint().getEndpointUri());
+ }
this.defaultConsumer = consumer;
} else {
if (consumerRegistry.putIfAbsent(messageName, consumer) != null) {
@@ -94,13 +113,15 @@ public class AvroListener {
* It means that this responder can be unregistered.
*/
public boolean unregister(String messageName) {
- if(!StringUtils.isEmpty(messageName)) {
- if(consumerRegistry.remove(messageName) == null)
+ if (!StringUtils.isEmpty(messageName)) {
+ if (consumerRegistry.remove(messageName) == null) {
Log.warn("Consumer with message name " + messageName + " was already unregistered.");
+ }
+ } else {
+ defaultConsumer = null;
}
- else defaultConsumer = null;
- if((defaultConsumer == null) && (consumerRegistry.isEmpty())) {
+ if ((defaultConsumer == null) && (consumerRegistry.isEmpty())) {
if (server != null) {
server.close();
}
@@ -111,10 +132,13 @@ public class AvroListener {
public Object respond(Protocol.Message message, Object request, SpecificData data) throws Exception {
AvroConsumer consumer = this.defaultConsumer;
- if(this.consumerRegistry.containsKey(message.getName()))
+ if (this.consumerRegistry.containsKey(message.getName())) {
consumer = this.consumerRegistry.get(message.getName());
+ }
- if(consumer == null) throw new AvroComponentException("No consumer defined for message: " + message.getName());
+ if (consumer == null) {
+ throw new AvroComponentException("No consumer defined for message: " + message.getName());
+ }
Object params = extractParams(message, request, consumer.getEndpoint().getConfiguration().isSingleParameter(), data);
@@ -125,15 +149,15 @@ public class AvroListener {
* Extracts parameters from RPC call to List or converts to object of appropriate type
* if only one parameter set.
*
- * @param message Avro message
- * @param request Avro request
- * @param singleParameter Indicates that called method has single parameter
- * @param dataResolver Extracts type of parameters in call
- * @return Parameters of RPC method invocation
+ * @param message Avro message
+ * @param request Avro request
+ * @param singleParameter Indicates that called method has single parameter
+ * @param dataResolver Extracts type of parameters in call
+ * @return Parameters of RPC method invocation
*/
private static Object extractParams(Protocol.Message message, Object request, boolean singleParameter, SpecificData dataResolver) {
- if(singleParameter) {
+ if (singleParameter) {
Schema.Field field = message.getRequest().getFields().get(0);
return dataResolver.getField(request, field.name(), field.pos());
} else {
@@ -150,10 +174,10 @@ public class AvroListener {
/**
* Creates exchange and processes it.
*
- * @param consumer Holds processor and exception handler
- * @param message Message on which exchange is created
- * @param params Params of exchange
- * @return Response of exchange processing
+ * @param consumer Holds processor and exception handler
+ * @param message Message on which exchange is created
+ * @param params Params of exchange
+ * @return Response of exchange processing
* @throws Exception
*/
private static Object processExchange(AvroConsumer consumer, Protocol.Message message, Object params) throws Exception {
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroProducer.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroProducer.java
index b3ba04c..2762f02 100644
--- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroProducer.java
+++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroProducer.java
@@ -45,10 +45,11 @@ public abstract class AvroProducer extends DefaultAsyncProducer implements Servi
if (transceiver == null) {
try {
transceiver = createTransceiver();
- if(configuration.isReflectionProtocol())
+ if (configuration.isReflectionProtocol()) {
requestor = new AvroReflectRequestor(configuration.getProtocol(), transceiver);
- else
+ } else {
requestor = new AvroSpecificRequestor(configuration.getProtocol(), transceiver);
+ }
} catch (Exception e) {
exchange.setException(e);
callback.done(true);
@@ -57,12 +58,13 @@ public abstract class AvroProducer extends DefaultAsyncProducer implements Servi
}
try {
- String messageName;
- if(!StringUtils.isEmpty(exchange.getIn().getHeader(AvroConstants.AVRO_MESSAGE_NAME, String.class)))
- messageName = exchange.getIn().getHeader(AvroConstants.AVRO_MESSAGE_NAME, String.class);
- else
- messageName = configuration.getMessageName();
-
+ String messageName;
+ if (!StringUtils.isEmpty(exchange.getIn().getHeader(AvroConstants.AVRO_MESSAGE_NAME, String.class))) {
+ messageName = exchange.getIn().getHeader(AvroConstants.AVRO_MESSAGE_NAME, String.class);
+ } else {
+ messageName = configuration.getMessageName();
+ }
+
requestor.request(messageName, wrapObjectToArray(request), new Callback<Object>() {
@Override
public void handleResult(Object result) {
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroReflectRequestor.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroReflectRequestor.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroReflectRequestor.java
index 1d6fc2a..55d253c 100644
--- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroReflectRequestor.java
+++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroReflectRequestor.java
@@ -24,11 +24,11 @@ import org.apache.avro.ipc.reflect.ReflectRequestor;
public class AvroReflectRequestor extends ReflectRequestor {
- public AvroReflectRequestor(Class<?> iface, Transceiver transceiver) throws IOException {
- super(iface, transceiver);
- }
+ public AvroReflectRequestor(Class<?> iface, Transceiver transceiver) throws IOException {
+ super(iface, transceiver);
+ }
- public AvroReflectRequestor(Protocol protocol, Transceiver transceiver) throws IOException {
- super(protocol, transceiver);
- }
+ public AvroReflectRequestor(Protocol protocol, Transceiver transceiver) throws IOException {
+ super(protocol, transceiver);
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroReflectResponder.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroReflectResponder.java b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroReflectResponder.java
index c841021..16fd712 100644
--- a/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroReflectResponder.java
+++ b/components/camel-avro/src/main/java/org/apache/camel/component/avro/AvroReflectResponder.java
@@ -23,15 +23,14 @@ import org.apache.avro.reflect.ReflectData;
public class AvroReflectResponder extends ReflectResponder {
private AvroListener listener;
-
- public AvroReflectResponder(Protocol protocol, AvroListener listener) throws Exception {
+ public AvroReflectResponder(Protocol protocol, AvroListener listener) throws Exception {
super(protocol, null);
this.listener = listener;
}
- @Override
+ @Override
public Object respond(Protocol.Message message, Object request) throws Exception {
- return listener.respond(message, request, ReflectData.get());
+ return listener.respond(message, request, ReflectData.get());
}
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestPojo.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestPojo.java b/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestPojo.java
index d7290d8..d045db2 100644
--- a/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestPojo.java
+++ b/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestPojo.java
@@ -18,13 +18,13 @@ package org.apache.camel.avro.test;
public class TestPojo {
- private String pojoName;
+ private String pojoName;
- public String getPojoName() {
- return pojoName;
- }
+ public String getPojoName() {
+ return pojoName;
+ }
- public void setPojoName(String pojoName) {
- this.pojoName = pojoName;
- }
+ public void setPojoName(String pojoName) {
+ this.pojoName = pojoName;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestReflection.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestReflection.java b/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestReflection.java
index 07eb08b..09156f3 100644
--- a/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestReflection.java
+++ b/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestReflection.java
@@ -17,19 +17,19 @@
package org.apache.camel.avro.test;
public interface TestReflection {
-
- public String getName();
-
- public void setName(String name);
-
- public int getAge();
-
- public void setAge(int age);
-
- public int increaseAge(int age);
-
- public void setTestPojo(TestPojo testPojo);
-
- public TestPojo getTestPojo();
-
+
+ String getName();
+
+ void setName(String name);
+
+ int getAge();
+
+ void setAge(int age);
+
+ int increaseAge(int age);
+
+ void setTestPojo(TestPojo testPojo);
+
+ TestPojo getTestPojo();
+
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestReflectionImpl.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestReflectionImpl.java b/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestReflectionImpl.java
index 98b9eea..5929168 100644
--- a/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestReflectionImpl.java
+++ b/components/camel-avro/src/test/java/org/apache/camel/avro/test/TestReflectionImpl.java
@@ -18,44 +18,44 @@ package org.apache.camel.avro.test;
public class TestReflectionImpl implements TestReflection {
- String name = "";
- int age = 0;
- TestPojo testPojo;
-
- @Override
- public String getName() {
- return this.name;
- }
-
- @Override
- public void setName(String name) {
- this.name = name;
- }
-
- @Override
- public int getAge() {
- return this.age;
- }
-
- @Override
- public void setAge(int age) {
- this.age = age;
- }
-
- @Override
- public int increaseAge(int age) {
- this.age = ++age;
- return this.age;
- }
-
- @Override
- public void setTestPojo(TestPojo testPojo) {
- this.testPojo = testPojo;
- }
-
- @Override
- public TestPojo getTestPojo() {
- return testPojo;
- }
+ String name = "";
+ int age;
+ TestPojo testPojo;
+
+ @Override
+ public String getName() {
+ return this.name;
+ }
+
+ @Override
+ public void setName(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int getAge() {
+ return this.age;
+ }
+
+ @Override
+ public void setAge(int age) {
+ this.age = age;
+ }
+
+ @Override
+ public int increaseAge(int age) {
+ this.age = ++age;
+ return this.age;
+ }
+
+ @Override
+ public void setTestPojo(TestPojo testPojo) {
+ this.testPojo = testPojo;
+ }
+
+ @Override
+ public TestPojo getTestPojo() {
+ return testPojo;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroConsumerTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroConsumerTestSupport.java b/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroConsumerTestSupport.java
index 4ee9cd9..bef6654 100644
--- a/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroConsumerTestSupport.java
+++ b/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroConsumerTestSupport.java
@@ -23,7 +23,6 @@ import java.io.IOException;
import org.apache.avro.AvroRuntimeException;
import org.apache.avro.ipc.Requestor;
import org.apache.avro.ipc.Transceiver;
-import org.apache.camel.CamelContext;
import org.apache.camel.avro.generated.Key;
import org.apache.camel.avro.generated.Value;
import org.apache.camel.avro.impl.KeyValueProtocolImpl;
@@ -34,6 +33,8 @@ import org.junit.After;
import org.junit.Test;
public abstract class AvroConsumerTestSupport extends AvroTestSupport {
+ public static final String REFLECTION_TEST_NAME = "Chucky";
+ public static final int REFLECTION_TEST_AGE = 100;
protected int avroPortMessageInRoute = setupFreePort("avroPortMessageInRoute");
protected int avroPortForWrongMessages = setupFreePort("avroPortForWrongMessages");
@@ -53,9 +54,6 @@ public abstract class AvroConsumerTestSupport extends AvroTestSupport {
KeyValueProtocolImpl keyValue = new KeyValueProtocolImpl();
TestReflection testReflection = new TestReflectionImpl();
- public static final String REFLECTION_TEST_NAME = "Chucky";
- public static final int REFLECTION_TEST_AGE = 100;
-
protected abstract void initializeTranceiver() throws IOException;
@Override
@@ -106,7 +104,7 @@ public abstract class AvroConsumerTestSupport extends AvroTestSupport {
assertEquals(REFLECTION_TEST_NAME, testReflection.getName());
}
- @Test(expected=AvroRuntimeException.class)
+ @Test(expected = AvroRuntimeException.class)
public void testInOnlyWrongMessageName() throws Exception {
initializeTranceiver();
Key key = Key.newBuilder().setKey("1").build();
@@ -115,7 +113,7 @@ public abstract class AvroConsumerTestSupport extends AvroTestSupport {
requestorMessageInRoute.request("throwException", request);
}
- @Test(expected=AvroRuntimeException.class)
+ @Test(expected = AvroRuntimeException.class)
public void testInOnlyToNotExistingRoute() throws Exception {
initializeTranceiver();
Key key = Key.newBuilder().setKey("1").build();
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpProducerTest.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpProducerTest.java b/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpProducerTest.java
index 177eae2..e646c32 100644
--- a/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpProducerTest.java
+++ b/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroHttpProducerTest.java
@@ -36,8 +36,9 @@ public class AvroHttpProducerTest extends AvroProducerTestSupport {
}
if (serverReflection == null) {
- serverReflection = new HttpServer(new ReflectResponder(TestReflection.class, testReflection), avroPortReflection);
- serverReflection.start();
+ serverReflection = new HttpServer(new ReflectResponder(TestReflection.class, testReflection),
+ avroPortReflection);
+ serverReflection.start();
}
}
@@ -47,32 +48,32 @@ public class AvroHttpProducerTest extends AvroProducerTestSupport {
public void configure() throws Exception {
//In Only
from("direct:in")
- .to("avro:http:localhost:" + avroPort + "?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol");
+ .to("avro:http:localhost:" + avroPort + "?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol");
//In Only with message in route
from("direct:in-message-name")
- .errorHandler(deadLetterChannel("mock:in-message-name-error"))
- .to("avro:http:localhost:" + avroPort + "/put?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol")
- .to("mock:result-in-message-name");
+ .errorHandler(deadLetterChannel("mock:in-message-name-error"))
+ .to("avro:http:localhost:" + avroPort + "/put?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol")
+ .to("mock:result-in-message-name");
//In Only with existing interface
from("direct:in-reflection")
- .to("avro:http:localhost:" + avroPortReflection + "/setName?protocolClassName=org.apache.camel.avro.test.TestReflection&singleParameter=true");
+ .to("avro:http:localhost:" + avroPortReflection + "/setName?protocolClassName=org.apache.camel.avro.test.TestReflection&singleParameter=true");
//InOut
from("direct:inout")
- .to("avro:http:localhost:" + avroPort + "?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol")
- .to("mock:result-inout");
+ .to("avro:http:localhost:" + avroPort + "?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol")
+ .to("mock:result-inout");
//InOut with message in route
from("direct:inout-message-name")
- .to("avro:http:localhost:" + avroPort + "/get?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol")
- .to("mock:result-inout-message-name");
+ .to("avro:http:localhost:" + avroPort + "/get?protocolClassName=org.apache.camel.avro.generated.KeyValueProtocol")
+ .to("mock:result-inout-message-name");
//InOut with existing interface
from("direct:inout-reflection")
- .to("avro:http:localhost:" + avroPortReflection + "/increaseAge?protocolClassName=org.apache.camel.avro.test.TestReflection&singleParameter=true")
- .to("mock:result-inout-reflection");
+ .to("avro:http:localhost:" + avroPortReflection + "/increaseAge?protocolClassName=org.apache.camel.avro.test.TestReflection&singleParameter=true")
+ .to("mock:result-inout-reflection");
}
};
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroSettingsTest.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroSettingsTest.java b/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroSettingsTest.java
index 5d96b57..ec345ba 100644
--- a/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroSettingsTest.java
+++ b/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroSettingsTest.java
@@ -20,7 +20,7 @@ import org.apache.camel.FailedToCreateRouteException;
import org.apache.camel.builder.RouteBuilder;
import org.junit.Test;
-public class AvroSettingsTest extends AvroTestSupport{
+public class AvroSettingsTest extends AvroTestSupport {
@Test(expected = FailedToCreateRouteException.class)
public void testConsumerForUnknownMessage() throws Exception {
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroTestSupport.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroTestSupport.java b/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroTestSupport.java
index d5be014..8af50cd 100644
--- a/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroTestSupport.java
+++ b/components/camel-avro/src/test/java/org/apache/camel/component/avro/AvroTestSupport.java
@@ -21,10 +21,10 @@ import org.apache.camel.test.AvailablePortFinder;
import org.apache.camel.test.junit4.CamelTestSupport;
public class AvroTestSupport extends CamelTestSupport {
-
- private int port = 9100;
+ protected int port = 9100;
protected int avroPort = setupFreePort("avroport");
protected int avroPortReflection = setupFreePort("avroPortReflection");
+
public int setupFreePort(String name) {
port = AvailablePortFinder.getNextAvailable(++port);
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/GetProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/GetProcessor.java b/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/GetProcessor.java
index 74809cf..d3a233c 100644
--- a/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/GetProcessor.java
+++ b/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/GetProcessor.java
@@ -34,7 +34,7 @@ public class GetProcessor implements Processor {
public void process(Exchange exchange) throws Exception {
Object body = exchange.getIn().getBody();
if (body instanceof Key) {
- Value v = keyValue.get((Key) body);
+ Value v = keyValue.get((Key) body);
exchange.getOut().setBody(v);
}
if (body instanceof Object[]) {
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/ReflectionInOnlyProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/ReflectionInOnlyProcessor.java b/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/ReflectionInOnlyProcessor.java
index 056973c..dd6f1fe 100644
--- a/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/ReflectionInOnlyProcessor.java
+++ b/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/ReflectionInOnlyProcessor.java
@@ -23,29 +23,29 @@ import org.apache.camel.avro.test.TestReflection;
public class ReflectionInOnlyProcessor implements Processor {
- private TestReflection testReflection;
-
- public ReflectionInOnlyProcessor(TestReflection testReflection) {
- this.testReflection = testReflection;
- }
-
- @Override
- public void process(Exchange exchange) throws Exception {
+ private TestReflection testReflection;
+
+ public ReflectionInOnlyProcessor(TestReflection testReflection) {
+ this.testReflection = testReflection;
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
Object body = exchange.getIn().getBody();
- if(body instanceof String) {
- testReflection.setName(String.valueOf(body));
+ if (body instanceof String) {
+ testReflection.setName(String.valueOf(body));
}
- if(body instanceof TestPojo) {
- testReflection.setTestPojo((TestPojo) body);
+ if (body instanceof TestPojo) {
+ testReflection.setTestPojo((TestPojo)body);
}
}
-
- public TestReflection getTestReflection() {
- return testReflection;
- }
-
- public void setTestReflection(TestReflection testReflection) {
- this.testReflection = testReflection;
- }
+
+ public TestReflection getTestReflection() {
+ return testReflection;
+ }
+
+ public void setTestReflection(TestReflection testReflection) {
+ this.testReflection = testReflection;
+ }
}
http://git-wip-us.apache.org/repos/asf/camel/blob/0d090200/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/ReflectionInOutProcessor.java
----------------------------------------------------------------------
diff --git a/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/ReflectionInOutProcessor.java b/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/ReflectionInOutProcessor.java
index 778aed3..78f8765 100644
--- a/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/ReflectionInOutProcessor.java
+++ b/components/camel-avro/src/test/java/org/apache/camel/component/avro/processors/ReflectionInOutProcessor.java
@@ -23,19 +23,19 @@ import org.apache.camel.avro.test.TestReflectionImpl;
public class ReflectionInOutProcessor implements Processor {
- private TestReflection testReflection = new TestReflectionImpl();
-
- public ReflectionInOutProcessor(TestReflection testReflection) {
- this.testReflection = testReflection;
- }
-
- @Override
- public void process(Exchange exchange) throws Exception {
+ private TestReflection testReflection = new TestReflectionImpl();
+
+ public ReflectionInOutProcessor(TestReflection testReflection) {
+ this.testReflection = testReflection;
+ }
+
+ @Override
+ public void process(Exchange exchange) throws Exception {
Object body = exchange.getIn().getBody();
- if (body instanceof Object[] && ((Object[]) body).length == 0) {
+ if (body instanceof Object[] && ((Object[])body).length == 0) {
exchange.getOut().setBody(testReflection.getTestPojo());
} else if (body instanceof Object) {
- exchange.getOut().setBody(testReflection.increaseAge((Integer) body));
+ exchange.getOut().setBody(testReflection.increaseAge((Integer)body));
}
}
}