1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package net.sf.jameleon.plugin.jiffie.tags;
21
22 import net.sf.jameleon.plugin.jiffie.IEFunctionTag;
23
24 /***
25 * Validates the title in several different ways.
26 * When the title has whitespace leading or trailing whitespace it can get
27 * tricking, depending on whether they used the  
28 * character or not.
29 *
30 * @jameleon.function name="ie-validate-title" type="validation"
31 * @jameleon.step Verify that the document title equals the given text.
32 */
33 public class IEValidateTitleTag extends IEFunctionTag {
34
35 /***
36 * The exact title of the page
37 * @jameleon.attribute contextName="ieValidateTitleTitle"
38 */
39 protected String title;
40 /***
41 * The text that the title should not match
42 * @jameleon.attribute
43 * contextName="ieValidateTitleTitleNotEquals"
44 */
45 protected String titleNotEquals;
46 /***
47 * The text that title should contain
48 * @jameleon.attribute
49 * contextName="ieValidateTitleTitleContains"
50 */
51 protected String titleContains;
52 /***
53 * The text that the title should begin with
54 * @jameleon.attribute
55 * contextName="ieValidateTitleTitleBeginsWith"
56 */
57 protected String titleBeginsWith;
58 /***
59 * The text that the title should end with
60 * @jameleon.attribute
61 * contextName="ieValidateTitleTitleEndsWith"
62 */
63 protected String titleEndsWith;
64
65 public void testBlock() {
66 String actualTitle = getDocument().getTitle();
67 if (title != null) {
68 assertTitleEquals("title of page", title);
69 }else if (titleContains != null) {
70 assertTextContains("title, '"+actualTitle+"', does not contain '"+titleContains+"'", actualTitle, titleContains);
71 }else if (titleBeginsWith != null) {
72 assertTrue("title, '"+actualTitle+"', does not begin with '"+titleBeginsWith+"'", actualTitle.startsWith(titleBeginsWith));
73 }else if (titleEndsWith != null) {
74 assertTrue("title, '"+actualTitle+"', does not end with '"+titleEndsWith+"'", actualTitle.endsWith(titleEndsWith));
75 }else if (titleNotEquals != null) {
76 assertTitleNotEquals("title of page", titleNotEquals);
77 }else{
78 fail("No tests were run for this tag!");
79 }
80 }
81 }