01: package nl.knowlogy.validation.test.xdoclet;
02:
03: import nl.knowlogy.validation.Message;
04: import nl.knowlogy.validation.Messages;
05: import nl.knowlogy.validation.MessagesImpl;
06: import nl.knowlogy.validation.Validatable;
07: import junit.framework.TestCase;
08:
09: public class PropertyValidationTestCase extends TestCase {
10:
11: protected Messages doValidation(Validatable validatable) {
12: Messages messages = new MessagesImpl();
13: validatable.validate(messages);
14: return messages;
15: }
16:
17: protected void assertErrorMessageForProperty(Messages messages,
18: Object validatedObject, String propertyName,
19: String expectedErrorCode) {
20: Message message = messages.getMessage(validatedObject,
21: propertyName);
22: assertNotNull("expected a message for property ["
23: + propertyName + "], but not found in messages "
24: + messages, message);
25: assertEquals("expected a message code ", message
26: .getMessageCode(), expectedErrorCode);
27: }
28:
29: protected void assertNoErrorMessageForProperty(Messages messages,
30: Object validatedObject, String propertyName,
31: String expectedErrorCode) {
32: Message message = messages.getMessage(validatedObject,
33: propertyName);
34: assertNull("expected not a message for property ["
35: + propertyName + "], but found message " + message,
36: message);
37: }
38:
39: public void test() {
40:
41: }
42: }
|