01: // Copyright © 2002-2005 Canoo Engineering AG, Switzerland.
02: package com.canoo.webtest.steps.verify;
03:
04: import com.canoo.webtest.steps.Step;
05: import com.canoo.webtest.util.ConversionUtil;
06:
07: /**
08: * @author Marc Guillemot
09: * @webtest.step
10: */
11: public abstract class AbstractVerifyTextStep extends Step {
12: /** True if the text attribute is optional. */
13: private boolean fOptionalText;
14: /** True if the step does not require a previous page available. */
15: private boolean fOptionalPreviousPage;
16: private String fText;
17: private String fRegex;
18:
19: public String getText() {
20: return fText;
21: }
22:
23: public boolean isRegex() {
24: return ConversionUtil.convertToBoolean(getRegex(), false);
25: }
26:
27: public String getRegex() {
28: return fRegex;
29: }
30:
31: /**
32: * @param regex
33: * @webtest.parameter
34: * required="no"
35: * default="'false'"
36: * description="Specifies whether the text value represents a <key>regex</key>."
37: */
38: public void setRegex(final String regex) {
39: fRegex = regex;
40: }
41:
42: /**
43: * @param text
44: * @webtest.parameter
45: * required="yes"
46: * description="The text value to verify against."
47: */
48: public void setText(final String text) {
49: fText = text;
50: }
51:
52: public void setOptionalPreviousPage(
53: final boolean optionalPreviousPage) {
54: fOptionalPreviousPage = optionalPreviousPage;
55: }
56:
57: public void setOptionalText(final boolean optionalText) {
58: fOptionalText = optionalText;
59: }
60:
61: protected boolean verifyStrings(final String expectedValue,
62: final String actualValue) {
63: return getVerifier(isRegex()).verifyStrings(expectedValue,
64: actualValue);
65: }
66:
67: protected boolean verifyText(final String actualValue) {
68: return verifyStrings(getText(), actualValue);
69: }
70:
71: protected void verifyParameters() {
72: super .verifyParameters();
73: if (!fOptionalText) {
74: nullParamCheck(getText(), "text");
75: }
76: if (!fOptionalPreviousPage) {
77: nullResponseCheck();
78: }
79: }
80: }
|