activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From chir...@apache.org
Subject svn commit: r407816 - in /incubator/activemq/trunk/activemq-core/src: main/java/org/apache/activemq/filter/ComparisonExpression.java test/java/org/apache/activemq/selector/SelectorTest.java
Date Fri, 19 May 2006 15:05:04 GMT
Author: chirino
Date: Fri May 19 08:05:04 2006
New Revision: 407816

URL: http://svn.apache.org/viewvc?rev=407816&view=rev
Log:
Test and Fix for http://issues.apache.org/activemq/browse/AMQ-715

Modified:
    incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java
    incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java

Modified: incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java?rev=407816&r1=407815&r2=407816&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/filter/ComparisonExpression.java
Fri May 19 08:05:04 2006
@@ -351,7 +351,42 @@
         // 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());
                 }

Modified: incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java
URL: http://svn.apache.org/viewvc/incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java?rev=407816&r1=407815&r2=407816&view=diff
==============================================================================
--- incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java
(original)
+++ incubator/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/selector/SelectorTest.java
Fri May 19 08:05:04 2006
@@ -78,8 +78,33 @@
         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 @@
         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'");



Mime
View raw message