ARTEMIS-4589: consolidate utility code and remove the remaining test-jar creations in tests/ tree

This commit is contained in:
Robbie Gemmell 2024-01-30 16:05:25 +00:00 committed by clebertsuconic
parent 14bbc041d7
commit 8ad8c9d385
70 changed files with 200 additions and 351 deletions

View File

@ -167,12 +167,6 @@
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-junit</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<!-- The johnzon-core and json-api contents are repackaged in -commons, <!-- The johnzon-core and json-api contents are repackaged in -commons,
However maven can still need them during tests, which run against However maven can still need them during tests, which run against

View File

@ -80,11 +80,6 @@
<artifactId>proton-j</artifactId> <artifactId>proton-j</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>io.netty</groupId> <groupId>io.netty</groupId>
<artifactId>netty-buffer</artifactId> <artifactId>netty-buffer</artifactId>
@ -115,6 +110,11 @@
<artifactId>jakarta.jms-api</artifactId> <artifactId>jakarta.jms-api</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>jakarta.resource</groupId>
<artifactId>jakarta.resource-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
@ -126,12 +126,28 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-server</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>artemis-stomp-protocol</artifactId> <artifactId>artemis-stomp-protocol</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<scope>provided</scope>
</dependency>
<!-- This should be the only dependency not at 'provided' scope --> <!-- This should be the only dependency not at 'provided' scope -->
<dependency> <dependency>

View File

