01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com>
03: * Distributed under the terms of either:
04: * - the common development and distribution license (CDDL), v1.0; or
05: * - the GNU Lesser General Public License, v2.1 or later
06: * $Id: TestPropertyValidationRule.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.site;
09:
10: import junit.framework.TestCase;
11:
12: public class TestPropertyValidationRule extends TestCase {
13: public TestPropertyValidationRule(String name) {
14: super (name);
15: }
16:
17: public void testInstantiation() {
18: Rule rule = new Rule("property");
19: assertNotNull(rule);
20: assertEquals("property", rule.getPropertyName());
21: assertNull(rule.getBean());
22: assertEquals("property", rule.getSubject());
23: }
24:
25: public void testPropertyName() {
26: Rule rule = new Rule("property");
27: assertSame(rule, rule.setPropertyName("property2"));
28: assertEquals("property2", rule.getPropertyName());
29: assertEquals("property", rule.getSubject());
30: }
31:
32: public void testBean() {
33: Rule rule = new Rule("property");
34: assertSame(rule, rule.setBean(this ));
35: assertSame(this , rule.getBean());
36: }
37:
38: public void testSubjectName() {
39: Rule rule = new Rule("property");
40: assertSame(rule, rule.setSubject("property2"));
41: assertEquals("property", rule.getPropertyName());
42: assertEquals("property2", rule.getSubject());
43: assertSame(rule, rule.setSubject(null));
44: assertEquals("property", rule.getSubject());
45: }
46:
47: public class Rule extends PropertyValidationRule {
48: Rule(String property) {
49: super (property);
50: }
51:
52: public boolean validate() {
53: return false;
54: }
55:
56: public ValidationError getError() {
57: return null;
58: }
59: }
60: }
|