Search in sources :

Example 1 with FakeQueue

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;
}
Also used : FakeQueue(org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) PageSubscription(org.apache.activemq.artemis.core.paging.cursor.PageSubscription)

Example 2 with FakeQueue

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());
}
Also used : ManagementServiceImpl(org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl) AddressControl(org.apache.activemq.artemis.api.core.management.AddressControl) NullStorageManager(org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager) FakeStorageManager(org.apache.activemq.artemis.tests.integration.server.FakeStorageManager) Configuration(org.apache.activemq.artemis.core.config.Configuration) FakeQueue(org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Queue(org.apache.activemq.artemis.core.server.Queue) FakeQueue(org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue) QueueControl(org.apache.activemq.artemis.api.core.management.QueueControl) AddressInfo(org.apache.activemq.artemis.core.server.impl.AddressInfo) Test(org.junit.Test)

Example 3 with FakeQueue

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);
    }
}
Also used : PostOfficeJournalLoader(org.apache.activemq.artemis.core.server.impl.PostOfficeJournalLoader) GroupingInfo(org.apache.activemq.artemis.core.persistence.GroupingInfo) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) Message(org.apache.activemq.artemis.api.core.Message) HashMap(java.util.HashMap) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) QueueBindingInfo(org.apache.activemq.artemis.core.persistence.QueueBindingInfo) FakePostOffice(org.apache.activemq.artemis.tests.unit.core.server.impl.fakes.FakePostOffice) CoreMessage(org.apache.activemq.artemis.core.message.impl.CoreMessage) FakeQueue(org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue) AddressBindingInfo(org.apache.activemq.artemis.core.persistence.AddressBindingInfo) Queue(org.apache.activemq.artemis.core.server.Queue) FakeQueue(org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue) Test(org.junit.Test)

Example 4 with FakeQueue

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());
}
Also used : FakeQueue(org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue) RemoteQueueBindingImpl(org.apache.activemq.artemis.core.server.cluster.impl.RemoteQueueBindingImpl) SimpleString(org.apache.activemq.artemis.api.core.SimpleString) Queue(org.apache.activemq.artemis.core.server.Queue) FakeQueue(org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue) Test(org.junit.Test)

Aggregations

SimpleString (org.apache.activemq.artemis.api.core.SimpleString)4 FakeQueue (org.apache.activemq.artemis.tests.unit.core.postoffice.impl.FakeQueue)4 Queue (org.apache.activemq.artemis.core.server.Queue)3 Test (org.junit.Test)3 HashMap (java.util.HashMap)1 Message (org.apache.activemq.artemis.api.core.Message)1 AddressControl (org.apache.activemq.artemis.api.core.management.AddressControl)1 QueueControl (org.apache.activemq.artemis.api.core.management.QueueControl)1 Configuration (org.apache.activemq.artemis.core.config.Configuration)1 CoreMessage (org.apache.activemq.artemis.core.message.impl.CoreMessage)1 PageSubscription (org.apache.activemq.artemis.core.paging.cursor.PageSubscription)1 AddressBindingInfo (org.apache.activemq.artemis.core.persistence.AddressBindingInfo)1 GroupingInfo (org.apache.activemq.artemis.core.persistence.GroupingInfo)1 QueueBindingInfo (org.apache.activemq.artemis.core.persistence.QueueBindingInfo)1 NullStorageManager (org.apache.activemq.artemis.core.persistence.impl.nullpm.NullStorageManager)1 RemoteQueueBindingImpl (org.apache.activemq.artemis.core.server.cluster.impl.RemoteQueueBindingImpl)1 AddressInfo (org.apache.activemq.artemis.core.server.impl.AddressInfo)1 PostOfficeJournalLoader (org.apache.activemq.artemis.core.server.impl.PostOfficeJournalLoader)1 ManagementServiceImpl (org.apache.activemq.artemis.core.server.management.impl.ManagementServiceImpl)1 FakeStorageManager (org.apache.activemq.artemis.tests.integration.server.FakeStorageManager)1