ARTEMIS-2023 Avoiding boolean on every message for 1x and tests
Project: http://git-wip-us.apache.org/repos/asf/activemq-artemis/repo Commit: http://git-wip-us.apache.org/repos/asf/activemq-artemis/commit/93cffedc Tree: http://git-wip-us.apache.org/repos/asf/activemq-artemis/tree/93cffedc Diff: http://git-wip-us.apache.org/repos/asf/activemq-artemis/diff/93cffedc Branch: refs/heads/master Commit: 93cffedcba9d293c24b3497a1aff1de491bbf39c Parents: 88914e9 Author: Clebert Suconic <clebertsuco...@apache.org> Authored: Tue Aug 28 17:35:57 2018 -0400 Committer: Clebert Suconic <clebertsuco...@apache.org> Committed: Thu Aug 30 14:29:58 2018 -0400 ---------------------------------------------------------------------- .../artemis/jms/client/ActiveMQMapMessage.java | 2 +- .../artemis/jms/client/ActiveMQMessage.java | 57 ++----- .../jms/client/ActiveMQMessageConsumer.java | 6 +- .../jms/client/ActiveMQQueueBrowser.java | 7 +- .../artemis/jms/client/ActiveMQSession.java | 70 ++++++-- .../jms/client/ActiveMQStreamMessage.java | 2 +- .../jms/client/JMSMessageListenerWrapper.java | 13 +- .../ActiveMQBytesCompatibleMessage.java | 57 +++++++ .../compatible1X/ActiveMQCompatibleMessage.java | 159 ++++++++++++++++++ .../ActiveMQMapCompatibleMessage.java | 58 +++++++ .../ActiveMQObjectCompatibleMessage.java | 61 +++++++ .../ActiveMQStreamCompatibleMessage.java | 59 +++++++ .../ActiveMQTextCompabileMessage.java | 50 ++++++ .../artemis/ra/inflow/ActiveMQActivation.java | 5 + .../ra/inflow/ActiveMQMessageHandler.java | 13 +- .../artemis/tests/compatibility/GroovyRun.java | 6 + .../validateClient.groovy | 2 + .../resources/ReplyToTest/replyToReceive.groovy | 87 ++++++++++ .../resources/ReplyToTest/replyToSend.groovy | 70 ++++++++ .../addressConfig/artemisServer.groovy | 2 +- .../addressConfig/receiveMessages.groovy | 2 +- .../addressConfig/sendMessagesAddress.groovy | 2 +- .../resources/exportimport/artemisServer.groovy | 2 +- .../main/resources/exportimport/export.groovy | 1 + .../main/resources/exportimport/export1X.groovy | 1 + .../main/resources/exportimport/import.groovy | 1 + .../journalcompatibility/forcepaging.groovy | 2 + .../journalcompatibility/ispaging.groovy | 2 + .../oldAddressSpace/receiveMessages.groovy | 2 + .../prefixSendAckTest/artemisServer.groovy | 2 +- .../prefixSendAckTest/sendAckMessages.groovy | 2 +- .../sendAckTest/sendAckMessages.groovy | 2 +- .../src/main/resources/serial/cfserial.groovy | 2 +- .../src/main/resources/serial/jbmserial.groovy | 2 +- .../src/main/resources/serial/serial.groovy | 2 +- .../ActiveMQJMSClientCompatibilityTest.java | 3 +- .../tests/compatibility/AddressConfigTest.java | 3 +- .../tests/compatibility/ClasspathBaseTest.java | 152 ----------------- ...onFactoryConfigurationSerializationTest.java | 3 +- .../tests/compatibility/ExportImportTest.java | 3 +- .../compatibility/HQClientTopologyTest.java | 3 +- .../tests/compatibility/HQFailoverTest.java | 3 +- .../compatibility/JournalCompatibilityTest.java | 3 +- .../artemis/tests/compatibility/MeshTest.java | 11 +- .../compatibility/OldAddressSpaceTest.java | 3 +- .../tests/compatibility/PrefixSendAckTest.java | 3 +- .../tests/compatibility/ReplyToTest.java | 134 +++++++++++++++ .../tests/compatibility/SendAckTest.java | 3 +- .../tests/compatibility/SerializationTest.java | 3 +- .../tests/compatibility/ServerBaseTest.java | 41 ----- .../tests/compatibility/VersionedBaseTest.java | 103 ------------ .../tests/compatibility/base/ClasspathBase.java | 164 +++++++++++++++++++ .../tests/compatibility/base/ServerBase.java | 41 +++++ .../tests/compatibility/base/VersionedBase.java | 115 +++++++++++++ 54 files changed, 1216 insertions(+), 391 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java index 9749328..557b0b8 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMapMessage.java @@ -38,7 +38,7 @@ import static org.apache.activemq.artemis.reader.MapMessageUtil.writeBodyMap; /** * ActiveMQ Artemis implementation of a JMS MapMessage. */ -public final class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage { +public class ActiveMQMapMessage extends ActiveMQMessage implements MapMessage { // Constants ----------------------------------------------------- public static final byte TYPE = Message.MAP_TYPE; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java index ff7da00..a3360ef 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessage.java @@ -197,7 +197,7 @@ public class ActiveMQMessage implements javax.jms.Message { private String msgID; // Cache it - private Destination replyTo; + protected Destination replyTo; // Cache it private String jmsCorrelationID; @@ -209,8 +209,6 @@ public class ActiveMQMessage implements javax.jms.Message { private boolean clientAck; - private boolean enable1xPrefixes; - private long jmsDeliveryTime; // Constructors -------------------------------------------------- @@ -366,23 +364,11 @@ public class ActiveMQMessage implements javax.jms.Message { @Override public Destination getJMSReplyTo() throws JMSException { if (replyTo == null) { - SimpleString address = MessageUtil.getJMSReplyTo(message); - if (address != null) { - String name = address.toString(); - - // swap the old prefixes for the new ones so the proper destination type gets created - if (enable1xPrefixes) { - if (address.startsWith(OLD_QUEUE_QUALIFIED_PREFIX)) { - name = address.subSeq(OLD_QUEUE_QUALIFIED_PREFIX.length(), address.length()).toString(); - } else if (address.startsWith(OLD_TEMP_QUEUE_QUALIFED_PREFIX)) { - name = address.subSeq(OLD_TEMP_QUEUE_QUALIFED_PREFIX.length(), address.length()).toString(); - } else if (address.startsWith(OLD_TOPIC_QUALIFIED_PREFIX)) { - name = address.subSeq(OLD_TOPIC_QUALIFIED_PREFIX.length(), address.length()).toString(); - } else if (address.startsWith(OLD_TEMP_TOPIC_QUALIFED_PREFIX)) { - name = address.subSeq(OLD_TEMP_TOPIC_QUALIFED_PREFIX.length(), address.length()).toString(); - } - } - replyTo = ActiveMQDestination.fromPrefixedName(address.toString(), name); + + SimpleString repl = MessageUtil.getJMSReplyTo(message); + + if (repl != null) { + replyTo = ActiveMQDestination.fromPrefixedName(repl.toString()); } } return replyTo; @@ -417,23 +403,20 @@ public class ActiveMQMessage implements javax.jms.Message { } } + protected SimpleString checkPrefix(SimpleString address) { + return address; + } + + protected SimpleString checkPrefixStr(SimpleString address) { + return address; + } + + @Override public Destination getJMSDestination() throws JMSException { if (dest == null) { SimpleString address = message.getAddressSimpleString(); - SimpleString name = address; - - if (address != null & enable1xPrefixes) { - if (address.startsWith(PacketImpl.OLD_QUEUE_PREFIX)) { - name = address.subSeq(PacketImpl.OLD_QUEUE_PREFIX.length(), address.length()); - } else if (address.startsWith(PacketImpl.OLD_TEMP_QUEUE_PREFIX)) { - name = address.subSeq(PacketImpl.OLD_TEMP_QUEUE_PREFIX.length(), address.length()); - } else if (address.startsWith(PacketImpl.OLD_TOPIC_PREFIX)) { - name = address.subSeq(PacketImpl.OLD_TOPIC_PREFIX.length(), address.length()); - } else if (address.startsWith(PacketImpl.OLD_TEMP_TOPIC_PREFIX)) { - name = address.subSeq(PacketImpl.OLD_TEMP_TOPIC_PREFIX.length(), address.length()); - } - } + SimpleString changedAddress = checkPrefix(address); if (address == null) { dest = null; @@ -445,8 +428,8 @@ public class ActiveMQMessage implements javax.jms.Message { dest = (ActiveMQDestination) ActiveMQDestination.fromPrefixedName(address.toString()); } - if (name != null) { - ((ActiveMQDestination) dest).setName(name.toString()); + if (changedAddress != null) { + ((ActiveMQDestination) dest).setName(changedAddress.toString()); } } @@ -903,10 +886,6 @@ public class ActiveMQMessage implements javax.jms.Message { } } - public void setEnable1xPrefixes(boolean enable1xPrefixes) { - this.enable1xPrefixes = enable1xPrefixes; - } - @Override public String toString() { StringBuffer sb = new StringBuffer("ActiveMQMessage["); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java index 8fabe8b..dac8e57 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQMessageConsumer.java @@ -36,6 +36,7 @@ import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; import org.apache.activemq.artemis.core.client.ActiveMQClientLogger; import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; +import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQCompatibleMessage; /** * ActiveMQ Artemis implementation of a JMS MessageConsumer. @@ -218,10 +219,11 @@ public final class ActiveMQMessageConsumer implements QueueReceiver, TopicSubscr boolean needSession = ackMode == Session.CLIENT_ACKNOWLEDGE || ackMode == ActiveMQJMSConstants.INDIVIDUAL_ACKNOWLEDGE || coreMessage.getType() == ActiveMQObjectMessage.TYPE; - jmsMsg = ActiveMQMessage.createMessage(coreMessage, needSession ? coreSession : null, options); if (session.isEnable1xPrefixes()) { - jmsMsg.setEnable1xPrefixes(true); + jmsMsg = ActiveMQCompatibleMessage.createMessage(coreMessage, needSession ? coreSession : null, options); + } else { + jmsMsg = ActiveMQMessage.createMessage(coreMessage, needSession ? coreSession : null, options); } try { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java index 716d044..810166c 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQQueueBrowser.java @@ -27,6 +27,7 @@ import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQCompatibleMessage; import org.apache.activemq.artemis.utils.SelectorTranslator; /** @@ -141,10 +142,10 @@ public final class ActiveMQQueueBrowser implements QueueBrowser { if (hasMoreElements()) { ClientMessage next = current; current = null; - msg = ActiveMQMessage.createMessage(next, session, options); - if (enable1xPrefixes) { - msg.setEnable1xPrefixes(true); + msg = ActiveMQCompatibleMessage.createMessage(next, session, options); + } else { + msg = ActiveMQMessage.createMessage(next, session, options); } try { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java index 528310f..95d3608 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQSession.java @@ -62,6 +62,12 @@ import org.apache.activemq.artemis.api.core.client.ClientSession.AddressQuery; import org.apache.activemq.artemis.api.core.client.ClientSession.QueueQuery; import org.apache.activemq.artemis.api.core.RoutingType; import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; +import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQBytesCompatibleMessage; +import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQCompatibleMessage; +import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQMapCompatibleMessage; +import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQObjectCompatibleMessage; +import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQStreamCompatibleMessage; +import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQTextCompabileMessage; import org.apache.activemq.artemis.selector.filter.FilterException; import org.apache.activemq.artemis.selector.impl.SelectorParser; import org.apache.activemq.artemis.utils.SelectorTranslator; @@ -144,8 +150,12 @@ public class ActiveMQSession implements QueueSession, TopicSession { public BytesMessage createBytesMessage() throws JMSException { checkClosed(); - ActiveMQBytesMessage message = new ActiveMQBytesMessage(session); - message.setEnable1xPrefixes(enable1xPrefixes); + ActiveMQBytesMessage message; + if (enable1xPrefixes) { + message = new ActiveMQBytesCompatibleMessage(session); + } else { + message = new ActiveMQBytesMessage(session); + } return message; } @@ -153,8 +163,12 @@ public class ActiveMQSession implements QueueSession, TopicSession { public MapMessage createMapMessage() throws JMSException { checkClosed(); - ActiveMQMapMessage message = new ActiveMQMapMessage(session); - message.setEnable1xPrefixes(enable1xPrefixes); + ActiveMQMapMessage message; + if (enable1xPrefixes) { + message = new ActiveMQMapCompatibleMessage(session); + } else { + message = new ActiveMQMapMessage(session); + } return message; } @@ -162,8 +176,12 @@ public class ActiveMQSession implements QueueSession, TopicSession { public Message createMessage() throws JMSException { checkClosed(); - ActiveMQMessage message = new ActiveMQMessage(session); - message.setEnable1xPrefixes(enable1xPrefixes); + ActiveMQMessage message; + if (enable1xPrefixes) { + message = new ActiveMQCompatibleMessage(session); + } else { + message = new ActiveMQMessage(session); + } return message; } @@ -171,8 +189,12 @@ public class ActiveMQSession implements QueueSession, TopicSession { public ObjectMessage createObjectMessage() throws JMSException { checkClosed(); - ActiveMQObjectMessage message = new ActiveMQObjectMessage(session, options); - message.setEnable1xPrefixes(enable1xPrefixes); + ActiveMQObjectMessage message; + if (enable1xPrefixes) { + message = new ActiveMQObjectCompatibleMessage(session, options); + } else { + message = new ActiveMQObjectMessage(session, options); + } return message; } @@ -180,9 +202,13 @@ public class ActiveMQSession implements QueueSession, TopicSession { public ObjectMessage createObjectMessage(final Serializable object) throws JMSException { checkClosed(); - ActiveMQObjectMessage msg = new ActiveMQObjectMessage(session, options); + ActiveMQObjectMessage msg; + if (enable1xPrefixes) { + msg = new ActiveMQObjectCompatibleMessage(session, options); + } else { + msg = new ActiveMQObjectMessage(session, options); + } msg.setObject(object); - msg.setEnable1xPrefixes(enable1xPrefixes); return msg; } @@ -191,8 +217,12 @@ public class ActiveMQSession implements QueueSession, TopicSession { public StreamMessage createStreamMessage() throws JMSException { checkClosed(); - ActiveMQStreamMessage message = new ActiveMQStreamMessage(session); - message.setEnable1xPrefixes(enable1xPrefixes); + ActiveMQStreamMessage message; + if (enable1xPrefixes) { + message = new ActiveMQStreamMessage(session); + } else { + message = new ActiveMQStreamCompatibleMessage(session); + } return message; } @@ -200,9 +230,13 @@ public class ActiveMQSession implements QueueSession, TopicSession { public TextMessage createTextMessage() throws JMSException { checkClosed(); - ActiveMQTextMessage msg = new ActiveMQTextMessage(session); + ActiveMQTextMessage msg; + if (enable1xPrefixes) { + msg = new ActiveMQTextCompabileMessage(session); + } else { + msg = new ActiveMQTextMessage(session); + } msg.setText(null); - msg.setEnable1xPrefixes(enable1xPrefixes); return msg; } @@ -211,9 +245,13 @@ public class ActiveMQSession implements QueueSession, TopicSession { public TextMessage createTextMessage(final String text) throws JMSException { checkClosed(); - ActiveMQTextMessage msg = new ActiveMQTextMessage(session); + ActiveMQTextMessage msg; + if (enable1xPrefixes) { + msg = new ActiveMQTextCompabileMessage(session); + } else { + msg = new ActiveMQTextMessage(session); + } msg.setText(text); - msg.setEnable1xPrefixes(enable1xPrefixes); return msg; } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java index 1c70c5b..6904df4 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/ActiveMQStreamMessage.java @@ -44,7 +44,7 @@ import static org.apache.activemq.artemis.reader.StreamMessageUtil.streamReadStr /** * ActiveMQ Artemis implementation of a JMS StreamMessage. */ -public final class ActiveMQStreamMessage extends ActiveMQMessage implements StreamMessage { +public class ActiveMQStreamMessage extends ActiveMQMessage implements StreamMessage { public static final byte TYPE = Message.STREAM_TYPE; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java index 0d2420b..f24e90d 100644 --- a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/JMSMessageListenerWrapper.java @@ -25,6 +25,7 @@ import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.jms.ActiveMQJMSConstants; import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; +import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQCompatibleMessage; public class JMSMessageListenerWrapper implements MessageHandler { @@ -72,7 +73,13 @@ public class JMSMessageListenerWrapper implements MessageHandler { */ @Override public void onMessage(final ClientMessage message) { - ActiveMQMessage msg = ActiveMQMessage.createMessage(message, session.getCoreSession(), options); + ActiveMQMessage msg; + + if (session.isEnable1xPrefixes()) { + msg = ActiveMQCompatibleMessage.createMessage(message, session.getCoreSession(), options); + } else { + msg = ActiveMQMessage.createMessage(message, session.getCoreSession(), options); + } if (individualACK) { msg.setIndividualAcknowledge(); @@ -82,10 +89,6 @@ public class JMSMessageListenerWrapper implements MessageHandler { msg.setClientAcknowledge(); } - if (session.isEnable1xPrefixes()) { - msg.setEnable1xPrefixes(true); - } - try { msg.doBeforeReceive(); } catch (Exception e) { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQBytesCompatibleMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQBytesCompatibleMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQBytesCompatibleMessage.java new file mode 100644 index 0000000..626b5a5 --- /dev/null +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQBytesCompatibleMessage.java @@ -0,0 +1,57 @@ +/* + * 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.activemq.artemis.jms.client.compatible1X; + +import javax.jms.BytesMessage; +import javax.jms.Destination; +import javax.jms.JMSException; + +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ClientMessage; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage; + +public class ActiveMQBytesCompatibleMessage extends ActiveMQBytesMessage { + + @Override + protected SimpleString checkPrefix(SimpleString address) { + return ActiveMQCompatibleMessage.checkPrefix1X(address); + } + + + @Override + public Destination getJMSReplyTo() throws JMSException { + if (replyTo == null) { + replyTo = ActiveMQCompatibleMessage.findCompatibleReplyTo(message); + } + return replyTo; + } + + + public ActiveMQBytesCompatibleMessage(ClientSession session) { + super(session); + } + + protected ActiveMQBytesCompatibleMessage(ClientMessage message, ClientSession session) { + super(message, session); + } + + public ActiveMQBytesCompatibleMessage(BytesMessage foreign, ClientSession session) throws JMSException { + super(foreign, session); + } +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQCompatibleMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQCompatibleMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQCompatibleMessage.java new file mode 100644 index 0000000..1b21cbf --- /dev/null +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQCompatibleMessage.java @@ -0,0 +1,159 @@ +/* + * 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.activemq.artemis.jms.client.compatible1X; + +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.JMSRuntimeException; +import javax.jms.Message; + +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ClientMessage; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.core.protocol.core.impl.PacketImpl; +import org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage; +import org.apache.activemq.artemis.jms.client.ActiveMQDestination; +import org.apache.activemq.artemis.jms.client.ActiveMQMapMessage; +import org.apache.activemq.artemis.jms.client.ActiveMQMessage; +import org.apache.activemq.artemis.jms.client.ActiveMQObjectMessage; +import org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage; +import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; +import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; +import org.apache.activemq.artemis.reader.MessageUtil; + +public class ActiveMQCompatibleMessage extends ActiveMQMessage { + + public ActiveMQCompatibleMessage(byte type, ClientSession session) { + super(type, session); + } + + public ActiveMQCompatibleMessage(ClientSession session) { + super(session); + } + + public ActiveMQCompatibleMessage(ClientMessage message, ClientSession session) { + super(message, session); + } + + public ActiveMQCompatibleMessage(Message foreign, ClientSession session) throws JMSException { + super(foreign, session); + } + + public ActiveMQCompatibleMessage() { + } + + public ActiveMQCompatibleMessage(Message foreign, byte type, ClientSession session) throws JMSException { + super(foreign, type, session); + } + + @Override + public Destination getJMSReplyTo() throws JMSException { + if (replyTo == null) { + replyTo = findCompatibleReplyTo(message); + } + return replyTo; + } + + public static Destination findCompatibleReplyTo(ClientMessage message) { + SimpleString address = MessageUtil.getJMSReplyTo(message); + if (address != null) { + String name = address.toString(); + + // swap the old prefixes for the new ones so the proper destination type gets created + if (address.startsWith(OLD_QUEUE_QUALIFIED_PREFIX)) { + name = address.subSeq(OLD_QUEUE_QUALIFIED_PREFIX.length(), address.length()).toString(); + } else if (address.startsWith(OLD_TEMP_QUEUE_QUALIFED_PREFIX)) { + name = address.subSeq(OLD_TEMP_QUEUE_QUALIFED_PREFIX.length(), address.length()).toString(); + } else if (address.startsWith(OLD_TOPIC_QUALIFIED_PREFIX)) { + name = address.subSeq(OLD_TOPIC_QUALIFIED_PREFIX.length(), address.length()).toString(); + } else if (address.startsWith(OLD_TEMP_TOPIC_QUALIFED_PREFIX)) { + name = address.subSeq(OLD_TEMP_TOPIC_QUALIFED_PREFIX.length(), address.length()).toString(); + } + return ActiveMQDestination.fromPrefixedName(address.toString(), name); + } + + return null; + } + + @Override + public SimpleString checkPrefix(SimpleString address) { + return checkPrefix1X(address); + } + + protected static SimpleString checkPrefix1X(SimpleString address) { + if (address != null) { + if (address.startsWith(PacketImpl.OLD_QUEUE_PREFIX)) { + return address.subSeq(PacketImpl.OLD_QUEUE_PREFIX.length(), address.length()); + } else if (address.startsWith(PacketImpl.OLD_TEMP_QUEUE_PREFIX)) { + return address.subSeq(PacketImpl.OLD_TEMP_QUEUE_PREFIX.length(), address.length()); + } else if (address.startsWith(PacketImpl.OLD_TOPIC_PREFIX)) { + return address.subSeq(PacketImpl.OLD_TOPIC_PREFIX.length(), address.length()); + } else if (address.startsWith(PacketImpl.OLD_TEMP_TOPIC_PREFIX)) { + return address.subSeq(PacketImpl.OLD_TEMP_TOPIC_PREFIX.length(), address.length()); + } + } + + return null; + } + + public static ActiveMQMessage createMessage(final ClientMessage message, + final ClientSession session, + final ConnectionFactoryOptions options) { + int type = message.getType(); + + ActiveMQMessage msg; + + switch (type) { + case ActiveMQMessage.TYPE: // 0 + { + msg = new ActiveMQCompatibleMessage(message, session); + break; + } + case ActiveMQBytesMessage.TYPE: // 4 + { + msg = new ActiveMQBytesCompatibleMessage(message, session); + break; + } + case ActiveMQMapMessage.TYPE: // 5 + { + msg = new ActiveMQMapCompatibleMessage(message, session); + break; + } + case ActiveMQObjectMessage.TYPE: { + msg = new ActiveMQObjectCompatibleMessage(message, session, options); + break; + } + case ActiveMQStreamMessage.TYPE: // 6 + { + msg = new ActiveMQStreamCompatibleMessage(message, session); + break; + } + case ActiveMQTextMessage.TYPE: // 3 + { + msg = new ActiveMQTextCompabileMessage(message, session); + break; + } + default: { + throw new JMSRuntimeException("Invalid message type " + type); + } + } + + return msg; + } + +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQMapCompatibleMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQMapCompatibleMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQMapCompatibleMessage.java new file mode 100644 index 0000000..2d6e576 --- /dev/null +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQMapCompatibleMessage.java @@ -0,0 +1,58 @@ +/* + * 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.activemq.artemis.jms.client.compatible1X; + +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.MapMessage; + +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ClientMessage; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.jms.client.ActiveMQMapMessage; + +public class ActiveMQMapCompatibleMessage extends ActiveMQMapMessage { + + @Override + protected SimpleString checkPrefix(SimpleString address) { + return ActiveMQCompatibleMessage.checkPrefix1X(address); + } + + @Override + public Destination getJMSReplyTo() throws JMSException { + if (replyTo == null) { + replyTo = ActiveMQCompatibleMessage.findCompatibleReplyTo(message); + } + return replyTo; + } + + public ActiveMQMapCompatibleMessage(ClientSession session) { + super(session); + } + + public ActiveMQMapCompatibleMessage(ClientMessage message, ClientSession session) { + super(message, session); + } + + public ActiveMQMapCompatibleMessage() { + } + + public ActiveMQMapCompatibleMessage(MapMessage foreign, ClientSession session) throws JMSException { + super(foreign, session); + } +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQObjectCompatibleMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQObjectCompatibleMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQObjectCompatibleMessage.java new file mode 100644 index 0000000..13a9d7d --- /dev/null +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQObjectCompatibleMessage.java @@ -0,0 +1,61 @@ +/* + * 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.activemq.artemis.jms.client.compatible1X; + +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.ObjectMessage; + +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ClientMessage; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.jms.client.ActiveMQObjectMessage; +import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; + +public class ActiveMQObjectCompatibleMessage extends ActiveMQObjectMessage { + + @Override + protected SimpleString checkPrefix(SimpleString address) { + return ActiveMQCompatibleMessage.checkPrefix1X(address); + } + + + @Override + public Destination getJMSReplyTo() throws JMSException { + if (replyTo == null) { + replyTo = ActiveMQCompatibleMessage.findCompatibleReplyTo(message); + } + return replyTo; + } + + public ActiveMQObjectCompatibleMessage(ClientSession session, ConnectionFactoryOptions options) { + super(session, options); + } + + public ActiveMQObjectCompatibleMessage(ClientMessage message, + ClientSession session, + ConnectionFactoryOptions options) { + super(message, session, options); + } + + public ActiveMQObjectCompatibleMessage(ObjectMessage foreign, + ClientSession session, + ConnectionFactoryOptions options) throws JMSException { + super(foreign, session, options); + } +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQStreamCompatibleMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQStreamCompatibleMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQStreamCompatibleMessage.java new file mode 100644 index 0000000..bb2fda6 --- /dev/null +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQStreamCompatibleMessage.java @@ -0,0 +1,59 @@ +/* + * 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.activemq.artemis.jms.client.compatible1X; + +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.StreamMessage; + +import org.apache.activemq.artemis.api.core.SimpleString; +import org.apache.activemq.artemis.api.core.client.ClientMessage; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.jms.client.ActiveMQStreamMessage; + +public class ActiveMQStreamCompatibleMessage extends ActiveMQStreamMessage { + + @Override + protected SimpleString checkPrefix(SimpleString address) { + return ActiveMQCompatibleMessage.checkPrefix1X(address); + } + + + @Override + public Destination getJMSReplyTo() throws JMSException { + if (replyTo == null) { + replyTo = ActiveMQCompatibleMessage.findCompatibleReplyTo(message); + } + return replyTo; + } + + public ActiveMQStreamCompatibleMessage(ClientSession session) { + super(session); + } + + public ActiveMQStreamCompatibleMessage(ClientMessage message, ClientSession session) { + super(message, session); + } + + public ActiveMQStreamCompatibleMessage(StreamMessage foreign, ClientSession session) throws JMSException { + super(foreign, session); + } + + public ActiveMQStreamCompatibleMessage() { + } +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQTextCompabileMessage.java ---------------------------------------------------------------------- diff --git a/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQTextCompabileMessage.java b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQTextCompabileMessage.java new file mode 100644 index 0000000..451c582 --- /dev/null +++ b/artemis-jms-client/src/main/java/org/apache/activemq/artemis/jms/client/compatible1X/ActiveMQTextCompabileMessage.java @@ -0,0 +1,50 @@ +/* + * 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.activemq.artemis.jms.client.compatible1X; + +import javax.jms.Destination; +import javax.jms.JMSException; +import javax.jms.TextMessage; + +import org.apache.activemq.artemis.api.core.client.ClientMessage; +import org.apache.activemq.artemis.api.core.client.ClientSession; +import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; + +public class ActiveMQTextCompabileMessage extends ActiveMQTextMessage { + + + @Override + public Destination getJMSReplyTo() throws JMSException { + if (replyTo == null) { + replyTo = ActiveMQCompatibleMessage.findCompatibleReplyTo(message); + } + return replyTo; + } + + public ActiveMQTextCompabileMessage(ClientSession session) { + super(session); + } + + public ActiveMQTextCompabileMessage(ClientMessage message, ClientSession session) { + super(message, session); + } + + public ActiveMQTextCompabileMessage(TextMessage foreign, ClientSession session) throws JMSException { + super(foreign, session); + } +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java ---------------------------------------------------------------------- diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java index d6013e3..b0f0aff 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQActivation.java @@ -385,6 +385,11 @@ public class ActiveMQActivation { Thread interruptThread = handler.getCurrentThread(); if (interruptThread != null) { try { + logger.tracef("Interrupting thread %s", interruptThread.getName()); + } catch (Throwable justLog) { + logger.warn(justLog); + } + try { interruptThread.interrupt(); } catch (Throwable e) { //ok http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java ---------------------------------------------------------------------- diff --git a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java index 33c6445..ef23d50 100644 --- a/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java +++ b/artemis-ra/src/main/java/org/apache/activemq/artemis/ra/inflow/ActiveMQMessageHandler.java @@ -41,6 +41,7 @@ import org.apache.activemq.artemis.core.client.impl.ClientSessionInternal; import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.client.ActiveMQMessage; import org.apache.activemq.artemis.jms.client.ConnectionFactoryOptions; +import org.apache.activemq.artemis.jms.client.compatible1X.ActiveMQCompatibleMessage; import org.apache.activemq.artemis.ra.ActiveMQRALogger; import org.apache.activemq.artemis.ra.ActiveMQResourceAdapter; import org.apache.activemq.artemis.service.extensions.ServiceUtils; @@ -86,6 +87,8 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList private volatile boolean connected; + private boolean enable1XPrefix; + public ActiveMQMessageHandler(final ConnectionFactoryOptions options, final ActiveMQActivation activation, final TransactionManager tm, @@ -105,6 +108,8 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList logger.trace("setup()"); } + this.enable1XPrefix = activation.getConnectionFactory().isEnable1xPrefixes(); + ActiveMQActivationSpec spec = activation.getActivationSpec(); String selector = spec.getMessageSelector(); @@ -281,8 +286,12 @@ public class ActiveMQMessageHandler implements MessageHandler, FailoverEventList logger.trace("onMessage(" + message + ")"); } - ActiveMQMessage msg = ActiveMQMessage.createMessage(message, session, options); - msg.setEnable1xPrefixes(activation.getConnectionFactory().isEnable1xPrefixes()); + ActiveMQMessage msg; + if (enable1XPrefix) { + msg = ActiveMQCompatibleMessage.createMessage(message, session, options); + } else { + msg = ActiveMQMessage.createMessage(message, session, options); + } boolean beforeDelivery = false; http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/java/org/apache/activemq/artemis/tests/compatibility/GroovyRun.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/java/org/apache/activemq/artemis/tests/compatibility/GroovyRun.java b/tests/compatibility-tests/src/main/java/org/apache/activemq/artemis/tests/compatibility/GroovyRun.java index 5efa3d3..3be275b 100644 --- a/tests/compatibility-tests/src/main/java/org/apache/activemq/artemis/tests/compatibility/GroovyRun.java +++ b/tests/compatibility-tests/src/main/java/org/apache/activemq/artemis/tests/compatibility/GroovyRun.java @@ -39,6 +39,11 @@ public class GroovyRun { public static Binding binding = new Binding(); public static GroovyShell shell = new GroovyShell(binding); + public static void clear() { + binding = new Binding(); + shell = new GroovyShell(binding); + } + /** * This can be called from the scripts as well. * The scripts will use this method instead of its own groovy method. @@ -68,6 +73,7 @@ public class GroovyRun { return shell.evaluate(scriptURI); } + public static void setVariable(String name, Object arg) { binding.setVariable(name, arg); } http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/ActiveMQJMSClientCompatibilityTest/validateClient.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/ActiveMQJMSClientCompatibilityTest/validateClient.groovy b/tests/compatibility-tests/src/main/resources/ActiveMQJMSClientCompatibilityTest/validateClient.groovy index 400a69e..d1c77f8 100644 --- a/tests/compatibility-tests/src/main/resources/ActiveMQJMSClientCompatibilityTest/validateClient.groovy +++ b/tests/compatibility-tests/src/main/resources/ActiveMQJMSClientCompatibilityTest/validateClient.groovy @@ -1,3 +1,5 @@ +package ActiveMQJMSClientCompatibilityTest + import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient import org.apache.activemq.artemis.jms.client.ActiveMQQueue import org.apache.activemq.artemis.jms.client.ActiveMQTopic http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/ReplyToTest/replyToReceive.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/ReplyToTest/replyToReceive.groovy b/tests/compatibility-tests/src/main/resources/ReplyToTest/replyToReceive.groovy new file mode 100644 index 0000000..156cbdb --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/ReplyToTest/replyToReceive.groovy @@ -0,0 +1,87 @@ +package ReplyToTest + +import org.apache.activemq.artemis.api.core.client.ActiveMQClient +import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory +import org.apache.activemq.artemis.jms.client.ActiveMQQueue +import org.apache.activemq.artemis.tests.compatibility.GroovyRun + +import javax.jms.* + +/* + * 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. + */ + +cf = new ActiveMQConnectionFactory("tcp://localhost:61616?confirmationWindowSize=1048576&blockOnDurableSend=false&ha=true&reconnectAttempts=-1&retryInterval=100"); +Connection connection = cf.createConnection(); +connection.start(); +Session session = connection.createSession(true, Session.SESSION_TRANSACTED); +Queue queue = session.createQueue("queue"); +QueueBrowser browser = session.createBrowser(queue); + +Enumeration<Message> messageEnumeration = browser.getEnumeration(); + +ArrayList<Message> messages = new ArrayList<>(); + +while (messageEnumeration.hasMoreElements()) { + messages.add(messageEnumeration.nextElement()); +} + +check(messages); + +MessageConsumer consumer = session.createConsumer(queue); +messages.clear(); + +while(true) { + Message message = consumer.receiveNoWait(); + if (message == null) { + break; + } + messages.add(message); +} + +check(messages); + +connection.close(); + +void check(List<Message> messages) { + Iterator<Message> iterator = messages.iterator(); + Message bareMessage = iterator.next(); + checkMessage(bareMessage); + + BytesMessage bytesMessage = iterator.next(); + checkMessage(bytesMessage); + + + MapMessage mapMessage = iterator.next(); + checkMessage(mapMessage); + + ObjectMessage objectMessage = iterator.next(); + checkMessage(objectMessage); + + StreamMessage streamMessage = iterator.next(); + checkMessage(streamMessage); + + TextMessage textMessage = iterator.next(); + checkMessage(objectMessage); +} + + +void checkMessage(Message message) { + ActiveMQQueue queue = message.getJMSReplyTo(); + GroovyRun.assertEquals("jms.queue.t1", queue.getAddress()); + GroovyRun.assertEquals("t1", queue.getName()); +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/ReplyToTest/replyToSend.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/ReplyToTest/replyToSend.groovy b/tests/compatibility-tests/src/main/resources/ReplyToTest/replyToSend.groovy new file mode 100644 index 0000000..478699e --- /dev/null +++ b/tests/compatibility-tests/src/main/resources/ReplyToTest/replyToSend.groovy @@ -0,0 +1,70 @@ +package ReplyToTest + +import org.apache.activemq.artemis.api.core.client.ActiveMQClient +import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient +import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory +import org.apache.activemq.artemis.jms.client.ActiveMQQueue +import org.apache.activemq.artemis.jms.client.ActiveMQTopic +import org.apache.activemq.artemis.tests.compatibility.GroovyRun + +import javax.jms.* + +/* + * 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. + */ + +ActiveMQQueue queue = (ActiveMQQueue) ActiveMQJMSClient.createQueue("q1"); +GroovyRun.assertEquals("jms.queue.q1", queue.getAddress()); +GroovyRun.assertEquals("q1", queue.getQueueName()); +ActiveMQTopic topic = (ActiveMQTopic) ActiveMQJMSClient.createTopic("t1"); +GroovyRun.assertEquals("jms.topic.t1", topic.getAddress()); +GroovyRun.assertEquals("t1", topic.getTopicName()); + +cf = new ActiveMQConnectionFactory("tcp://localhost:61616?confirmationWindowSize=1048576&blockOnDurableSend=false&ha=true&reconnectAttempts=-1&retryInterval=100"); +Connection connection = cf.createConnection(); +Session session = connection.createSession(true, Session.SESSION_TRANSACTED); +queue = session.createQueue("queue"); +replyToQueue = ActiveMQJMSClient.createQueue("t1"); + +producer = session.createProducer(queue); +producer.setDeliveryMode(DeliveryMode.PERSISTENT); + +Message bareMessage = session.createMessage(); +send(bareMessage); + +BytesMessage bytesMessage = session.createBytesMessage(); +bytesMessage.writeBytes("hello".getBytes()); +send(bytesMessage); + + +MapMessage mapMessage = session.createMapMessage(); +send(mapMessage); + +ObjectMessage objectMessage = session.createObjectMessage("hello"); +send(objectMessage); + +send(session.createStreamMessage()); + +TextMessage textMessage = session.createTextMessage("May the force be with you"); +send(textMessage); + +session.commit(); + + +void send(Message message) { + message.setJMSReplyTo(replyToQueue); + producer.send(message); +} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/addressConfig/artemisServer.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/addressConfig/artemisServer.groovy b/tests/compatibility-tests/src/main/resources/addressConfig/artemisServer.groovy index c739942..8221de7 100644 --- a/tests/compatibility-tests/src/main/resources/addressConfig/artemisServer.groovy +++ b/tests/compatibility-tests/src/main/resources/addressConfig/artemisServer.groovy @@ -1,4 +1,4 @@ -package servers +package addressConfig /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/addressConfig/receiveMessages.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/addressConfig/receiveMessages.groovy b/tests/compatibility-tests/src/main/resources/addressConfig/receiveMessages.groovy index 0dbf4ba..441b8e5 100644 --- a/tests/compatibility-tests/src/main/resources/addressConfig/receiveMessages.groovy +++ b/tests/compatibility-tests/src/main/resources/addressConfig/receiveMessages.groovy @@ -1,4 +1,4 @@ -package meshTest +package addressConfig import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory import org.apache.activemq.artemis.tests.compatibility.GroovyRun http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/addressConfig/sendMessagesAddress.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/addressConfig/sendMessagesAddress.groovy b/tests/compatibility-tests/src/main/resources/addressConfig/sendMessagesAddress.groovy index b75f8f5..7567b2c 100644 --- a/tests/compatibility-tests/src/main/resources/addressConfig/sendMessagesAddress.groovy +++ b/tests/compatibility-tests/src/main/resources/addressConfig/sendMessagesAddress.groovy @@ -1,4 +1,4 @@ -package meshTest +package addressConfig import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/exportimport/artemisServer.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/exportimport/artemisServer.groovy b/tests/compatibility-tests/src/main/resources/exportimport/artemisServer.groovy index 92d2a10..0064493 100644 --- a/tests/compatibility-tests/src/main/resources/exportimport/artemisServer.groovy +++ b/tests/compatibility-tests/src/main/resources/exportimport/artemisServer.groovy @@ -1,4 +1,4 @@ -package servers +package exportimport /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/exportimport/export.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/exportimport/export.groovy b/tests/compatibility-tests/src/main/resources/exportimport/export.groovy index bad99e7..2388fdd 100644 --- a/tests/compatibility-tests/src/main/resources/exportimport/export.groovy +++ b/tests/compatibility-tests/src/main/resources/exportimport/export.groovy @@ -1,3 +1,4 @@ +package exportimport /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/exportimport/export1X.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/exportimport/export1X.groovy b/tests/compatibility-tests/src/main/resources/exportimport/export1X.groovy index 79b81c1..399f5c3 100644 --- a/tests/compatibility-tests/src/main/resources/exportimport/export1X.groovy +++ b/tests/compatibility-tests/src/main/resources/exportimport/export1X.groovy @@ -1,3 +1,4 @@ +package exportimport /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/exportimport/import.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/exportimport/import.groovy b/tests/compatibility-tests/src/main/resources/exportimport/import.groovy index 39481d5..b71871c 100644 --- a/tests/compatibility-tests/src/main/resources/exportimport/import.groovy +++ b/tests/compatibility-tests/src/main/resources/exportimport/import.groovy @@ -1,3 +1,4 @@ +package exportimport /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/journalcompatibility/forcepaging.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/journalcompatibility/forcepaging.groovy b/tests/compatibility-tests/src/main/resources/journalcompatibility/forcepaging.groovy index 032bcc1..76e5f0d 100644 --- a/tests/compatibility-tests/src/main/resources/journalcompatibility/forcepaging.groovy +++ b/tests/compatibility-tests/src/main/resources/journalcompatibility/forcepaging.groovy @@ -1,3 +1,5 @@ +package journalcompatibility + import org.apache.activemq.artemis.api.core.SimpleString import org.apache.activemq.artemis.core.server.Queue import org.apache.activemq.artemis.tests.compatibility.GroovyRun http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/journalcompatibility/ispaging.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/journalcompatibility/ispaging.groovy b/tests/compatibility-tests/src/main/resources/journalcompatibility/ispaging.groovy index a6dea7d..8bc8ed5 100644 --- a/tests/compatibility-tests/src/main/resources/journalcompatibility/ispaging.groovy +++ b/tests/compatibility-tests/src/main/resources/journalcompatibility/ispaging.groovy @@ -1,3 +1,5 @@ +package journalcompatibility + import org.apache.activemq.artemis.api.core.SimpleString import org.apache.activemq.artemis.core.server.Queue import org.apache.activemq.artemis.tests.compatibility.GroovyRun http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/oldAddressSpace/receiveMessages.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/oldAddressSpace/receiveMessages.groovy b/tests/compatibility-tests/src/main/resources/oldAddressSpace/receiveMessages.groovy index 632993f..0a32798 100644 --- a/tests/compatibility-tests/src/main/resources/oldAddressSpace/receiveMessages.groovy +++ b/tests/compatibility-tests/src/main/resources/oldAddressSpace/receiveMessages.groovy @@ -65,6 +65,8 @@ for (int i = 0; i < 500; i++) { } session.commit(); +connection.close(); + // Defined on AddressConfigTest.java at the test with setVariable latch.countDown(); http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/prefixSendAckTest/artemisServer.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/prefixSendAckTest/artemisServer.groovy b/tests/compatibility-tests/src/main/resources/prefixSendAckTest/artemisServer.groovy index b85cfcf..5c456a8 100644 --- a/tests/compatibility-tests/src/main/resources/prefixSendAckTest/artemisServer.groovy +++ b/tests/compatibility-tests/src/main/resources/prefixSendAckTest/artemisServer.groovy @@ -1,4 +1,4 @@ -package servers +package prefixSendAckTest /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/prefixSendAckTest/sendAckMessages.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/prefixSendAckTest/sendAckMessages.groovy b/tests/compatibility-tests/src/main/resources/prefixSendAckTest/sendAckMessages.groovy index a24ad83..03d98b9 100644 --- a/tests/compatibility-tests/src/main/resources/prefixSendAckTest/sendAckMessages.groovy +++ b/tests/compatibility-tests/src/main/resources/prefixSendAckTest/sendAckMessages.groovy @@ -1,4 +1,4 @@ -package meshTest +package prefixSendAckTest import org.apache.activemq.artemis.tests.compatibility.GroovyRun http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/sendAckTest/sendAckMessages.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/sendAckTest/sendAckMessages.groovy b/tests/compatibility-tests/src/main/resources/sendAckTest/sendAckMessages.groovy index b0814ce..89a0dc1 100644 --- a/tests/compatibility-tests/src/main/resources/sendAckTest/sendAckMessages.groovy +++ b/tests/compatibility-tests/src/main/resources/sendAckTest/sendAckMessages.groovy @@ -1,4 +1,4 @@ -package meshTest +package sendAckTest import org.apache.activemq.artemis.tests.compatibility.GroovyRun http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/serial/cfserial.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/serial/cfserial.groovy b/tests/compatibility-tests/src/main/resources/serial/cfserial.groovy index 26085cd..a1a82da 100644 --- a/tests/compatibility-tests/src/main/resources/serial/cfserial.groovy +++ b/tests/compatibility-tests/src/main/resources/serial/cfserial.groovy @@ -1,4 +1,4 @@ -package clients +package serial import io.netty.buffer.Unpooled import org.apache.activemq.artemis.api.core.ActiveMQBuffer http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/serial/jbmserial.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/serial/jbmserial.groovy b/tests/compatibility-tests/src/main/resources/serial/jbmserial.groovy index 02ee468..93cceeb 100644 --- a/tests/compatibility-tests/src/main/resources/serial/jbmserial.groovy +++ b/tests/compatibility-tests/src/main/resources/serial/jbmserial.groovy @@ -1,4 +1,4 @@ -package clients +package serial /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/main/resources/serial/serial.groovy ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/main/resources/serial/serial.groovy b/tests/compatibility-tests/src/main/resources/serial/serial.groovy index 7caa332..d112c6c 100644 --- a/tests/compatibility-tests/src/main/resources/serial/serial.groovy +++ b/tests/compatibility-tests/src/main/resources/serial/serial.groovy @@ -1,4 +1,4 @@ -package clients +package serial /* * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed with http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ActiveMQJMSClientCompatibilityTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ActiveMQJMSClientCompatibilityTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ActiveMQJMSClientCompatibilityTest.java index 91e0e22..da60623 100644 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ActiveMQJMSClientCompatibilityTest.java +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ActiveMQJMSClientCompatibilityTest.java @@ -23,13 +23,14 @@ import java.io.PrintStream; import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient; import org.apache.activemq.artemis.jms.client.ActiveMQQueue; +import org.apache.activemq.artemis.tests.compatibility.base.ClasspathBase; import org.junit.Assert; import org.junit.Assume; import org.junit.Test; import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT; import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE; -public class ActiveMQJMSClientCompatibilityTest extends ClasspathBaseTest { +public class ActiveMQJMSClientCompatibilityTest extends ClasspathBase { @Test public void testActiveMQJMSCompatibility_1XPrefix_SNAPSHOT() throws Exception { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AddressConfigTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AddressConfigTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AddressConfigTest.java index cba29af..2419e29 100644 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AddressConfigTest.java +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AddressConfigTest.java @@ -24,6 +24,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase; import org.apache.activemq.artemis.utils.FileUtil; import org.junit.After; import org.junit.Assert; @@ -36,7 +37,7 @@ import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ONE_FIVE import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT; @RunWith(Parameterized.class) -public class AddressConfigTest extends VersionedBaseTest { +public class AddressConfigTest extends VersionedBase { // this will ensure that all tests in this class are run twice, // once with "true" passed to the class' constructor and once with "false" http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ClasspathBaseTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ClasspathBaseTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ClasspathBaseTest.java deleted file mode 100644 index d2a4b50..0000000 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ClasspathBaseTest.java +++ /dev/null @@ -1,152 +0,0 @@ -/* - * 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.activemq.artemis.tests.compatibility; - -import java.io.File; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.util.HashMap; -import java.util.HashSet; -import java.util.Map; - -import org.junit.Assume; -import org.junit.ClassRule; -import org.junit.rules.TemporaryFolder; - -import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT; - -public class ClasspathBaseTest { - - - @ClassRule - public static TemporaryFolder serverFolder; - - static { - File parent = new File("./target/tmp"); - parent.mkdirs(); - serverFolder = new TemporaryFolder(parent); - } - - protected static Map<String, ClassLoader> loaderMap = new HashMap<>(); - - private static HashSet<String> printed = new HashSet<>(); - - protected static ClassLoader defineClassLoader(String classPath) throws MalformedURLException { - String[] classPathArray = classPath.split(File.pathSeparator); - URL[] elements = new URL[classPathArray.length]; - for (int i = 0; i < classPathArray.length; i++) { - elements[i] = new File(classPathArray[i]).toPath().toUri().toURL(); - } - - return new URLClassLoader(elements, null); - } - - public static ClassLoader getClasspath(String name) throws Exception { - return getClasspath(name, false); - } - - public static ClassLoader getClasspath(String name, boolean forceNew) throws Exception { - - if (!forceNew) { - if (name.equals(SNAPSHOT)) { - return VersionedBaseTest.class.getClassLoader(); - } - - ClassLoader loader = loaderMap.get(name); - if (loader != null && !forceNew) { - return loader; - } - } - - String value = System.getProperty(name); - - if (!printed.contains(name)) { - boolean ok = value != null && !value.trim().isEmpty(); - if (!ok) { - System.out.println("Add \"-D" + name + "=\'CLASSPATH\'\" into your VM settings"); - System.out.println("You will see it in the output from mvn install at the compatibility-tests"); - System.out.println("... look for output from dependency-scan"); - - // our dependency scan used at the pom under compatibility-tests/pom.xml will generate these, example: - // [INFO] dependency-scan setting: -DARTEMIS-140="/Users/someuser/....." - // copy that into your IDE setting and you should be able to debug it - } - Assume.assumeTrue("Cannot run these tests, no classpath found", ok); - } - - ClassLoader loader = defineClassLoader(value); - if (!forceNew) { - // if we are forcing a new one, there's no point in caching it - loaderMap.put(name, loader); - } - - return loader; - } - - protected static Object evaluate(ClassLoader loader, String script, String... arguments) throws Exception { - return tclCall(loader, () -> { - Class clazz = loader.loadClass(GroovyRun.class.getName()); - Method method = clazz.getMethod("evaluate", String.class, String[].class); - return method.invoke(null, script, arguments); - }); - } - - protected static void setVariable(ClassLoader loader, String name, Object object) throws Exception { - tclCall(loader, () -> { - Class clazz = loader.loadClass(GroovyRun.class.getName()); - Method method = clazz.getMethod("setVariable", String.class, Object.class); - method.invoke(null, name, object); - return null; - }); - } - - protected static Object setVariable(ClassLoader loader, String name) throws Exception { - return tclCall(loader, () -> { - Class clazz = loader.loadClass(GroovyRun.class.getName()); - Method method = clazz.getMethod("getVariable", String.class); - return method.invoke(null, name); - }); - } - - protected static Object execute(ClassLoader loader, String script) throws Exception { - return tclCall(loader, () -> { - Class clazz = loader.loadClass(GroovyRun.class.getName()); - Method method = clazz.getMethod("execute", String.class); - return method.invoke(null, script); - }); - } - - protected static Object tclCall(ClassLoader loader, CallIt run) throws Exception { - - ClassLoader original = Thread.currentThread().getContextClassLoader(); - Thread.currentThread().setContextClassLoader(loader); - try { - return run.run(); - } finally { - Thread.currentThread().setContextClassLoader(original); - } - } - - public interface CallIt { - - Object run() throws Exception; - } - -} http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ConnectionFactoryConfigurationSerializationTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ConnectionFactoryConfigurationSerializationTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ConnectionFactoryConfigurationSerializationTest.java index 9389452..18bcd7b 100644 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ConnectionFactoryConfigurationSerializationTest.java +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ConnectionFactoryConfigurationSerializationTest.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase; import org.apache.activemq.artemis.utils.FileUtil; import org.junit.After; import org.junit.Before; @@ -47,7 +48,7 @@ import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.TWO_FOUR * Run->Edit Configuration->Add ArtemisMeshTest and add your properties. */ @RunWith(Parameterized.class) -public class ConnectionFactoryConfigurationSerializationTest extends VersionedBaseTest { +public class ConnectionFactoryConfigurationSerializationTest extends VersionedBase { // this will ensure that all tests in this class are run twice, // once with "true" passed to the class' constructor and once with "false" http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ExportImportTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ExportImportTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ExportImportTest.java index 854ef1e..903165f 100644 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ExportImportTest.java +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/ExportImportTest.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase; import org.apache.activemq.artemis.utils.FileUtil; import org.junit.After; import org.junit.Before; @@ -45,7 +46,7 @@ import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT * Run->Edit Configuration->Add ArtemisMeshTest and add your properties. */ @RunWith(Parameterized.class) -public class ExportImportTest extends VersionedBaseTest { +public class ExportImportTest extends VersionedBase { private String serverScriptToUse; // this will ensure that all tests in this class are run twice, http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQClientTopologyTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQClientTopologyTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQClientTopologyTest.java index 7a9ab9d..87299d4 100644 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQClientTopologyTest.java +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQClientTopologyTest.java @@ -17,6 +17,7 @@ package org.apache.activemq.artemis.tests.compatibility; +import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase; import org.apache.activemq.artemis.utils.FileUtil; import org.junit.After; import org.junit.Before; @@ -37,7 +38,7 @@ import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT * correct connector parameters (keys must be dash-delimited instead of camelCase). */ @RunWith(Parameterized.class) -public class HQClientTopologyTest extends VersionedBaseTest { +public class HQClientTopologyTest extends VersionedBase { @Parameterized.Parameters(name = "server={0}, producer={1}, consumer={2}") public static Collection getParameters() { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQFailoverTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQFailoverTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQFailoverTest.java index d3bdaf1..8b34946 100644 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQFailoverTest.java +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/HQFailoverTest.java @@ -30,6 +30,7 @@ import java.util.concurrent.TimeUnit; import org.apache.activemq.artemis.api.core.client.FailoverEventType; import org.apache.activemq.artemis.jms.client.ActiveMQConnection; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; +import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase; import org.apache.activemq.artemis.utils.FileUtil; import org.junit.After; import org.junit.Before; @@ -46,7 +47,7 @@ import static org.junit.Assert.assertTrue; * and it will make sure that failover happens without any problems. */ @RunWith(Parameterized.class) -public class HQFailoverTest extends VersionedBaseTest { +public class HQFailoverTest extends VersionedBase { @Parameterized.Parameters(name = "server={0}, producer={1}, consumer={2}") public static Collection getParameters() { http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JournalCompatibilityTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JournalCompatibilityTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JournalCompatibilityTest.java index 27ebdd0..ae94083 100644 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JournalCompatibilityTest.java +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/JournalCompatibilityTest.java @@ -26,6 +26,7 @@ import java.util.ArrayList; import java.util.Collection; import java.util.List; +import org.apache.activemq.artemis.tests.compatibility.base.VersionedBase; import org.apache.activemq.artemis.utils.FileUtil; import org.junit.After; import org.junit.Before; @@ -47,7 +48,7 @@ import org.junit.runners.Parameterized; * Run->Edit Configuration->Add ArtemisMeshTest and add your properties. */ @RunWith(Parameterized.class) -public class JournalCompatibilityTest extends VersionedBaseTest { +public class JournalCompatibilityTest extends VersionedBase { // this will ensure that all tests in this class are run twice, // once with "true" passed to the class' constructor and once with "false" http://git-wip-us.apache.org/repos/asf/activemq-artemis/blob/93cffedc/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/MeshTest.java ---------------------------------------------------------------------- diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/MeshTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/MeshTest.java index 3721979..d37f8e5 100644 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/MeshTest.java +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/MeshTest.java @@ -24,6 +24,7 @@ import java.util.concurrent.CountDownLatch; import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; +import org.apache.activemq.artemis.tests.compatibility.base.ServerBase; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @@ -50,7 +51,7 @@ import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.TWO_FOUR * Run->Edit Configuration->Add ArtemisMeshTest and add your properties. */ @RunWith(Parameterized.class) -public class MeshTest extends ServerBaseTest { +public class MeshTest extends ServerBase { // this will ensure that all tests in this class are run twice, // once with "true" passed to the class' constructor and once with "false" @@ -67,10 +68,10 @@ public class MeshTest extends ServerBaseTest { // combinations.add(new Object[]{SNAPSHOT, ONE_FIVE, ONE_FIVE}); // combinations.add(new Object[]{ONE_FIVE, ONE_FIVE, ONE_FIVE}); - combinations.addAll(combinatory(new Object[]{SNAPSHOT}, new Object[]{ONE_FIVE, TWO_FOUR, SNAPSHOT, HORNETQ_235}, new Object[]{ONE_FIVE, TWO_FOUR, SNAPSHOT, HORNETQ_235})); - combinations.addAll(combinatory(new Object[]{ONE_FIVE}, new Object[]{ONE_FIVE, SNAPSHOT}, new Object[]{ONE_FIVE, SNAPSHOT})); - combinations.addAll(combinatory(new Object[]{HORNETQ_235}, new Object[]{ONE_FIVE, SNAPSHOT, HORNETQ_235}, new Object[]{ONE_FIVE, SNAPSHOT, HORNETQ_235})); - combinations.addAll(combinatory(new Object[]{HORNETQ_247}, new Object[]{SNAPSHOT, HORNETQ_247}, new Object[]{SNAPSHOT, HORNETQ_247})); + combinations.addAll(combinatory(SNAPSHOT, new Object[]{SNAPSHOT}, new Object[]{ONE_FIVE, TWO_FOUR, SNAPSHOT, HORNETQ_235}, new Object[]{ONE_FIVE, TWO_FOUR, SNAPSHOT, HORNETQ_235})); + combinations.addAll(combinatory(SNAPSHOT, new Object[]{ONE_FIVE}, new Object[]{ONE_FIVE, SNAPSHOT}, new Object[]{ONE_FIVE, SNAPSHOT})); + combinations.addAll(combinatory(SNAPSHOT, new Object[]{HORNETQ_235}, new Object[]{ONE_FIVE, SNAPSHOT, HORNETQ_235}, new Object[]{ONE_FIVE, SNAPSHOT, HORNETQ_235})); + combinations.addAll(combinatory(SNAPSHOT, new Object[]{HORNETQ_247}, new Object[]{SNAPSHOT, HORNETQ_247}, new Object[]{SNAPSHOT, HORNETQ_247})); combinations.add(new Object[]{SNAPSHOT, ONE_FOUR, ONE_FOUR}); return combinations; }