cqs1.setQueueAttributes(new SetQueueAttributesRequest(queueUrl, attributeParams));
logger.info("Send a message with empty message body");
try {
SendMessageRequest sendMessageRequest = new SendMessageRequest();
sendMessageRequest.setQueueUrl(queueUrl);
cqs1.sendMessage(sendMessageRequest);
fail("missing expected exception");
} catch (AmazonServiceException ase) {
assertTrue("Did not get missing parameter exception", ase.getErrorCode().equals(CQSErrorCodes.MissingParameter.getCMBCode()));
}
logger.info("Send a message with invalid DelaySeconds");
try {
SendMessageRequest sendMessageRequest = new SendMessageRequest();
sendMessageRequest.setQueueUrl(queueUrl);
String msg = "This is a message to test invalid delay seconds;";
sendMessageRequest.setMessageBody(msg);
sendMessageRequest.setDelaySeconds(1000);
cqs1.sendMessage(sendMessageRequest);
fail("missing expected exception");
} catch (AmazonServiceException ase) {
assertTrue("Did not get invalid parameter exception", ase.getErrorCode().contains(CQSErrorCodes.InvalidParameterValue.getCMBCode()));
}
logger.info("Send a very long message");
try {
SendMessageRequest sendMessageRequest = new SendMessageRequest();
sendMessageRequest.setQueueUrl(queueUrl);
StringBuffer msg = new StringBuffer("");
for (int i=0; i<300*1024; i++) {
msg.append("M");
}
sendMessageRequest.setMessageBody(msg.toString());
cqs1.sendMessage(sendMessageRequest);
fail("missing expected exception");
} catch (AmazonServiceException ase) {
assertTrue("Did not get an invalid value exception", ase.getErrorCode().equals(CQSErrorCodes.InvalidParameterValue.getCMBCode()));