Skip to content

Commit fb08884

Browse files
committed
1 parent b462bdc commit fb08884

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
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: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1194,6 +1194,8 @@ private static String getType(Object value) throws JMSException {
11941194
private static Object getObjectValue(String value, String type) throws JMSException {
11951195
if (INT.equals(type)) {
11961196
return Integer.valueOf(value);
1197+
} else if (STRING.equals(type) || NUMBER.equals(type) || BINARY.equals(type)) {
1198+
return value;
11971199
} else if (LONG.equals(type)) {
11981200
return Long.valueOf(value);
11991201
} else if (BOOLEAN.equals(type)) {

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ public class SQSMessageTest {
5555
final String myString = "myString";
5656
final String myCustomString = "myCustomString";
5757
final String myNumber = "myNumber";
58+
final String myBinary = "myBinary";
5859

5960
@Before
6061
public void setup() {
@@ -79,6 +80,7 @@ public void testProperty() throws JMSException {
7980
message.setByteProperty("myByteProperty", (byte) 'a');
8081
message.setStringProperty("myString", "StringValue");
8182
message.setStringProperty("myNumber", "500");
83+
message.setStringProperty("myBinary", "binarydata");
8284

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

130+
Assert.assertTrue(message.propertyExists("myBinary"));
131+
Assert.assertEquals(message.getObjectProperty("myBinary"), "binarydata");
132+
Assert.assertEquals(message.getStringProperty("myBinary"), "binarydata");
133+
128134
// Validate property names
129135
Set<String> propertyNamesSet = new HashSet<String>(Arrays.asList(
130136
"myTrueBoolean",
@@ -136,6 +142,7 @@ public void testProperty() throws JMSException {
136142
"myShort",
137143
"myByteProperty",
138144
"myNumber",
145+
"myBinary",
139146
"myString"));
140147

141148
Enumeration<String > propertyNames = message.getPropertyNames();
@@ -156,6 +163,7 @@ public void testProperty() throws JMSException {
156163
Assert.assertFalse(message.propertyExists("myByteProperty"));
157164
Assert.assertFalse(message.propertyExists("myString"));
158165
Assert.assertFalse(message.propertyExists("myNumber"));
166+
Assert.assertFalse(message.propertyExists("myBinary"));
159167

160168
propertyNames = message.getPropertyNames();
161169
assertFalse(propertyNames.hasMoreElements());
@@ -335,6 +343,10 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
335343
.withDataType(SQSMessagingClientConstants.NUMBER)
336344
.withStringValue("500"));
337345

346+
messageAttributes.put(myBinary, new MessageAttributeValue()
347+
.withDataType(SQSMessagingClientConstants.BINARY)
348+
.withStringValue("binarydata"));
349+
338350
com.amazonaws.services.sqs.model.Message sqsMessage = new com.amazonaws.services.sqs.model.Message()
339351
.withMessageAttributes(messageAttributes)
340352
.withAttributes(systemAttributes)
@@ -392,6 +404,9 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
392404
Assert.assertEquals(message.getFloatProperty(myNumber), 500f);
393405
Assert.assertEquals(message.getDoubleProperty(myNumber), 500d);
394406

407+
Assert.assertTrue(message.propertyExists(myBinary));
408+
Assert.assertEquals(message.getObjectProperty(myBinary), "binarydata");
409+
Assert.assertEquals(message.getStringProperty(myBinary), "binarydata");
395410

396411
// Validate property names
397412
Set<String> propertyNamesSet = new HashSet<String>(Arrays.asList(
@@ -406,6 +421,7 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
406421
myString,
407422
myCustomString,
408423
myNumber,
424+
myBinary,
409425
JMSX_DELIVERY_COUNT));
410426

411427
Enumeration<String > propertyNames = message.getPropertyNames();
@@ -426,6 +442,7 @@ public void testSQSMessageAttributeToProperty() throws JMSException {
426442
Assert.assertFalse(message.propertyExists("myByteProperty"));
427443
Assert.assertFalse(message.propertyExists("myString"));
428444
Assert.assertFalse(message.propertyExists("myNumber"));
445+
Assert.assertFalse(message.propertyExists("myBinary"));
429446

430447
propertyNames = message.getPropertyNames();
431448
assertFalse(propertyNames.hasMoreElements());

0 commit comments

Comments
 (0)