session.deleteQueue(otherQueue);
}
public void testMoveMessage() throws Exception
{
SimpleString address = RandomUtil.randomSimpleString();
SimpleString queue = RandomUtil.randomSimpleString();
SimpleString otherAddress = RandomUtil.randomSimpleString();
SimpleString otherQueue = RandomUtil.randomSimpleString();
session.createQueue(address, queue, null, false);
session.createQueue(otherAddress, otherQueue, null, false);
ClientProducer producer = session.createProducer(address);
// send 2 messages on queue
producer.send(session.createMessage(false));
producer.send(session.createMessage(false));
QueueControl queueControl = createManagementControl(address, queue);
QueueControl otherQueueControl = createManagementControl(otherAddress, otherQueue);
Assert.assertEquals(2, queueControl.getMessageCount());
Assert.assertEquals(0, otherQueueControl.getMessageCount());
// the message IDs are set on the server
Map<String, Object>[] messages = queueControl.listMessages(null);
Assert.assertEquals(2, messages.length);
long messageID = (Long)messages[0].get("messageID");
boolean moved = queueControl.moveMessage(messageID, otherQueue.toString());
Assert.assertTrue(moved);
Assert.assertEquals(1, queueControl.getMessageCount());
Assert.assertEquals(1, otherQueueControl.getMessageCount());
ManagementTestBase.consumeMessages(1, session, queue);