@ -25,6 +25,7 @@ import java.util.concurrent.TimeUnit;
import org.apache.activemq.artemis.api.core.ActiveMQException; import org.apache.activemq.artemis.api.core.ActiveMQException;
import org.apache.activemq.artemis.api.core.QueueConfiguration; import org.apache.activemq.artemis.api.core.QueueConfiguration;
import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.api.core.client.ClientConsumer; import org.apache.activemq.artemis.api.core.client.ClientConsumer;
import org.apache.activemq.artemis.api.core.client.ClientMessage; import org.apache.activemq.artemis.api.core.client.ClientMessage;
@ -33,6 +34,8 @@ import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.api.core.client.ClientSessionFactory; import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.MessageHandler; import org.apache.activemq.artemis.api.core.client.MessageHandler;
import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
import org.apache.activemq.artemis.core.remoting.impl.invm.InVMRegistry; import org.apache.activemq.artemis.core.remoting.impl.invm.InVMRegistry;
import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage; import org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage;
@ -60,7 +63,25 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
protected ActiveMQServer server; protected ActiveMQServer server;
protected abstract int getNumIterations();
@Override
protected void start() throws Exception {
Configuration primaryConf = createDefaultInVMConfig();
server = createServer(false, primaryConf);
server.getConfiguration().getAddressConfigurations().add(new CoreAddressConfiguration().setName(ADDRESS.toString()).addRoutingType(RoutingType.MULTICAST));
server.start();
waitForServerToStart(server);
}
protected void setBody(final ClientMessage message) throws Exception {
// Give each msg a body
message.getBodyBuffer().writeBytes(new byte[250]);
}
protected boolean checkSize(final ClientMessage message) {
return message.getBodyBuffer().readableBytes() == 250;
}
@Test @Test
public void testA() throws Exception { public void testA() throws Exception {
@ -215,15 +236,6 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
}, NUM_THREADS, false); }, NUM_THREADS, false);
} }
@Override
protected abstract void start() throws Exception;
protected abstract void setBody(ClientMessage message) throws Exception;
protected abstract boolean checkSize(ClientMessage message);
protected ClientSession createAutoCommitSession(final ClientSessionFactory sf) throws Exception { protected ClientSession createAutoCommitSession(final ClientSessionFactory sf) throws Exception {
ClientSession session = sf.createSession(false, true, true); ClientSession session = sf.createSession(false, true, true);
session.addMetaData("someData", RandomUtil.randomString()); session.addMetaData("someData", RandomUtil.randomString());
@ -246,9 +258,9 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession session = addClientSession(sf.createSession(false, true, true)); ClientSession session = addClientSession(sf.createSession(false, true, true));
session.createQueue(new QueueConfiguration(subName).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); session.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientProducer producer = session.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = session.createProducer(ADDRESS);
ClientConsumer consumer = session.createConsumer(subName); ClientConsumer consumer = session.createConsumer(subName);
@ -302,7 +314,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sessConsume.start(); sessConsume.start();
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -314,7 +326,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessSend = sf.createSession(false, true, true); ClientSession sessSend = sf.createSession(false, true, true);
ClientProducer producer = sessSend.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
sendMessages(sessSend, producer, numMessages, threadNum); sendMessages(sessSend, producer, numMessages, threadNum);
@ -378,7 +390,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessConsume = createAutoCommitSession(sf); ClientSession sessConsume = createAutoCommitSession(sf);
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -390,7 +402,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessSend = sf.createSession(false, true, true); ClientSession sessSend = sf.createSession(false, true, true);
sessSend.addMetaData("some-data", RandomUtil.randomString()); sessSend.addMetaData("some-data", RandomUtil.randomString());
ClientProducer producer = sessSend.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
sendMessages(sessSend, producer, numMessages, threadNum); sendMessages(sessSend, producer, numMessages, threadNum);
@ -462,7 +474,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sessConsume.start(); sessConsume.start();
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -474,7 +486,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessSend = sf.createSession(false, false, false); ClientSession sessSend = sf.createSession(false, false, false);
sessSend.addMetaData("some-data", RandomUtil.randomString()); sessSend.addMetaData("some-data", RandomUtil.randomString());
ClientProducer producer = sessSend.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
sendMessages(sessSend, producer, numMessages, threadNum); sendMessages(sessSend, producer, numMessages, threadNum);
@ -561,7 +573,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessConsume = sf.createSession(false, false, false); ClientSession sessConsume = sf.createSession(false, false, false);
sessConsume.addMetaData("data", RandomUtil.randomString()); sessConsume.addMetaData("data", RandomUtil.randomString());
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -573,7 +585,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessSend = sf.createSession(false, false, false); ClientSession sessSend = sf.createSession(false, false, false);
sessSend.addMetaData("some-data", RandomUtil.randomString()); sessSend.addMetaData("some-data", RandomUtil.randomString());
ClientProducer producer = sessSend.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
sendMessages(sessSend, producer, numMessages, threadNum); sendMessages(sessSend, producer, numMessages, threadNum);
@ -690,7 +702,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sessConsume.start(); sessConsume.start();
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -702,7 +714,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessSend = sf.createSession(false, true, true); ClientSession sessSend = sf.createSession(false, true, true);
sessSend.addMetaData("some-data", RandomUtil.randomString()); sessSend.addMetaData("some-data", RandomUtil.randomString());
ClientProducer producer = sessSend.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
sendMessages(sessSend, producer, numMessages, threadNum); sendMessages(sessSend, producer, numMessages, threadNum);
@ -745,7 +757,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessConsume = sf.createSession(false, true, true); ClientSession sessConsume = sf.createSession(false, true, true);
sessConsume.addMetaData("data", RandomUtil.randomString()); sessConsume.addMetaData("data", RandomUtil.randomString());
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -757,7 +769,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessSend = sf.createSession(false, true, true); ClientSession sessSend = sf.createSession(false, true, true);
sessSend.addMetaData("data", RandomUtil.randomString()); sessSend.addMetaData("data", RandomUtil.randomString());
ClientProducer producer = sessSend.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
sendMessages(sessSend, producer, numMessages, threadNum); sendMessages(sessSend, producer, numMessages, threadNum);
@ -806,7 +818,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sessConsume.start(); sessConsume.start();
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -818,7 +830,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessSend = sf.createSession(false, false, false); ClientSession sessSend = sf.createSession(false, false, false);
sessSend.addMetaData("data", RandomUtil.randomString()); sessSend.addMetaData("data", RandomUtil.randomString());
ClientProducer producer = sessSend.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
sendMessages(sessSend, producer, numMessages, threadNum); sendMessages(sessSend, producer, numMessages, threadNum);
@ -877,7 +889,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessConsume = sf.createSession(false, false, false); ClientSession sessConsume = sf.createSession(false, false, false);
sessConsume.addMetaData("data", RandomUtil.randomString()); sessConsume.addMetaData("data", RandomUtil.randomString());
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -889,7 +901,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessSend = sf.createSession(false, false, false); ClientSession sessSend = sf.createSession(false, false, false);
sessSend.addMetaData("data", RandomUtil.randomString()); sessSend.addMetaData("data", RandomUtil.randomString());
ClientProducer producer = sessSend.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
sendMessages(sessSend, producer, numMessages, threadNum); sendMessages(sessSend, producer, numMessages, threadNum);
@ -937,16 +949,16 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessCreate = sf.createSession(false, true, true); ClientSession sessCreate = sf.createSession(false, true, true);
sessCreate.addMetaData("data", RandomUtil.randomString()); sessCreate.addMetaData("data", RandomUtil.randomString());
sessCreate.createQueue(new QueueConfiguration(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessCreate.createQueue(new QueueConfiguration(new SimpleString(threadNum + ADDRESS.toString())).setAddress(ADDRESS).setDurable(false));
ClientSession sess = sf.createSession(false, true, true); ClientSession sess = sf.createSession(false, true, true);
sess.addMetaData("data", RandomUtil.randomString()); sess.addMetaData("data", RandomUtil.randomString());
sess.start(); sess.start();
ClientConsumer consumer = sess.createConsumer(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())); ClientConsumer consumer = sess.createConsumer(new SimpleString(threadNum + ADDRESS.toString()));
ClientProducer producer = sess.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = sess.createProducer(ADDRESS);
ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
producer.send(message); producer.send(message);
@ -959,7 +971,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sess.close(); sess.close();
sessCreate.deleteQueue(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())); sessCreate.deleteQueue(new SimpleString(threadNum + ADDRESS.toString()));
sessCreate.close(); sessCreate.close();
} }
@ -968,16 +980,16 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession sessCreate = sf.createSession(false, true, true); ClientSession sessCreate = sf.createSession(false, true, true);
sessCreate.addMetaData("data", RandomUtil.randomString()); sessCreate.addMetaData("data", RandomUtil.randomString());
sessCreate.createQueue(new QueueConfiguration(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessCreate.createQueue(new QueueConfiguration(new SimpleString(threadNum + ADDRESS.toString())).setAddress(ADDRESS).setDurable(false));
ClientSession sess = sf.createSession(false, true, true); ClientSession sess = sf.createSession(false, true, true);
sess.addMetaData("data", RandomUtil.randomString()); sess.addMetaData("data", RandomUtil.randomString());
sess.start(); sess.start();
ClientConsumer consumer = sess.createConsumer(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())); ClientConsumer consumer = sess.createConsumer(new SimpleString(threadNum + ADDRESS.toString()));
ClientProducer producer = sess.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = sess.createProducer(ADDRESS);
ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
producer.send(message); producer.send(message);
@ -990,7 +1002,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sess.close(); sess.close();
sessCreate.deleteQueue(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())); sessCreate.deleteQueue(new SimpleString(threadNum + ADDRESS.toString()));
sessCreate.close(); sessCreate.close();
} }
@ -999,17 +1011,17 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
ClientSession s = sf.createSession(false, false, false); ClientSession s = sf.createSession(false, false, false);
s.addMetaData("data", RandomUtil.randomString()); s.addMetaData("data", RandomUtil.randomString());
s.createQueue(new QueueConfiguration(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); s.createQueue(new QueueConfiguration(new SimpleString(threadNum + ADDRESS.toString())).setAddress(ADDRESS).setDurable(false));
final int numConsumers = 100; final int numConsumers = 100;
for (int i = 0; i < numConsumers; i++) { for (int i = 0; i < numConsumers; i++) {
ClientConsumer consumer = s.createConsumer(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())); ClientConsumer consumer = s.createConsumer(new SimpleString(threadNum + ADDRESS.toString()));
consumer.close(); consumer.close();
} }
s.deleteQueue(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())); s.deleteQueue(new SimpleString(threadNum + ADDRESS.toString()));
s.close(); s.close();
} }
@ -1032,7 +1044,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
protected void doTestN(final ClientSessionFactory sf, final int threadNum) throws Exception { protected void doTestN(final ClientSessionFactory sf, final int threadNum) throws Exception {
ClientSession sessCreate = sf.createSession(false, true, true); ClientSession sessCreate = sf.createSession(false, true, true);
sessCreate.createQueue(new QueueConfiguration(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessCreate.createQueue(new QueueConfiguration(new SimpleString(threadNum + ADDRESS.toString())).setAddress(ADDRESS).setDurable(false));
ClientSession sess = sf.createSession(false, true, true); ClientSession sess = sf.createSession(false, true, true);
sess.addMetaData("data", RandomUtil.randomString()); sess.addMetaData("data", RandomUtil.randomString());
@ -1043,9 +1055,9 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sess.stop(); sess.stop();
ClientConsumer consumer = sess.createConsumer(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())); ClientConsumer consumer = sess.createConsumer(new SimpleString(threadNum + ADDRESS.toString()));
ClientProducer producer = sess.createProducer(MultiThreadRandomReattachTestBase.ADDRESS); ClientProducer producer = sess.createProducer(ADDRESS);
ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
producer.send(message); producer.send(message);
@ -1064,7 +1076,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sess.close(); sess.close();
sessCreate.deleteQueue(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())); sessCreate.deleteQueue(new SimpleString(threadNum + ADDRESS.toString()));
sessCreate.close(); sessCreate.close();
} }
@ -1072,13 +1084,13 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
protected void doTestO(final ClientSessionFactory sf, final int threadNum) throws Exception { protected void doTestO(final ClientSessionFactory sf, final int threadNum) throws Exception {
ClientSession sessCreate = sf.createSession(false, true, true); ClientSession sessCreate = sf.createSession(false, true, true);
sessCreate.createQueue(new QueueConfiguration(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())).setAddress(MultiThreadRandomReattachTestBase.ADDRESS).setDurable(false)); sessCreate.createQueue(new QueueConfiguration(new SimpleString(threadNum + ADDRESS.toString())).setAddress(ADDRESS).setDurable(false));
ClientSession sess = sf.createSession(false, true, true); ClientSession sess = sf.createSession(false, true, true);
sess.start(); sess.start();
ClientConsumer consumer = sess.createConsumer(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())); ClientConsumer consumer = sess.createConsumer(new SimpleString(threadNum + ADDRESS.toString()));
for (int i = 0; i < 100; i++) { for (int i = 0; i < 100; i++) {
Assert.assertNull(consumer.receiveImmediate()); Assert.assertNull(consumer.receiveImmediate());
@ -1086,7 +1098,7 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
sess.close(); sess.close();
sessCreate.deleteQueue(new SimpleString(threadNum + MultiThreadRandomReattachTestBase.ADDRESS.toString())); sessCreate.deleteQueue(new SimpleString(threadNum + ADDRESS.toString()));
sessCreate.close(); sessCreate.close();
} }
@ -1095,10 +1107,6 @@ public abstract class MultiThreadRandomReattachTestBase extends MultiThreadReatt
return 60000; return 60000;
} }
protected int getNumIterations() {
return 2;
}
protected int getNumThreads() { protected int getNumThreads() {
return 10; return 10;
} }

