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: TestValidationError.java 3634 2007-01-08 21:42:24Z gbevin $
07: */
08: package com.uwyn.rife.site;
09:
10: import com.uwyn.rife.site.ValidationError;
11: import junit.framework.TestCase;
12:
13: public class TestValidationError extends TestCase {
14: public TestValidationError(String name) {
15: super (name);
16: }
17:
18: public void testMandatory() {
19: ValidationError error = new ValidationError.MANDATORY(
20: "subject1");
21: assertEquals(ValidationError.IDENTIFIER_MANDATORY, error
22: .getIdentifier());
23: assertEquals("subject1", error.getSubject());
24: }
25:
26: public void testUnicity() {
27: ValidationError error = new ValidationError.UNICITY("subject3");
28: assertEquals(ValidationError.IDENTIFIER_UNICITY, error
29: .getIdentifier());
30: assertEquals("subject3", error.getSubject());
31: }
32:
33: public void testWrongLength() {
34: ValidationError error = new ValidationError.WRONGLENGTH(
35: "subject4");
36: assertEquals(ValidationError.IDENTIFIER_WRONGLENGTH, error
37: .getIdentifier());
38: assertEquals("subject4", error.getSubject());
39: }
40:
41: public void testWrongFormat() {
42: ValidationError error = new ValidationError.WRONGFORMAT(
43: "subject5");
44: assertEquals(ValidationError.IDENTIFIER_WRONGFORMAT, error
45: .getIdentifier());
46: assertEquals("subject5", error.getSubject());
47: }
48:
49: public void testNotNumeric() {
50: ValidationError error = new ValidationError.NOTNUMERIC(
51: "subject6");
52: assertEquals(ValidationError.IDENTIFIER_NOTNUMERIC, error
53: .getIdentifier());
54: assertEquals("subject6", error.getSubject());
55: }
56:
57: public void testUnexpected() {
58: ValidationError error = new ValidationError.UNEXPECTED(
59: "subject7");
60: assertEquals(ValidationError.IDENTIFIER_UNEXPECTED, error
61: .getIdentifier());
62: assertEquals("subject7", error.getSubject());
63: }
64:
65: public void testIncomplete() {
66: ValidationError error = new ValidationError.INCOMPLETE(
67: "subject8");
68: assertEquals(ValidationError.IDENTIFIER_INCOMPLETE, error
69: .getIdentifier());
70: assertEquals("subject8", error.getSubject());
71: }
72:
73: public void testInvalid() {
74: ValidationError error = new ValidationError.INVALID("subject9");
75: assertEquals(ValidationError.IDENTIFIER_INVALID, error
76: .getIdentifier());
77: assertEquals("subject9", error.getSubject());
78: }
79:
80: public void testCustom() {
81: ValidationError error = new CustomError();
82: assertEquals("CUSTOM", error.getIdentifier());
83: assertEquals("customsubject", error.getSubject());
84: }
85:
86: class CustomError extends ValidationError {
87: CustomError() {
88: super ("CUSTOM", "customsubject");
89: }
90: }
91: }
|