Skip to content

Commit 95a5509

Browse files
committed
1 parent 5562c5a commit 95a5509

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

src/main/java/com/amazon/sqs/javamessaging/SQSMessagingClientConstants.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ public class SQSMessagingClientConstants {
3636
*/
3737
public static final String STRING = "String";
3838

39+
public static final String BINARY = "Binary";
40+
3941
public static final String NUMBER = "Number";
4042

4143
public static final String INT = "Number.int";

src/main/java/com/amazon/sqs/javamessaging/message/SQSMessage.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ private static String getType(Object value) throws JMSException {
11911191
}
11921192

11931193
private static Object getObjectValue(String value, String type) throws JMSException {
1194-
if (STRING.equals(type) || NUMBER.equals(type)) {
1194+
if (STRING.equals(type) || NUMBER.equals(type) || BINARY.equals(type)) {
11951195
return value;
11961196
} else if (INT.equals(type)) {
11971197
return Integer.valueOf(value);

src/test/java/com/amazon/sqs/javamessaging/message/SQSMessageTest.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ public class SQSMessageTest {
5454
final String myByte = "myByte";
5555
final String myString = "myString";
5656
final String myNumber = "myNumber";
57+
final String myBinary = "myBinary";
5758

5859
@Before
5960
public void setup() {
@@ -78,6 +79,7 @@ public void testProperty() throws JMSException {
7879
message.setByteProperty("myByteProperty", (byte) 'a');
7980
message.setStringProperty("myString", "StringValue");
8081
message.setStringProperty("myNumber", "500");
82+
message.setStringProperty("myBinary", "binarydata");
8183

8284
Assert.assertTrue(message.propertyExists("myTrueBoolean"));
8385
Assert.assertEquals(message.getObjectProperty("myTrueBoolean"), true);
@@ -124,6 +126,10 @@ public void testProperty() throws JMSException {
124126
Assert.assertEquals(message.getDoubleProperty("myNumber"), 500d);
125127
Assert.assertEquals(message.getIntProperty("myNumber"), 500);
126128

129+
Assert.assertTrue(message.propertyExists("myBinary"));
130+
Assert.assertEquals(message.getObjectProperty("myBinary"), "binarydata");
131+
Assert.assertEquals(message.getStringProperty("myBinary"), "binarydata");
132+
127133
// Validate property names
128134
Set<String> propertyNamesSet = new HashSet<String>(Arrays.asList(
129135
"myTrueBoolean",
@@ -135,6 +141,7 @@ public void testProperty() throws JMSException {
135141
"myShort",
136142
"myByteProperty",
137143
"myNumber",
144+
"myBinary",
138145
"myString"));
139146

140147
Enumeration<String > propertyNames = message.getPropertyNames();
@@ -155,6 +162,7 @@ public void testProperty() throws JMSException {
155162
Assert.assertFalse(message.propertyExists("myByteProperty"));
156163
Assert.assertFalse(message.propertyExists("myString"));
157164
Assert.assertFalse(message.propertyExists("myNumber"));
165+
Assert.assertFalse(message.propertyExists("myBinary"));
158166

159167
propertyNames = message.getPropertyNames();
160168
assertFalse(propertyNames.hasMoreElements());
@@ -330,6 +338,10 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
330338
.withDataType(SQSMessagingClientConstants.NUMBER)
331339
.withStringValue("500"));
332340

341+
messageAttributes.put(myBinary, new MessageAttributeValue()
342+
.withDataType(SQSMessagingClientConstants.BINARY)
343+
.withStringValue("binarydata"));
344+
333345
com.amazonaws.services.sqs.model.Message sqsMessage = new com.amazonaws.services.sqs.model.Message()
334346
.withMessageAttributes(messageAttributes)
335347
.withAttributes(systemAttributes)
@@ -383,6 +395,9 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
383395
Assert.assertEquals(message.getFloatProperty(myNumber), 500f);
384396
Assert.assertEquals(message.getDoubleProperty(myNumber), 500d);
385397

398+
Assert.assertTrue(message.propertyExists(myBinary));
399+
Assert.assertEquals(message.getObjectProperty(myBinary), "binarydata");
400+
Assert.assertEquals(message.getStringProperty(myBinary), "binarydata");
386401

387402
// Validate property names
388403
Set<String> propertyNamesSet = new HashSet<String>(Arrays.asList(
@@ -396,6 +411,7 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
396411
myByte,
397412
myString,
398413
myNumber,
414+
myBinary,
399415
JMSX_DELIVERY_COUNT));
400416

401417
Enumeration<String > propertyNames = message.getPropertyNames();
@@ -416,6 +432,7 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
416432
Assert.assertFalse(message.propertyExists("myByteProperty"));
417433
Assert.assertFalse(message.propertyExists("myString"));
418434
Assert.assertFalse(message.propertyExists("myNumber"));
435+
Assert.assertFalse(message.propertyExists("myBinary"));
419436

420437
propertyNames = message.getPropertyNames();
421438
assertFalse(propertyNames.hasMoreElements());

0 commit comments

Comments
 (0)