use of org.apache.qpid.server.protocol.v0_8.AMQShortString in project qpid-broker-j by apache.
the class UpgradeFrom4to5Test method assertQueueHasOwner.
private void assertQueueHasOwner(String queueName, final String expectedOwner) {
List<AMQShortString> durableSubNames = Collections.emptyList();
final UpgradeFrom4To5.QueueRecordBinding binding = new UpgradeFrom4To5.QueueRecordBinding(durableSubNames);
final AtomicReference<String> actualOwner = new AtomicReference<String>();
final AtomicBoolean foundQueue = new AtomicBoolean(false);
CursorOperation queueNameCollector = new CursorOperation() {
@Override
public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
QueueRecord record = binding.entryToObject(value);
String queueName = record.getNameShortString().toString();
if (queueName.equals(queueName)) {
foundQueue.set(true);
actualOwner.set(AMQShortString.toString(record.getOwner()));
}
}
};
new DatabaseTemplate(_environment, "queueDb_v5", null).run(queueNameCollector);
assertTrue("Could not find queue in database", foundQueue.get());
assertEquals("Queue has unexpected owner", expectedOwner, actualOwner.get());
}
use of org.apache.qpid.server.protocol.v0_8.AMQShortString in project qpid-broker-j by apache.
the class UpgradeFrom4to5Test method assertQueues.
private void assertQueues(Set<String> expectedQueueNames) {
List<AMQShortString> durableSubNames = Collections.emptyList();
final UpgradeFrom4To5.QueueRecordBinding binding = new UpgradeFrom4To5.QueueRecordBinding(durableSubNames);
final Set<String> actualQueueNames = new HashSet<String>();
CursorOperation queueNameCollector = new CursorOperation() {
@Override
public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
QueueRecord record = binding.entryToObject(value);
String queueName = record.getNameShortString().toString();
actualQueueNames.add(queueName);
}
};
new DatabaseTemplate(_environment, "queueDb_v5", null).run(queueNameCollector);
assertEquals("Unexpected queue names", expectedQueueNames, actualQueueNames);
}
use of org.apache.qpid.server.protocol.v0_8.AMQShortString in project qpid-broker-j by apache.
the class AMQShortStringEncodingTest method testWriteReadNullValues.
public void testWriteReadNullValues() {
// write into tuple output
TupleOutput tupleOutput = new TupleOutput();
AMQShortStringEncoding.writeShortString(null, tupleOutput);
byte[] data = tupleOutput.getBufferBytes();
// read from tuple input
TupleInput tupleInput = new TupleInput(data);
AMQShortString result = AMQShortStringEncoding.readShortString(tupleInput);
assertNull("Expected null but got " + result, result);
}
use of org.apache.qpid.server.protocol.v0_8.AMQShortString in project qpid-broker-j by apache.
the class MessageFormat_0_9_1 method createMessage.
@Override
public AMQMessage createMessage(final QpidByteBuffer payload, final MessageStore store, final Object connectionReference) {
try {
AMQShortString exchange = readShortString(payload);
AMQShortString routingKey = readShortString(payload);
byte flags = payload.get();
final MessagePublishInfo publishBody = new MessagePublishInfo(exchange, (flags & IMMEDIATE_MASK) != 0, (flags & MANDATORY_MASK) != 0, routingKey);
final ContentHeaderBody contentHeaderBody = readContentBody(payload);
MessageMetaData mmd = new MessageMetaData(publishBody, contentHeaderBody);
final MessageHandle<MessageMetaData> handle = store.addMessage(mmd);
handle.addContent(payload);
final StoredMessage<MessageMetaData> storedMessage = handle.allContentAdded();
return new AMQMessage(storedMessage, connectionReference);
} catch (AMQFrameDecodingException | BufferUnderflowException e) {
throw new ConnectionScopedRuntimeException("Error parsing AMQP 0-9-1 message format", e);
}
}
use of org.apache.qpid.server.protocol.v0_8.AMQShortString in project qpid-broker-j by apache.
the class ProtocolOutputConverterImpl method writeReturn.
@Override
public void writeReturn(MessagePublishInfo messagePublishInfo, ContentHeaderBody header, MessageContentSource message, int channelId, int replyCode, AMQShortString replyText) {
AMQBody returnFrame = createEncodedReturnFrame(messagePublishInfo, replyCode, replyText);
writeMessageDelivery(message, header, channelId, returnFrame);
}
Aggregations