View File

@ -52,7 +52,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodHandles;
public class RandomReattachTest extends ActiveMQTestBase { public abstract class RandomReattachTestBase extends ActiveMQTestBase {
@Rule @Rule
public RetryRule retryRule = new RetryRule(2); public RetryRule retryRule = new RetryRule(2);
@ -69,7 +69,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
private Timer timer; private Timer timer;
protected abstract int getNumIterations();
@Test @Test
public void testA() throws Exception { public void testA() throws Exception {
@ -243,7 +243,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
sessConsume.start(); sessConsume.start();
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(RandomReattachTest.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -254,7 +254,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessSend = sf.createSession(false, true, true); ClientSession sessSend = sf.createSession(false, true, true);
ClientProducer producer = sessSend.createProducer(RandomReattachTest.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
@ -281,7 +281,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
try { try {
message.acknowledge(); message.acknowledge();
} catch (ActiveMQException me) { } catch (ActiveMQException me) {
RandomReattachTest.logger.error("Failed to process", me); logger.error("Failed to process", me);
} }
if (count == numMessages) { if (count == numMessages) {
@ -343,7 +343,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessConsume = sf.createSession(false, true, true); ClientSession sessConsume = sf.createSession(false, true, true);
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(RandomReattachTest.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -354,7 +354,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessSend = sf.createSession(false, true, true); ClientSession sessSend = sf.createSession(false, true, true);
ClientProducer producer = sessSend.createProducer(RandomReattachTest.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
@ -445,7 +445,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
sessConsume.start(); sessConsume.start();
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(RandomReattachTest.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -456,7 +456,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessSend = sf.createSession(false, false, true); ClientSession sessSend = sf.createSession(false, false, true);
ClientProducer producer = sessSend.createProducer(RandomReattachTest.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
@ -583,7 +583,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessConsume = sf.createSession(false, false, false); ClientSession sessConsume = sf.createSession(false, false, false);
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(RandomReattachTest.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -594,7 +594,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessSend = sf.createSession(false, false, true); ClientSession sessSend = sf.createSession(false, false, true);
ClientProducer producer = sessSend.createProducer(RandomReattachTest.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
@ -722,7 +722,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
sessConsume.start(); sessConsume.start();
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(RandomReattachTest.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -733,7 +733,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessSend = sf.createSession(false, true, true); ClientSession sessSend = sf.createSession(false, true, true);
ClientProducer producer = sessSend.createProducer(RandomReattachTest.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
@ -743,7 +743,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
for (ClientConsumer consumer : consumers) { for (ClientConsumer consumer : consumers) {
ClientMessage msg = consumer.receive(RandomReattachTest.RECEIVE_TIMEOUT); ClientMessage msg = consumer.receive(RECEIVE_TIMEOUT);
Assert.assertNotNull(msg); Assert.assertNotNull(msg);
@ -796,7 +796,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessConsume = sf.createSession(false, true, true); ClientSession sessConsume = sf.createSession(false, true, true);
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(RandomReattachTest.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -807,7 +807,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessSend = sf.createSession(false, true, true); ClientSession sessSend = sf.createSession(false, true, true);
ClientProducer producer = sessSend.createProducer(RandomReattachTest.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
@ -821,7 +821,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
for (ClientConsumer consumer : consumers) { for (ClientConsumer consumer : consumers) {
ClientMessage msg = consumer.receive(RandomReattachTest.RECEIVE_TIMEOUT); ClientMessage msg = consumer.receive(RECEIVE_TIMEOUT);
if (msg == null) { if (msg == null) {
throw new IllegalStateException("Failed to receive message " + i); throw new IllegalStateException("Failed to receive message " + i);
@ -882,7 +882,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
sessConsume.start(); sessConsume.start();
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(RandomReattachTest.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -893,7 +893,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessSend = sf.createSession(false, false, false); ClientSession sessSend = sf.createSession(false, false, false);
ClientProducer producer = sessSend.createProducer(RandomReattachTest.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
@ -913,7 +913,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
for (ClientConsumer consumer : consumers) { for (ClientConsumer consumer : consumers) {
ClientMessage msg = consumer.receive(RandomReattachTest.RECEIVE_TIMEOUT); ClientMessage msg = consumer.receive(RECEIVE_TIMEOUT);
Assert.assertNotNull(msg); Assert.assertNotNull(msg);
@ -935,7 +935,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
for (ClientConsumer consumer : consumers) { for (ClientConsumer consumer : consumers) {
ClientMessage msg = consumer.receive(RandomReattachTest.RECEIVE_TIMEOUT); ClientMessage msg = consumer.receive(RECEIVE_TIMEOUT);
Assert.assertNotNull(msg); Assert.assertNotNull(msg);
@ -992,7 +992,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessConsume = sf.createSession(false, false, false); ClientSession sessConsume = sf.createSession(false, false, false);
sessConsume.createQueue(new QueueConfiguration(subName).setAddress(RandomReattachTest.ADDRESS).setDurable(false)); sessConsume.createQueue(new QueueConfiguration(subName).setAddress(ADDRESS).setDurable(false));
ClientConsumer consumer = sessConsume.createConsumer(subName); ClientConsumer consumer = sessConsume.createConsumer(subName);
@ -1003,7 +1003,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
ClientSession sessSend = sf.createSession(false, false, false); ClientSession sessSend = sf.createSession(false, false, false);
ClientProducer producer = sessSend.createProducer(RandomReattachTest.ADDRESS); ClientProducer producer = sessSend.createProducer(ADDRESS);
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sessSend.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
@ -1027,7 +1027,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
for (ClientConsumer consumer : consumers) { for (ClientConsumer consumer : consumers) {
ClientMessage msg = consumer.receive(RandomReattachTest.RECEIVE_TIMEOUT); ClientMessage msg = consumer.receive(RECEIVE_TIMEOUT);
Assert.assertNotNull(msg); Assert.assertNotNull(msg);
@ -1051,7 +1051,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
for (int i = 0; i < numMessages; i++) { for (int i = 0; i < numMessages; i++) {
for (ClientConsumer consumer : consumers) { for (ClientConsumer consumer : consumers) {
ClientMessage msg = consumer.receive(RandomReattachTest.RECEIVE_TIMEOUT); ClientMessage msg = consumer.receive(RECEIVE_TIMEOUT);
Assert.assertNotNull(msg); Assert.assertNotNull(msg);
@ -1094,20 +1094,20 @@ public class RandomReattachTest extends ActiveMQTestBase {
protected void doTestI(final ClientSessionFactory sf) throws Exception { protected void doTestI(final ClientSessionFactory sf) throws Exception {
ClientSession sessCreate = sf.createSession(false, true, true); ClientSession sessCreate = sf.createSession(false, true, true);
sessCreate.createQueue(new QueueConfiguration(RandomReattachTest.ADDRESS).setDurable(false)); sessCreate.createQueue(new QueueConfiguration(ADDRESS).setDurable(false));
ClientSession sess = sf.createSession(false, true, true); ClientSession sess = sf.createSession(false, true, true);
sess.start(); sess.start();
ClientConsumer consumer = sess.createConsumer(RandomReattachTest.ADDRESS); ClientConsumer consumer = sess.createConsumer(ADDRESS);
ClientProducer producer = sess.createProducer(RandomReattachTest.ADDRESS); ClientProducer producer = sess.createProducer(ADDRESS);
ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
producer.send(message); producer.send(message);
ClientMessage message2 = consumer.receive(RandomReattachTest.RECEIVE_TIMEOUT); ClientMessage message2 = consumer.receive(RECEIVE_TIMEOUT);
Assert.assertNotNull(message2); Assert.assertNotNull(message2);
@ -1115,7 +1115,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
sess.close(); sess.close();
sessCreate.deleteQueue(RandomReattachTest.ADDRESS); sessCreate.deleteQueue(ADDRESS);
sessCreate.close(); sessCreate.close();
} }
@ -1123,20 +1123,20 @@ public class RandomReattachTest extends ActiveMQTestBase {
protected void doTestJ(final ClientSessionFactory sf) throws Exception { protected void doTestJ(final ClientSessionFactory sf) throws Exception {
ClientSession sessCreate = sf.createSession(false, true, true); ClientSession sessCreate = sf.createSession(false, true, true);
sessCreate.createQueue(new QueueConfiguration(RandomReattachTest.ADDRESS).setDurable(false)); sessCreate.createQueue(new QueueConfiguration(ADDRESS).setDurable(false));
ClientSession sess = sf.createSession(false, true, true); ClientSession sess = sf.createSession(false, true, true);
sess.start(); sess.start();
ClientConsumer consumer = sess.createConsumer(RandomReattachTest.ADDRESS); ClientConsumer consumer = sess.createConsumer(ADDRESS);
ClientProducer producer = sess.createProducer(RandomReattachTest.ADDRESS); ClientProducer producer = sess.createProducer(ADDRESS);
ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
producer.send(message); producer.send(message);
ClientMessage message2 = consumer.receive(RandomReattachTest.RECEIVE_TIMEOUT); ClientMessage message2 = consumer.receive(RECEIVE_TIMEOUT);
Assert.assertNotNull(message2); Assert.assertNotNull(message2);
@ -1144,7 +1144,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
sess.close(); sess.close();
sessCreate.deleteQueue(RandomReattachTest.ADDRESS); sessCreate.deleteQueue(ADDRESS);
sessCreate.close(); sessCreate.close();
} }
@ -1152,17 +1152,17 @@ public class RandomReattachTest extends ActiveMQTestBase {
protected void doTestK(final ClientSessionFactory sf) throws Exception { protected void doTestK(final ClientSessionFactory sf) throws Exception {
ClientSession s = sf.createSession(false, false, false); ClientSession s = sf.createSession(false, false, false);
s.createQueue(new QueueConfiguration(RandomReattachTest.ADDRESS).setDurable(false)); s.createQueue(new QueueConfiguration(ADDRESS).setDurable(false));
final int numConsumers = 100; final int numConsumers = 100;
for (int i = 0; i < numConsumers; i++) { for (int i = 0; i < numConsumers; i++) {
ClientConsumer consumer = s.createConsumer(RandomReattachTest.ADDRESS); ClientConsumer consumer = s.createConsumer(ADDRESS);
consumer.close(); consumer.close();
} }
s.deleteQueue(RandomReattachTest.ADDRESS); s.deleteQueue(ADDRESS);
s.close(); s.close();
} }
@ -1180,7 +1180,7 @@ public class RandomReattachTest extends ActiveMQTestBase {
protected void doTestN(final ClientSessionFactory sf) throws Exception { protected void doTestN(final ClientSessionFactory sf) throws Exception {
ClientSession sessCreate = sf.createSession(false, true, true); ClientSession sessCreate = sf.createSession(false, true, true);
sessCreate.createQueue(new QueueConfiguration(new SimpleString(RandomReattachTest.ADDRESS.toString())).setAddress(RandomReattachTest.ADDRESS).setDurable(false)); sessCreate.createQueue(new QueueConfiguration(new SimpleString(ADDRESS.toString())).setAddress(ADDRESS).setDurable(false));
ClientSession sess = sf.createSession(false, true, true); ClientSession sess = sf.createSession(false, true, true);
@ -1190,16 +1190,16 @@ public class RandomReattachTest extends ActiveMQTestBase {
sess.stop(); sess.stop();
ClientConsumer consumer = sess.createConsumer(new SimpleString(RandomReattachTest.ADDRESS.toString())); ClientConsumer consumer = sess.createConsumer(new SimpleString(ADDRESS.toString()));
ClientProducer producer = sess.createProducer(RandomReattachTest.ADDRESS); ClientProducer producer = sess.createProducer(ADDRESS);
ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1); ClientMessage message = sess.createMessage(ActiveMQTextMessage.TYPE, false, 0, System.currentTimeMillis(), (byte) 1);
producer.send(message); producer.send(message);
sess.start(); sess.start();
ClientMessage message2 = consumer.receive(RandomReattachTest.RECEIVE_TIMEOUT); ClientMessage message2 = consumer.receive(RECEIVE_TIMEOUT);
Assert.assertNotNull(message2); Assert.assertNotNull(message2);
@ -1211,15 +1211,11 @@ public class RandomReattachTest extends ActiveMQTestBase {
sess.close(); sess.close();
sessCreate.deleteQueue(new SimpleString(RandomReattachTest.ADDRESS.toString())); sessCreate.deleteQueue(new SimpleString(ADDRESS.toString()));
sessCreate.close(); sessCreate.close();
} }
protected int getNumIterations() {
return 2;
}
@Override @Override
@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {

View File

@ -15,7 +15,7 @@
* limitations under the License. * limitations under the License.
*/ */
package org.apache.activemq.artemis.tests.util; package org.apache.activemq.artemis.tests.rules;
import org.apache.activemq.artemis.utils.SpawnedVMSupport; import org.apache.activemq.artemis.utils.SpawnedVMSupport;
import org.junit.rules.ExternalResource; import org.junit.rules.ExternalResource;

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.activemq.artemis.tests.unit.core.postoffice.impl; package org.apache.activemq.artemis.tests.unit.core.postoffice.impl.fakes;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;

View File

@ -142,12 +142,6 @@
</exclusion> </exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-junit</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId> <artifactId>activemq-client</artifactId>

View File

@ -45,13 +45,6 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>unit-tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId> <artifactId>artemis-jms-client</artifactId>
@ -475,18 +468,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>

View File

@ -22,17 +22,12 @@ import java.util.HashMap;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.Map; import java.util.Map;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import org.apache.activemq.artemis.api.core.TransportConfiguration; import org.apache.activemq.artemis.api.core.TransportConfiguration;
import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants; import org.apache.activemq.artemis.core.remoting.impl.netty.TransportConstants;
import org.apache.activemq.artemis.core.server.ActiveMQServer; import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPStandardMessage;
import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.transport.amqp.client.AmqpClient; import org.apache.activemq.transport.amqp.client.AmqpClient;
import org.apache.activemq.transport.amqp.client.AmqpConnection; import org.apache.activemq.transport.amqp.client.AmqpConnection;
import org.apache.qpid.proton.message.impl.MessageImpl;
import org.junit.After; import org.junit.After;
/** /**
@ -163,17 +158,6 @@ public class AmqpTestSupport extends ActiveMQTestBase {
return new AmqpClient(brokerURI, username, password); return new AmqpClient(brokerURI, username, password);
} }
public static AMQPStandardMessage encodeAndDecodeMessage(int messageFormat, MessageImpl message, int expectedSize) {
ByteBuf nettyBuffer = Unpooled.buffer(expectedSize);
message.encode(new NettyWritable(nettyBuffer));
byte[] bytes = new byte[nettyBuffer.writerIndex()];
nettyBuffer.readBytes(bytes);
return new AMQPStandardMessage(messageFormat, bytes, null);
}
protected ActiveMQServer createServer(int port, boolean start) throws Exception { protected ActiveMQServer createServer(int port, boolean start) throws Exception {
final ActiveMQServer server = this.createServer(true, true); final ActiveMQServer server = this.createServer(true, true);

View File

@ -29,7 +29,7 @@ import org.apache.activemq.artemis.api.core.client.ClientSessionFactory;
import org.apache.activemq.artemis.api.core.client.ServerLocator; import org.apache.activemq.artemis.api.core.client.ServerLocator;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage; import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage;
import org.apache.activemq.artemis.tests.util.SpawnedVMCheck; import org.apache.activemq.artemis.tests.rules.SpawnedVMCheck;
import org.apache.activemq.artemis.utils.SpawnedVMSupport; import org.apache.activemq.artemis.utils.SpawnedVMSupport;
import org.junit.After; import org.junit.After;
import org.junit.Assert; import org.junit.Assert;

View File

@ -16,34 +16,10 @@
*/ */
package org.apache.activemq.artemis.tests.integration.cluster.reattach; package org.apache.activemq.artemis.tests.integration.cluster.reattach;
import org.apache.activemq.artemis.api.core.RoutingType;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.apache.activemq.artemis.core.config.Configuration;
import org.apache.activemq.artemis.core.config.CoreAddressConfiguration;
/**
* A MultiThreadRandomReattachTest
*/
public class MultiThreadRandomReattachTest extends MultiThreadRandomReattachTestBase { public class MultiThreadRandomReattachTest extends MultiThreadRandomReattachTestBase {
@Override @Override
protected void start() throws Exception { protected int getNumIterations() {
Configuration primaryConf = createDefaultInVMConfig(); return 2;
server = createServer(false, primaryConf);
server.getConfiguration().getAddressConfigurations().add(new CoreAddressConfiguration().setName(ADDRESS.toString()).addRoutingType(RoutingType.MULTICAST));
server.start();
waitForServerToStart(server);
} }
@Override
protected void setBody(final ClientMessage message) throws Exception {
// Give each msg a body
message.getBodyBuffer().writeBytes(new byte[250]);
}
@Override
protected boolean checkSize(final ClientMessage message) {
return message.getBodyBuffer().readableBytes() == 250;
}
} }

View File

@ -14,26 +14,12 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.activemq.artemis.tests.timing.util; package org.apache.activemq.artemis.tests.integration.cluster.reattach;
import org.apache.activemq.artemis.utils.UUIDGenerator; public class RandomReattachIntegrationTest extends RandomReattachTestBase {
public class UUIDTest extends org.apache.activemq.artemis.tests.unit.util.UUIDTest {
public static void main(String[] args) {
long start = System.currentTimeMillis();
int count = 10000;
for (int i = 0; i < count; i++) {
// System.out.println(i + " " + UUIDGenerator.asString(UUIDGenerator.getHardwareAddress()));
byte[] address = UUIDGenerator.getHardwareAddress();
}
long end = System.currentTimeMillis();
System.out.println("getHardwareAddress() => " + 1.0 * (end - start) / count + " ms");
}
@Override @Override
protected int getTimes() { protected int getNumIterations() {
return 1000000; return 2;
} }
} }

View File

@ -58,8 +58,8 @@ import org.apache.activemq.artemis.core.settings.impl.AddressFullMessagePolicy;
import org.apache.activemq.artemis.core.settings.impl.AddressSettings; import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.jms.client.ActiveMQDestination; import org.apache.activemq.artemis.jms.client.ActiveMQDestination;
import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue;
import org.apache.activemq.artemis.tests.util.Wait; import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.fakes.FakeQueue;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.ReusableLatch; import org.apache.activemq.artemis.utils.ReusableLatch;
import org.junit.Assert; import org.junit.Assert;

View File

@ -33,7 +33,7 @@ import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl; import org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl;
import org.apache.activemq.artemis.reader.MessageUtil; import org.apache.activemq.artemis.reader.MessageUtil;
import org.apache.activemq.artemis.tests.integration.server.FakeStorageManager; import org.apache.activemq.artemis.tests.integration.server.FakeStorageManager;
import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue; import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.fakes.FakeQueue;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.utils.RandomUtil;
import org.apache.activemq.artemis.utils.UUID; import org.apache.activemq.artemis.utils.UUID;

View File

@ -32,7 +32,7 @@ import org.apache.activemq.artemis.core.persistence.QueueBindingInfo;
import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager; import org.apache.activemq.artemis.core.persistence.impl.journal.JournalStorageManager;
import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.impl.PostOfficeJournalLoader; import org.apache.activemq.artemis.core.server.impl.PostOfficeJournalLoader;
import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue; import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.fakes.FakeQueue;
import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice; import org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice;
import org.apache.activemq.artemis.utils.critical.EmptyCriticalAnalyzer; import org.apache.activemq.artemis.utils.critical.EmptyCriticalAnalyzer;
import org.junit.Assert; import org.junit.Assert;

View File

@ -63,6 +63,7 @@ import org.apache.activemq.artemis.core.server.impl.ActiveMQServerImpl;
import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.core.settings.HierarchicalRepository; import org.apache.activemq.artemis.core.settings.HierarchicalRepository;
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory; import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage;
import org.apache.activemq.artemis.spi.core.protocol.RemotingConnection; 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.ActiveMQJAASSecurityManager;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager;
@ -72,7 +73,6 @@ import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager4;
import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager5; import org.apache.activemq.artemis.spi.core.security.ActiveMQSecurityManager5;
import org.apache.activemq.artemis.spi.core.security.jaas.NoCacheLoginException; import org.apache.activemq.artemis.spi.core.security.jaas.NoCacheLoginException;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.tests.util.CreateMessage;
import org.apache.activemq.artemis.utils.CompositeAddress; import org.apache.activemq.artemis.utils.CompositeAddress;
import org.apache.activemq.artemis.utils.SensitiveDataCodec; import org.apache.activemq.artemis.utils.SensitiveDataCodec;
import org.apache.activemq.artemis.utils.Wait; import org.apache.activemq.artemis.utils.Wait;
@ -1749,8 +1749,8 @@ public class SecurityTest extends ActiveMQTestBase {
ClientSession sendingSession = cf.createSession("auser", "pass", false, false, false, false, 0); ClientSession sendingSession = cf.createSession("auser", "pass", false, false, false, false, 0);
ClientProducer prod = sendingSession.createProducer(SecurityTest.addressA); ClientProducer prod = sendingSession.createProducer(SecurityTest.addressA);
prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true)); prod.send(createClientMessage(sendingSession, "Test", true));
prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true)); prod.send(createClientMessage(sendingSession, "Test", true));
try { try {
sendingSession.commit(); sendingSession.commit();
Assert.fail("Expected exception"); Assert.fail("Expected exception");
@ -1766,8 +1766,8 @@ public class SecurityTest extends ActiveMQTestBase {
sendingSession.start(xid, XAResource.TMNOFLAGS); sendingSession.start(xid, XAResource.TMNOFLAGS);
prod = sendingSession.createProducer(SecurityTest.addressA); prod = sendingSession.createProducer(SecurityTest.addressA);
prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true)); prod.send(createClientMessage(sendingSession, "Test", true));
prod.send(CreateMessage.createTextMessage(sendingSession, "Test", true)); prod.send(createClientMessage(sendingSession, "Test", true));
sendingSession.end(xid, XAResource.TMSUCCESS); sendingSession.end(xid, XAResource.TMSUCCESS);
try { try {
@ -1788,6 +1788,12 @@ public class SecurityTest extends ActiveMQTestBase {
sendingSession.close(); sendingSession.close();
} }
private static ClientMessage createClientMessage(final ClientSession session, final String s, final boolean durable) {
ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, durable, 0, System.currentTimeMillis(), (byte) 1);
message.getBodyBuffer().writeString(s);
return message;
}
@Test @Test
public void testSendManagementWithRole() throws Exception { public void testSendManagementWithRole() throws Exception {
ActiveMQServer server = createServer(); ActiveMQServer server = createServer();

View File

@ -17,6 +17,7 @@
package org.apache.activemq.artemis.tests.util; package org.apache.activemq.artemis.tests.util;
import org.apache.activemq.artemis.tests.rules.SpawnedVMCheck;
import org.junit.Rule; import org.junit.Rule;
public class SpawnedTestBase extends ActiveMQTestBase { public class SpawnedTestBase extends ActiveMQTestBase {

View File

@ -57,11 +57,6 @@
<artifactId>artemis-server</artifactId> <artifactId>artemis-server</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq</groupId>
<artifactId>artemis-junit</artifactId>
<version>${project.version}</version>
</dependency>
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>

View File

@ -32,14 +32,6 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>unit-tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<!-- necessary for the broker to support AMQP clients in the tests -->
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>artemis-amqp-protocol</artifactId> <artifactId>artemis-amqp-protocol</artifactId>
@ -114,6 +106,12 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>artemis-test-support</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -19,7 +19,7 @@ package org.apache.activemq.artemis.amqpJMS;
import java.io.IOException; import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import org.apache.activemq.artemis.tests.util.SpawnedVMCheck; import org.apache.activemq.artemis.tests.rules.SpawnedVMCheck;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;

View File

@ -19,7 +19,7 @@ package org.apache.activemq.artemis.jms;
import java.io.IOException; import java.io.IOException;
import java.util.Properties; import java.util.Properties;
import org.apache.activemq.artemis.tests.util.SpawnedVMCheck; import org.apache.activemq.artemis.tests.rules.SpawnedVMCheck;
import org.junit.AfterClass; import org.junit.AfterClass;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;

View File

@ -62,20 +62,6 @@
<artifactId>artemis-commons</artifactId> <artifactId>artemis-commons</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>unit-tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>integration-tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId> <artifactId>artemis-jms-client</artifactId>

View File

@ -108,13 +108,6 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>integration-tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>activemq-client</artifactId> <artifactId>activemq-client</artifactId>
@ -176,7 +169,6 @@
<artifactId>jakarta.json-api</artifactId> <artifactId>jakarta.json-api</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -41,8 +41,8 @@ import org.apache.activemq.artemis.api.core.management.SimpleManagement;
import org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectionAddressType; import org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectionAddressType;
import org.apache.activemq.artemis.tests.soak.SoakTestBase; import org.apache.activemq.artemis.tests.soak.SoakTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil; import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.activemq.artemis.util.ServerUtil; import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate; import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;

View File

@ -42,8 +42,8 @@ import org.apache.activemq.artemis.core.server.ActiveMQServer;
import org.apache.activemq.artemis.core.server.impl.AddressInfo; import org.apache.activemq.artemis.core.server.impl.AddressInfo;
import org.apache.activemq.artemis.tests.soak.SoakTestBase; import org.apache.activemq.artemis.tests.soak.SoakTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil; import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.activemq.artemis.util.ServerUtil; import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate; import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;

View File

@ -34,8 +34,8 @@ import org.apache.activemq.artemis.api.core.management.SimpleManagement;
import org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectionAddressType; import org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPBrokerConnectionAddressType;
import org.apache.activemq.artemis.tests.soak.SoakTestBase; import org.apache.activemq.artemis.tests.soak.SoakTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil; import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.activemq.artemis.util.ServerUtil; import org.apache.activemq.artemis.util.ServerUtil;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate; import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.junit.Assert; import org.junit.Assert;
import org.junit.BeforeClass; import org.junit.BeforeClass;

View File

@ -42,8 +42,8 @@ import org.apache.activemq.RedeliveryPolicy;
import org.apache.activemq.artemis.api.core.management.SimpleManagement; import org.apache.activemq.artemis.api.core.management.SimpleManagement;
import org.apache.activemq.artemis.tests.soak.SoakTestBase; import org.apache.activemq.artemis.tests.soak.SoakTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil; import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.activemq.artemis.utils.SpawnedVMSupport; import org.apache.activemq.artemis.utils.SpawnedVMSupport;
import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate; import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Assume; import org.junit.Assume;

View File

@ -16,11 +16,11 @@
*/ */
package org.apache.activemq.artemis.tests.soak.failover; package org.apache.activemq.artemis.tests.soak.failover;
import org.apache.activemq.artemis.tests.integration.cluster.reattach.RandomReattachTest; import org.apache.activemq.artemis.tests.integration.cluster.reattach.RandomReattachTestBase;
import static org.apache.activemq.artemis.utils.TestParameters.testProperty; import static org.apache.activemq.artemis.utils.TestParameters.testProperty;
public class RandomFailoverSoakTest extends RandomReattachTest { public class RandomFailoverSoakTest extends RandomReattachTestBase {
private static final String TEST_NAME = "RANDOM"; private static final String TEST_NAME = "RANDOM";
public static final int TEST_REPETITION = testProperty(TEST_NAME, "TEST_REPETITION", 10); public static final int TEST_REPETITION = testProperty(TEST_NAME, "TEST_REPETITION", 10);

View File

@ -31,7 +31,7 @@ import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
import org.apache.activemq.artemis.api.core.management.QueueControl; import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.tests.soak.SoakTestBase; import org.apache.activemq.artemis.tests.soak.SoakTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil; import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.tests.util.Wait; import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate; import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;

View File

@ -39,7 +39,7 @@ import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
import org.apache.activemq.artemis.api.core.management.QueueControl; import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.tests.soak.SoakTestBase; import org.apache.activemq.artemis.tests.soak.SoakTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil; import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.tests.util.Wait; import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate; import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;

View File

@ -38,7 +38,7 @@ import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil; import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.tests.util.TcpProxy; import org.apache.activemq.artemis.tests.util.TcpProxy;
import org.apache.activemq.artemis.tests.util.Wait; import org.apache.activemq.artemis.utils.Wait;
import org.apache.qpid.jms.JmsConnectionFactory; import org.apache.qpid.jms.JmsConnectionFactory;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;

View File

@ -38,7 +38,7 @@ import org.apache.activemq.artemis.api.core.management.ObjectNameBuilder;
import org.apache.activemq.artemis.api.core.management.QueueControl; import org.apache.activemq.artemis.api.core.management.QueueControl;
import org.apache.activemq.artemis.tests.soak.SoakTestBase; import org.apache.activemq.artemis.tests.soak.SoakTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil; import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.tests.util.Wait; import org.apache.activemq.artemis.utils.Wait;
import org.apache.activemq.artemis.utils.cli.helper.HelperCreate; import org.apache.activemq.artemis.utils.cli.helper.HelperCreate;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Before; import org.junit.Before;

View File

@ -40,8 +40,8 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.logs.AssertionLoggerHandler; import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.tests.util.CFUtil; import org.apache.activemq.artemis.tests.util.CFUtil;
import org.apache.activemq.artemis.tests.util.Wait;
import org.apache.activemq.artemis.utils.SpawnedVMSupport; import org.apache.activemq.artemis.utils.SpawnedVMSupport;
import org.apache.activemq.artemis.utils.Wait;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;
import org.slf4j.Logger; import org.slf4j.Logger;

View File

@ -86,26 +86,12 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>unit-tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency> <dependency>
<groupId>org.apache.activemq.tests</groupId> <groupId>org.apache.activemq.tests</groupId>
<artifactId>artemis-test-support</artifactId> <artifactId>artemis-test-support</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>integration-tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>artemis-cli</artifactId> <artifactId>artemis-cli</artifactId>

View File

@ -16,9 +16,9 @@
*/ */
package org.apache.activemq.artemis.tests.stress.failover; package org.apache.activemq.artemis.tests.stress.failover;
import org.apache.activemq.artemis.tests.integration.cluster.reattach.MultiThreadRandomReattachTest; import org.apache.activemq.artemis.tests.integration.cluster.reattach.MultiThreadRandomReattachTestBase;
public class MultiThreadRandomReattachStressTest extends MultiThreadRandomReattachTest { public class MultiThreadRandomReattachStressTest extends MultiThreadRandomReattachTestBase {
@Override @Override
protected int getNumIterations() { protected int getNumIterations() {

View File

@ -16,9 +16,9 @@
*/ */
package org.apache.activemq.artemis.tests.stress.failover; package org.apache.activemq.artemis.tests.stress.failover;
import org.apache.activemq.artemis.tests.integration.cluster.reattach.RandomReattachTest; import org.apache.activemq.artemis.tests.integration.cluster.reattach.RandomReattachTestBase;
public class RandomReattachStressTest extends RandomReattachTest { public class RandomReattachStressTest extends RandomReattachTestBase {

View File

@ -47,7 +47,7 @@ import org.apache.activemq.artemis.core.settings.impl.AddressSettings;
import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.core.transaction.Transaction;
import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl; import org.apache.activemq.artemis.core.transaction.impl.TransactionImpl;
import org.apache.activemq.artemis.selector.filter.Filterable; import org.apache.activemq.artemis.selector.filter.Filterable;
import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue; import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.fakes.FakeQueue;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.utils.RandomUtil;
import org.apache.activemq.artemis.utils.collections.LinkedListIterator; import org.apache.activemq.artemis.utils.collections.LinkedListIterator;

View File

@ -33,11 +33,6 @@
</properties> </properties>
<dependencies> <dependencies>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>artemis-core-client</artifactId> <artifactId>artemis-core-client</artifactId>
@ -74,13 +69,6 @@
<version>${project.version}</version> <version>${project.version}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.apache.activemq.tests</groupId>
<artifactId>unit-tests</artifactId>
<version>${project.version}</version>
<scope>test</scope>
<type>test-jar</type>
</dependency>
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>artemis-jms-client</artifactId> <artifactId>artemis-jms-client</artifactId>
@ -114,6 +102,16 @@
<artifactId>jakarta.jms-api</artifactId> <artifactId>jakarta.jms-api</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-slf4j2-impl</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@ -147,8 +147,6 @@
<artifactId>log4j-slf4j2-impl</artifactId> <artifactId>log4j-slf4j2-impl</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!-- this is for the log assertion -->
<dependency> <dependency>
<groupId>org.apache.activemq</groupId> <groupId>org.apache.activemq</groupId>
<artifactId>artemis-commons</artifactId> <artifactId>artemis-commons</artifactId>
@ -228,18 +226,6 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<phase>test</phase>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>

View File

@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and * See the License for the specific language governing permissions and
* limitations under the License. * limitations under the License.
*/ */
package org.apache.activemq.artemis.tests.integration.amqp.paging; package org.apache.activemq.artemis.tests.unit.core.paging.impl;
import org.apache.activemq.artemis.api.core.Message; import org.apache.activemq.artemis.api.core.Message;
import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.SimpleString;
@ -23,11 +23,13 @@ import org.apache.activemq.artemis.core.paging.impl.PagedMessageImpl;
import org.apache.activemq.artemis.core.persistence.StorageManager; import org.apache.activemq.artemis.core.persistence.StorageManager;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPLargeMessage; import org.apache.activemq.artemis.protocol.amqp.broker.AMQPLargeMessage;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPStandardMessage; import org.apache.activemq.artemis.protocol.amqp.broker.AMQPStandardMessage;
import org.apache.activemq.artemis.tests.integration.amqp.AmqpTestSupport; import org.apache.activemq.artemis.protocol.amqp.util.NettyWritable;
import org.apache.activemq.artemis.tests.unit.core.paging.impl.PageTest;
import org.apache.activemq.transport.amqp.client.AmqpMessage; import org.apache.activemq.transport.amqp.client.AmqpMessage;
import org.apache.qpid.proton.message.impl.MessageImpl; import org.apache.qpid.proton.message.impl.MessageImpl;
import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
public class AmqpPageTest extends PageTest { public class AmqpPageTest extends PageTest {
private static MessageImpl createProtonMessage(String address, byte[] content) { private static MessageImpl createProtonMessage(String address, byte[] content) {
@ -41,7 +43,7 @@ public class AmqpPageTest extends PageTest {
private static AMQPStandardMessage createStandardMessage(SimpleString address, long msgId, byte[] content) { private static AMQPStandardMessage createStandardMessage(SimpleString address, long msgId, byte[] content) {
MessageImpl protonMessage = createProtonMessage(address.toString(), content); MessageImpl protonMessage = createProtonMessage(address.toString(), content);
AMQPStandardMessage amqpMessage = AmqpTestSupport.encodeAndDecodeMessage(0, protonMessage, content.length + 1000); AMQPStandardMessage amqpMessage = encodeAndDecodeMessage(0, protonMessage, content.length + 1000);
amqpMessage.setMessageID(msgId); amqpMessage.setMessageID(msgId);
return amqpMessage; return amqpMessage;
} }
@ -74,4 +76,14 @@ public class AmqpPageTest extends PageTest {
message.releaseResources(false, false); message.releaseResources(false, false);
} }
} }
public static AMQPStandardMessage encodeAndDecodeMessage(int messageFormat, MessageImpl message, int expectedSize) {
ByteBuf nettyBuffer = Unpooled.buffer(expectedSize);
message.encode(new NettyWritable(nettyBuffer));
byte[] bytes = new byte[nettyBuffer.writerIndex()];
nettyBuffer.readBytes(bytes);
return new AMQPStandardMessage(messageFormat, bytes, null);
}
} }

View File

@ -67,7 +67,7 @@ import org.apache.activemq.artemis.logs.AssertionLoggerHandler;
import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessagePersister; import org.apache.activemq.artemis.protocol.amqp.broker.AMQPMessagePersister;
import org.apache.activemq.artemis.spi.core.protocol.MessagePersister; import org.apache.activemq.artemis.spi.core.protocol.MessagePersister;
import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory; import org.apache.activemq.artemis.tests.unit.core.journal.impl.fakes.FakeSequentialFileFactory;
import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue; import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.fakes.FakeQueue;
import org.apache.activemq.artemis.tests.unit.util.FakePagingManager; import org.apache.activemq.artemis.tests.unit.util.FakePagingManager;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.ActiveMQThreadFactory; import org.apache.activemq.artemis.utils.ActiveMQThreadFactory;

View File

@ -45,6 +45,7 @@ import org.apache.activemq.artemis.core.server.impl.RoutingContextImpl;
import org.apache.activemq.artemis.core.transaction.Transaction; import org.apache.activemq.artemis.core.transaction.Transaction;
import org.apache.activemq.artemis.core.transaction.TransactionOperation; import org.apache.activemq.artemis.core.transaction.TransactionOperation;
import org.apache.activemq.artemis.selector.filter.Filterable; import org.apache.activemq.artemis.selector.filter.Filterable;
import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.fakes.FakeQueue;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.junit.Test; import org.junit.Test;

View File

@ -23,6 +23,7 @@ import java.util.List;
import org.apache.activemq.artemis.api.core.SimpleString; import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.impl.ScaleDownHandler; import org.apache.activemq.artemis.core.server.impl.ScaleDownHandler;
import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.fakes.FakeQueue;
import org.junit.Assert; import org.junit.Assert;
import org.junit.Test; import org.junit.Test;

View File

@ -24,7 +24,7 @@ import org.apache.activemq.artemis.api.core.SimpleString;
import org.apache.activemq.artemis.core.server.Queue; import org.apache.activemq.artemis.core.server.Queue;
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType; import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
import org.apache.activemq.artemis.core.server.cluster.impl.RemoteQueueBindingImpl; import org.apache.activemq.artemis.core.server.cluster.impl.RemoteQueueBindingImpl;
import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue; import org.apache.activemq.artemis.tests.unit.core.postoffice.impl.fakes.FakeQueue;
import org.apache.activemq.artemis.tests.util.ActiveMQTestBase; import org.apache.activemq.artemis.tests.util.ActiveMQTestBase;
import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.utils.RandomUtil;
import org.junit.Test; import org.junit.Test;

View File

@ -18,7 +18,7 @@ package org.apache.activemq.artemis.tests.unit.core.util;
import java.util.HashSet; import java.util.HashSet;
import org.apache.activemq.artemis.tests.util.SpawnedVMCheck; import org.apache.activemq.artemis.tests.rules.SpawnedVMCheck;
import org.apache.activemq.artemis.utils.RandomUtil; import org.apache.activemq.artemis.utils.RandomUtil;
import org.apache.activemq.artemis.utils.SpawnedVMSupport; import org.apache.activemq.artemis.utils.SpawnedVMSupport;
import org.junit.Assert; import org.junit.Assert;

View File

@ -1,48 +0,0 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.activemq.artemis.tests.util;
import org.apache.activemq.artemis.api.core.client.ClientMessage;
import org.apache.activemq.artemis.api.core.client.ClientSession;
import org.apache.activemq.artemis.jms.client.ActiveMQBytesMessage;
import org.apache.activemq.artemis.jms.client.ActiveMQTextMessage;
public final class CreateMessage {
private CreateMessage() {
// Utility class
}
public static ClientMessage createTextMessage(final String s, final ClientSession clientSession) {
ClientMessage message = clientSession.createMessage(ActiveMQTextMessage.TYPE, true, 0, System.currentTimeMillis(), (byte) 4);
message.getBodyBuffer().writeString(s);
return message;
}
public static ClientMessage createBytesMessage(final ClientSession session, final byte[] b, final boolean durable) {
ClientMessage message = session.createMessage(ActiveMQBytesMessage.TYPE, durable, 0, System.currentTimeMillis(), (byte) 1);
message.getBodyBuffer().writeBytes(b);
return message;
}
public static ClientMessage createTextMessage(final ClientSession session, final String s, final boolean durable) {
ClientMessage message = session.createMessage(ActiveMQTextMessage.TYPE, durable, 0, System.currentTimeMillis(), (byte) 1);
message.getBodyBuffer().writeString(s);
return message;
}
}