use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.
the class PropertyConverter_Internal_to_v0_8Test method testReplyToConversionWhenQueueIsSpecified.
public void testReplyToConversionWhenQueueIsSpecified() {
final String replyTo = "testQueue";
final AMQMessageHeader header = mock(AMQMessageHeader.class);
when(header.getReplyTo()).thenReturn(replyTo);
Queue queue = mock(Queue.class);
when(queue.getName()).thenReturn(replyTo);
when(_addressSpace.getAttainedMessageDestination(replyTo)).thenReturn(queue);
InternalMessage originalMessage = createTestMessage(header);
AMQMessage convertedMessage = _messageConverter.convert(originalMessage, _addressSpace);
assertEquals("Unexpected reply-to", "direct:////" + replyTo, convertedMessage.getContentHeaderBody().getProperties().getReplyToAsString());
}
use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.
the class AbstractQueueTestBase method testAlternateBinding.
public void testAlternateBinding() {
Map<String, Object> attributes = new HashMap<>(_arguments);
attributes.put(Queue.NAME, getTestName());
attributes.put(Queue.ALTERNATE_BINDING, Collections.singletonMap(AlternateBinding.DESTINATION, _qname));
Queue newQueue = _virtualHost.createChild(Queue.class, attributes);
assertEquals("Unexpected alternate binding", _qname, newQueue.getAlternateBinding().getDestination());
}
use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.
the class AbstractQueueTestBase method testMessageHoldingDependentOnQueueProperty.
public void testMessageHoldingDependentOnQueueProperty() throws Exception {
_queue.close();
Map<String, Object> attributes = new HashMap<>(_arguments);
attributes.put(Queue.NAME, _qname);
attributes.put(Queue.OWNER, _owner);
attributes.put(Queue.HOLD_ON_PUBLISH_ENABLED, Boolean.FALSE);
_queue = _virtualHost.createChild(Queue.class, attributes);
ServerMessage messageA = createMessage(new Long(24));
AMQMessageHeader messageHeader = messageA.getMessageHeader();
when(messageHeader.getNotValidBefore()).thenReturn(System.currentTimeMillis() + 20000L);
_queue.enqueue(messageA, null, null);
_consumer = (QueueConsumer<?, ?>) _queue.addConsumer(_consumerTarget, null, messageA.getClass(), "test", EnumSet.of(ConsumerOption.ACQUIRES, ConsumerOption.SEES_REQUEUES), 0);
while (_consumerTarget.processPending()) ;
assertEquals("Message was held despite queue not having holding enabled", 1, _consumerTarget.getMessages().size());
}
use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.
the class AbstractQueueTestBase method doMoveOrCopyMessageTest.
private void doMoveOrCopyMessageTest(final boolean move) {
Queue target = _virtualHost.createChild(Queue.class, Collections.singletonMap(Queue.NAME, getTestName() + "_target"));
_queue.enqueue(createMessage(1L), null, null);
_queue.enqueue(createMessage(2L), null, null);
_queue.enqueue(createMessage(3L), null, null);
assertEquals("Unexpected number of messages on source queue", 3, _queue.getQueueDepthMessages());
assertEquals("Unexpected number of messages on target queue before test", 0, target.getQueueDepthMessages());
if (move) {
_queue.moveMessages(target, null, "true = true", -1);
} else {
_queue.copyMessages(target, null, "true = true", -1);
}
assertEquals("Unexpected number of messages on source queue after test", move ? 0 : 3, _queue.getQueueDepthMessages());
assertEquals("Unexpected number of messages on target queue after test", 3, target.getQueueDepthMessages());
}
use of org.apache.qpid.server.model.Queue in project qpid-broker-j by apache.
the class AbstractQueueTestBase method testDeleteOfQueueSetAsAlternate.
public void testDeleteOfQueueSetAsAlternate() {
Map<String, Object> attributes = new HashMap<>(_arguments);
attributes.put(Queue.NAME, getTestName());
attributes.put(Queue.ALTERNATE_BINDING, Collections.singletonMap(AlternateBinding.DESTINATION, _qname));
Queue newQueue = _virtualHost.createChild(Queue.class, attributes);
assertEquals("Unexpected alternate binding", _qname, newQueue.getAlternateBinding().getDestination());
try {
_queue.delete();
fail("Expected exception is not thrown");
} catch (MessageDestinationIsAlternateException e) {
// pass
}
assertFalse(_queue.isDeleted());
}
Aggregations