KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > view > jsp > actionflow > test > ATeiTest


1 /*
2  * Copyright (c) 2003, Inversoft
3  *
4  * This software is distribuable under the GNU Lesser General Public License.
5  * For more information visit gnu.org.
6  */

7 package com.inversoft.verge.mvc.view.jsp.actionflow.test;
8
9
10 import javax.servlet.ServletException JavaDoc;
11 import javax.servlet.jsp.tagext.TagData JavaDoc;
12 import javax.servlet.jsp.tagext.VariableInfo JavaDoc;
13
14 import com.inversoft.junit.JspTestCase;
15 import com.inversoft.verge.config.VergeConfigConstants;
16 import com.inversoft.verge.config.servlet.ConfigServlet;
17 import com.inversoft.verge.mvc.view.jsp.actionflow.ATei;
18
19
20 /**
21  * <p>
22  * This class has the tests for the anchor tag extra info
23  * </p>
24  *
25  * @author Brian Pontarelli
26  * @since 2.0
27  * @version 2.0
28  */

29 public class ATeiTest extends JspTestCase {
30
31     /**
32      * Constructor for ATeiTest.
33      *
34      * @param name The name of the test to run
35      */

36     public ATeiTest(String JavaDoc name) {
37         super(name);
38         setLocal(true);
39     }
40
41
42     /**
43      * Tests the tag extra info
44      */

45     public void testWithForm() {
46         if (isLocal()) {
47             getContext().setInitParameter(VergeConfigConstants.CONTEXT_PARAM,
48                 "src/com/inversoft/verge/mvc/view/jsp/actionflow/test/test-config.xml");
49         }
50
51         ConfigServlet cs = new ConfigServlet();
52         try {
53             cs.init(createConfig("ConfigServlet"));
54         } catch (ServletException JavaDoc se) {
55             fail(se.toString());
56         }
57
58         ATei tei = new ATei();
59         Object JavaDoc[][] params = {{"form", "testForm"}, {"namespace", "testNS"}};
60         TagData JavaDoc data = new TagData JavaDoc(params);
61         assertTrue(tei.isValid(data));
62
63         VariableInfo JavaDoc[] infos = tei.getVariableInfo(data);
64         assertEquals(1, infos.length);
65         assertEquals("User", infos[0].getVarName());
66         assertEquals(VariableInfo.NESTED, infos[0].getScope());
67     }
68
69     /**
70      * Tests the tag extra info
71      */

72     public void testWithoutForm() {
73         if (isLocal()) {
74             getContext().setInitParameter(VergeConfigConstants.CONTEXT_PARAM,
75                 "src/com/inversoft/verge/mvc/view/jsp/actionflow/test/test-config.xml");
76         }
77
78         ConfigServlet cs = new ConfigServlet();
79         try {
80             cs.init(createConfig("ConfigServlet"));
81         } catch (ServletException JavaDoc se) {
82             fail(se.toString());
83         }
84
85         ATei tei = new ATei();
86         Object JavaDoc[][] params = {{"namespace", "testNS"}};
87         TagData JavaDoc data = new TagData JavaDoc(params);
88         assertTrue(tei.isValid(data));
89
90         VariableInfo JavaDoc[] infos = tei.getVariableInfo(data);
91         assertNull(infos);
92     }
93 }
Popular Tags