View Javadoc

1   /*
2       Jagacy plug-in - A TN3270 plug-in for Jameleon.
3       Copyright (C) 2005 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.jagacy.tags;
20  
21  import net.sf.jameleon.plugin.jagacy.JagacyFunctionTag;
22  
23  /***
24   * Verifies that the given text exists on the screen or on the provided row if defined.
25   * @jameleon.function name="jagacy-validate-text-present" type="validation"
26   */
27  public class JagacyValidateTextPresentTag extends JagacyFunctionTag{
28  
29      /***
30       * The text that should exist on the screen
31       * @jameleon.attribute required="true"
32       */
33      protected String text;
34      /***
35       * The row number that the text should exist on. 
36       * If not set, then the entire screen is searched. 
37       * @jameleon.attribute
38       */
39      protected Integer row;
40  
41      public void testBlock(){
42          if (row == null) {
43              assertTextPresent(text);
44          }else{
45              String[] lines = readScreen();
46              if (lines != null && lines.length > 0) {
47                  String lineToValide = lines[row.intValue()];
48                  assertTextContains("'"+text+"' not in text in row # "+row.intValue(), lineToValide, text);
49              }
50          }
51      }
52  }