diff --git a/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java b/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java index 3780aa8bee..e0b804c985 100755 --- a/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java +++ b/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java @@ -351,7 +351,42 @@ public abstract class ComparisonExpression extends BinaryExpression implements B // If the the objects are not of the same type, // try to convert up to allow the comparison. if (lc != rc) { - if (lc == Integer.class) { + if (lc == Byte.class) { + if (rc == Short.class) { + lv = new Short(((Number) lv).shortValue()); + } + else if (rc == Integer.class) { + lv = new Integer(((Number) lv).intValue()); + } + else if (rc == Long.class) { + lv = new Long(((Number) lv).longValue()); + } + else if (rc == Float.class) { + lv = new Float(((Number) lv).floatValue()); + } + else if (rc == Double.class) { + lv = new Double(((Number) lv).doubleValue()); + } + else { + return Boolean.FALSE; + } + } else if (lc == Short.class) { + if (rc == Integer.class) { + lv = new Integer(((Number) lv).intValue()); + } + else if (rc == Long.class) { + lv = new Long(((Number) lv).longValue()); + } + else if (rc == Float.class) { + lv = new Float(((Number) lv).floatValue()); + } + else if (rc == Double.class) { + lv = new Double(((Number) lv).doubleValue()); + } + else { + return Boolean.FALSE; + } + } else if (lc == Integer.class) { if (rc == Long.class) { lv = new Long(((Number) lv).longValue()); } diff --git a/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java b/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java index f5d6f1964c..6c8ca8d2df 100755 --- a/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java +++ b/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java @@ -78,8 +78,33 @@ public class SelectorTest extends TestCase { assertSelector(message, "rank > 100", true); assertSelector(message, "rank >= 123", true); assertSelector(message, "rank >= 124", false); + } + public void testPropertyTypes() throws Exception { + Message message = createMessage(); + assertSelector(message, "byteProp = 123", true); + assertSelector(message, "byteProp = 10", false); + + assertSelector(message, "shortProp = 123", true); + assertSelector(message, "shortProp = 10", false); + + + assertSelector(message, "shortProp = 123", true); + assertSelector(message, "shortProp = 10", false); + + assertSelector(message, "intProp = 123", true); + assertSelector(message, "intProp = 10", false); + + assertSelector(message, "longProp = 123", true); + assertSelector(message, "longProp = 10", false); + + assertSelector(message, "floatProp = 123", true); + assertSelector(message, "floatProp = 10", false); + + assertSelector(message, "doubleProp = 123", true); + assertSelector(message, "doubleProp = 10", false); + } public void testAndSelectors() throws Exception { Message message = createMessage(); @@ -297,6 +322,14 @@ public class SelectorTest extends TestCase { message.setJMSMessageID("connection:1:1:1:1"); message.setObjectProperty("name", "James"); message.setObjectProperty("location", "London"); + + message.setByteProperty("byteProp", (byte)123); + message.setShortProperty("shortProp", (short)123); + message.setIntProperty("intProp", (int)123); + message.setLongProperty("longProp", (long)123); + message.setFloatProperty("floatProp", (float)123); + message.setDoubleProperty("doubleProp", (double)123); + message.setIntProperty("rank", 123); message.setIntProperty("version", 2); message.setStringProperty("quote", "'In God We Trust'");