use of org.apache.qpid.server.protocol.v0_8.FieldTable in project qpid-broker-j by apache.
the class MalformedMessageTest method malformedHeaderValue.
@Test
public void malformedHeaderValue() throws Exception {
final FieldTable malformedHeader = createHeadersWithMalformedLongString();
byte[] contentBytes = CONTENT_TEXT.getBytes(StandardCharsets.UTF_8);
publishMalformedMessage(malformedHeader, contentBytes);
assertThat(getBrokerAdmin().getQueueDepthMessages(BrokerAdmin.TEST_QUEUE_NAME), is(equalTo(0)));
}
use of org.apache.qpid.server.protocol.v0_8.FieldTable in project qpid-broker-j by apache.
the class UpgradeFrom5To6 method upgradeQueueBindings.
private void upgradeQueueBindings(Environment environment, Transaction transaction, final UpgradeInteractionHandler handler, final String virtualHostName) {
LOGGER.info("Queue Bindings");
if (environment.getDatabaseNames().contains(OLD_QUEUE_BINDINGS_DB_NAME)) {
final QueueBindingBinding binding = new QueueBindingBinding();
CursorOperation bindingCursor = new CursorOperation() {
@Override
public void processEntry(Database exchangeDatabase, Database configuredObjectsDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
// TODO: check and remove orphaned bindings
BindingRecord bindingRecord = binding.entryToObject(key);
String exchangeName = bindingRecord.getExchangeName() == null ? ExchangeDefaults.DEFAULT_EXCHANGE_NAME : bindingRecord.getExchangeName().toString();
String queueName = bindingRecord.getQueueName().toString();
String routingKey = bindingRecord.getRoutingKey().toString();
FieldTable arguments = bindingRecord.getArguments();
UUID bindingId = UUIDGenerator.generateBindingUUID(exchangeName, queueName, routingKey, virtualHostName);
UpgradeConfiguredObjectRecord configuredObject = createBindingConfiguredObjectRecord(exchangeName, queueName, routingKey, arguments, virtualHostName);
storeConfiguredObjectEntry(configuredObjectsDatabase, bindingId, configuredObject, transaction);
}
};
new DatabaseTemplate(environment, OLD_QUEUE_BINDINGS_DB_NAME, CONFIGURED_OBJECTS_DB_NAME, transaction).run(bindingCursor);
environment.removeDatabase(transaction, OLD_QUEUE_BINDINGS_DB_NAME);
LOGGER.info(bindingCursor.getRowCount() + " Queue Binding Entries");
}
}
use of org.apache.qpid.server.protocol.v0_8.FieldTable in project qpid-broker-j by apache.
the class UpgradeFrom5To6 method createBindingConfiguredObjectRecord.
private UpgradeConfiguredObjectRecord createBindingConfiguredObjectRecord(String exchangeName, String queueName, String routingKey, FieldTable arguments, String virtualHostName) {
Map<String, Object> attributesMap = new HashMap<String, Object>();
attributesMap.put("name", routingKey);
attributesMap.put("exchange", UUIDGenerator.generateExchangeUUID(exchangeName, virtualHostName));
attributesMap.put("queue", UUIDGenerator.generateQueueUUID(queueName, virtualHostName));
if (arguments != null) {
attributesMap.put("arguments", FieldTable.convertToMap(arguments));
}
String json = serialiseMap(attributesMap);
UpgradeConfiguredObjectRecord configuredObject = new UpgradeConfiguredObjectRecord(Binding.class.getName(), json);
return configuredObject;
}
use of org.apache.qpid.server.protocol.v0_8.FieldTable in project qpid-broker-j by apache.
the class UpgradeFrom4to5Test method loadBindings.
private List<BindingRecord> loadBindings() {
final BindingTuple bindingTuple = new BindingTuple();
final List<BindingRecord> queueBindings = new ArrayList<BindingRecord>();
CursorOperation databaseOperation = new CursorOperation() {
@Override
public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
BindingRecord bindingRecord = bindingTuple.entryToObject(key);
AMQShortString queueName = bindingRecord.getQueueName();
AMQShortString exchangeName = bindingRecord.getExchangeName();
AMQShortString routingKey = bindingRecord.getRoutingKey();
FieldTable arguments = bindingRecord.getArguments();
queueBindings.add(new BindingRecord(exchangeName, queueName, routingKey, arguments));
}
};
new DatabaseTemplate(_environment, BINDING_DB_NAME, null).run(databaseOperation);
return queueBindings;
}
use of org.apache.qpid.server.protocol.v0_8.FieldTable in project qpid-broker-j by apache.
the class AMQDecoderTest method testContentHeaderPropertiesFrame.
@Test
public void testContentHeaderPropertiesFrame() throws AMQProtocolVersionException, AMQFrameDecodingException, IOException {
final BasicContentHeaderProperties props = new BasicContentHeaderProperties();
Map<String, Object> headersMap = new LinkedHashMap<>();
headersMap.put("hello", "world");
headersMap.put("1+1=", 2);
final FieldTable table = FieldTableFactory.createFieldTable(headersMap);
props.setHeaders(table);
final AMQBody body = new ContentHeaderBody(props);
AMQFrame frame = new AMQFrame(1, body);
TestSender sender = new TestSender();
frame.writePayload(sender);
ByteBuffer msg = combine(sender.getSentBuffers());
_decoder.decodeBuffer(msg);
List<AMQDataBlock> frames = _methodProcessor.getProcessedMethods();
AMQDataBlock firstFrame = frames.get(0);
if (firstFrame instanceof AMQFrame) {
assertEquals((long) ContentHeaderBody.TYPE, (long) ((AMQFrame) firstFrame).getBodyFrame().getFrameType());
BasicContentHeaderProperties decodedProps = ((ContentHeaderBody) ((AMQFrame) firstFrame).getBodyFrame()).getProperties();
final Map<String, Object> headers = decodedProps.getHeadersAsMap();
assertEquals("world", headers.get("hello"));
} else {
fail("decode was not a frame");
}
}
Aggregations