diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AMQPJournalCompatibilityTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AMQPJournalCompatibilityTest.java new file mode 100644 index 00000000000..7188659e784 --- /dev/null +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AMQPJournalCompatibilityTest.java @@ -0,0 +1,120 @@ +/* + * 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 static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ARTEMIS_2_10_0; +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ARTEMIS_2_33_0; +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ARTEMIS_2_44_0; +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; + +import javax.jms.Connection; +import javax.jms.ConnectionFactory; +import javax.jms.MessageConsumer; +import javax.jms.MessageProducer; +import javax.jms.Session; +import javax.jms.TextMessage; + +import static org.junit.jupiter.api.Assumptions.assumeTrue; + +import org.apache.activemq.artemis.tests.compatibility.base.ClasspathBase; +import org.apache.activemq.artemis.utils.FileUtil; +import org.apache.qpid.jms.JmsConnectionFactory; +import org.junit.jupiter.api.AfterEach; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +public class AMQPJournalCompatibilityTest extends ClasspathBase { + + private ClassLoader senderClassloader; + private ClassLoader receiverClassloader; + + @BeforeEach + public void setUp() throws Exception { + FileUtil.deleteDirectory(serverFolder); + serverFolder.mkdirs(); + } + + @AfterEach + public void tearDown() { + try { + stopServer(senderClassloader); + } catch (Throwable ignored) { + } + try { + stopServer(receiverClassloader); + } catch (Throwable ignored) { + } + } + + @Test + public void testAMQPSendReceive_2_33_0() throws Throwable { + testAMQPSendReceive(ARTEMIS_2_33_0); + } + + @Test + public void testAMQPSendReceive_2_10_0() throws Throwable { + assumeTrue(getJavaVersion() <= 22, "2.10.0 server fails on JDK23+"); + testAMQPSendReceive(ARTEMIS_2_10_0); + } + + @Test + public void testAMQPSendReceive_2_44_0() throws Throwable { + testAMQPSendReceive(ARTEMIS_2_44_0); + } + + private void testAMQPSendReceive(String senderVersion) throws Throwable { + senderClassloader = getClasspath(senderVersion); + receiverClassloader = getClasspath(SNAPSHOT); + + setVariable(senderClassloader, "persistent", true); + startServer(serverFolder, senderClassloader, "journalTest", null, true, "servers/artemisServer.groovy", senderVersion, senderVersion, SNAPSHOT); + + ConnectionFactory factory = new JmsConnectionFactory("amqp://localhost:61616"); + + try (Connection connection = factory.createConnection()) { + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + MessageProducer producer = session.createProducer(session.createQueue("queue")); + for (int i = 0; i < 10; i++) { + TextMessage message = session.createTextMessage("hello " + i); + message.setIntProperty("count", i); + producer.send(message); + } + session.commit(); + } + + stopServer(senderClassloader); + + setVariable(receiverClassloader, "persistent", true); + startServer(serverFolder, receiverClassloader, "journalTest", null, false, "servers/artemisServer.groovy", SNAPSHOT, senderVersion, SNAPSHOT); + + try (Connection connection = factory.createConnection()) { + Session session = connection.createSession(true, Session.SESSION_TRANSACTED); + MessageConsumer consumer = session.createConsumer(session.createQueue("queue")); + connection.start(); + for (int i = 0; i < 10; i++) { + TextMessage message = (TextMessage) consumer.receive(5000); + assertNotNull(message); + assertEquals("hello " + i, message.getText()); + assertEquals(i, message.getIntProperty("count")); + } + session.commit(); + } + } +} diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AddressPauseJournalCompatibilityTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AddressPauseJournalCompatibilityTest.java index 8933bc4419a..dcb784a5eed 100644 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AddressPauseJournalCompatibilityTest.java +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/AddressPauseJournalCompatibilityTest.java @@ -19,6 +19,7 @@ import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT; import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ARTEMIS_2_10_0; +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ARTEMIS_2_44_0; import java.util.ArrayList; import java.util.Collection; @@ -48,6 +49,7 @@ public static Collection getParameters() { // 2.10.0 server fails on JDK23+ without workarounds. combinations.add(new Object[]{ARTEMIS_2_10_0, SNAPSHOT}); } + combinations.add(new Object[]{ARTEMIS_2_44_0, SNAPSHOT}); // the purpose on this one is just to validate the test itself. /// if it can't run against itself it won't work at all combinations.add(new Object[]{SNAPSHOT, SNAPSHOT}); 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 9008aacecd3..0161a36e289 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 @@ -18,8 +18,9 @@ package org.apache.activemq.artemis.tests.compatibility; import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT; -import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ARTEMIS_2_4_0; import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ARTEMIS_2_1_0; +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ARTEMIS_2_4_0; +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ARTEMIS_2_44_0; import java.util.ArrayList; import java.util.Collection; @@ -47,6 +48,7 @@ public static Collection getParameters() { combinations.add(new Object[]{ARTEMIS_2_1_0, SNAPSHOT}); combinations.add(new Object[]{ARTEMIS_2_4_0, SNAPSHOT}); + combinations.add(new Object[]{ARTEMIS_2_44_0, SNAPSHOT}); // the purpose on this one is just to validate the test itself. /// if it can't run against itself it won't work at all combinations.add(new Object[]{SNAPSHOT, SNAPSHOT}); diff --git a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/QueuePauseJournalCompatibilityTest.java b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/QueuePauseJournalCompatibilityTest.java index c1bde82c01a..a2447a33bd0 100644 --- a/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/QueuePauseJournalCompatibilityTest.java +++ b/tests/compatibility-tests/src/test/java/org/apache/activemq/artemis/tests/compatibility/QueuePauseJournalCompatibilityTest.java @@ -18,7 +18,7 @@ package org.apache.activemq.artemis.tests.compatibility; import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.SNAPSHOT; -import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ARTEMIS_2_6_3; +import static org.apache.activemq.artemis.tests.compatibility.GroovyRun.ARTEMIS_2_44_0; import java.util.ArrayList; import java.util.Collection; @@ -44,7 +44,7 @@ public static Collection getParameters() { // if we keep testing current one against 2.4 and 1.4.. we are sure the wire and API won't change over time List combinations = new ArrayList<>(); - combinations.add(new Object[]{ARTEMIS_2_6_3, SNAPSHOT}); + combinations.add(new Object[]{ARTEMIS_2_44_0, SNAPSHOT}); // the purpose on this one is just to validate the test itself. /// if it can't run against itself it won't work at all combinations.add(new Object[]{SNAPSHOT, SNAPSHOT});