01: // Copyright 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // Unless required by applicable law or agreed to in writing, software
10: // distributed under the License is distributed on an "AS IS" BASIS,
11: // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12: // See the License for the specific language governing permissions and
13: // limitations under the License.
14:
15: package org.apache.tapestry.corelib.components;
16:
17: import org.apache.tapestry.Field;
18: import org.apache.tapestry.ValidationTracker;
19: import org.apache.tapestry.test.TapestryTestCase;
20: import org.testng.annotations.Test;
21:
22: public class FormTest extends TapestryTestCase {
23: @Test
24: public void record_error() {
25: ValidationTracker tracker = mockValidationTracker();
26: String message = "A recorded message.";
27:
28: tracker.recordError(message);
29:
30: replay();
31:
32: Form form = new Form();
33:
34: form.setTracker(tracker);
35:
36: form.recordError(message);
37:
38: verify();
39: }
40:
41: @Test
42: public void record_error_for_field() {
43: ValidationTracker tracker = mockValidationTracker();
44: String message = "A recorded message.";
45: Field field = mockField();
46:
47: tracker.recordError(field, message);
48:
49: replay();
50:
51: Form form = new Form();
52:
53: form.setTracker(tracker);
54:
55: form.recordError(field, message);
56:
57: verify();
58: }
59: }
|