use of org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.UpgradeConfiguredObjectRecord in project qpid-broker-j by apache.
the class UpgradeFrom5To6Test method assertConfiguredObjects.
private void assertConfiguredObjects() throws Exception {
Map<UUID, UpgradeConfiguredObjectRecord> configuredObjects = loadConfiguredObjects();
assertEquals("Unexpected number of configured objects", 21, configuredObjects.size());
Set<Map<String, Object>> expected = new HashSet<Map<String, Object>>(12);
List<UUID> expectedBindingIDs = new ArrayList<UUID>();
expected.add(createExpectedQueueMap("myUpgradeQueue", Boolean.FALSE, null, null));
expected.add(createExpectedQueueMap("clientid:mySelectorDurSubName", Boolean.TRUE, "clientid", null));
expected.add(createExpectedQueueMap("clientid:myDurSubName", Boolean.TRUE, "clientid", null));
final Map<String, Object> queueWithOwnerArguments = new HashMap<String, Object>();
queueWithOwnerArguments.put(QueueArgumentsConverter.X_QPID_PRIORITIES, 10);
queueWithOwnerArguments.put(QueueArgumentsConverter.X_QPID_DESCRIPTION, "misused-owner-as-description");
expected.add(createExpectedQueueMap("nonexclusive-with-erroneous-owner", Boolean.FALSE, null, queueWithOwnerArguments));
final Map<String, Object> priorityQueueArguments = new HashMap<String, Object>();
priorityQueueArguments.put(QueueArgumentsConverter.X_QPID_PRIORITIES, 10);
expected.add(createExpectedQueueMap(PRIORITY_QUEUE_NAME, Boolean.FALSE, null, priorityQueueArguments));
final Map<String, Object> queueWithDLQArguments = new HashMap<String, Object>();
queueWithDLQArguments.put("x-qpid-dlq-enabled", true);
queueWithDLQArguments.put("x-qpid-maximum-delivery-count", 2);
expected.add(createExpectedQueueMap(QUEUE_WITH_DLQ_NAME, Boolean.FALSE, null, queueWithDLQArguments));
final Map<String, Object> dlqArguments = new HashMap<String, Object>();
dlqArguments.put("x-qpid-dlq-enabled", false);
dlqArguments.put("x-qpid-maximum-delivery-count", 0);
expected.add(createExpectedQueueMap(QUEUE_WITH_DLQ_NAME + "_DLQ", Boolean.FALSE, null, dlqArguments));
expected.add(createExpectedExchangeMap(QUEUE_WITH_DLQ_NAME + "_DLE", "fanout"));
expected.add(createExpectedQueueBindingMapAndID("myUpgradeQueue", "myUpgradeQueue", "<<default>>", null, expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID("myUpgradeQueue", "myUpgradeQueue", "amq.direct", null, expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID("clientid:myDurSubName", "myUpgradeTopic", "amq.topic", Collections.singletonMap("x-filter-jms-selector", ""), expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID("clientid:mySelectorDurSubName", "mySelectorUpgradeTopic", "amq.topic", Collections.singletonMap("x-filter-jms-selector", "testprop='true'"), expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID("clientid:myDurSubName", "clientid:myDurSubName", "<<default>>", null, expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID("clientid:mySelectorDurSubName", "clientid:mySelectorDurSubName", "<<default>>", null, expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID("nonexclusive-with-erroneous-owner", "nonexclusive-with-erroneous-owner", "amq.direct", null, expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID("nonexclusive-with-erroneous-owner", "nonexclusive-with-erroneous-owner", "<<default>>", null, expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID(PRIORITY_QUEUE_NAME, PRIORITY_QUEUE_NAME, "<<default>>", null, expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID(PRIORITY_QUEUE_NAME, PRIORITY_QUEUE_NAME, "amq.direct", null, expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID(QUEUE_WITH_DLQ_NAME, QUEUE_WITH_DLQ_NAME, "<<default>>", null, expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID(QUEUE_WITH_DLQ_NAME, QUEUE_WITH_DLQ_NAME, "amq.direct", null, expectedBindingIDs));
expected.add(createExpectedQueueBindingMapAndID(QUEUE_WITH_DLQ_NAME + "_DLQ", "dlq", QUEUE_WITH_DLQ_NAME + "_DLE", null, expectedBindingIDs));
Set<String> expectedTypes = new HashSet<String>();
expectedTypes.add(Queue.class.getName());
expectedTypes.add(Exchange.class.getName());
expectedTypes.add(Binding.class.getName());
MapJsonSerializer jsonSerializer = new MapJsonSerializer();
for (Entry<UUID, UpgradeConfiguredObjectRecord> entry : configuredObjects.entrySet()) {
UpgradeConfiguredObjectRecord object = entry.getValue();
Map<String, Object> deserialized = jsonSerializer.deserialize(object.getAttributes());
assertTrue("Unexpected entry in a store - json [" + object.getAttributes() + "], map [" + deserialized + "]", expected.remove(deserialized));
String type = object.getType();
assertTrue("Unexpected type:" + type, expectedTypes.contains(type));
UUID key = entry.getKey();
assertNotNull("Key cannot be null", key);
if (type.equals(Exchange.class.getName())) {
String exchangeName = (String) deserialized.get(Exchange.NAME);
assertNotNull(exchangeName);
assertEquals("Unexpected key", key, UUIDGenerator.generateExchangeUUID(exchangeName, getVirtualHost().getName()));
} else if (type.equals(Queue.class.getName())) {
String queueName = (String) deserialized.get(Queue.NAME);
assertNotNull(queueName);
assertEquals("Unexpected key", key, UUIDGenerator.generateQueueUUID(queueName, getVirtualHost().getName()));
} else if (type.equals(Binding.class.getName())) {
assertTrue("unexpected binding id", expectedBindingIDs.remove(key));
}
}
assertTrue("Not all expected configured objects found:" + expected, expected.isEmpty());
assertTrue("Not all expected bindings found:" + expectedBindingIDs, expectedBindingIDs.isEmpty());
}
use of org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.UpgradeConfiguredObjectRecord in project qpid-broker-j by apache.
the class UpgradeFrom5To6Test method loadConfiguredObjects.
private Map<UUID, UpgradeConfiguredObjectRecord> loadConfiguredObjects() {
final Map<UUID, UpgradeConfiguredObjectRecord> configuredObjectsRecords = new HashMap<UUID, UpgradeConfiguredObjectRecord>();
final ConfiguredObjectBinding binding = new ConfiguredObjectBinding();
final UpgradeUUIDBinding uuidBinding = new UpgradeUUIDBinding();
CursorOperation configuredObjectsCursor = new CursorOperation() {
@Override
public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
UUID id = uuidBinding.entryToObject(key);
UpgradeConfiguredObjectRecord object = binding.entryToObject(value);
configuredObjectsRecords.put(id, object);
}
};
new DatabaseTemplate(_environment, CONFIGURED_OBJECTS_DB_NAME, null).run(configuredObjectsCursor);
return configuredObjectsRecords;
}
use of org.apache.qpid.server.store.berkeleydb.upgrade.UpgradeFrom5To6.UpgradeConfiguredObjectRecord in project qpid-broker-j by apache.
the class UpgradeFrom5To6Test method assertQueueEntries.
private void assertQueueEntries() {
final Map<UUID, UpgradeConfiguredObjectRecord> configuredObjects = loadConfiguredObjects();
final NewQueueEntryBinding newBinding = new NewQueueEntryBinding();
CursorOperation cursorOperation = new CursorOperation() {
@Override
public void processEntry(Database sourceDatabase, Database targetDatabase, Transaction transaction, DatabaseEntry key, DatabaseEntry value) {
NewQueueEntryKey newEntryRecord = newBinding.entryToObject(key);
assertTrue("Unexpected queue id", configuredObjects.containsKey(newEntryRecord.getQueueId()));
}
};
new DatabaseTemplate(_environment, NEW_DELIVERY_DB_NAME, null).run(cursorOperation);
}
Aggregations