[jboss-cvs] JBoss Messaging SVN: r5747 - in trunk: tests/src/org/jboss/messaging/tests/unit/core/filter/impl and 1 other directory.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Tue Jan 27 15:02:53 EST 2009


Author: timfox
Date: 2009-01-27 15:02:53 -0500 (Tue, 27 Jan 2009)
New Revision: 5747

Modified:
   trunk/src/main/org/jboss/messaging/core/filter/impl/Operator.java
   trunk/tests/src/org/jboss/messaging/tests/unit/core/filter/impl/FilterTest.java
Log:
fixed filter LIKE implementation with null argument

Modified: trunk/src/main/org/jboss/messaging/core/filter/impl/Operator.java
===================================================================
--- trunk/src/main/org/jboss/messaging/core/filter/impl/Operator.java	2009-01-27 19:41:35 UTC (rev 5746)
+++ trunk/src/main/org/jboss/messaging/core/filter/impl/Operator.java	2009-01-27 20:02:53 UTC (rev 5747)
@@ -24,6 +24,7 @@
 
 import java.util.HashSet;
 
+import org.jboss.messaging.core.logging.Logger;
 import org.jboss.messaging.util.SimpleString;
 
 /**
@@ -38,6 +39,8 @@
 */
 public class Operator
 {
+   private static final Logger log = Logger.getLogger(Operator.class);
+
    int operation;
 
    Object oper1;
@@ -901,22 +904,30 @@
     */
    Object like(final boolean not, final boolean use_escape) throws Exception
    {
+      log.info("in like ");
       Character escapeChar = null;
 
       computeArgument1();
+      
+      log.info("arg 1 is " + arg1);
+      
       if (arg1 == null)
       {
-         return null;
+         return Boolean.FALSE;
       }
+      
       if (class1 != SIMPLE_STRING)
       {
          throwBadObjectException(class1);
       }
 
       computeArgument2();
+      
+      log.info("arg 2 is " + arg2);
+      
       if (arg2 == null)
       {
-         return null;
+         return Boolean.FALSE;
       }
       if (class2 != SIMPLE_STRING)
       {

Modified: trunk/tests/src/org/jboss/messaging/tests/unit/core/filter/impl/FilterTest.java
===================================================================
--- trunk/tests/src/org/jboss/messaging/tests/unit/core/filter/impl/FilterTest.java	2009-01-27 19:41:35 UTC (rev 5746)
+++ trunk/tests/src/org/jboss/messaging/tests/unit/core/filter/impl/FilterTest.java	2009-01-27 20:02:53 UTC (rev 5747)
@@ -225,6 +225,7 @@
    {
       // test LIKE operator with no wildcards
       filter = new FilterImpl(new SimpleString("MyString LIKE 'astring'"));
+      assertFalse(filter.match(message));
       
       // test where LIKE operand matches
       doPutStringProperty("MyString", "astring");
@@ -278,6 +279,7 @@
       
       // first, some tests with the wildcard by itself
       filter = new FilterImpl(new SimpleString("MyString LIKE '_'"));
+      assertFalse(filter.match(message));
       
       // test match against single character
       doPutStringProperty("MyString", "a");
@@ -402,6 +404,14 @@
       // test match failures
    }
    
+   public void testNotLikeExpression() throws Exception
+   {
+      //Should evaluate to true since the property MyString does not exist
+      filter = new FilterImpl(new SimpleString("NOT (MyString LIKE '%')"));
+
+      assertTrue(filter.match(message));
+   }
+   
    public void testStringLikePercentWildcard() throws Exception
    {
       // test LIKE operator with the % wildcard, which
@@ -411,6 +421,7 @@
       
       // first, some tests with the wildcard by itself
       filter = new FilterImpl(new SimpleString("MyString LIKE '%'"));
+      assertFalse(filter.match(message));
       
       // test match against single character
       doPutStringProperty("MyString", "a");
@@ -548,6 +559,8 @@
       // GNU regexp.
       
       filter = new FilterImpl(new SimpleString("MyString LIKE 'a^$b'"));
+      assertFalse(filter.match(message));
+      
       doPutStringProperty("MyString", "a^$b");
       assertTrue(filter.match(message));
       




More information about the jboss-cvs-commits mailing list