commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-commons-sandbox/jexl/src/test/org/apache/commons/jexl JexlTest.java
Date Thu, 04 Jul 2002 18:05:05 GMT
jstrachan    2002/07/04 11:05:05

  Modified:    jexl/src/test/org/apache/commons/jexl JexlTest.java
  Log:
  Added some more test cases for null and empty string tests.
  
  It appears that tests for equality or non-equality to null are not working.
  
  Revision  Changes    Path
  1.12      +72 -1     jakarta-commons-sandbox/jexl/src/test/org/apache/commons/jexl/JexlTest.java
  
  Index: JexlTest.java
  ===================================================================
  RCS file: /home/cvs/jakarta-commons-sandbox/jexl/src/test/org/apache/commons/jexl/JexlTest.java,v
  retrieving revision 1.11
  retrieving revision 1.12
  diff -u -r1.11 -r1.12
  --- JexlTest.java	13 Jun 2002 16:11:28 -0000	1.11
  +++ JexlTest.java	4 Jul 2002 18:05:05 -0000	1.12
  @@ -540,6 +540,77 @@
       }
   
       /**
  +      *  test some null conditions
  +      */
  +    public void testNull()
  +         throws Exception
  +    {
  +        JexlContext jc = JexlHelper.createContext();
  +        jc.getVars().put("bar", new Integer(2) );
  +        
  +        Expression e = ExpressionFactory.createExpression("empty foo");
  +        Object o = e.evaluate(jc);
  +
  +        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  +        assertEquals("o incorrect", Boolean.TRUE, o);
  +
  +        e = ExpressionFactory.createExpression("bar == null");
  +        o = e.evaluate(jc);
  +
  +        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  +        assertEquals("o incorrect", Boolean.FALSE, o );
  +
  +        e = ExpressionFactory.createExpression("bar != null");
  +        o = e.evaluate(jc);
  +
  +        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  +        assertEquals("o incorrect", Boolean.TRUE, o );
  +
  +        e = ExpressionFactory.createExpression("foo != null");
  +        o = e.evaluate(jc);
  +
  +        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  +        assertEquals("o incorrect", Boolean.FALSE, o);
  +
  +        e = ExpressionFactory.createExpression("foo == null");
  +        o = e.evaluate(jc);
  +
  +        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  +        assertEquals("o incorrect", Boolean.TRUE, o);
  +    }
  +
  +    /**
  +      *  test some blank strings
  +      */
  +    public void testBlankStrings()
  +         throws Exception
  +    {
  +        JexlContext jc = JexlHelper.createContext();
  +        jc.getVars().put("bar", "" );
  +        
  +        Expression e = ExpressionFactory.createExpression("foo == ''");
  +        Object o = e.evaluate(jc);
  +
  +        assertTrue("o not instanceof Boolean", o instanceof Boolean);
  +        assertEquals("o incorrect", Boolean.FALSE, o);
  +
  +        e = ExpressionFactory.createExpression("bar == ''");
  +        o = e.evaluate(jc);
  +
  +        assertEquals("o incorrect", Boolean.TRUE, o );
  +        
  +        e = ExpressionFactory.createExpression("empty bar");
  +        o = e.evaluate(jc);
  +
  +        assertEquals("o incorrect", Boolean.TRUE, o );
  +        
  +        e = ExpressionFactory.createExpression("bar.length() == 0");
  +        o = e.evaluate(jc);
  +
  +        assertEquals("o incorrect", Boolean.TRUE, o );
  +    }
  +
  +    /**
         *  test some simple double array lookups
         */
       public void testDoubleArrays()
  
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message