View Javadoc

1   /*
2       Jameleon - An automation testing tool..
3       Copyright (C) 2003-2006 Christian W. Hargraves (engrean@hotmail.com)
4       
5       This library is free software; you can redistribute it and/or
6       modify it under the terms of the GNU Lesser General Public
7       License as published by the Free Software Foundation; either
8       version 2.1 of the License, or (at your option) any later version.
9   
10      This library is distributed in the hope that it will be useful,
11      but WITHOUT ANY WARRANTY; without even the implied warranty of
12      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13      Lesser General Public License for more details.
14  
15      You should have received a copy of the GNU Lesser General Public
16      License along with this library; if not, write to the Free Software
17      Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */
19  package net.sf.jameleon.plugin.junit.tags;
20  
21  import org.apache.commons.jelly.expression.Expression;
22  
23  /***
24   * Performs an assertTrue on a given expression. This tag, along with all JUnit tags
25   * can be used inside any other plug-in's session tag
26   * 
27   * The following is an example:
28   * <pre><source>
29   *     &lt;testcase xmlns="jelly:jameleon" xmlns:j="jelly:core"&gt;
30   *         &lt;j:set var="greeting" value="Hello World!"/&gt;
31   *         &lt;ju-session&gt;
32   *             &lt;ju-assert-true
33   *                 functionId="check that 'greeting' has at least one character in it"
34   *                 test="${greeting.length() >= 1"/&gt;
35   *         &lt;/ju-session&gt;
36   *     &lt;/testcase&gt;
37   * </source></pre>
38   * @jameleon.function name="ju-assert-true" type="action"
39   * @jameleon.step Verify that the expected expression validates to true.
40   */
41  public class AssertTrueTag extends AbstractAssertTag{
42  
43      /***
44       * The test to be executed
45       * @jameleon.attribute required="true"
46       */
47      protected Expression test;
48  
49      public void testBlock(){
50          if (msg != null) {
51              assertTrue(msg, test.evaluateAsBoolean(context));
52          }else{
53              assertTrue(test.evaluateAsBoolean(context));
54          }
55      }
56  
57  }