01: /*******************************************************************************
02: * Portions created by Sebastian Thomschke are copyright (c) 2005-2007 Sebastian
03: * Thomschke.
04: *
05: * All Rights Reserved. This program and the accompanying materials
06: * are made available under the terms of the Eclipse Public License v1.0
07: * which accompanies this distribution, and is available at
08: * http://www.eclipse.org/legal/epl-v10.html
09: *
10: * Contributors:
11: * Sebastian Thomschke - initial implementation.
12: *******************************************************************************/package net.sf.oval.test.validator;
13:
14: import java.util.List;
15:
16: import junit.framework.TestCase;
17: import net.sf.oval.ConstraintViolation;
18: import net.sf.oval.Validator;
19: import net.sf.oval.constraint.NotNull;
20:
21: /**
22: * @author Sebastian Thomschke
23: */
24: public class InheritanceTest extends TestCase {
25: public static abstract class AbstractEntity {
26: @NotNull(message="NOT_NULL")
27: private String name;
28:
29: /**
30: * @return the name
31: */
32: public String getName() {
33: return name;
34: }
35:
36: /**
37: * @param name the name to set
38: */
39: public void setName(final String name) {
40: this .name = name;
41: }
42: }
43:
44: public static class EntityImpl extends AbstractEntity {
45: // do nothing
46: }
47:
48: public void testInheritance() {
49: final Validator validator = new Validator();
50:
51: final AbstractEntity e = new EntityImpl();
52:
53: final List<ConstraintViolation> violations = validator
54: .validate(e);
55: assertTrue(violations.size() == 1);
56: assertTrue(violations.get(0).getMessage().equals("NOT_NULL"));
57: }
58: }
|