1 7 package com.inversoft.verge.mvc.view.jsp.actionflow.test; 8 9 10 import javax.servlet.ServletException ; 11 import javax.servlet.jsp.tagext.TagData ; 12 import javax.servlet.jsp.tagext.VariableInfo ; 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 29 public class FormTeiTest extends WebTestCase { 30 31 36 public FormTeiTest(String 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 se) { 52 fail(se.toString()); 53 } 54 55 FormTei tei = new FormTei(); 56 TagData td = new TagData (new Object [][]{{"method", "post"}, 57 {"form", "testForm"}, {"namespace", "testNS"}}); 58 assertTrue("Should be valid", tei.isValid(td)); 59 60 td = new TagData (new Object [][]{{"method", "post"}, {"form", "testForm"}}); 61 assertFalse("Should be invalid", tei.isValid(td)); 62 63 td = new TagData (new Object [][]{{"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 td = new TagData (new Object [][]{{"method", "post"}, {"form", "testForm"}, 71 {"namespace", "testNS"}}); 72 VariableInfo [] 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 |