use of org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue in project activemq-artemis by apache.
the class PageCursorStressTest method createNonPersistentCursor.
/**
* @return
* @throws Exception
*/
private PageSubscription createNonPersistentCursor(Filter filter) throws Exception {
long id = server.getStorageManager().generateID();
FakeQueue queue = new FakeQueue(new SimpleString(filter.toString()), id);
queueList.add(queue);
PageSubscription subs = lookupCursorProvider().createSubscription(id, filter, false);
queue.setPageSubscription(subs);
return subs;
}
use of org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue in project activemq-artemis by apache.
the class ManagementServiceImplTest method testGetResources.
@Test
public void testGetResources() throws Exception {
Configuration config = createBasicConfig().setJMXManagementEnabled(false);
ManagementServiceImpl managementService = new ManagementServiceImpl(null, config);
managementService.setStorageManager(new NullStorageManager());
SimpleString address = RandomUtil.randomSimpleString();
managementService.registerAddress(new AddressInfo(address));
Queue queue = new FakeQueue(RandomUtil.randomSimpleString());
managementService.registerQueue(queue, RandomUtil.randomSimpleString(), new FakeStorageManager());
Object[] addresses = managementService.getResources(AddressControl.class);
Assert.assertEquals(1, addresses.length);
Assert.assertTrue(addresses[0] instanceof AddressControl);
AddressControl addressControl = (AddressControl) addresses[0];
Assert.assertEquals(address.toString(), addressControl.getAddress());
Object[] queues = managementService.getResources(QueueControl.class);
Assert.assertEquals(1, queues.length);
Assert.assertTrue(queues[0] instanceof QueueControl);
QueueControl queueControl = (QueueControl) queues[0];
Assert.assertEquals(queue.getName().toString(), queueControl.getName());
}
use of org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue in project activemq-artemis by apache.
the class DeleteMessagesOnStartupTest method testDeleteMessagesOnStartup.
@Test
public void testDeleteMessagesOnStartup() throws Exception {
createStorage();
Queue theQueue = new FakeQueue(new SimpleString(""));
HashMap<Long, Queue> queues = new HashMap<>();
queues.put(100L, theQueue);
Message msg = new CoreMessage(1, 100);
journal.storeMessage(msg);
for (int i = 2; i < 100; i++) {
journal.storeMessage(new CoreMessage(i, 100));
}
journal.storeReference(100, 1, true);
journal.stop();
journal.start();
journal.loadBindingJournal(new ArrayList<QueueBindingInfo>(), new ArrayList<GroupingInfo>(), new ArrayList<AddressBindingInfo>());
FakePostOffice postOffice = new FakePostOffice();
journal.loadMessageJournal(postOffice, null, null, null, null, null, null, new PostOfficeJournalLoader(postOffice, null, journal, null, null, null, null, null, queues));
Assert.assertEquals(98, deletedMessage.size());
for (Long messageID : deletedMessage) {
Assert.assertTrue("messageID = " + messageID, messageID.longValue() >= 2 && messageID <= 99);
}
}
use of org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue in project activemq-artemis by apache.
the class RemoteQueueBindImplTest method testAddRemoveConsumer.
// Constants -----------------------------------------------------
// Attributes ----------------------------------------------------
// Static --------------------------------------------------------
// Constructors --------------------------------------------------
// Public --------------------------------------------------------
@Test
public void testAddRemoveConsumer() throws Exception {
final long id = RandomUtil.randomLong();
final SimpleString address = RandomUtil.randomSimpleString();
final SimpleString uniqueName = RandomUtil.randomSimpleString();
final SimpleString routingName = RandomUtil.randomSimpleString();
final Long remoteQueueID = RandomUtil.randomLong();
final SimpleString filterString = new SimpleString("A>B");
final Queue storeAndForwardQueue = new FakeQueue(null);
final SimpleString bridgeName = RandomUtil.randomSimpleString();
final int distance = 0;
RemoteQueueBindingImpl binding = new RemoteQueueBindingImpl(id, address, uniqueName, routingName, remoteQueueID, filterString, storeAndForwardQueue, bridgeName, distance);
for (int i = 0; i < 100; i++) {
binding.addConsumer(new SimpleString("B" + i + "<A"));
}
assertEquals(100, binding.getFilters().size());
for (int i = 0; i < 100; i++) {
binding.removeConsumer(new SimpleString("B" + i + "<A"));
}
assertEquals(0, binding.getFilters().size());
}
Aggregations