[jboss-cvs] JBoss Messaging SVN: r5473 - in trunk: tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl and 1 other directory.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Mon Dec 8 07:39:39 EST 2008
Author: jmesnil
Date: 2008-12-08 07:39:39 -0500 (Mon, 08 Dec 2008)
New Revision: 5473
Modified:
trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java
Log:
refactored JMSQueueControl.expireMessages() to delegate directly to the same core Queue's method instead of listing all the messages and expire them one by one
Modified: trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java
===================================================================
--- trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java 2008-12-08 12:35:16 UTC (rev 5472)
+++ trunk/src/main/org/jboss/messaging/jms/server/management/impl/JMSQueueControl.java 2008-12-08 12:39:39 UTC (rev 5473)
@@ -290,16 +290,7 @@
try
{
Filter filter = createFilterFromJMSSelector(filterStr);
-
- List<MessageReference> refs = coreQueue.list(filter);
- for (MessageReference ref : refs)
- {
- coreQueue.expireMessage(ref.getMessage().getMessageID(),
- storageManager,
- postOffice,
- queueSettingsRepository);
- }
- return refs.size();
+ return coreQueue.expireMessages(filter, storageManager, postOffice, queueSettingsRepository);
}
catch (MessagingException e)
{
Modified: trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java 2008-12-08 12:35:16 UTC (rev 5472)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/jms/server/management/impl/JMSQueueControlTest.java 2008-12-08 12:39:39 UTC (rev 5473)
@@ -23,6 +23,7 @@
package org.jboss.messaging.tests.unit.jms.server.management.impl;
import static org.easymock.EasyMock.createMock;
+import static org.easymock.EasyMock.eq;
import static org.easymock.EasyMock.expect;
import static org.easymock.EasyMock.isA;
import static org.easymock.EasyMock.replay;
@@ -57,7 +58,6 @@
import org.jboss.messaging.core.settings.impl.QueueSettings;
import org.jboss.messaging.jms.JBossQueue;
import org.jboss.messaging.jms.server.management.impl.JMSQueueControl;
-import org.jboss.messaging.tests.util.RandomUtil;
import org.jboss.messaging.util.SimpleString;
/**
@@ -420,27 +420,18 @@
public void testExpireMessages() throws Exception
{
- long messageID = randomLong();
-
- List<MessageReference> refs = new ArrayList<MessageReference>();
- MessageReference ref = createMock(MessageReference.class);
- ServerMessage serverMessage = createMock(ServerMessage.class);
- expect(serverMessage.getMessageID()).andReturn(messageID);
- expect(ref.getMessage()).andReturn(serverMessage);
- refs.add(ref);
- expect(coreQueue.list(isA(Filter.class))).andReturn(refs);
+ int expiredMessages = randomInt();
+
expect(
- coreQueue.expireMessage(messageID, storageManager, postOffice,
- queueSettingsRepository)).andReturn(true);
+ coreQueue.expireMessages(isA(Filter.class), eq(storageManager), eq(postOffice),
+ eq(queueSettingsRepository))).andReturn(expiredMessages);
replayMockedAttributes();
- replay(ref, serverMessage);
JMSQueueControl control = createControl();
- assertEquals(1, control.expireMessages("color = 'green'"));
+ assertEquals(expiredMessages, control.expireMessages("color = 'green'"));
verifyMockedAttributes();
- verify(ref, serverMessage);
}
public void testSendMessageToDLQ() throws Exception
More information about the jboss-cvs-commits
mailing list