try {
String userId = user.getUserId();
ICQSQueuePersistence persistence = new CQSQueueCassandraPersistence();
//deleteQueuesTest();
List<CQSQueue> queueList = persistence.listQueues(userId, null, false);
assertEquals(queueList.size(), 0);
String queueName = QUEUE_PREFIX + randomGenerator.nextLong();
CQSQueue queue = new CQSQueue(queueName, userId);
persistence.createQueue(queue);
queueList = persistence.listQueues(userId, null, false);
assertEquals(queueList.size(), 1);
String queueURL = queue.getRelativeUrl();
String key = CQSConstants.COL_VISIBILITY_TO;
String value = "5";
String key2 = CQSConstants.COL_MSG_RETENTION_PERIOD;
String value2 = "30";
String key3 = CQSConstants.COL_MAX_MSG_SIZE;
String value3 = "4002";
String key4 = CQSConstants.COL_DELAY_SECONDS;
String value4 = "26";
String key5 = CQSConstants.COL_POLICY;
String value5 = "no";
HashMap<String, String> values = new HashMap<String, String>();
values.put(key, value);
values.put(key2, value2);
values.put(key3, value3);
values.put(key4, value4);
values.put(key5, value5);
persistence.updateQueueAttribute(queueURL, values);
queueName = queue.getName();
CQSQueue queue2 = persistence.getQueue(userId, queueName);
assertTrue(queue2.getVisibilityTO() == 5);
assertTrue(queue2.getMsgRetentionPeriod() == 30);
assertTrue(queue2.getMaxMsgSize() == 4002);
assertTrue(queue2.getDelaySeconds() == 26);
assertTrue(queue2.getPolicy().equals("no"));
key3 = CQSConstants.COL_MAX_MSG_SIZE;
value3 = "4150";
key4 = CQSConstants.COL_DELAY_SECONDS;
value4 = "20";
HashMap<String, String> values2 = new HashMap<String, String>();
values2.put(key3, value3);
values2.put(key4, value4);
persistence.updateQueueAttribute(queueURL, values2);
CQSQueue queue3 = persistence.getQueue(userId, queueName);
assertTrue(queue3.getVisibilityTO() == 5);
assertTrue(queue3.getMsgRetentionPeriod() == 30);
assertTrue(queue3.getMaxMsgSize() == 4150);
assertTrue(queue3.getDelaySeconds() == 20);
assertTrue(queue3.getPolicy().equals("no"));
key = CQSConstants.COL_VISIBILITY_TO;
value = "8";
key2 = CQSConstants.COL_MSG_RETENTION_PERIOD;
value2 = "32";
HashMap<String, String> values3 = new HashMap<String, String>();
values3.put(key, value);
values3.put(key2, value2);
persistence.updateQueueAttribute(queueURL, values3);
CQSQueue queue4 = persistence.getQueue(userId, queueName);
assertTrue(queue4.getVisibilityTO() == 8);
assertTrue(queue4.getMsgRetentionPeriod() == 32);
assertTrue(queue4.getMaxMsgSize() == 4150);
assertTrue(queue4.getDelaySeconds() == 20);
assertTrue(queue4.getPolicy().equals("no"));
queueList = persistence.listQueues(user.getUserId(), null, false);
for(CQSQueue queue_: queueList) {
persistence.deleteQueue(queue_.getRelativeUrl());
}
} catch (PersistenceException e) {
fail("Test failed:" + e.toString());
}