Repository: camel Updated Branches: refs/heads/master 0dc847eaf -> cded03c5a
formatting changes for compliance Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/927205e6 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/927205e6 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/927205e6 Branch: refs/heads/master Commit: 927205e6cbbf44ea3f98ead1ab03ffb196b35b61 Parents: 3879b2c Author: Bryan Love <bryan.l...@iovation.com> Authored: Mon Mar 27 17:22:12 2017 -0700 Committer: Claus Ibsen <davscl...@apache.org> Committed: Tue Mar 28 10:03:54 2017 +0200 ---------------------------------------------------------------------- .../component/sjms/batch/SjmsBatchConsumer.java | 10 +++-- .../component/sjms/batch/SjmsBatchEndpoint.java | 2 +- .../component/sjms/support/MockConnection.java | 36 +++++++++++++----- .../sjms/support/MockConnectionFactory.java | 32 ++++++++++++---- .../sjms/support/MockMessageConsumer.java | 36 +++++++++++++----- .../component/sjms/support/MockSession.java | 40 ++++++++++++++++---- 6 files changed, 118 insertions(+), 38 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/927205e6/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchConsumer.java b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchConsumer.java index 5a28dc2..708cbba 100644 --- a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchConsumer.java +++ b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchConsumer.java @@ -298,7 +298,7 @@ public class SjmsBatchConsumer extends DefaultConsumer { public AtomicBoolean getCompletionTimeoutTrigger() { return completionTimeoutTrigger; } - public void setKeepAliveDelay(int i){ + public void setKeepAliveDelay(int i) { keepAliveDelay = i; } @@ -325,11 +325,15 @@ public class SjmsBatchConsumer extends DefaultConsumer { } catch (javax.jms.IllegalStateException ex) { // from consumeBatchesOnLoop // if keepAliveDelay was not specified (defaults to -1) just rethrow to break the loop. This preserves original default behavior - if(keepAliveDelay < 0) throw ex; + if (keepAliveDelay < 0) { + throw ex; + } // this will log the exception and the parent loop will create a new session getExceptionHandler().handleException("Exception caught consuming from " + destinationName, ex); //sleep to avoid log spamming - if(keepAliveDelay > 0) Thread.sleep(keepAliveDelay); + if (keepAliveDelay > 0) { + Thread.sleep(keepAliveDelay); + } } finally { closeJmsSession(session); } http://git-wip-us.apache.org/repos/asf/camel/blob/927205e6/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchEndpoint.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchEndpoint.java b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchEndpoint.java index 395c23f..c8debd7 100644 --- a/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchEndpoint.java +++ b/components/camel-sjms/src/main/java/org/apache/camel/component/sjms/batch/SjmsBatchEndpoint.java @@ -407,7 +407,7 @@ public class SjmsBatchEndpoint extends DefaultEndpoint implements HeaderFilterSt * it will bail out and the route will shut down if it sees an IllegalStateException. */ public void setKeepAliveDelay(int keepAliveDelay) { - this.keepAliveDelay = keepAliveDelay; + this.keepAliveDelay = keepAliveDelay; } public int getKeepAliveDelay() { return keepAliveDelay; http://git-wip-us.apache.org/repos/asf/camel/blob/927205e6/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockConnection.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockConnection.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockConnection.java index 00f06be..441a263 100644 --- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockConnection.java +++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockConnection.java @@ -1,18 +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.sjms.support; +import javax.jms.JMSException; +import javax.jms.Session; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.management.JMSStatsImpl; import org.apache.activemq.transport.Transport; import org.apache.activemq.util.IdGenerator; -import javax.jms.JMSException; -import javax.jms.Session; - /** * Created by bryan.love on 3/22/17. */ public class MockConnection extends ActiveMQConnection { - private int returnBadSessionNTimes = 0; + private int returnBadSessionNTimes; protected MockConnection(final Transport transport, IdGenerator clientIdGenerator, IdGenerator connectionIdGenerator, JMSStatsImpl factoryStats, int returnBadSessionNTimes) throws Exception { super(transport, clientIdGenerator, connectionIdGenerator, factoryStats); @@ -22,22 +37,23 @@ public class MockConnection extends ActiveMQConnection { public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException { this.checkClosedOrFailed(); this.ensureConnectionInfoSent(); - if(!transacted) { - if(acknowledgeMode == 0) { + if (!transacted) { + if (acknowledgeMode == 0) { throw new JMSException("acknowledgeMode SESSION_TRANSACTED cannot be used for an non-transacted Session"); } - if(acknowledgeMode < 0 || acknowledgeMode > 4) { - throw new JMSException("invalid acknowledgeMode: " + acknowledgeMode + ". Valid values are Session.AUTO_ACKNOWLEDGE (1), Session.CLIENT_ACKNOWLEDGE (2), Session.DUPS_OK_ACKNOWLEDGE (3), ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE (4) or for transacted sessions Session.SESSION_TRANSACTED (0)"); + if (acknowledgeMode < 0 || acknowledgeMode > 4) { + throw new JMSException("invalid acknowledgeMode: " + acknowledgeMode + ". Valid values are Session.AUTO_ACKNOWLEDGE (1), Session.CLIENT_ACKNOWLEDGE (2), " + + "Session.DUPS_OK_ACKNOWLEDGE (3), ActiveMQSession.INDIVIDUAL_ACKNOWLEDGE (4) or for transacted sessions Session.SESSION_TRANSACTED (0)"); } } boolean useBadSession = false; - if(returnBadSessionNTimes > 0){ + if (returnBadSessionNTimes > 0) { useBadSession = true; returnBadSessionNTimes = returnBadSessionNTimes - 1; } - return new MockSession(this, this.getNextSessionId(), transacted?0:acknowledgeMode, this.isDispatchAsync(), this.isAlwaysSessionAsync(), useBadSession); + return new MockSession(this, this.getNextSessionId(), transacted ? 0 : acknowledgeMode, this.isDispatchAsync(), this.isAlwaysSessionAsync(), useBadSession); } } http://git-wip-us.apache.org/repos/asf/camel/blob/927205e6/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockConnectionFactory.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockConnectionFactory.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockConnectionFactory.java index 75cbe0f..0158ff7 100644 --- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockConnectionFactory.java +++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockConnectionFactory.java @@ -1,27 +1,43 @@ +/** + * 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.sjms.support; +import java.net.URI; +import java.net.URISyntaxException; +import javax.jms.Connection; +import javax.jms.JMSException; import org.apache.activemq.ActiveMQConnection; import org.apache.activemq.ActiveMQConnectionFactory; import org.apache.activemq.management.JMSStatsImpl; import org.apache.activemq.transport.Transport; -import javax.jms.Connection; -import javax.jms.JMSException; -import java.net.URI; -import java.net.URISyntaxException; /** * Created by bryan.love on 3/22/17. */ public class MockConnectionFactory extends ActiveMQConnectionFactory { - private int returnBadSessionNTimes = 0; + private int returnBadSessionNTimes; - public Connection createConnection() throws JMSException { - return this.createActiveMQConnection(); - } public MockConnectionFactory(String brokerURL) { super(createURI(brokerURL)); } + public Connection createConnection() throws JMSException { + return this.createActiveMQConnection(); + } private static URI createURI(String brokerURL) { try { return new URI(brokerURL); http://git-wip-us.apache.org/repos/asf/camel/blob/927205e6/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockMessageConsumer.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockMessageConsumer.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockMessageConsumer.java index 624c152..467aedf 100644 --- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockMessageConsumer.java +++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockMessageConsumer.java @@ -1,29 +1,47 @@ +/** + * 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.sjms.support; -import org.apache.activemq.ActiveMQMessageConsumer; -import org.apache.activemq.ActiveMQSession; -import org.apache.activemq.command.ActiveMQDestination; -import org.apache.activemq.command.ConsumerId; -import org.apache.activemq.command.MessageDispatch; - import javax.jms.IllegalStateException; import javax.jms.JMSException; import javax.jms.Message; import javax.jms.MessageListener; +import org.apache.activemq.ActiveMQMessageConsumer; +import org.apache.activemq.ActiveMQSession; +import org.apache.activemq.command.ActiveMQDestination; +import org.apache.activemq.command.ConsumerId; /** * Created by bryan.love on 3/22/17. */ -public class MockMessageConsumer extends ActiveMQMessageConsumer{ +public class MockMessageConsumer extends ActiveMQMessageConsumer { private boolean isBadSession; - public MockMessageConsumer(ActiveMQSession session, ConsumerId consumerId, ActiveMQDestination dest, String name, String selector, int prefetch, int maximumPendingMessageCount, boolean noLocal, boolean browser, boolean dispatchAsync, MessageListener messageListener, boolean isBadSession) throws JMSException { + public MockMessageConsumer(ActiveMQSession session, ConsumerId consumerId, ActiveMQDestination dest, String name, String selector, int prefetch, + int maximumPendingMessageCount, boolean noLocal, boolean browser, boolean dispatchAsync, MessageListener messageListener, + boolean isBadSession) throws JMSException { super(session, consumerId, dest, name, selector, prefetch, maximumPendingMessageCount, noLocal, browser, dispatchAsync, messageListener); this.isBadSession = isBadSession; } public Message receive(long timeout) throws JMSException { - if(isBadSession) throw new IllegalStateException("asdf"); + if (isBadSession) { + throw new IllegalStateException("asdf"); + } return super.receive(timeout); } } http://git-wip-us.apache.org/repos/asf/camel/blob/927205e6/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockSession.java ---------------------------------------------------------------------- diff --git a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockSession.java b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockSession.java index 4290e34..391d734 100644 --- a/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockSession.java +++ b/components/camel-sjms/src/test/java/org/apache/camel/component/sjms/support/MockSession.java @@ -1,18 +1,43 @@ +/** + * 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.sjms.support; -import org.apache.activemq.*; +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MessageConsumer; +import javax.jms.MessageListener; +import javax.jms.Queue; +import javax.jms.Topic; +import org.apache.activemq.ActiveMQConnection; +import org.apache.activemq.ActiveMQMessageTransformation; +import org.apache.activemq.ActiveMQPrefetchPolicy; +import org.apache.activemq.ActiveMQSession; +import org.apache.activemq.CustomDestination; import org.apache.activemq.command.ActiveMQDestination; import org.apache.activemq.command.ActiveMQQueue; import org.apache.activemq.command.ActiveMQTempQueue; import org.apache.activemq.command.SessionId; -import javax.jms.*; /** * Created by bryan.love on 3/22/17. */ public class MockSession extends ActiveMQSession { - private boolean isBadSession = false; + private boolean isBadSession; protected MockSession(ActiveMQConnection connection, SessionId sessionId, int acknowledgeMode, boolean asyncDispatch, boolean sessionAsyncDispatch, boolean isBadSession) throws JMSException { super(connection, sessionId, acknowledgeMode, asyncDispatch, sessionAsyncDispatch); @@ -20,26 +45,27 @@ public class MockSession extends ActiveMQSession { } public Queue createQueue(String queueName) throws JMSException { this.checkClosed(); - return (Queue)(queueName.startsWith("ID:")?new ActiveMQTempQueue(queueName):new ActiveMQQueue(queueName)); + return (Queue)(queueName.startsWith("ID:") ? new ActiveMQTempQueue(queueName) : new ActiveMQQueue(queueName)); } public MessageConsumer createConsumer(Destination destination, String messageSelector, boolean noLocal, MessageListener messageListener) throws JMSException { this.checkClosed(); - if(destination instanceof CustomDestination) { + if (destination instanceof CustomDestination) { CustomDestination prefetchPolicy1 = (CustomDestination)destination; return prefetchPolicy1.createConsumer(this, messageSelector, noLocal); } else { ActiveMQPrefetchPolicy prefetchPolicy = this.connection.getPrefetchPolicy(); boolean prefetch = false; int prefetch1; - if(destination instanceof Topic) { + if (destination instanceof Topic) { prefetch1 = prefetchPolicy.getTopicPrefetch(); } else { prefetch1 = prefetchPolicy.getQueuePrefetch(); } ActiveMQDestination activemqDestination = ActiveMQMessageTransformation.transformDestination(destination); - return new MockMessageConsumer(this, this.getNextConsumerId(), activemqDestination, (String)null, messageSelector, prefetch1, prefetchPolicy.getMaximumPendingMessageLimit(), noLocal, false, this.isAsyncDispatch(), messageListener, isBadSession); + return new MockMessageConsumer(this, this.getNextConsumerId(), activemqDestination, (String)null, messageSelector, prefetch1, prefetchPolicy.getMaximumPendingMessageLimit(), + noLocal, false, this.isAsyncDispatch(), messageListener, isBadSession); } } }