1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.myfaces.extensions.validator.test.propval.crossval;
20
21
22 import org.apache.myfaces.extensions.validator.test.propval.AbstractPropertyValidationTestCase;
23 import org.junit.Test;
24
25 import javax.faces.component.UIViewRoot;
26 import javax.faces.component.html.HtmlForm;
27 import javax.faces.component.html.HtmlInputText;
28
29 public class EqualsStringTestCase extends AbstractPropertyValidationTestCase
30 {
31
32 HtmlInputText inputComponent1 = null;
33 HtmlInputText inputComponent2 = null;
34
35 UIViewRoot rootComponent = null;
36
37 public EqualsStringTestCase()
38 {
39 inputComponent1 = null;
40 inputComponent2 = null;
41 rootComponent = null;
42 }
43
44
45 @Override
46 protected void setUpTestCase()
47 {
48 super.setUpTestCase();
49 EqualsStringTestBean bean = new EqualsStringTestBean();
50 createValueBinding(null, "value", "#{testBean}");
51 facesContext.getExternalContext().getRequestMap().put("testBean", bean);
52
53 rootComponent = new UIViewRoot();
54 HtmlForm form = new HtmlForm();
55 form.setId("form");
56 rootComponent.getChildren().add(form);
57 inputComponent1 = new HtmlInputText();
58 form.getChildren().add(inputComponent1);
59 inputComponent1.setId("input1");
60 inputComponent2 = new HtmlInputText();
61 form.getChildren().add(inputComponent2);
62 inputComponent2.setId("input2");
63 }
64
65 @Test
66 public void testEqualsCaseSensitiveSame() throws Exception
67 {
68 createValueBinding(inputComponent1, "value", "#{testBean.property1}");
69 createValueBinding(inputComponent2, "value", "#{testBean.property2}");
70
71
72 inputComponent1.setSubmittedValue("1d3");
73 inputComponent2.setSubmittedValue("1d3");
74
75
76 inputComponent1.validate(facesContext);
77 inputComponent2.validate(facesContext);
78
79 processCrossValidation();
80 checkMessageCount(0);
81 }
82
83 @Test
84 public void testEqualsCaseSensitiveDifferent() throws Exception
85 {
86 createValueBinding(inputComponent1, "value", "#{testBean.property1}");
87 createValueBinding(inputComponent2, "value", "#{testBean.property2}");
88
89
90 inputComponent1.setSubmittedValue("1d3");
91 inputComponent2.setSubmittedValue("1D3");
92
93
94 inputComponent1.validate(facesContext);
95 inputComponent2.validate(facesContext);
96
97 processCrossValidation();
98 checkMessageCount(2);
99 }
100
101 @Test
102 public void testEqualsCaseInsensitiveSame() throws Exception
103 {
104 createValueBinding(inputComponent1, "value", "#{testBean.property1}");
105 createValueBinding(inputComponent2, "value", "#{testBean.property3}");
106
107
108 inputComponent1.setSubmittedValue("1d3");
109 inputComponent2.setSubmittedValue("1d3");
110
111
112 inputComponent1.validate(facesContext);
113 inputComponent2.validate(facesContext);
114
115 processCrossValidation();
116 checkMessageCount(0);
117 }
118
119 @Test
120 public void testEqualsCaseInsensitiveDifferent() throws Exception
121 {
122 createValueBinding(inputComponent1, "value", "#{testBean.property1}");
123 createValueBinding(inputComponent2, "value", "#{testBean.property3}");
124
125
126 inputComponent1.setSubmittedValue("1d3");
127 inputComponent2.setSubmittedValue("1D3");
128
129
130 inputComponent1.validate(facesContext);
131 inputComponent2.validate(facesContext);
132
133 processCrossValidation();
134 checkMessageCount(0);
135 }
136 }