logger.info("Send a batch of messages with empty supplied Id");
try {
List<SendMessageBatchRequestEntry> messageList = Arrays.asList(
new SendMessageBatchRequestEntry("id1", "This is the first message in a batch"),
new SendMessageBatchRequestEntry("id.1", "This is the second message in a batch"),
new SendMessageBatchRequestEntry("id3", "This is the third message in a batch")
);
SendMessageBatchRequest batchSendRequest = new SendMessageBatchRequest(queueUrl, messageList);
cqs1.sendMessageBatch(batchSendRequest);
fail("missing expected exception");
} catch (AmazonServiceException ase) {
assertTrue("Did not get invalid batch entry id exception", ase.getErrorCode().contains(CQSErrorCodes.InvalidBatchEntryId.getCMBCode()));
}
logger.info("Send a batch of messages with empty message");
try {
List<SendMessageBatchRequestEntry> messageList = Arrays.asList(
new SendMessageBatchRequestEntry("id1", "This is the first message in a batch"),
new SendMessageBatchRequestEntry("id2", "This is the second message in a batch"),
new SendMessageBatchRequestEntry("id3", "")
);
SendMessageBatchRequest batchSendRequest = new SendMessageBatchRequest(queueUrl, messageList);
cqs1.sendMessageBatch(batchSendRequest);
} catch (AmazonServiceException ase) {
fail(ase.getMessage());
}
logger.info("Send a batch of messages with same supplied id");
try {
List<SendMessageBatchRequestEntry> messageList = Arrays.asList(
new SendMessageBatchRequestEntry("1", "This is the first message in a batch"),
new SendMessageBatchRequestEntry("2", "This is the second message in a batch"),
new SendMessageBatchRequestEntry("1", "Test")
);
SendMessageBatchRequest batchSendRequest = new SendMessageBatchRequest(queueUrl, messageList);
cqs1.sendMessageBatch(batchSendRequest);
fail("missing expected exception");
} catch (AmazonServiceException ase) {
//assertTrue("Did not get batch entry id not distinct exception", ase.getErrorCode().contains(CQSErrorCodes.BatchEntryIdsNotDistinct.getCMBCode()));
}
logger.info("Send a batch of messages with supplied id too long");
try {
List<SendMessageBatchRequestEntry> messageList = Arrays.asList(
new SendMessageBatchRequestEntry("1", "This is the first message in a batch"),
new SendMessageBatchRequestEntry("2", "This is the second message in a batch"),
new SendMessageBatchRequestEntry("123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890", "Test")
);
SendMessageBatchRequest batchSendRequest = new SendMessageBatchRequest(queueUrl, messageList);
cqs1.sendMessageBatch(batchSendRequest);
fail("missing expected exception");
} catch (AmazonServiceException ase) {
assertTrue("Did not get invalid batch entry id", ase.getErrorCode().contains(CQSErrorCodes.InvalidBatchEntryId.getCMBCode()));
}
logger.info("Send a batch of messages total length over 64KB");
try {
char[] chars = new char[300*1024 - 10];
java.util.Arrays.fill(chars, 'x');
List<SendMessageBatchRequestEntry> messageList = Arrays.asList(
new SendMessageBatchRequestEntry("1", "This is the first message in a batch"),
new SendMessageBatchRequestEntry("2", "This is the second message in a batch"),
new SendMessageBatchRequestEntry("3", new String(chars))
);
SendMessageBatchRequest batchSendRequest = new SendMessageBatchRequest(queueUrl, messageList);
cqs1.sendMessageBatch(batchSendRequest);
fail("missing expected exception");
} catch (AmazonServiceException ase) {