2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.validator;
19
20 import javax.servlet.ServletContextEvent;
21 import junit.framework.Test;
22 import junit.framework.TestSuite;
23 import org.apache.commons.validator.ValidatorAction;
24 import org.apache.shale.test.base.AbstractJsfTestCase;
25 import org.apache.shale.validator.faces.ValidatorLifecycleListener;
26
27 /***
28 * <p>Test case for <code>CommonsValidator</code>.</p>
29 */
30 public class ValidatorDefaultTestCase extends AbstractJsfTestCase {
31
32
33
34
35
36
37 public ValidatorDefaultTestCase(String name) {
38 super(name);
39 }
40
41
42
43
44
45
46 protected void setUp() throws Exception {
47
48 super.setUp();
49
50 servletContext.addInitParameter
51 (Globals.VALIDATOR_RULES,
52 Globals.DEFAULT_VALIDATOR_RULES +
53 ", /org/apache/shale/validator/custom-rules.xml");
54 listener = new ValidatorLifecycleListener();
55 listener.contextInitialized(new ServletContextEvent(servletContext));
56
57 }
58
59
60
61 public static Test suite() {
62
63 return (new TestSuite(ValidatorDefaultTestCase.class));
64
65 }
66
67
68
69 protected void tearDown() throws Exception {
70
71 listener.contextDestroyed(new ServletContextEvent(servletContext));
72 listener = null;
73
74 super.tearDown();
75
76 }
77
78
79
80
81
82
83 ValidatorLifecycleListener listener = null;
84
85
86
87
88
89
90 public void testRequired() {
91
92 ValidatorAction va = CommonsValidator.getValidatorAction( "required" );
93 assertNotNull(va);
94 assertEquals("required",va.getName());
95 assertEquals("org.apache.shale.validator.CommonsValidator",
96 va.getClassname());
97 assertEquals("isSupplied",va.getMethod());
98
99 }
100
101 }