1 7 package com.inversoft.verge.mvc.view.jsp.form.test; 8 9 10 import javax.servlet.jsp.tagext.TagData ; 11 import javax.servlet.jsp.tagext.VariableInfo ; 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 29 public class FormTeiTest extends TestCase { 30 31 static { 34 FormMVCBuilderTest2 test = new FormMVCBuilderTest2("testValidate"); 36 test.setRequest(new MockHttpServletRequest(null)); test.testValidate(); 38 } 39 40 45 public FormTeiTest(String name) { 46 super(name); 47 } 48 49 50 public void testIsValid() { 51 FormTei tei = new FormTei(); 52 TagData td = new TagData (new Object [][]{{"method", "post"}, {"form", "form1"}}); 53 assertTrue("Should be valid", tei.isValid(td)); 54 55 td = new TagData (new Object [][]{{"method", "post"}, {"form", "invalid"}}); 56 assertFalse("Should be invalid", tei.isValid(td)); 57 58 td = new TagData (new Object [][]{{"method", "post"}}); 59 assertFalse("Should be invalid", tei.isValid(td)); 60 } 61 62 public void testVariables() { 63 FormTei tei = new FormTei(); 64 TagData td = new TagData (new Object [][]{{"method", "post"}, {"form", "form1"}, 65 {"var", "fb"}}); 66 VariableInfo [] 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 |