ARTEMIS-5000 stop running most STOMP tests twice

This commit is contained in:
Justin Bertram 2024-08-19 16:56:35 -05:00 committed by Robbie Gemmell
parent ac666f3ab1
commit 18999a83bf
18 changed files with 460 additions and 596 deletions

View File

@ -16,8 +16,6 @@
*/
package org.apache.activemq.artemis.tests.integration.stomp;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
@ -28,8 +26,6 @@ import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler.LogLevel;
import org.apache.activemq.artemis.logs.AuditLogger;
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
@ -38,10 +34,8 @@ import org.apache.activemq.artemis.tests.util.Wait;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
@ExtendWith(ParameterizedTestExtension.class)
public class StompAuditLoggingTest extends StompTestBase {
private static final String BASE_AUDIT_LOGGER_NAME = AuditLogger.BASE_LOGGER.getLogger().getName();
@ -52,13 +46,8 @@ public class StompAuditLoggingTest extends StompTestBase {
private final String pass = user;
private final String role = "nopriv";
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v10.stomp"}, {"tcp+v10.stomp"}});
}
public StompAuditLoggingTest(String scheme) {
super(scheme);
public StompAuditLoggingTest() {
super("tcp+v10.stomp");
}
@Override
@ -101,7 +90,7 @@ public class StompAuditLoggingTest extends StompTestBase {
}
}
@TestTemplate
@Test
public void testAuthzFailureAuditLogging() throws Exception {
conn.connect(user, pass);

View File

@ -16,31 +16,23 @@
*/
package org.apache.activemq.artemis.tests.integration.stomp;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
// Parameters set in super class
@ExtendWith(ParameterizedTestExtension.class)
public class StompConnectionCleanupTest extends StompTest {
private static final long CONNECTION_TTL = 2000;
public StompConnectionCleanupTest(String scheme) {
super(scheme);
}
// ARTEMIS-231
@TestTemplate
@Test
public void testConnectionCleanupWithTopicSubscription() throws Exception {
conn.connect(defUser, defPass);
@ -70,7 +62,7 @@ public class StompConnectionCleanupTest extends StompTest {
}
}
@TestTemplate
@Test
public void testConnectionCleanup() throws Exception {
conn.connect(defUser, defPass);
@ -107,7 +99,7 @@ public class StompConnectionCleanupTest extends StompTest {
}
}
@TestTemplate
@Test
public void testConnectionNotCleanedUp() throws Exception {
conn.connect(defUser, defPass);

View File

@ -16,31 +16,25 @@
*/
package org.apache.activemq.artemis.tests.integration.stomp;
import static org.junit.jupiter.api.Assertions.assertEquals;
import java.lang.invoke.MethodHandles;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.UUID;
import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.QueueConfiguration;
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ExtendWith(ParameterizedTestExtension.class)
import static org.junit.jupiter.api.Assertions.assertEquals;
public class StompLVQTest extends StompTestBase {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@ -50,13 +44,8 @@ public class StompLVQTest extends StompTestBase {
private final String queue = "lvq";
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v10.stomp"}, {"tcp+v10.stomp"}});
}
public StompLVQTest(String scheme) {
super(scheme);
public StompLVQTest() {
super("tcp+v10.stomp");
}
@Override
@ -100,7 +89,7 @@ public class StompLVQTest extends StompTestBase {
super.tearDown();
}
@TestTemplate
@Test
public void testLVQ() throws Exception {
producerConn.connect(defUser, defPass);

View File

@ -25,8 +25,6 @@ import java.io.ByteArrayOutputStream;
import java.lang.invoke.MethodHandles;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
@ -68,8 +66,6 @@ import org.apache.activemq.artemis.json.JsonObject;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
import org.apache.activemq.artemis.reader.MessageUtil;
import org.apache.activemq.artemis.spi.core.remoting.Acceptor;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.mqtt.FuseMQTTClientProvider;
import org.apache.activemq.artemis.tests.integration.mqtt.MQTTClientProvider;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
@ -79,8 +75,7 @@ import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.activemq.artemis.utils.RandomUtil;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -92,20 +87,14 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@ExtendWith(ParameterizedTestExtension.class)
public class StompTest extends StompTestBase {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
protected StompClientConnection conn;
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v10.stomp"}, {"tcp+v10.stomp"}});
}
public StompTest(String scheme) {
super(scheme);
public StompTest() {
super("tcp+v10.stomp");
}
@Override
@ -141,7 +130,7 @@ public class StompTest extends StompTestBase {
}
}
@TestTemplate
@Test
public void testConnectionTTL() throws Exception {
int port = 61614;
@ -160,7 +149,7 @@ public class StompTest extends StompTestBase {
assertFalse(conn.isConnected());
}
@TestTemplate
@Test
public void testSendManyMessages() throws Exception {
conn.connect(defUser, defPass);
@ -177,7 +166,7 @@ public class StompTest extends StompTestBase {
assertTrue(latch.await(60, TimeUnit.SECONDS));
}
@TestTemplate
@Test
public void testProducerMetrics() throws Exception {
conn.connect(defUser, defPass);
@ -215,7 +204,7 @@ public class StompTest extends StompTestBase {
assertEquals(0, array.size(), "number of producers returned from query");
}
@TestTemplate
@Test
public void testSendOverDiskFull() throws Exception {
try (AssertionLoggerHandler loggerHandler = new AssertionLoggerHandler()) {
MessageConsumer consumer = session.createConsumer(queue);
@ -242,7 +231,7 @@ public class StompTest extends StompTestBase {
}
}
@TestTemplate
@Test
public void testConnect() throws Exception {
ClientStompFrame frame = conn.createFrame(Stomp.Commands.CONNECT).addHeader(Stomp.Headers.Connect.LOGIN, defUser).addHeader(Stomp.Headers.Connect.PASSCODE, defPass).addHeader(Stomp.Headers.Connect.REQUEST_ID, "1");
ClientStompFrame response = conn.sendFrame(frame);
@ -251,7 +240,7 @@ public class StompTest extends StompTestBase {
assertTrue(response.getHeader(Stomp.Headers.Connected.RESPONSE_ID).equals("1"));
}
@TestTemplate
@Test
public void testDisconnectAndError() throws Exception {
ClientStompFrame frame = conn.createFrame(Stomp.Commands.CONNECT).addHeader(Stomp.Headers.Connect.LOGIN, defUser).addHeader(Stomp.Headers.Connect.PASSCODE, defPass).addHeader(Stomp.Headers.Connect.REQUEST_ID, "1");
ClientStompFrame response = conn.sendFrame(frame);
@ -270,7 +259,7 @@ public class StompTest extends StompTestBase {
}
}
@TestTemplate
@Test
public void testSendMessage() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -292,7 +281,7 @@ public class StompTest extends StompTestBase {
assertTrue(Math.abs(tnow - tmsg) < 1000);
}
@TestTemplate
@Test
public void testNullCorrelationIDandTypeProperties() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -307,7 +296,7 @@ public class StompTest extends StompTestBase {
assertFalse(((ActiveMQMessage)message).getCoreMessage().getPropertyNames().contains(MessageUtil.TYPE_HEADER_NAME));
}
@TestTemplate
@Test
public void sendSTOMPReceiveMQTT() throws Exception {
// Set up MQTT Subscription
MQTTClientProvider clientProvider = new FuseMQTTClientProvider();
@ -328,7 +317,7 @@ public class StompTest extends StompTestBase {
clientProvider.disconnect();
}
@TestTemplate
@Test
public void sendMQTTReceiveSTOMP() throws Exception {
String payload = "This is a test message";
@ -348,7 +337,7 @@ public class StompTest extends StompTestBase {
}
@TestTemplate
@Test
public void sendEmptyCoreMessage() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO);
@ -389,12 +378,12 @@ public class StompTest extends StompTestBase {
Wait.assertTrue(() -> server.getPostOffice().getBinding(SimpleString.of(queue)) == null);
}
@TestTemplate
@Test
public void testSendMessageToNonExistentQueue() throws Exception {
sendMessageToNonExistentQueue(getQueuePrefix(), RandomUtil.randomString(), RoutingType.ANYCAST);
}
@TestTemplate
@Test
public void testSendMessageToNonExistentQueueUsingExplicitDefaultRouting() throws Exception {
String nonExistentQueue = RandomUtil.randomString();
server.getAddressSettingsRepository().addMatch(nonExistentQueue, new AddressSettings().setDefaultAddressRoutingType(RoutingType.ANYCAST).setDefaultQueueRoutingType(RoutingType.ANYCAST));
@ -431,19 +420,19 @@ public class StompTest extends StompTestBase {
Wait.assertTrue(() -> server.getAddressInfo(SimpleString.of(topic)) == null);
}
@TestTemplate
@Test
public void testSendMessageToNonExistentTopic() throws Exception {
sendMessageToNonExistentTopic(getTopicPrefix(), RandomUtil.randomString(), RoutingType.MULTICAST);
}
@TestTemplate
@Test
public void testSendMessageToNonExistentTopicUsingExplicitDefaultRouting() throws Exception {
String nonExistentTopic = RandomUtil.randomString();
server.getAddressSettingsRepository().addMatch(nonExistentTopic, new AddressSettings().setDefaultAddressRoutingType(RoutingType.MULTICAST).setDefaultQueueRoutingType(RoutingType.MULTICAST));
sendMessageToNonExistentTopic(getTopicPrefix(), nonExistentTopic, null);
}
@TestTemplate
@Test
public void testSendMessageToNonExistentTopicUsingImplicitDefaultRouting() throws Exception {
sendMessageToNonExistentTopic(getTopicPrefix(), RandomUtil.randomString(), null);
}
@ -453,7 +442,7 @@ public class StompTest extends StompTestBase {
* This means next frame read might have a \n a the beginning.
* This is contrary to STOMP spec but we deal with it so we can work nicely with crappy STOMP clients
*/
@TestTemplate
@Test
public void testSendMessageWithLeadingNewLine() throws Exception {
conn.connect(defUser, defPass);
ClientStompFrame frame = conn.createFrame(Stomp.Commands.SEND).addHeader(Stomp.Headers.Send.DESTINATION, getQueuePrefix() + getQueueName()).setBody("Hello World");
@ -476,7 +465,7 @@ public class StompTest extends StompTestBase {
assertTrue(Math.abs(tnow - tmsg) < 1000);
}
@TestTemplate
@Test
public void testSendMessageWithReceipt() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -495,7 +484,7 @@ public class StompTest extends StompTestBase {
assertTrue(Math.abs(tnow - tmsg) < 1000);
}
@TestTemplate
@Test
public void testSendMessageWithContentLength() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
conn.connect(defUser, defPass);
@ -517,7 +506,7 @@ public class StompTest extends StompTestBase {
assertEquals(data[3], message.readByte());
}
@TestTemplate
@Test
public void testJMSXGroupIdCanBeSet() throws Exception {
final String jmsxGroupID = "JMSXGroupID";
MessageConsumer consumer = session.createConsumer(queue);
@ -534,7 +523,7 @@ public class StompTest extends StompTestBase {
assertEquals(jmsxGroupID, message.getStringProperty("JMSXGroupID"));
}
@TestTemplate
@Test
public void testSendMessageWithCustomHeadersAndSelector() throws Exception {
MessageConsumer consumer = session.createConsumer(queue, "foo = 'abc'");
@ -551,7 +540,7 @@ public class StompTest extends StompTestBase {
assertEquals("123", message.getStringProperty("bar"), "bar");
}
@TestTemplate
@Test
public void testSendMessageWithCustomHeadersAndHyphenatedSelector() throws Exception {
MessageConsumer consumer = session.createConsumer(queue, "hyphenated_props:b-ar = '123'");
@ -568,7 +557,7 @@ public class StompTest extends StompTestBase {
assertEquals("123", message.getStringProperty("b-ar"), "b-ar");
}
@TestTemplate
@Test
public void testSendMessageWithStandardHeaders() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -593,7 +582,7 @@ public class StompTest extends StompTestBase {
// Assert.assertEquals("GroupID", "abc", amqMessage.getGroupID());
}
@TestTemplate
@Test
public void testSendMessageWithLongHeaders() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -620,7 +609,7 @@ public class StompTest extends StompTestBase {
assertEquals("abc", message.getStringProperty("JMSXGroupID"), "JMSXGroupID");
}
@TestTemplate
@Test
public void testSendMessageWithDelay() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -642,7 +631,7 @@ public class StompTest extends StompTestBase {
assertEquals("abc", message.getStringProperty("JMSXGroupID"), "JMSXGroupID");
}
@TestTemplate
@Test
public void testSendMessageWithDeliveryTime() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -664,7 +653,7 @@ public class StompTest extends StompTestBase {
assertEquals("abc", message.getStringProperty("JMSXGroupID"), "JMSXGroupID");
}
@TestTemplate
@Test
public void testSendMessageWithDelayWithBadValue() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -681,7 +670,7 @@ public class StompTest extends StompTestBase {
assertTrue(error.getCommand().equals("ERROR"));
}
@TestTemplate
@Test
public void testSendMessageWithDeliveryTimeWithBadValue() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -698,7 +687,7 @@ public class StompTest extends StompTestBase {
assertTrue(error.getCommand().equals("ERROR"));
}
@TestTemplate
@Test
public void testSubscribeWithAutoAck() throws Exception {
conn.connect(defUser, defPass);
@ -724,7 +713,7 @@ public class StompTest extends StompTestBase {
}
@TestTemplate
@Test
public void testNullPropertyValue() throws Exception {
conn.connect(defUser, defPass);
@ -741,7 +730,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testTransactedSessionLeak() throws Exception {
for (int i = 0; i < 10; i++) {
conn = StompClientConnectionFactory.createClientConnection(uri);
@ -772,7 +761,7 @@ public class StompTest extends StompTestBase {
assertEquals(0, stompProtocolManager.getTransactedSessions().size());
}
@TestTemplate
@Test
public void testIngressTimestamp() throws Exception {
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setEnableIngressTimestamp(true));
conn.connect(defUser, defPass);
@ -793,7 +782,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testAnycastDestinationTypeMessageProperty() throws Exception {
conn.connect(defUser, defPass);
@ -811,7 +800,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testMulticastDestinationTypeMessageProperty() throws Exception {
conn.connect(defUser, defPass);
@ -829,7 +818,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscriptionQueueCreatedWhenAutoCreateDisabled() throws Exception {
SimpleString topic = SimpleString.of(getTopicPrefix() + getTopicName());
server.getAddressSettingsRepository().getMatch(topic.toString()).setAutoCreateQueues(false);
@ -842,7 +831,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithAutoAckAndBytesMessage() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO);
@ -866,7 +855,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithMessageSentWithProperties() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO);
@ -900,7 +889,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithID() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "mysubid", Stomp.Headers.Subscribe.AckModeValues.AUTO);
@ -917,7 +906,7 @@ public class StompTest extends StompTestBase {
}
//
@TestTemplate
@Test
public void testBodyWithUTF8() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO);
@ -935,7 +924,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testMessagesAreInOrder() throws Exception {
int ctr = 10;
String[] data = new String[ctr];
@ -969,7 +958,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithAutoAckAndSelector() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO, null, "foo = 'zzz'");
@ -984,7 +973,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithAutoAckAndHyphenatedSelector() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO, null, "hyphenated_props:foo-bar = 'zzz'");
@ -1012,7 +1001,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithAutoAckAndXpathSelector() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO, null, "XPATH 'root/a'");
@ -1027,7 +1016,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithClientAck() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.CLIENT);
@ -1046,7 +1035,7 @@ public class StompTest extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testRedeliveryWithClientAck() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.CLIENT);
@ -1064,12 +1053,12 @@ public class StompTest extends StompTestBase {
assertTrue(message.getJMSRedelivered());
}
@TestTemplate
@Test
public void testSubscribeWithClientAckThenConsumingAgainWithAutoAckWithNoDisconnectFrame() throws Exception {
assertSubscribeWithClientAckThenConsumeWithAutoAck(false);
}
@TestTemplate
@Test
public void testSubscribeWithClientAckThenConsumingAgainWithAutoAckWithExplicitDisconnect() throws Exception {
assertSubscribeWithClientAckThenConsumeWithAutoAck(true);
}
@ -1119,7 +1108,7 @@ public class StompTest extends StompTestBase {
assertEquals("shouldBeNextMessage", frame.getBody());
}
@TestTemplate
@Test
public void testUnsubscribe() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.AUTO);
@ -1142,7 +1131,7 @@ public class StompTest extends StompTestBase {
assertNull(frame, "No message should have been received since subscription was removed");
}
@TestTemplate
@Test
public void testUnsubscribeWithID() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, "mysubid", Stomp.Headers.Subscribe.AckModeValues.AUTO);
@ -1166,7 +1155,7 @@ public class StompTest extends StompTestBase {
}
@TestTemplate
@Test
public void testTransactionCommit() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
conn.connect(defUser, defPass);
@ -1183,7 +1172,7 @@ public class StompTest extends StompTestBase {
assertNotNull(message, "Should have received a message");
}
@TestTemplate
@Test
public void testSuccessiveTransactionsWithSameID() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
conn.connect(defUser, defPass);
@ -1205,7 +1194,7 @@ public class StompTest extends StompTestBase {
assertNotNull(message, "Should have received a message");
}
@TestTemplate
@Test
public void testBeginSameTransactionTwice() throws Exception {
conn.connect(defUser, defPass);
beginTransaction(conn, "tx1");
@ -1215,7 +1204,7 @@ public class StompTest extends StompTestBase {
assertEquals(Stomp.Responses.ERROR, frame.getCommand());
}
@TestTemplate
@Test
public void testTransactionRollback() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
String txId = "tx1";
@ -1235,7 +1224,7 @@ public class StompTest extends StompTestBase {
assertEquals("second message", message.getText());
}
@TestTemplate
@Test
public void testSubscribeToTopic() throws Exception {
final int baselineQueueCount = server.getActiveMQServerControl().getQueueNames().length;
@ -1273,7 +1262,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeToQueue() throws Exception {
final int baselineQueueCount = server.getActiveMQServerControl().getQueueNames().length;
@ -1308,7 +1297,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeToNonExistentQueue() throws Exception {
String nonExistentQueue = RandomUtil.randomString();
@ -1341,7 +1330,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDurableSubscriberWithReconnection() throws Exception {
conn.connect(defUser, defPass, "myclientid");
subscribeTopic(conn, null, null, getName());
@ -1370,7 +1359,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDurableSubscriberWithReconnectionLegacy() throws Exception {
conn.connect(defUser, defPass, "myclientid");
subscribeTopicLegacyActiveMQ(conn, null, null, getName(), true, false);
@ -1399,7 +1388,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDurableSubscriber() throws Exception {
conn.connect(defUser, defPass, "myclientid");
subscribeTopic(conn, null, null, getName(), true);
@ -1411,7 +1400,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDurableSubscriberLegacySubscriptionHeader() throws Exception {
conn.connect(defUser, defPass, "myclientid");
subscribeTopicLegacyActiveMQ(conn, null, null, getName(), true, false);
@ -1423,7 +1412,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDurableUnSubscribe() throws Exception {
conn.connect(defUser, defPass, "myclientid");
subscribeTopic(conn, null, null, getName(), true);
@ -1443,7 +1432,7 @@ public class StompTest extends StompTestBase {
Wait.assertTrue(() -> server.locateQueue(SimpleString.of("myclientid." + getName())) == null);
}
@TestTemplate
@Test
public void testDurableUnSubscribeWithoutDurableSubName() throws Exception {
server.getConfiguration().getWildcardConfiguration().setDelimiter('/');
server.getAddressSettingsRepository().addMatch("/topic/#", new AddressSettings().setDefaultAddressRoutingType(RoutingType.MULTICAST).setDefaultQueueRoutingType(RoutingType.MULTICAST));
@ -1470,7 +1459,7 @@ public class StompTest extends StompTestBase {
Wait.assertTrue(() -> server.locateQueue(SimpleString.of("myclientid." + durableSubName)) != null);
}
@TestTemplate
@Test
public void testDurableUnSubscribeLegacySubscriptionHeader() throws Exception {
conn.connect(defUser, defPass, "myclientid");
subscribeTopicLegacyActiveMQ(conn, null, null, getName(), true, false);
@ -1490,7 +1479,7 @@ public class StompTest extends StompTestBase {
Wait.assertTrue(() -> server.locateQueue(SimpleString.of("myclientid." + getName())) == null);
}
@TestTemplate
@Test
public void testSubscribeToTopicWithNoLocal() throws Exception {
conn.connect(defUser, defPass);
subscribeTopic(conn, null, null, null, true, true);
@ -1512,7 +1501,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testTopicExistsAfterNoUnsubscribeDisconnect() throws Exception {
conn.connect(defUser, defPass);
subscribeTopic(conn, null, null, null, true);
@ -1540,7 +1529,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testClientAckNotPartOfTransaction() throws Exception {
conn.connect(defUser, defPass);
subscribe(conn, null, Stomp.Headers.Subscribe.AckModeValues.CLIENT);
@ -1567,7 +1556,7 @@ public class StompTest extends StompTestBase {
}
// HORNETQ-1007
@TestTemplate
@Test
public void testMultiProtocolConsumers() throws Exception {
final int TIME_OUT = 2000;
// a timeout for when we expect negative results (like receive==null)
@ -1609,7 +1598,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
//stomp should return an ERROR when acking a non-existent message
public void testUnexpectedAck() throws Exception {
String messageID = "888888";
@ -1624,42 +1613,42 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDotAnycastPrefixOnSend() throws Exception {
testPrefix("jms.queue.", RoutingType.ANYCAST, true);
}
@TestTemplate
@Test
public void testDotMulticastPrefixOnSend() throws Exception {
testPrefix("jms.topic.", RoutingType.MULTICAST, true);
}
@TestTemplate
@Test
public void testDotAnycastPrefixOnSubscribe() throws Exception {
testPrefix("jms.queue.", RoutingType.ANYCAST, false);
}
@TestTemplate
@Test
public void testDotMulticastPrefixOnSubscribe() throws Exception {
testPrefix("jms.topic.", RoutingType.MULTICAST, false);
}
@TestTemplate
@Test
public void testSlashAnycastPrefixOnSend() throws Exception {
testPrefix("/queue/", RoutingType.ANYCAST, true);
}
@TestTemplate
@Test
public void testSlashMulticastPrefixOnSend() throws Exception {
testPrefix("/topic/", RoutingType.MULTICAST, true);
}
@TestTemplate
@Test
public void testSlashAnycastPrefixOnSubscribe() throws Exception {
testPrefix("/queue/", RoutingType.ANYCAST, false);
}
@TestTemplate
@Test
public void testSlashMulticastPrefixOnSubscribe() throws Exception {
testPrefix("/topic/", RoutingType.MULTICAST, false);
}
@ -1706,7 +1695,7 @@ public class StompTest extends StompTestBase {
*
* @throws Exception
*/
@TestTemplate
@Test
public void testPrefixedAutoCreatedAnycastAndMulticastWithSameName() throws Exception {
int port = 61614;
@ -1785,7 +1774,7 @@ public class StompTest extends StompTestBase {
*
* @throws Exception
*/
@TestTemplate
@Test
public void testPrefixedAutoCreatedMulticastAndAnycastWithSameName() throws Exception {
int port = 61614;
@ -1853,22 +1842,22 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDotPrefixedSendAndRecieveAnycast() throws Exception {
testPrefixedSendAndRecieve("jms.queue.", RoutingType.ANYCAST);
}
@TestTemplate
@Test
public void testDotPrefixedSendAndRecieveMulticast() throws Exception {
testPrefixedSendAndRecieve("jms.topic.", RoutingType.MULTICAST);
}
@TestTemplate
@Test
public void testSlashPrefixedSendAndRecieveAnycast() throws Exception {
testPrefixedSendAndRecieve("/queue/", RoutingType.ANYCAST);
}
@TestTemplate
@Test
public void testSlashPrefixedSendAndRecieveMulticast() throws Exception {
testPrefixedSendAndRecieve("/topic/", RoutingType.MULTICAST);
}
@ -1902,13 +1891,13 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testMulticastOperationsOnAnycastAddress() throws Exception {
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
testRoutingSemantics(getQueuePrefix() + getQueueName(), RoutingType.MULTICAST.toString());
}
@TestTemplate
@Test
public void testAnycastOperationsOnMulticastAddress() throws Exception {
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
testRoutingSemantics(getTopicPrefix() + getTopicName(), RoutingType.ANYCAST.toString());
@ -1932,7 +1921,7 @@ public class StompTest extends StompTestBase {
assertEquals(Stomp.Responses.ERROR, frame.getCommand());
}
@TestTemplate
@Test
public void testGetManagementAttributeFromStomp() throws Exception {
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoCreateAddresses(false).setAutoCreateQueues(false));
conn.connect(defUser, defPass);
@ -1956,7 +1945,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testInvokeOperationFromStomp() throws Exception {
conn.connect(defUser, defPass);
@ -1979,7 +1968,7 @@ public class StompTest extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testAnycastMessageRoutingExclusivity() throws Exception {
conn.connect(defUser, defPass);
@ -2000,7 +1989,7 @@ public class StompTest extends StompTestBase {
Wait.assertTrue(() -> server.locateQueue(SimpleString.of(queueC)).getMessageCount() == 0);
}
@TestTemplate
@Test
public void testMulticastMessageRoutingExclusivity() throws Exception {
conn.connect(defUser, defPass);
@ -2021,7 +2010,7 @@ public class StompTest extends StompTestBase {
Wait.assertTrue(() -> server.locateQueue(SimpleString.of(queueC)).getMessageCount() + server.locateQueue(SimpleString.of(queueB)).getMessageCount() == 2);
}
@TestTemplate
@Test
public void testAmbiguousMessageRouting() throws Exception {
conn.connect(defUser, defPass);
@ -2044,7 +2033,7 @@ public class StompTest extends StompTestBase {
Wait.assertTrue(() -> server.locateQueue(SimpleString.of(queueC)).getMessageCount() + server.locateQueue(SimpleString.of(queueD)).getMessageCount() == 2);
}
@TestTemplate
@Test
public void testAutoCreatedAnycastAddress() throws Exception {
conn.connect(defUser, defPass);
@ -2063,7 +2052,7 @@ public class StompTest extends StompTestBase {
assertEquals(RoutingType.ANYCAST, server.locateQueue(simpleQueueName).getRoutingType());
}
@TestTemplate
@Test
public void testAutoCreatedMulticastAddress() throws Exception {
conn.connect(defUser, defPass);
@ -2080,7 +2069,7 @@ public class StompTest extends StompTestBase {
assertNull(server.locateQueue(simpleQueueName));
}
@TestTemplate
@Test
public void directDeliverDisabledOnStomp() throws Exception {
String payload = "This is a test message";
@ -2104,7 +2093,7 @@ public class StompTest extends StompTestBase {
}
@TestTemplate
@Test
public void testSameMessageHasDifferentMessageIdPerConsumer() throws Exception {
conn.connect(defUser, defPass);

View File

@ -16,35 +16,24 @@
*/
package org.apache.activemq.artemis.tests.integration.stomp;
import static org.junit.jupiter.api.Assertions.assertFalse;
import java.net.URI;
import java.util.Arrays;
import java.util.Collection;
import java.util.UUID;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
@ExtendWith(ParameterizedTestExtension.class)
public class StompTestMultiThreaded extends StompTestBase {
private static final SimpleString QUEUE = SimpleString.of("x");
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v10.stomp"}, {"tcp+v10.stomp"}});
}
public StompTestMultiThreaded(String scheme) {
super(scheme);
public StompTestMultiThreaded() {
super("tcp+v10.stomp");
}
class SomeConsumer extends Thread {
@ -76,7 +65,7 @@ public class StompTestMultiThreaded extends StompTestBase {
}
}
@TestTemplate
@Test
public void testTwoConcurrentSubscribers() throws Exception {
server.getAddressSettingsRepository().addMatch("#", new AddressSettings().setAutoDeleteAddresses(false).setAutoDeleteQueues(false));
server.getRemotingService().createAcceptor("test", "tcp://localhost:61614?protocols=STOMP&anycastPrefix=/queue/").start();

View File

@ -16,27 +16,21 @@
*/
package org.apache.activemq.artemis.tests.integration.stomp;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.net.URI;
import java.util.Arrays;
import java.util.Collection;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(ParameterizedTestExtension.class)
public class StompWebSocketMaxFrameTest extends StompTestBase {
private final int wsPortWithStompMaxFrame = 61614;
@ -50,13 +44,8 @@ public class StompWebSocketMaxFrameTest extends StompTestBase {
private final int stompWSMaxFrameSize = 131072; // 128kb
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v10.stomp"}, {"ws+v11.stomp"}, {"ws+v12.stomp"}});
}
public StompWebSocketMaxFrameTest(String scheme) {
super(scheme);
public StompWebSocketMaxFrameTest() {
super("ws+v10.stomp");
}
@BeforeEach
@ -74,7 +63,7 @@ public class StompWebSocketMaxFrameTest extends StompTestBase {
wsURIForBothMaxFrameButFails = createStompClientUri(scheme, hostname, wsPortWithBothMaxFrameButFails);
}
@TestTemplate
@Test
public void testStompSendReceiveWithMaxFramePayloadLength() throws Exception {
// Assert that sending message > default 64kb fails
int size = 65536;
@ -154,5 +143,4 @@ public class StompWebSocketMaxFrameTest extends StompTestBase {
conn.closeTransport();
}
}
}

View File

@ -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.tests.integration.stomp;
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
/*
* This is a sanity check to ensure a client can connect via WebSocket. Only basic connectivity is tested here because
* once the connection is established the code paths should be the same as normal TCP clients. Those code paths are
* tested elsewhere.
*/
public class StompWebSocketTest extends StompTestBase {
protected StompClientConnection conn;
public StompWebSocketTest() {
super("ws+v10.stomp");
}
@Override
@BeforeEach
public void setUp() throws Exception {
super.setUp();
conn = StompClientConnectionFactory.createClientConnection(uri);
}
@Test
public void testConnect() throws Exception {
ClientStompFrame response = conn.sendFrame(conn.createFrame(Stomp.Commands.CONNECT).addHeader(Stomp.Headers.Connect.LOGIN, defUser).addHeader(Stomp.Headers.Connect.PASSCODE, defPass).addHeader(Stomp.Headers.Connect.REQUEST_ID, "1"));
assertTrue(response.getCommand().equals(Stomp.Responses.CONNECTED));
assertTrue(response.getHeader(Stomp.Headers.Connected.RESPONSE_ID).equals("1"));
conn.disconnect();
}
}

View File

@ -17,12 +17,8 @@
package org.apache.activemq.artemis.tests.integration.stomp;
import static org.junit.jupiter.api.Assertions.assertEquals;
import javax.security.auth.Subject;
import java.lang.management.ManagementFactory;
import java.util.Arrays;
import java.util.Collection;
import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.core.config.Configuration;
@ -34,23 +30,16 @@ import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
import org.apache.activemq.artemis.spi.core.security.jaas.InVMLoginModule;
import org.apache.activemq.artemis.spi.core.security.jaas.NoCacheLoginException;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
@ExtendWith(ParameterizedTestExtension.class)
public class StompWithClientIdValidationTest extends StompTestBase {
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v10.stomp"}, {"tcp+v10.stomp"}});
}
public StompWithClientIdValidationTest(String scheme) {
super(scheme);
public StompWithClientIdValidationTest() {
super("tcp+v10.stomp");
}
@Override
@ -96,7 +85,7 @@ public class StompWithClientIdValidationTest extends StompTestBase {
return server;
}
@TestTemplate
@Test
public void testStompConnectWithClientId() throws Exception {
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
@ -107,7 +96,7 @@ public class StompWithClientIdValidationTest extends StompTestBase {
}
}
@TestTemplate
@Test
public void testStompConnectWithoutClientId() throws Exception {
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
try {

View File

@ -16,12 +16,7 @@
*/
package org.apache.activemq.artemis.tests.integration.stomp;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@ -30,25 +25,19 @@ import org.apache.activemq.artemis.core.protocol.core.Packet;
import org.apache.activemq.artemis.core.protocol.stomp.StompFrame;
import org.apache.activemq.artemis.core.protocol.stomp.StompFrameInterceptor;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.apache.activemq.artemis.tests.util.Wait;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(ParameterizedTestExtension.class)
public class StompWithInterceptorsTest extends StompTestBase {
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v10.stomp"}, {"tcp+v10.stomp"}});
}
public StompWithInterceptorsTest(String scheme) {
super(scheme);
public StompWithInterceptorsTest() {
super("tcp+v10.stomp");
}
@Override
@ -68,7 +57,7 @@ public class StompWithInterceptorsTest extends StompTestBase {
return stompOutgoingInterceptor;
}
@TestTemplate
@Test
public void stompFrameInterceptor() throws Exception {
IncomingStompInterceptor.interceptedFrames.clear();
OutgoingStompInterceptor.interceptedFrames.clear();

View File

@ -16,37 +16,25 @@
*/
package org.apache.activemq.artemis.tests.integration.stomp;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import javax.jms.Message;
import javax.jms.MessageConsumer;
import javax.jms.QueueBrowser;
import javax.jms.TextMessage;
import java.util.Arrays;
import java.util.Collection;
import java.util.Enumeration;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(ParameterizedTestExtension.class)
public class StompWithMessageIDTest extends StompTestBase {
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v10.stomp"}, {"tcp+v10.stomp"}});
}
public StompWithMessageIDTest(String scheme) {
super(scheme);
public StompWithMessageIDTest() {
super("tcp+v10.stomp");
}
@Override
@ -54,7 +42,7 @@ public class StompWithMessageIDTest extends StompTestBase {
return true;
}
@TestTemplate
@Test
public void testEnableMessageID() throws Exception {
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
conn.connect(defUser, defPass);

View File

@ -16,12 +16,7 @@
*/
package org.apache.activemq.artemis.tests.integration.stomp;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
@ -30,25 +25,19 @@ import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.core.protocol.stomp.StompFrame;
import org.apache.activemq.artemis.core.protocol.stomp.StompFrameInterceptor;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.apache.activemq.artemis.tests.util.Wait;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(ParameterizedTestExtension.class)
public class StompWithRejectingInterceptorTest extends StompTestBase {
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v10.stomp"}, {"tcp+v10.stomp"}});
}
public StompWithRejectingInterceptorTest(String scheme) {
super(scheme);
public StompWithRejectingInterceptorTest() {
super("tcp+v10.stomp");
}
@Override
@ -59,7 +48,7 @@ public class StompWithRejectingInterceptorTest extends StompTestBase {
return stompIncomingInterceptor;
}
@TestTemplate
@Test
public void stompFrameInterceptor() throws Exception {
IncomingStompFrameRejectInterceptor.interceptedFrames.clear();

View File

@ -16,38 +16,27 @@
*/
package org.apache.activemq.artemis.tests.integration.stomp;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.lang.management.ManagementFactory;
import java.net.URI;
import java.net.URL;
import java.util.Arrays;
import java.util.Collection;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.ActiveMQServers;
import org.apache.activemq.artemis.spi.core.security.ActiveMQJAASSecurityManager;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(ParameterizedTestExtension.class)
public class StompWithSecurityPerAcceptorTest extends StompTestBase {
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v10.stomp"}, {"tcp+v10.stomp"}});
}
public StompWithSecurityPerAcceptorTest(String scheme) {
super(scheme);
public StompWithSecurityPerAcceptorTest() {
super("tcp+v10.stomp");
}
static {
@ -88,14 +77,14 @@ public class StompWithSecurityPerAcceptorTest extends StompTestBase {
return server;
}
@TestTemplate
@Test
public void testSecurityPerAcceptorPositive() throws Exception {
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
ClientStompFrame frame = conn.connect("first", "secret");
assertTrue(frame.getCommand().equals(Stomp.Responses.CONNECTED));
}
@TestTemplate
@Test
public void testSecurityPerAcceptorNegative() throws Exception {
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
ClientStompFrame frame = conn.connect("fail", "secret");

View File

@ -16,34 +16,22 @@
*/
package org.apache.activemq.artemis.tests.integration.stomp;
import javax.jms.MessageConsumer;
import javax.jms.TextMessage;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import java.util.Arrays;
import java.util.Collection;
import javax.jms.MessageConsumer;
import javax.jms.TextMessage;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
@ExtendWith(ParameterizedTestExtension.class)
public class StompWithSecurityTest extends StompTestBase {
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v10.stomp"}, {"tcp+v10.stomp"}});
}
public StompWithSecurityTest(String scheme) {
super(scheme);
public StompWithSecurityTest() {
super("tcp+v10.stomp");
}
@Override
@ -51,7 +39,7 @@ public class StompWithSecurityTest extends StompTestBase {
return true;
}
@TestTemplate
@Test
public void testJMSXUserID() throws Exception {
server.getConfiguration().setPopulateValidatedUser(true);

View File

@ -16,33 +16,24 @@
*/
package org.apache.activemq.artemis.tests.integration.stomp.v11;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import java.lang.invoke.MethodHandles;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.StompTestBase;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/*
* Some Stomp tests against server with persistence enabled are put here.
*/
@ExtendWith(ParameterizedTestExtension.class)
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
public class ExtraStompTest extends StompTestBase {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@ -50,13 +41,8 @@ public class ExtraStompTest extends StompTestBase {
private StompClientConnection connV10;
private StompClientConnection connV11;
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v11.stomp"}, {"tcp+v11.stomp"}});
}
public ExtraStompTest(String scheme) {
super(scheme);
public ExtraStompTest() {
super("tcp+v11.stomp");
}
@Override
@ -87,12 +73,12 @@ public class ExtraStompTest extends StompTestBase {
}
}
@TestTemplate
@Test
public void testSendAndReceive10() throws Exception {
testSendAndReceive(connV10);
}
@TestTemplate
@Test
public void testSendAndReceive11() throws Exception {
testSendAndReceive(connV11);
}
@ -138,12 +124,12 @@ public class ExtraStompTest extends StompTestBase {
unsubscribe(conn, "a-sub");
}
@TestTemplate
@Test
public void testNoGarbageAfterPersistentMessageV10() throws Exception {
testNoGarbageAfterPersistentMessage(connV10);
}
@TestTemplate
@Test
public void testNoGarbageAfterPersistentMessageV11() throws Exception {
testNoGarbageAfterPersistentMessage(connV11);
}
@ -180,12 +166,12 @@ public class ExtraStompTest extends StompTestBase {
unsubscribe(conn, "a-sub");
}
@TestTemplate
@Test
public void testNoGarbageOnPersistentRedeliveryV10() throws Exception {
testNoGarbageOnPersistentRedelivery(connV10);
}
@TestTemplate
@Test
public void testNoGarbageOnPersistentRedeliveryV11() throws Exception {
testNoGarbageOnPersistentRedelivery(connV11);
}

View File

@ -26,8 +26,6 @@ import java.lang.invoke.MethodHandles;
import java.net.URI;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
@ -41,8 +39,6 @@ import org.apache.activemq.artemis.core.protocol.stomp.v11.StompFrameHandlerV11;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.StompTestBase;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
@ -51,8 +47,7 @@ import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConne
import org.apache.activemq.artemis.tests.util.Wait;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -63,7 +58,6 @@ import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;
@ExtendWith(ParameterizedTestExtension.class)
public class StompV11Test extends StompTestBase {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@ -74,13 +68,8 @@ public class StompV11Test extends StompTestBase {
private URI v10Uri;
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v11.stomp"}, {"tcp+v11.stomp"}});
}
public StompV11Test(String scheme) {
super(scheme);
public StompV11Test() {
super("tcp+v11.stomp");
}
@Override
@ -105,7 +94,7 @@ public class StompV11Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testConnection() throws Exception {
server.getSecurityStore().setSecurityEnabled(true);
StompClientConnection connection = StompClientConnectionFactory.createClientConnection(v10Uri);
@ -163,7 +152,7 @@ public class StompV11Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testNegotiation() throws Exception {
// case 1 accept-version absent. It is a 1.0 connect
ClientStompFrame frame = conn.createFrame(Stomp.Commands.CONNECT)
@ -247,7 +236,7 @@ public class StompV11Test extends StompTestBase {
}
@TestTemplate
@Test
public void testServerFrame() throws Exception {
{ // the default case
ClientStompFrame frame = conn.connect(defUser, defPass);
@ -274,7 +263,7 @@ public class StompV11Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testSendAndReceive() throws Exception {
conn.connect(defUser, defPass);
@ -315,7 +304,7 @@ public class StompV11Test extends StompTestBase {
newConn.disconnect();
}
@TestTemplate
@Test
public void testHeaderContentType() throws Exception {
conn.connect(defUser, defPass);
send(conn, getQueuePrefix() + getQueueName(), "application/xml", "Hello World 1!");
@ -340,7 +329,7 @@ public class StompV11Test extends StompTestBase {
newConn.disconnect();
}
@TestTemplate
@Test
public void testHeaderContentLength() throws Exception {
conn.connect(defUser, defPass);
@ -375,7 +364,7 @@ public class StompV11Test extends StompTestBase {
newConn.disconnect();
}
@TestTemplate
@Test
public void testHeaderEncoding() throws Exception {
conn.connect(defUser, defPass);
@ -421,7 +410,7 @@ public class StompV11Test extends StompTestBase {
/**
* In 1.1, undefined escapes must cause a fatal protocol error.
*/
@TestTemplate
@Test
public void testHeaderUndefinedEscape() throws Exception {
conn.connect(defUser, defPass);
ClientStompFrame frame = conn.createFrame("SEND");
@ -452,7 +441,7 @@ public class StompV11Test extends StompTestBase {
assertEquals("ERROR", error.getCommand(), desc);
}
@TestTemplate
@Test
public void testHeartBeat() throws Exception {
//no heart beat at all if heat-beat absent
ClientStompFrame frame = conn.createFrame(Stomp.Commands.CONNECT)
@ -549,7 +538,7 @@ public class StompV11Test extends StompTestBase {
}
//server ping
@TestTemplate
@Test
public void testHeartBeat2() throws Exception {
//heart-beat (1,1)
ClientStompFrame frame = conn.createFrame(Stomp.Commands.CONNECT)
@ -601,7 +590,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSendWithHeartBeatsAndReceive() throws Exception {
StompClientConnection newConn = null;
try {
@ -648,7 +637,7 @@ public class StompV11Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testSendAndReceiveWithHeartBeats() throws Exception {
conn.connect(defUser, defPass);
@ -694,7 +683,7 @@ public class StompV11Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testSendWithHeartBeatsAndReceiveWithHeartBeats() throws Exception {
StompClientConnection newConn = null;
try {
@ -751,7 +740,7 @@ public class StompV11Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testHeartBeatToTTL() throws Exception {
ClientStompFrame frame;
ClientStompFrame reply;
@ -901,7 +890,7 @@ public class StompV11Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testHeartBeatToConnectionTTLModifier() throws Exception {
ClientStompFrame frame;
ClientStompFrame reply;
@ -954,7 +943,7 @@ public class StompV11Test extends StompTestBase {
connection.disconnect();
}
@TestTemplate
@Test
public void testNack() throws Exception {
conn.connect(defUser, defPass);
@ -978,7 +967,7 @@ public class StompV11Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testNackWithWrongSubId() throws Exception {
conn.connect(defUser, defPass);
@ -1006,7 +995,7 @@ public class StompV11Test extends StompTestBase {
assertNotNull(message);
}
@TestTemplate
@Test
public void testNackWithWrongMessageId() throws Exception {
conn.connect(defUser, defPass);
@ -1034,7 +1023,7 @@ public class StompV11Test extends StompTestBase {
assertNotNull(message);
}
@TestTemplate
@Test
public void testAck() throws Exception {
conn.connect(defUser, defPass);
@ -1058,7 +1047,7 @@ public class StompV11Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testAckWithWrongSubId() throws Exception {
conn.connect(defUser, defPass);
@ -1086,7 +1075,7 @@ public class StompV11Test extends StompTestBase {
assertNotNull(message);
}
@TestTemplate
@Test
public void testAckWithWrongMessageId() throws Exception {
conn.connect(defUser, defPass);
@ -1114,7 +1103,7 @@ public class StompV11Test extends StompTestBase {
assertNotNull(message);
}
@TestTemplate
@Test
public void testErrorWithReceipt() throws Exception {
conn.connect(defUser, defPass);
@ -1150,7 +1139,7 @@ public class StompV11Test extends StompTestBase {
assertNotNull(message);
}
@TestTemplate
@Test
public void testErrorWithReceipt2() throws Exception {
conn.connect(defUser, defPass);
@ -1186,7 +1175,7 @@ public class StompV11Test extends StompTestBase {
assertNotNull(message);
}
@TestTemplate
@Test
public void testAckModeClient() throws Exception {
conn.connect(defUser, defPass);
@ -1218,7 +1207,7 @@ public class StompV11Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testAckModeClient2() throws Exception {
conn.connect(defUser, defPass);
@ -1255,7 +1244,7 @@ public class StompV11Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testAckModeAuto() throws Exception {
conn.connect(defUser, defPass);
@ -1284,7 +1273,7 @@ public class StompV11Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testAckModeClientIndividual() throws Exception {
conn.connect(defUser, defPass);
@ -1328,7 +1317,7 @@ public class StompV11Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testTwoSubscribers() throws Exception {
conn.connect(defUser, defPass, CLIENT_ID);
@ -1362,7 +1351,7 @@ public class StompV11Test extends StompTestBase {
newConn.disconnect();
}
@TestTemplate
@Test
public void testSendAndReceiveOnDifferentConnections() throws Exception {
conn.connect(defUser, defPass);
@ -1384,7 +1373,7 @@ public class StompV11Test extends StompTestBase {
//----------------Note: tests below are adapted from StompTest
@TestTemplate
@Test
public void testBeginSameTransactionTwice() throws Exception {
conn.connect(defUser, defPass);
@ -1396,7 +1385,7 @@ public class StompV11Test extends StompTestBase {
assertTrue(f.getCommand().equals(Stomp.Responses.ERROR));
}
@TestTemplate
@Test
public void testBodyWithUTF8() throws Exception {
conn.connect(defUser, defPass);
@ -1415,7 +1404,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testClientAckNotPartOfTransaction() throws Exception {
conn.connect(defUser, defPass);
@ -1447,7 +1436,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDisconnectAndError() throws Exception {
conn.connect(defUser, defPass);
@ -1499,7 +1488,7 @@ public class StompV11Test extends StompTestBase {
assertTrue(count == 0, "Server failed to disconnect.");
}
@TestTemplate
@Test
public void testDurableSubscriber() throws Exception {
conn.connect(defUser, defPass);
@ -1513,7 +1502,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDurableSubscriberWithReconnection() throws Exception {
conn.connect(defUser, defPass, CLIENT_ID);
@ -1551,7 +1540,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDurableUnSubscribe() throws Exception {
SimpleString queueName = SimpleString.of(CLIENT_ID + "." + getName());
@ -1579,7 +1568,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testJMSXGroupIdCanBeSet() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1599,7 +1588,7 @@ public class StompV11Test extends StompTestBase {
assertEquals("TEST", message.getStringProperty("JMSXGroupID"));
}
@TestTemplate
@Test
public void testMessagesAreInOrder() throws Exception {
int ctr = 10;
String[] data = new String[ctr];
@ -1633,7 +1622,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithAutoAckAndSelector() throws Exception {
conn.connect(defUser, defPass);
@ -1649,7 +1638,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testRedeliveryWithClientAck() throws Exception {
conn.connect(defUser, defPass);
@ -1670,7 +1659,7 @@ public class StompV11Test extends StompTestBase {
assertTrue(message.getJMSRedelivered());
}
@TestTemplate
@Test
public void testSendManyMessages() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1689,7 +1678,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSendMessage() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1710,7 +1699,7 @@ public class StompV11Test extends StompTestBase {
assertTrue(Math.abs(tnow - tmsg) < 1000);
}
@TestTemplate
@Test
public void testSendMessageWithContentLength() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1735,7 +1724,7 @@ public class StompV11Test extends StompTestBase {
assertEquals(data[3], message.readByte());
}
@TestTemplate
@Test
public void testSendMessageWithCustomHeadersAndSelector() throws Exception {
MessageConsumer consumer = session.createConsumer(queue, "foo = 'abc'");
@ -1756,7 +1745,7 @@ public class StompV11Test extends StompTestBase {
assertEquals("123", message.getStringProperty("bar"), "bar");
}
@TestTemplate
@Test
public void testSendMessageWithLeadingNewLine() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
Thread.sleep(1000);
@ -1784,7 +1773,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSendMessageWithReceipt() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1806,7 +1795,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSendMessageWithStandardHeaders() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1840,7 +1829,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSendMessageWithLongHeaders() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1879,7 +1868,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeToTopic() throws Exception {
conn.connect(defUser, defPass);
@ -1903,7 +1892,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeToTopicWithNoLocal() throws Exception {
conn.connect(defUser, defPass);
@ -1929,7 +1918,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithAutoAck() throws Exception {
conn.connect(defUser, defPass);
@ -1951,7 +1940,7 @@ public class StompV11Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testSubscribeWithAutoAckAndBytesMessage() throws Exception {
conn.connect(defUser, defPass);
@ -1975,7 +1964,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithClientAck() throws Exception {
conn.connect(defUser, defPass);
@ -1997,17 +1986,17 @@ public class StompV11Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testSubscribeWithClientAckThenConsumingAgainWithAutoAckWithExplicitDisconnect() throws Exception {
assertSubscribeWithClientAckThenConsumeWithAutoAck(true);
}
@TestTemplate
@Test
public void testSubscribeWithClientAckThenConsumingAgainWithAutoAckWithNoDisconnectFrame() throws Exception {
assertSubscribeWithClientAckThenConsumeWithAutoAck(false);
}
@TestTemplate
@Test
public void testSubscribeWithID() throws Exception {
conn.connect(defUser, defPass);
@ -2022,7 +2011,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithMessageSentWithProperties() throws Exception {
conn.connect(defUser, defPass);
@ -2057,7 +2046,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSuccessiveTransactionsWithSameID() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -2096,7 +2085,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testTransactionCommit() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -2125,7 +2114,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testTransactionRollback() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -2162,7 +2151,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testUnsubscribe() throws Exception {
conn.connect(defUser, defPass);
@ -2189,7 +2178,7 @@ public class StompV11Test extends StompTestBase {
}
@TestTemplate
@Test
public void testHeartBeat3() throws Exception {
connection.close();
@ -2229,7 +2218,7 @@ public class StompV11Test extends StompTestBase {
Wait.assertFalse("HeartBeater is still running!!", () -> stompFrameHandler.getHeartBeater().isStarted());
}
@TestTemplate
@Test
public void testHeartBeat4() throws Exception {
connection.close();
ClientStompFrame frame = conn.createFrame("CONNECT");
@ -2329,7 +2318,7 @@ public class StompV11Test extends StompTestBase {
assertEquals("shouldBeNextMessage", frame.getBody());
}
@TestTemplate
@Test
public void testSendMessageToNonExistentQueueWithAutoCreation() throws Exception {
conn.connect(defUser, defPass);
@ -2338,7 +2327,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSendAndReceiveWithEscapedCharactersInSenderId() throws Exception {
conn.connect(defUser, defPass);
send(conn, getQueuePrefix() + getQueueName(), null, "Hello World 1!");
@ -2358,7 +2347,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testReceiveContentType() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -2371,7 +2360,7 @@ public class StompV11Test extends StompTestBase {
assertEquals("text/plain", message.getStringProperty(org.apache.activemq.artemis.api.core.Message.HDR_CONTENT_TYPE.toString()));
}
@TestTemplate
@Test
public void testSendContentType() throws Exception {
conn.connect(defUser, defPass);
@ -2391,7 +2380,7 @@ public class StompV11Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSameMessageHasDifferentMessageIdPerConsumer() throws Exception {
conn.connect(defUser, defPass);

View File

@ -14,15 +14,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.artemis.tests.integration.stomp;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
package org.apache.activemq.artemis.tests.integration.stomp.v12;
import java.lang.invoke.MethodHandles;
import java.util.Arrays;
import java.util.Collection;
import org.apache.activemq.artemis.api.core.QueueConfiguration;
import org.apache.activemq.artemis.api.core.RoutingType;
@ -31,33 +25,29 @@ import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.QueueQueryResult;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.StompTestBase;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.apache.activemq.artemis.tests.util.Wait;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ExtendWith(ParameterizedTestExtension.class)
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
public class FQQNStompTest extends StompTestBase {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
private StompClientConnection conn;
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v12.stomp"}, {"tcp+v12.stomp"}});
}
public FQQNStompTest(String scheme) {
super(scheme);
public FQQNStompTest() {
super("tcp+v12.stomp");
}
@Override
@ -86,7 +76,7 @@ public class FQQNStompTest extends StompTestBase {
}
}
@TestTemplate
@Test
//to receive from a FQQN queue like testQueue::testQueue
//special care is needed as ":" is a reserved character
//in STOMP. Clients need to escape it.
@ -101,7 +91,7 @@ public class FQQNStompTest extends StompTestBase {
unsubscribe(conn, "sub-01");
}
@TestTemplate
@Test
public void testReceiveFQQN2() throws Exception {
final SimpleString myAddress = SimpleString.of("myAddress");
final SimpleString q1Name = SimpleString.of("q1");
@ -125,7 +115,7 @@ public class FQQNStompTest extends StompTestBase {
unsubscribe(conn, "sub-01");
}
@TestTemplate
@Test
public void testSendFQQNMulticast() throws Exception {
final SimpleString myAddress = SimpleString.of("myAddress");
final SimpleString q1Name = SimpleString.of("q1");
@ -150,7 +140,7 @@ public class FQQNStompTest extends StompTestBase {
unsubscribe(conn, "sub-01");
}
@TestTemplate
@Test
public void testSendFQQNAnycast() throws Exception {
final SimpleString myAddress = SimpleString.of("myAddress");
final SimpleString q1Name = SimpleString.of("q1");
@ -189,7 +179,7 @@ public class FQQNStompTest extends StompTestBase {
unsubscribe(conn, "sub-01");
}
@TestTemplate
@Test
public void testReceiveFQQNSpecial() throws Exception {
conn.connect(defUser, defPass);
//::queue
@ -217,7 +207,7 @@ public class FQQNStompTest extends StompTestBase {
assertEquals(Stomp.Responses.ERROR, frame.getCommand());
}
@TestTemplate
@Test
public void testAutoCreateOnSendFQQN() throws Exception {
final SimpleString myAddress = SimpleString.of("myAddress");
final SimpleString q1Name = SimpleString.of("q1");
@ -237,17 +227,17 @@ public class FQQNStompTest extends StompTestBase {
unsubscribe(conn, "sub-01");
}
@TestTemplate
@Test
public void testAutoCreateOnSubscribeFQQNAnycast() throws Exception {
internalTestAutoCreateOnSubscribeFQQN(RoutingType.ANYCAST);
}
@TestTemplate
@Test
public void testAutoCreateOnSubscribeFQQNMulticast() throws Exception {
internalTestAutoCreateOnSubscribeFQQN(RoutingType.MULTICAST);
}
@TestTemplate
@Test
public void testAutoCreateOnSubscribeFQQNNoRoutingType() throws Exception {
internalTestAutoCreateOnSubscribeFQQN(null);
}

View File

@ -14,77 +14,61 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.artemis.tests.integration.stomp;
package org.apache.activemq.artemis.tests.integration.stomp.v12;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import org.apache.activemq.artemis.core.protocol.stomp.StompFrame;
import org.apache.activemq.artemis.core.protocol.stomp.StompFrameInterceptor;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.Timeout;
import org.junit.jupiter.api.extension.ExtendWith;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@ExtendWith(ParameterizedTestExtension.class)
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.core.protocol.stomp.StompFrame;
import org.apache.activemq.artemis.core.protocol.stomp.StompFrameInterceptor;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection;
import org.apache.activemq.artemis.tests.integration.stomp.StompTestBase;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnectionFactory;
import org.apache.activemq.artemis.tests.util.Wait;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import static org.junit.jupiter.api.Assertions.assertEquals;
public class StompPropertiesInterceptorTest extends StompTestBase {
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v12.stomp"}, {"tcp+v12.stomp"}});
}
private static volatile boolean interceptSendSuccess = false;
private static volatile boolean interceptSubscribeSuccess = false;
private static final String MESSAGE_TEXT = "messageText";
private static final String MY_HEADER = "my-header";
private static Map<String, Object> expectedProperties = new ConcurrentHashMap<>();
public StompPropertiesInterceptorTest(String scheme) {
super(scheme);
public StompPropertiesInterceptorTest() {
super("tcp+v12.stomp");
}
@Override
public List<String> getIncomingInterceptors() {
List<String> stompIncomingInterceptor = new ArrayList<>();
stompIncomingInterceptor.add("org.apache.activemq.artemis.tests.integration.stomp.StompPropertiesInterceptorTest$StompFramePropertiesInterceptor");
return stompIncomingInterceptor;
}
@Override
public List<String> getOutgoingInterceptors() {
List<String> stompOutgoingInterceptor = new ArrayList<>();
stompOutgoingInterceptor.add("org.apache.activemq.artemis.tests.integration.stomp.StompPropertiesInterceptorTest$StompFramePropertiesInterceptor");
return stompOutgoingInterceptor;
return List.of(StompFramePropertiesInterceptor.class.getName());
}
public static class StompFramePropertiesInterceptor implements StompFrameInterceptor {
@Override
public boolean intercept(StompFrame stompFrame, RemotingConnection connection) {
if (stompFrame.getCommand().equals("CONNECT") || stompFrame.getCommand().equals("CONNECTED")) {
return true;
if (stompFrame.getCommand().equals(Stomp.Commands.SEND)) {
assertEquals(stompFrame.getHeader(MY_HEADER), expectedProperties.get(MY_HEADER));
interceptSendSuccess = true;
}
if (stompFrame.getCommand().equals(Stomp.Commands.SUBSCRIBE)) {
assertEquals(stompFrame.getHeader(MY_HEADER), expectedProperties.get(MY_HEADER));
assertEquals(stompFrame.getBody(), expectedProperties.get(MESSAGE_TEXT));
interceptSubscribeSuccess = true;
}
assertNotNull(stompFrame);
assertEquals(stompFrame.getHeader(MY_HEADER), expectedProperties.get(MY_HEADER));
assertEquals(stompFrame.getBody(), expectedProperties.get(MESSAGE_TEXT));
return true;
}
}
private static final String MESSAGE_TEXT = "messageText";
private static final String MY_HEADER = "my-header";
private static Map<String, Object> expectedProperties = new ConcurrentHashMap<>();
@TestTemplate
@Test
@Timeout(60)
public void testCheckInterceptedStompMessageProperties() throws Exception {
final String msgText = "Test intercepted message";
@ -95,23 +79,24 @@ public class StompPropertiesInterceptorTest extends StompTestBase {
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
conn.connect(defUser, defPass);
ClientStompFrame subFrame = conn.createFrame("SUBSCRIBE");
ClientStompFrame subFrame = conn.createFrame(Stomp.Commands.SUBSCRIBE);
subFrame.addHeader("subscription-type", "ANYCAST");
subFrame.addHeader("destination", name);
subFrame.addHeader("ack", "auto");
subFrame.addHeader(Stomp.Headers.Subscribe.SUBSCRIPTION_TYPE, "ANYCAST");
subFrame.addHeader(Stomp.Headers.Subscribe.DESTINATION, name);
subFrame.addHeader(Stomp.Headers.Subscribe.ACK_MODE, "auto");
subFrame.addHeader(MY_HEADER, myHeader);
subFrame.setBody(msgText);
conn.sendFrame(subFrame);
Wait.assertTrue(() -> interceptSubscribeSuccess == true, 2000, 100);
ClientStompFrame frame = conn.createFrame("SEND");
frame.addHeader("destination", name);
frame.addHeader("ack", "auto");
frame.addHeader(MY_HEADER, myHeader);
conn.sendFrame(frame);
ClientStompFrame sendFrame = conn.createFrame(Stomp.Commands.SEND);
sendFrame.addHeader(Stomp.Headers.Send.DESTINATION, name);
sendFrame.addHeader(MY_HEADER, myHeader);
conn.sendFrame(sendFrame);
Wait.assertTrue(() -> interceptSendSuccess == true, 2000, 100);
Wait.assertEquals(1L, () -> server.locateQueue(name).getMessagesAcknowledged(), 2000, 100);
conn.disconnect();
}
}

View File

@ -27,8 +27,6 @@ import java.lang.invoke.MethodHandles;
import java.net.URI;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.Collection;
import java.util.UUID;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.TimeUnit;
@ -39,8 +37,6 @@ import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.protocol.stomp.Stomp;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.tests.extensions.parameterized.ParameterizedTestExtension;
import org.apache.activemq.artemis.tests.extensions.parameterized.Parameters;
import org.apache.activemq.artemis.tests.integration.stomp.StompTestBase;
import org.apache.activemq.artemis.tests.integration.stomp.util.ClientStompFrame;
import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConnection;
@ -50,8 +46,7 @@ import org.apache.activemq.artemis.tests.integration.stomp.util.StompClientConne
import org.apache.activemq.artemis.utils.Wait;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@ -65,7 +60,6 @@ import static org.junit.jupiter.api.Assertions.fail;
/**
* Testing Stomp version 1.2 functionalities
*/
@ExtendWith(ParameterizedTestExtension.class)
public class StompV12Test extends StompTestBase {
private static final Logger logger = LoggerFactory.getLogger(MethodHandles.lookup().lookupClass());
@ -78,13 +72,8 @@ public class StompV12Test extends StompTestBase {
private URI v11Uri;
@Parameters(name = "{0}")
public static Collection<Object[]> data() {
return Arrays.asList(new Object[][]{{"ws+v12.stomp"}, {"tcp+v12.stomp"}});
}
public StompV12Test(String scheme) {
super(scheme);
public StompV12Test() {
super("tcp+v12.stomp");
}
@Override
@ -111,7 +100,7 @@ public class StompV12Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testSubscribeWithReceipt() throws Exception {
conn.connect(defUser, defPass);
@ -121,7 +110,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testConnection() throws Exception {
server.getSecurityStore().setSecurityEnabled(true);
StompClientConnection connection = StompClientConnectionFactory.createClientConnection(v10Uri);
@ -159,7 +148,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testConnectionAsInSpec() throws Exception {
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(v10Uri);
@ -193,7 +182,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testNegotiation() throws Exception {
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(v10Uri);
// case 1 accept-version absent. It is a 1.0 connect
@ -280,7 +269,7 @@ public class StompV12Test extends StompTestBase {
}
@TestTemplate
@Test
public void testSendAndReceive() throws Exception {
conn.connect(defUser, defPass);
@ -320,7 +309,7 @@ public class StompV12Test extends StompTestBase {
newConn.disconnect();
}
@TestTemplate
@Test
public void testHeaderContentType() throws Exception {
conn.connect(defUser, defPass);
@ -345,7 +334,7 @@ public class StompV12Test extends StompTestBase {
newConn.disconnect();
}
@TestTemplate
@Test
public void testHeaderContentLength() throws Exception {
conn.connect(defUser, defPass);
@ -396,7 +385,7 @@ public class StompV12Test extends StompTestBase {
}
//test that repetitive headers
@TestTemplate
@Test
public void testHeaderRepetitive() throws Exception {
AddressSettings addressSettings = new AddressSettings();
addressSettings.setAutoCreateQueues(false);
@ -458,7 +447,7 @@ public class StompV12Test extends StompTestBase {
}
//padding shouldn't be trimmed
@TestTemplate
@Test
public void testHeadersPadding() throws Exception {
conn.connect(defUser, defPass);
@ -507,7 +496,7 @@ public class StompV12Test extends StompTestBase {
/**
* Since 1.2 the CR ('\r') needs to be escaped.
*/
@TestTemplate
@Test
public void testHeaderEncoding() throws Exception {
conn.connect(defUser, defPass);
String body = "Hello World 1!";
@ -551,7 +540,7 @@ public class StompV12Test extends StompTestBase {
/**
* In 1.2, undefined escapes must cause a fatal protocol error.
*/
@TestTemplate
@Test
public void testHeaderUndefinedEscape() throws Exception {
conn.connect(defUser, defPass);
ClientStompFrame frame = conn.createFrame("SEND");
@ -584,7 +573,7 @@ public class StompV12Test extends StompTestBase {
assertFalse(conn.isConnected(), "Should be disconnected in STOMP 1.2 after ERROR");
}
@TestTemplate
@Test
public void testHeartBeat() throws Exception {
StompClientConnection conn = StompClientConnectionFactory.createClientConnection(uri);
//no heart beat at all if heat-beat absent
@ -678,7 +667,7 @@ public class StompV12Test extends StompTestBase {
}
//server ping
@TestTemplate
@Test
public void testHeartBeat2() throws Exception {
//heart-beat (1,1)
ClientStompFrame frame = conn.createFrame(Stomp.Commands.CONNECT)
@ -728,7 +717,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSendWithHeartBeatsAndReceive() throws Exception {
StompClientConnection newConn = null;
try {
@ -774,7 +763,7 @@ public class StompV12Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testSendAndReceiveWithHeartBeats() throws Exception {
conn.connect(defUser, defPass);
@ -820,7 +809,7 @@ public class StompV12Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testSendWithHeartBeatsAndReceiveWithHeartBeats() throws Exception {
StompClientConnection newConn = null;
try {
@ -877,7 +866,7 @@ public class StompV12Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testNack() throws Exception {
conn.connect(defUser, defPass);
@ -901,7 +890,7 @@ public class StompV12Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testNackWithWrongSubId() throws Exception {
conn.connect(defUser, defPass);
@ -928,7 +917,7 @@ public class StompV12Test extends StompTestBase {
assertNotNull(message);
}
@TestTemplate
@Test
public void testNackWithWrongMessageId() throws Exception {
conn.connect(defUser, defPass);
@ -957,7 +946,7 @@ public class StompV12Test extends StompTestBase {
assertNotNull(message);
}
@TestTemplate
@Test
public void testAck() throws Exception {
conn.connect(defUser, defPass);
@ -983,7 +972,7 @@ public class StompV12Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testAckNoIDHeader() throws Exception {
conn.connect(defUser, defPass);
@ -1014,7 +1003,7 @@ public class StompV12Test extends StompTestBase {
assertNotNull(message);
}
@TestTemplate
@Test
public void testAckWithWrongMessageId() throws Exception {
conn.connect(defUser, defPass);
@ -1041,7 +1030,7 @@ public class StompV12Test extends StompTestBase {
assertNotNull(message);
}
@TestTemplate
@Test
public void testErrorWithReceipt() throws Exception {
conn.connect(defUser, defPass);
@ -1076,7 +1065,7 @@ public class StompV12Test extends StompTestBase {
assertNotNull(message);
}
@TestTemplate
@Test
public void testErrorWithReceipt2() throws Exception {
conn.connect(defUser, defPass);
@ -1119,7 +1108,7 @@ public class StompV12Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testAckModeClient() throws Exception {
conn.connect(defUser, defPass);
@ -1151,7 +1140,7 @@ public class StompV12Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testAckModeClient2() throws Exception {
conn.connect(defUser, defPass);
@ -1188,7 +1177,7 @@ public class StompV12Test extends StompTestBase {
}
//when ack is missing the mode default to auto
@TestTemplate
@Test
public void testAckModeDefault() throws Exception {
conn.connect(defUser, defPass);
@ -1217,7 +1206,7 @@ public class StompV12Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testAckModeAuto() throws Exception {
conn.connect(defUser, defPass);
@ -1246,7 +1235,7 @@ public class StompV12Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testAckModeClientIndividual() throws Exception {
conn.connect(defUser, defPass);
@ -1290,7 +1279,7 @@ public class StompV12Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testTwoSubscribers() throws Exception {
conn.connect(defUser, defPass, CLIENT_ID);
@ -1324,7 +1313,7 @@ public class StompV12Test extends StompTestBase {
newConn.disconnect();
}
@TestTemplate
@Test
public void testSendAndReceiveOnDifferentConnections() throws Exception {
conn.connect(defUser, defPass);
@ -1346,7 +1335,7 @@ public class StompV12Test extends StompTestBase {
//----------------Note: tests below are adapted from StompTest
@TestTemplate
@Test
public void testBeginSameTransactionTwice() throws Exception {
conn.connect(defUser, defPass);
@ -1358,7 +1347,7 @@ public class StompV12Test extends StompTestBase {
assertTrue(f.getCommand().equals(Stomp.Responses.ERROR));
}
@TestTemplate
@Test
public void testBodyWithUTF8() throws Exception {
conn.connect(defUser, defPass);
@ -1377,7 +1366,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testClientAckNotPartOfTransaction() throws Exception {
conn.connect(defUser, defPass);
@ -1410,7 +1399,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDisconnectAndError() throws Exception {
conn.connect(defUser, defPass);
@ -1460,7 +1449,7 @@ public class StompV12Test extends StompTestBase {
assertTrue(count == 0, "Server failed to disconnect.");
}
@TestTemplate
@Test
public void testDurableSubscriber() throws Exception {
conn.connect(defUser, defPass);
@ -1474,7 +1463,7 @@ public class StompV12Test extends StompTestBase {
assertFalse(conn.isConnected(), "Should be disconnected in STOMP 1.2 after ERROR");
}
@TestTemplate
@Test
public void testMultipleDurableSubscribers() throws Exception {
conn.connect(defUser, defPass, "myClientID");
StompClientConnectionV12 conn2 = (StompClientConnectionV12) StompClientConnectionFactory.createClientConnection(uri);
@ -1489,7 +1478,7 @@ public class StompV12Test extends StompTestBase {
waitDisconnect(conn2);
}
@TestTemplate
@Test
public void testMultipleConcurrentDurableSubscribers() throws Exception {
int NUMBER_OF_THREADS = 25;
SubscriberThread[] threads = new SubscriberThread[NUMBER_OF_THREADS];
@ -1552,7 +1541,7 @@ public class StompV12Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testDurableSubscriberWithReconnection() throws Exception {
conn.connect(defUser, defPass, CLIENT_ID);
@ -1588,7 +1577,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDurableUnSubscribe() throws Exception {
conn.connect(defUser, defPass, CLIENT_ID);
@ -1607,7 +1596,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testJMSXGroupIdCanBeSet() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1627,7 +1616,7 @@ public class StompV12Test extends StompTestBase {
assertEquals("TEST", message.getStringProperty("JMSXGroupID"));
}
@TestTemplate
@Test
public void testMessagesAreInOrder() throws Exception {
int ctr = 10;
String[] data = new String[ctr];
@ -1661,7 +1650,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithAutoAckAndSelector() throws Exception {
conn.connect(defUser, defPass);
@ -1677,7 +1666,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testRedeliveryWithClientAck() throws Exception {
conn.connect(defUser, defPass);
@ -1698,7 +1687,7 @@ public class StompV12Test extends StompTestBase {
assertTrue(message.getJMSRedelivered());
}
@TestTemplate
@Test
public void testSendManyMessages() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1726,7 +1715,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSendMessage() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1747,7 +1736,7 @@ public class StompV12Test extends StompTestBase {
assertTrue(Math.abs(tnow - tmsg) < 1000);
}
@TestTemplate
@Test
public void testSendMessageWithContentLength() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1772,7 +1761,7 @@ public class StompV12Test extends StompTestBase {
assertEquals(data[3], message.readByte());
}
@TestTemplate
@Test
public void testSendMessageWithCustomHeadersAndSelector() throws Exception {
MessageConsumer consumer = session.createConsumer(queue, "foo = 'abc'");
@ -1793,7 +1782,7 @@ public class StompV12Test extends StompTestBase {
assertEquals("123", message.getStringProperty("bar"), "bar");
}
@TestTemplate
@Test
public void testSendMessageWithLeadingNewLine() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1820,7 +1809,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSendMessageWithReceipt() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1841,7 +1830,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSendMessageWithStandardHeaders() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1875,7 +1864,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSendMessageWithLongHeaders() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -1914,7 +1903,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeToTopic() throws Exception {
conn.connect(defUser, defPass);
@ -1938,7 +1927,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeToTopicWithNoLocal() throws Exception {
conn.connect(defUser, defPass);
@ -1965,7 +1954,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithAutoAck() throws Exception {
conn.connect(defUser, defPass);
@ -1987,7 +1976,7 @@ public class StompV12Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testSubscribeWithAutoAckAndBytesMessage() throws Exception {
conn.connect(defUser, defPass);
@ -2011,7 +2000,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithClientAck() throws Exception {
conn.connect(defUser, defPass);
@ -2031,17 +2020,17 @@ public class StompV12Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testSubscribeWithClientAckThenConsumingAgainWithAutoAckWithExplicitDisconnect() throws Exception {
assertSubscribeWithClientAckThenConsumeWithAutoAck(true);
}
@TestTemplate
@Test
public void testSubscribeWithClientAckThenConsumingAgainWithAutoAckWithNoDisconnectFrame() throws Exception {
assertSubscribeWithClientAckThenConsumeWithAutoAck(false);
}
@TestTemplate
@Test
public void testSubscribeWithID() throws Exception {
conn.connect(defUser, defPass);
@ -2056,7 +2045,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithMessageSentWithProperties() throws Exception {
conn.connect(defUser, defPass);
@ -2091,7 +2080,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSuccessiveTransactionsWithSameID() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -2130,7 +2119,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testTransactionCommit() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -2159,7 +2148,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testTransactionRollback() throws Exception {
MessageConsumer consumer = session.createConsumer(queue);
@ -2196,7 +2185,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testUnsubscribe() throws Exception {
conn.connect(defUser, defPass);
@ -2222,7 +2211,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testDisconnectWithoutUnsubscribe() throws Exception {
conn.connect(defUser, defPass);
@ -2314,7 +2303,7 @@ public class StompV12Test extends StompTestBase {
assertEquals("shouldBeNextMessage", frame.getBody());
}
@TestTemplate
@Test
public void testSendMessageToNonExistentQueueWithAutoCreation() throws Exception {
conn.connect(defUser, defPass);
@ -2323,7 +2312,7 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testInvalidStompCommand() throws Exception {
try {
conn.connect(defUser, defPass);
@ -2343,7 +2332,7 @@ public class StompV12Test extends StompTestBase {
}
}
@TestTemplate
@Test
public void testSendAndReceiveWithEscapedCharactersInSenderId() throws Exception {
conn.connect(defUser, defPass);
@ -2370,22 +2359,22 @@ public class StompV12Test extends StompTestBase {
conn.disconnect();
}
@TestTemplate
@Test
public void testSubscribeWithZeroConsumerWindowSize() throws Exception {
internalSubscribeWithZeroConsumerWindowSize(Stomp.Headers.Subscribe.CONSUMER_WINDOW_SIZE, true);
}
@TestTemplate
@Test
public void testSubscribeWithZeroConsumerWindowSizeLegacyHeader() throws Exception {
internalSubscribeWithZeroConsumerWindowSize(Stomp.Headers.Subscribe.ACTIVEMQ_PREFETCH_SIZE, true);
}
@TestTemplate
@Test
public void testSubscribeWithZeroConsumerWindowSizeAndNack() throws Exception {
internalSubscribeWithZeroConsumerWindowSize(Stomp.Headers.Subscribe.CONSUMER_WINDOW_SIZE, false);
}
@TestTemplate
@Test
public void testSubscribeWithZeroConsumerWindowSizeLegacyHeaderAndNack() throws Exception {
internalSubscribeWithZeroConsumerWindowSize(Stomp.Headers.Subscribe.ACTIVEMQ_PREFETCH_SIZE, false);
}
@ -2428,22 +2417,22 @@ public class StompV12Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testSubscribeWithNonZeroConsumerWindowSize() throws Exception {
internalSubscribeWithNonZeroConsumerWindowSize(Stomp.Headers.Subscribe.CONSUMER_WINDOW_SIZE, true);
}
@TestTemplate
@Test
public void testSubscribeWithNonZeroConsumerWindowSizeLegacyHeader() throws Exception {
internalSubscribeWithNonZeroConsumerWindowSize(Stomp.Headers.Subscribe.ACTIVEMQ_PREFETCH_SIZE, true);
}
@TestTemplate
@Test
public void testSubscribeWithNonZeroConsumerWindowSizeAndNack() throws Exception {
internalSubscribeWithNonZeroConsumerWindowSize(Stomp.Headers.Subscribe.CONSUMER_WINDOW_SIZE, false);
}
@TestTemplate
@Test
public void testSubscribeWithNonZeroConsumerWindowSizeLegacyHeaderAndNack() throws Exception {
internalSubscribeWithNonZeroConsumerWindowSize(Stomp.Headers.Subscribe.ACTIVEMQ_PREFETCH_SIZE, false);
}
@ -2495,7 +2484,7 @@ public class StompV12Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testSubscribeWithNonZeroConsumerWindowSizeAndClientAck() throws Exception {
// the size of each message was determined from the DEBUG logging from org.apache.activemq.artemis.core.protocol.stomp.StompConnection
final int MESSAGE_SIZE = 270;
@ -2539,7 +2528,7 @@ public class StompV12Test extends StompTestBase {
assertNull(message);
}
@TestTemplate
@Test
public void testSameMessageHasDifferentAckIdPerConsumer() throws Exception {
conn.connect(defUser, defPass);