KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > inversoft > verge > mvc > view > jsp > form > 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.form.test;
8
9
10 import javax.servlet.jsp.tagext.TagData JavaDoc;
11 import javax.servlet.jsp.tagext.VariableInfo JavaDoc;
12
13 import junit.framework.TestCase;
14
15 import com.inversoft.junit.internal.http.MockHttpServletRequest;
16 import com.inversoft.verge.mvc.controller.form.config.test.FormMVCBuilderTest2;
17 import com.inversoft.verge.mvc.view.jsp.form.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 TestCase {
30
31     // This should only be called once, because of the Request stuff in the
32
// ConfigRegistry for the Form Basec MVC
33
static {
34         // Build the config to test
35
FormMVCBuilderTest2 test = new FormMVCBuilderTest2("testValidate");
36         test.setRequest(new MockHttpServletRequest(null)); // For ConfigRegistry stuff
37
test.testValidate();
38     }
39
40     /**
41      * Constructor for FormTeiTest.
42      *
43      * @param name
44      */

45     public FormTeiTest(String JavaDoc name) {
46         super(name);
47     }
48
49
50     public void testIsValid() {
51         FormTei tei = new FormTei();
52         TagData JavaDoc td = new TagData JavaDoc(new Object JavaDoc[][]{{"method", "post"}, {"form", "form1"}});
53         assertTrue("Should be valid", tei.isValid(td));
54
55         td = new TagData JavaDoc(new Object JavaDoc[][]{{"method", "post"}, {"form", "invalid"}});
56         assertFalse("Should be invalid", tei.isValid(td));
57
58         td = new TagData JavaDoc(new Object JavaDoc[][]{{"method", "post"}});
59         assertFalse("Should be invalid", tei.isValid(td));
60     }
61
62     public void testVariables() {
63         FormTei tei = new FormTei();
64         TagData JavaDoc td = new TagData JavaDoc(new Object JavaDoc[][]{{"method", "post"}, {"form", "form1"},
65             {"var", "fb"}});
66         VariableInfo JavaDoc [] variables = tei.getVariableInfo(td);
67         assertTrue("Should have one variable", variables.length == 1);
68         assertTrue("Should be declaring", variables[0].getDeclare());
69         assertTrue("Should be nested", variables[0].getScope() == VariableInfo.NESTED);
70         assertTrue("Should be named fb", variables[0].getVarName().equals("fb"));
71         assertTrue("Should be named of correct type",
72             variables[0].getClassName().equals("com.inversoft.verge.mvc.controller.form.config.test.TestFormBean"));
73     }
74 }
Popular Tags