1 7 package com.inversoft.verge.mvc.validator.test; 8 9 10 import com.inversoft.junit.Request; 11 import com.inversoft.junit.WebTestCase; 12 import com.inversoft.verge.mvc.MVCException; 13 import com.inversoft.verge.mvc.MVCRequest; 14 import com.inversoft.verge.mvc.validator.DefaultValidatorParser; 15 import com.inversoft.verge.mvc.validator.ValidatorConstants; 16 17 18 27 public class DefaultValidatorParserTest extends WebTestCase { 28 29 34 public DefaultValidatorParserTest(String name) { 35 super(name); 36 setLocal(true); 37 } 38 39 40 44 public void beginOverallValidation(Request request) { 45 request.addParameter(ValidatorConstants.VALIDATOR_PARAMETER, 46 "com.inversoft.verge.mvc.validator.test.TestValidator1"); 47 } 48 public void testOverallValidation() { 49 TestValidator1.validated = false; 50 DefaultValidatorParser mp = new DefaultValidatorParser(); 51 MVCRequest mvcRequest = new MVCRequest(request, response); 52 try { 53 mp.preExecute(mvcRequest); 54 mp.execute(mvcRequest); 55 assertTrue("Should have validated", TestValidator1.validated); 56 } catch (MVCException mvce) { 57 fail(mvce.toString()); 58 } 59 } 60 61 65 public void beginNoOverallValidation(Request request) { 66 } 67 public void testNoOverallValidation() { 68 DefaultValidatorParser mp = new DefaultValidatorParser(); 69 TestValidator1.validated = false; 70 MVCRequest mvcRequest = new MVCRequest(request, response); 71 try { 72 mp.preExecute(mvcRequest); 73 mp.execute(mvcRequest); 74 assertFalse("Should NOT have validated", TestValidator1.validated); 75 } catch (MVCException mvce) { 76 fail(mvce.toString()); 77 } 78 } 79 80 85 public void beginValidationDisabled(Request request) { 86 request.addParameter(ValidatorConstants.VALIDATOR_PARAMETER, 87 "com.inversoft.verge.mvc.validator.test.TestValidator1"); 88 } 89 public void testValidationDisabled() { 90 DefaultValidatorParser mp = new DefaultValidatorParser(); 91 TestValidator1.validated = false; 92 MVCRequest mvcRequest = new MVCRequest(request, response); 93 mvcRequest.setValidationEnabled(false); 94 try { 95 mp.preExecute(mvcRequest); 96 mp.execute(mvcRequest); 97 assertFalse("Should NOT have validated", TestValidator1.validated); 98 } catch (MVCException mvce) { 99 fail(mvce.toString()); 100 } 101 } 102 } | Popular Tags |