KickJava   Java API By Example, From Geeks To Geeks.

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


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.WebTestCase;
15 import com.inversoft.verge.config.VergeConfigConstants;
16 import com.inversoft.verge.config.servlet.ConfigServlet;
17 import com.inversoft.verge.mvc.view.jsp.actionflow.FormTei;
18
19
20 /**
21  * <p>
22  * This class tests the FormTei
23  * </p>
24  *
25  * @author Brian Pontarelli
26  * @since 2.0
27  * @version 2.0
28  */

29 public class FormTeiTest extends WebTestCase {
30
31     /**
32      * Constructor for FormTeiTest.
33      *
34      * @param name
35      */

36     public FormTeiTest(String JavaDoc name) {
37         super(name);
38         setLocal(true);
39     }
40
41
42     public void testIsValid() {
43         if (isLocal()) {
44             getContext().setInitParameter(VergeConfigConstants.CONTEXT_PARAM,
45                 "src/com/inversoft/verge/mvc/view/jsp/actionflow/test/test-config.xml");
46         }
47
48         ConfigServlet cs = new ConfigServlet();
49         try {
50             cs.init(createConfig("ConfigServlet"));
51         } catch (ServletException JavaDoc se) {
52             fail(se.toString());
53         }
54
55         FormTei tei = new FormTei();
56         TagData JavaDoc td = new TagData JavaDoc(new Object JavaDoc[][]{{"method", "post"},
57             {"form", "testForm"}, {"namespace", "testNS"}});
58         assertTrue("Should be valid", tei.isValid(td));
59
60         td = new TagData JavaDoc(new Object JavaDoc[][]{{"method", "post"}, {"form", "testForm"}});
61         assertFalse("Should be invalid", tei.isValid(td));
62
63         td = new TagData JavaDoc(new Object JavaDoc[][]{{"method", "post"}, {"form", "invalid"},
64             {"namespace", "testNS"}});
65         assertFalse("Should be invalid", tei.isValid(td));
66     }
67
68     public void testVariables() {
69         FormTei tei = new FormTei();
70         TagData JavaDoc td = new TagData JavaDoc(new Object JavaDoc[][]{{"method", "post"}, {"form", "testForm"},
71             {"namespace", "testNS"}});
72         VariableInfo JavaDoc [] variables = tei.getVariableInfo(td);
73         assertEquals("Should have one variable", 1, variables.length);
74         assertTrue("Should be declaring", variables[0].getDeclare());
75         assertEquals("Should be nested", VariableInfo.NESTED, variables[0].getScope());
76         assertEquals("Should be named User", "User", variables[0].getVarName());
77         assertEquals("Should be named of correct type",
78             "com.inversoft.verge.mvc.test.Customer",
79             variables[0].getClassName());
80     }
81 }
Popular Tags