KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > strutsel > taglib > logic > TestELNotMatchTag


1 /*
2  * $Id: TestELNotMatchTag.java 54933 2004-10-16 17:04:52Z germuska $
3  *
4  * Copyright 1999-2004 The Apache Software Foundation.
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18
19 package org.apache.strutsel.taglib.logic;
20
21 import javax.servlet.ServletException JavaDoc;
22 import javax.servlet.jsp.JspException JavaDoc;
23 import javax.servlet.jsp.tagext.Tag JavaDoc;
24 import junit.framework.Test;
25 import junit.framework.TestSuite;
26
27 import org.apache.cactus.JspTestCase;
28 import org.apache.cactus.WebRequest;
29 import org.apache.strutsel.taglib.utils.TestFormBean;
30
31 public class TestELNotMatchTag
32     extends JspTestCase {
33
34     protected final static String JavaDoc PROP_KEY = "stringProperty";
35     protected final static String JavaDoc VAR_KEY = "stringVar";
36     protected final static String JavaDoc VALUE_KEY = "abcde";
37     protected final static String JavaDoc PREFIX_VALUE_KEY = "abc";
38     protected final static String JavaDoc BAD_VALUE_KEY = "abx";
39     protected ELNotMatchTag elNotMatchTag = null;
40
41     public TestELNotMatchTag(String JavaDoc theName) {
42         super(theName);
43     }
44
45     public static void main(String JavaDoc[] args) {
46         junit.awtui.TestRunner.main(
47                 new String JavaDoc[] { TestELNotMatchTag.class.getName() });
48     }
49
50     public static Test suite() {
51
52         return new TestSuite(TestELNotMatchTag.class);
53     }
54
55     public void setUp() {
56         elNotMatchTag = new ELNotMatchTag();
57         elNotMatchTag.setPageContext(pageContext);
58     }
59
60     public void tearDown() {
61         elNotMatchTag = null;
62     }
63
64     public void beginMatchStringMatches(WebRequest testRequest) {
65     }
66
67     public void testMatchStringMatches()
68                                 throws ServletException JavaDoc, JspException JavaDoc {
69         TestFormBean formBean = new TestFormBean();
70         formBean.setStringProperty(VALUE_KEY);
71         pageContext.setAttribute("testFormBean", formBean);
72
73         pageContext.setAttribute(VAR_KEY, VALUE_KEY);
74
75         elNotMatchTag.setNameExpr("testFormBean");
76         elNotMatchTag.setPropertyExpr(PROP_KEY);
77
78         elNotMatchTag.setValueExpr(VALUE_KEY);
79
80         int startTagReturn = elNotMatchTag.doStartTag();
81         assertEquals("Match string matches comparison", false,
82                      startTagReturn == Tag.EVAL_BODY_INCLUDE);
83     }
84
85 // public void testPrefixMatchStringMatches()
86
// throws ServletException, JspException {
87
// pageContext.setAttribute(PROP_KEY, PREFIX_VALUE_KEY);
88
// pageContext.setAttribute(VAR_KEY, VALUE_KEY);
89
// elNotMatchTag.setVar(VAR_KEY);
90
// elNotMatchTag.setValue("${" + PROP_KEY + "}");
91

92 // int startTagReturn = elNotMatchTag.doStartTag();
93
// assertEquals("Match prefix string matches comparison", false,
94
// startTagReturn == Tag.EVAL_BODY_INCLUDE);
95
// }
96

97 // public void testMatchStringNotMatches()
98
// throws ServletException, JspException {
99
// pageContext.setAttribute(PROP_KEY, BAD_VALUE_KEY);
100
// pageContext.setAttribute(VAR_KEY, VALUE_KEY);
101
// elNotMatchTag.setVar(VAR_KEY);
102
// elNotMatchTag.setValue("${" + PROP_KEY + "}");
103

104 // int startTagReturn = elNotMatchTag.doStartTag();
105
// assertEquals("unMatched string not matches comparison", true,
106
// startTagReturn == Tag.EVAL_BODY_INCLUDE);
107
// }
108
}
109
Popular Tags