use of org.apache.qpid.server.message.MessageContainer in project qpid-broker-j by apache.
the class AbstractConsumerTargetTest method setUp.
@Override
public void setUp() throws Exception {
super.setUp();
when(_connection.getContextValue(eq(Long.class), eq(Consumer.SUSPEND_NOTIFICATION_PERIOD))).thenReturn(1000000L);
_consumer = mock(Consumer.class);
_messageSource = mock(MessageSource.class);
when(_messageSource.getMessageConversionExceptionHandlingPolicy()).thenReturn(MessageSource.MessageConversionExceptionHandlingPolicy.CLOSE);
_messageInstance = mock(MessageInstance.class);
when(_messageInstance.getOwningResource()).thenReturn(_messageSource);
final MessageContainer messageContainer = new MessageContainer(_messageInstance, mock(MessageReference.class));
when(_consumer.pullMessage()).thenReturn(messageContainer);
_consumerTarget = new TestAbstractConsumerTarget();
_consumerTarget.consumerAdded(_consumer);
}
use of org.apache.qpid.server.message.MessageContainer in project qpid-broker-j by apache.
the class TestConsumerTarget method processPending.
@Override
public boolean processPending() {
MessageContainer messageContainer = _consumer.pullMessage();
if (messageContainer == null) {
return false;
}
send(_consumer, messageContainer.getMessageInstance(), false);
return true;
}
use of org.apache.qpid.server.message.MessageContainer in project qpid-broker-j by apache.
the class VirtualHostPropertiesNodeTest method testAddConsumer.
public void testAddConsumer() throws Exception {
final EnumSet<ConsumerOption> options = EnumSet.noneOf(ConsumerOption.class);
final ConsumerTarget target = mock(ConsumerTarget.class);
when(target.allocateCredit(any(ServerMessage.class))).thenReturn(true);
MessageInstanceConsumer consumer = _virtualHostPropertiesNode.addConsumer(target, null, ServerMessage.class, getTestName(), options, 0);
final MessageContainer messageContainer = consumer.pullMessage();
assertNotNull("Could not pull message from VirtualHostPropertyNode", messageContainer);
if (messageContainer.getMessageReference() != null) {
messageContainer.getMessageReference().release();
}
}
Aggregations