Fixed the CS errors of camel-rabbitmq
Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/a496191c Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/a496191c Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/a496191c Branch: refs/heads/master Commit: a496191ce806d1ccf0f724007a5819283b9d0da3 Parents: 0e2498b Author: Willem Jiang <ningji...@apache.org> Authored: Mon Jul 15 18:59:23 2013 +0800 Committer: Willem Jiang <ningji...@apache.org> Committed: Mon Jul 15 18:59:59 2013 +0800 ---------------------------------------------------------------------- .../component/rabbitmq/RabbitMQComponent.java | 24 +++++-- .../component/rabbitmq/RabbitMQConstants.java | 28 ++++++-- .../component/rabbitmq/RabbitMQConsumer.java | 57 +++++++++------ .../component/rabbitmq/RabbitMQEndpoint.java | 73 ++++++++++++-------- .../component/rabbitmq/RabbitMQProducer.java | 69 ++++++++++++------ .../rabbitmq/RabbitMQComponentTest.java | 25 +++++-- .../rabbitmq/RabbitMQConsumerIntTest.java | 27 +++++--- .../rabbitmq/RabbitMQConsumerTest.java | 28 ++++++-- .../rabbitmq/RabbitMQEndpointTest.java | 28 ++++++-- .../rabbitmq/RabbitMQProducerIntTest.java | 42 +++++++---- .../rabbitmq/RabbitMQProducerTest.java | 27 ++++++-- .../camel-rabbitmq/src/test/resources/log4j.xml | 20 ------ 12 files changed, 302 insertions(+), 146 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java index 7055a6f..859a86d 100644 --- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java +++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQComponent.java @@ -1,13 +1,27 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apache.camel.component.rabbitmq; +import java.util.Map; + import org.apache.camel.CamelContext; import org.apache.camel.impl.DefaultComponent; -import java.util.Map; - -/** - * @author Stephen Samuel - */ public class RabbitMQComponent extends DefaultComponent { public RabbitMQComponent() { http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConstants.java ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConstants.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConstants.java index d163361..0fc1642 100644 --- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConstants.java +++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConstants.java @@ -1,9 +1,25 @@ -package org.apache.camel.component.rabbitmq; - /** - * @author Stephen Samuel + * 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. */ -public class RabbitMQConstants { + +package org.apache.camel.component.rabbitmq; + + +public final class RabbitMQConstants { + public static final String ROUTING_KEY = "rabbitmq.ROUTING_KEY"; public static final String EXCHANGE_NAME = "rabbitmq.EXCHANGE_NAME"; public static final String CONTENT_TYPE = "rabbitmq.CONTENT_TYPE"; @@ -20,4 +36,8 @@ public class RabbitMQConstants { public static final String EXPIRATION = "rabbitmq.EXPIRATION"; public static final String TIMESTAMP = "rabbitmq.TIMESTAMP"; public static final String APP_ID = "rabbitmq.APP_ID"; + + private RabbitMQConstants() { + //Constants class + } } http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java index e088568..d807df6 100644 --- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java +++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQConsumer.java @@ -1,31 +1,44 @@ +/** + * 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.rabbitmq; +import java.io.IOException; +import java.util.concurrent.ExecutorService; + import com.rabbitmq.client.AMQP; import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection; import com.rabbitmq.client.Envelope; + + import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.camel.impl.DefaultConsumer; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.util.concurrent.ExecutorService; -/** - * @author Stephen Samuel - */ public class RabbitMQConsumer extends DefaultConsumer { - - private static final Logger logger = LoggerFactory.getLogger(RabbitMQConsumer.class); - - private final RabbitMQEndpoint endpoint; - + ExecutorService executor; Connection conn; Channel channel; + private final RabbitMQEndpoint endpoint; + public RabbitMQConsumer(RabbitMQEndpoint endpoint, Processor processor) { super(endpoint, processor); this.endpoint = endpoint; @@ -37,13 +50,13 @@ public class RabbitMQConsumer extends DefaultConsumer { log.info("Starting RabbitMQ consumer"); executor = endpoint.createExecutor(); - logger.debug("Using executor {}", executor); + log.debug("Using executor {}", executor); conn = endpoint.connect(executor); - logger.debug("Using conn {}", conn); + log.debug("Using conn {}", conn); channel = conn.createChannel(); - logger.debug("Using channel {}", channel); + log.debug("Using channel {}", channel); channel.exchangeDeclare(endpoint.getExchangeName(), "direct", true); channel.queueDeclare(endpoint.getQueue(), true, false, false, null); @@ -57,10 +70,13 @@ public class RabbitMQConsumer extends DefaultConsumer { protected void doStop() throws Exception { super.doStop(); log.info("Stopping RabbitMQ consumer"); - if (conn != null) + if (conn != null) { try { conn.close(); - } catch (Exception ignored) { } + } catch (Exception ignored) { + // ignored + } + } channel = null; conn = null; @@ -88,17 +104,16 @@ public class RabbitMQConsumer extends DefaultConsumer { public void handleDelivery(String consumerTag, Envelope envelope, AMQP.BasicProperties properties, - byte[] body) - throws IOException { + byte[] body) throws IOException { Exchange exchange = consumer.endpoint.createRabbitExchange(envelope); - logger.trace("Created exchange [exchange={}]", new Object[]{exchange}); + log.trace("Created exchange [exchange={}]", new Object[]{exchange}); try { consumer.getProcessor().process(exchange); long deliveryTag = envelope.getDeliveryTag(); - logger.trace("Acknowleding receipt [delivery_tag={}]", deliveryTag); + log.trace("Acknowleding receipt [delivery_tag={}]", deliveryTag); channel.basicAck(deliveryTag, false); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java index 94ec68c..933a954 100644 --- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java +++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQEndpoint.java @@ -1,8 +1,34 @@ +/** + * 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.rabbitmq; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.util.UUID; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadPoolExecutor; + import com.rabbitmq.client.Connection; import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client.Envelope; + import org.apache.camel.Consumer; import org.apache.camel.Exchange; import org.apache.camel.Message; @@ -12,17 +38,6 @@ import org.apache.camel.impl.DefaultEndpoint; import org.apache.camel.impl.DefaultExchange; import org.apache.camel.impl.DefaultMessage; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; -import java.util.UUID; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadPoolExecutor; - -/** - * @author Stephen Samuel - */ public class RabbitMQEndpoint extends DefaultEndpoint { private String username; @@ -35,6 +50,21 @@ public class RabbitMQEndpoint extends DefaultEndpoint { private String queue = String.valueOf(UUID.randomUUID().toString().hashCode()); private String exchangeName; private String routingKey; + + public RabbitMQEndpoint() { + } + + public RabbitMQEndpoint(String endpointUri, + String remaining, + RabbitMQComponent component) throws URISyntaxException { + super(endpointUri, component); + + URI uri = new URI("http://" + remaining); + hostname = uri.getHost(); + portNumber = uri.getPort(); + exchangeName = uri.getPath().substring(1); + } + public String getExchangeName() { return exchangeName; @@ -71,21 +101,7 @@ public class RabbitMQEndpoint extends DefaultEndpoint { public void setRoutingKey(String routingKey) { this.routingKey = routingKey; } - - public RabbitMQEndpoint() { - } - - public RabbitMQEndpoint(String endpointUri, - String remaining, - RabbitMQComponent component) throws URISyntaxException { - super(endpointUri, component); - - URI uri = new URI("http://" + remaining); - hostname = uri.getHost(); - portNumber = uri.getPort(); - exchangeName = uri.getPath().substring(1); - } - + public Exchange createRabbitExchange(Envelope envelope) { Exchange exchange = new DefaultExchange(getCamelContext(), getExchangePattern()); @@ -110,10 +126,11 @@ public class RabbitMQEndpoint extends DefaultEndpoint { ConnectionFactory factory = new ConnectionFactory(); factory.setUsername(getUsername()); factory.setPassword(getPassword()); - if (getVhost() == null) + if (getVhost() == null) { factory.setVirtualHost("/"); - else + } else { factory.setVirtualHost(getVhost()); + } factory.setHost(getHostname()); factory.setPort(getPortNumber()); return factory.newConnection(executor); http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java index dcfdb2e..69086f6 100644 --- a/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java +++ b/components/camel-rabbitmq/src/main/java/org/apache/camel/component/rabbitmq/RabbitMQProducer.java @@ -1,18 +1,34 @@ +/** + * 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.rabbitmq; +import java.io.IOException; +import java.util.Date; +import java.util.concurrent.Executors; + import com.rabbitmq.client.AMQP; import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection; + import org.apache.camel.Exchange; import org.apache.camel.impl.DefaultProducer; -import java.io.IOException; -import java.util.Date; -import java.util.concurrent.Executors; -/** - * @author Stephen Samuel - */ public class RabbitMQProducer extends DefaultProducer { private final RabbitMQEndpoint endpoint; @@ -48,56 +64,69 @@ public class RabbitMQProducer extends DefaultProducer { AMQP.BasicProperties.Builder properties = new AMQP.BasicProperties.Builder(); final Object contentType = exchange.getIn().getHeader(RabbitMQConstants.CONTENT_TYPE); - if (contentType != null) + if (contentType != null) { properties.contentType(contentType.toString()); - + } + final Object priority = exchange.getIn().getHeader(RabbitMQConstants.PRIORITY); - if (priority != null) + if (priority != null) { properties.priority(Integer.parseInt(priority.toString())); + } final Object messageId = exchange.getIn().getHeader(RabbitMQConstants.MESSAGE_ID); - if (messageId != null) + if (messageId != null) { properties.messageId(messageId.toString()); + } final Object clusterId = exchange.getIn().getHeader(RabbitMQConstants.CLUSTERID); - if (clusterId != null) + if (clusterId != null) { properties.clusterId(clusterId.toString()); + } final Object replyTo = exchange.getIn().getHeader(RabbitMQConstants.REPLY_TO); - if (replyTo != null) + if (replyTo != null) { properties.replyTo(replyTo.toString()); + } final Object correlationId = exchange.getIn().getHeader(RabbitMQConstants.CORRELATIONID); - if (correlationId != null) + if (correlationId != null) { properties.correlationId(correlationId.toString()); + } final Object deliveryMode = exchange.getIn().getHeader(RabbitMQConstants.DELIVERY_MODE); - if (deliveryMode != null) + if (deliveryMode != null) { properties.deliveryMode(Integer.parseInt(deliveryMode.toString())); + } final Object userId = exchange.getIn().getHeader(RabbitMQConstants.USERID); - if (userId != null) + if (userId != null) { properties.userId(userId.toString()); + } final Object type = exchange.getIn().getHeader(RabbitMQConstants.TYPE); - if (type != null) + if (type != null) { properties.type(type.toString()); + } final Object contentEncoding = exchange.getIn().getHeader(RabbitMQConstants.CONTENT_ENCODING); - if (contentEncoding != null) + if (contentEncoding != null) { properties.contentEncoding(contentEncoding.toString()); + } final Object expiration = exchange.getIn().getHeader(RabbitMQConstants.EXPIRATION); - if (expiration != null) + if (expiration != null) { properties.expiration(expiration.toString()); + } final Object appId = exchange.getIn().getHeader(RabbitMQConstants.APP_ID); - if (appId != null) + if (appId != null) { properties.appId(appId.toString()); + } final Object timestamp = exchange.getIn().getHeader(RabbitMQConstants.TIMESTAMP); - if (timestamp != null) + if (timestamp != null) { properties.timestamp(new Date(Long.parseLong(timestamp.toString()))); + } return properties; } http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQComponentTest.java ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQComponentTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQComponentTest.java index 07b068f..7bf707f 100644 --- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQComponentTest.java +++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQComponentTest.java @@ -1,17 +1,30 @@ +/** + * 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.rabbitmq; +import java.util.HashMap; +import java.util.Map; + import org.apache.camel.CamelContext; import org.junit.Test; import org.mockito.Mockito; -import java.util.HashMap; -import java.util.Map; - import static org.junit.Assert.assertEquals; -/** - * @author Stephen Samuel - */ public class RabbitMQComponentTest { private CamelContext context = Mockito.mock(CamelContext.class); http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerIntTest.java ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerIntTest.java index 6f4dfa1..0c57391 100644 --- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerIntTest.java +++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerIntTest.java @@ -1,26 +1,37 @@ +/** + * 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.rabbitmq; +import java.io.IOException; + import com.rabbitmq.client.AMQP; import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection; import com.rabbitmq.client.ConnectionFactory; + import org.apache.camel.Endpoint; import org.apache.camel.EndpointInject; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.component.mock.MockEndpoint; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.io.IOException; - -/** - * @author Stephen Samuel - */ public class RabbitMQConsumerIntTest extends CamelTestSupport { - private static final Logger logger = LoggerFactory.getLogger(RabbitMQConsumerIntTest.class); private static final String EXCHANGE = "ex1"; @EndpointInject(uri = "rabbitmq:localhost:5672/" + EXCHANGE + "?username=cameltest&password=cameltest") http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerTest.java index 26af07b..4cb75f2 100644 --- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerTest.java +++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQConsumerTest.java @@ -1,22 +1,36 @@ +/** + * 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.rabbitmq; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.concurrent.ThreadPoolExecutor; + import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection; + import org.apache.camel.Processor; import org.junit.Test; import org.mockito.Matchers; import org.mockito.Mockito; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.concurrent.ThreadPoolExecutor; - import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; -/** - * @author Stephen Samuel - */ public class RabbitMQConsumerTest { private RabbitMQEndpoint endpoint = Mockito.mock(RabbitMQEndpoint.class); http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java index dbdb34b..a65ecb2 100644 --- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java +++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQEndpointTest.java @@ -1,20 +1,34 @@ +/** + * 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.rabbitmq; +import java.net.URISyntaxException; +import java.util.UUID; +import java.util.concurrent.ThreadPoolExecutor; + import com.rabbitmq.client.Envelope; + import org.apache.camel.Exchange; import org.junit.Test; import org.mockito.Mockito; -import java.net.URISyntaxException; -import java.util.UUID; -import java.util.concurrent.ThreadPoolExecutor; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; -/** - * @author Stephen Samuel - */ public class RabbitMQEndpointTest { private Envelope envelope = Mockito.mock(Envelope.class); http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerIntTest.java ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerIntTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerIntTest.java index b58d728..dbdc419 100644 --- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerIntTest.java +++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerIntTest.java @@ -1,11 +1,33 @@ +/** + * 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.rabbitmq; +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + import com.rabbitmq.client.AMQP; import com.rabbitmq.client.Channel; import com.rabbitmq.client.Connection; import com.rabbitmq.client.ConnectionFactory; import com.rabbitmq.client.DefaultConsumer; import com.rabbitmq.client.Envelope; + + import org.apache.camel.Endpoint; import org.apache.camel.EndpointInject; import org.apache.camel.Produce; @@ -13,27 +35,19 @@ import org.apache.camel.ProducerTemplate; import org.apache.camel.builder.RouteBuilder; import org.apache.camel.test.junit4.CamelTestSupport; import org.junit.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; -/** - * @author Stephen Samuel - */ public class RabbitMQProducerIntTest extends CamelTestSupport { - - private static final Logger logger = LoggerFactory.getLogger(RabbitMQProducerIntTest.class); private static final String EXCHANGE = "ex1"; - @EndpointInject(uri = "rabbitmq:localhost:5672/" + EXCHANGE + "?username=cameltest&password=cameltest") - private Endpoint to; - @Produce(uri = "direct:start") protected ProducerTemplate template; + + @EndpointInject(uri = "rabbitmq:localhost:5672/" + EXCHANGE + "?username=cameltest&password=cameltest") + private Endpoint to; + + @Override protected RouteBuilder createRouteBuilder() throws Exception { return new RouteBuilder() { @@ -56,7 +70,7 @@ public class RabbitMQProducerIntTest extends CamelTestSupport { factory.setVirtualHost("/"); Connection conn = factory.newConnection(); - final List received = new ArrayList(); + final List<Envelope> received = new ArrayList<Envelope>(); Channel channel = conn.createChannel(); channel.queueDeclare("sammyq", false, false, true, null); http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerTest.java ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerTest.java b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerTest.java index 26cff06..188d540 100644 --- a/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerTest.java +++ b/components/camel-rabbitmq/src/test/java/org/apache/camel/component/rabbitmq/RabbitMQProducerTest.java @@ -1,7 +1,28 @@ +/** + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + package org.apache.camel.component.rabbitmq; +import java.io.IOException; +import java.util.concurrent.ExecutorService; + import com.rabbitmq.client.AMQP; import com.rabbitmq.client.Connection; + import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.impl.DefaultMessage; @@ -10,14 +31,8 @@ import org.junit.Test; import org.mockito.Matchers; import org.mockito.Mockito; -import java.io.IOException; -import java.util.concurrent.ExecutorService; - import static org.junit.Assert.assertEquals; -/** - * @author Stephen Samuel - */ public class RabbitMQProducerTest { private RabbitMQEndpoint endpoint = Mockito.mock(RabbitMQEndpoint.class); http://git-wip-us.apache.org/repos/asf/camel/blob/a496191c/components/camel-rabbitmq/src/test/resources/log4j.xml ---------------------------------------------------------------------- diff --git a/components/camel-rabbitmq/src/test/resources/log4j.xml b/components/camel-rabbitmq/src/test/resources/log4j.xml deleted file mode 100644 index 7bdcb8a..0000000 --- a/components/camel-rabbitmq/src/test/resources/log4j.xml +++ /dev/null @@ -1,20 +0,0 @@ -<!DOCTYPE log4j:configuration SYSTEM "log4j.dtd"> -<log4j:configuration threshold="all" debug="true" - xmlns:log4j="http://jakarta.apache.org/log4j/"> - - <appender name="console" class="org.apache.log4j.ConsoleAppender"> - <param name="Target" value="System.out"/> - <layout class="org.apache.log4j.PatternLayout"> - <param name="ConversionPattern" value="[%t] %-5p %c{1}.%M - %m%n"/> - </layout> - </appender> - - <logger name="org.apache.camel.component.rabbitmq"> - <level value="debug"/> - </logger> - <root> - <level value="warn"/> - <appender-ref ref="console"/> - </root> - -</log4j:configuration> \ No newline at end of file