KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > form > TestForm


1 // Copyright 2005 The Apache Software Foundation
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// 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.form;
16
17 import org.apache.tapestry.IActionListener;
18 import org.apache.tapestry.components.BaseComponentTestCase;
19
20 /**
21  * Tests for {@link org.apache.tapestry.form.Form}. Most of the testing is, still alas, done with
22  * mock objects.
23  *
24  * @author Howard Lewis Ship
25  * @since 4.0
26  */

27 public class TestForm extends BaseComponentTestCase
28 {
29     private IActionListener newListener()
30     {
31         return (IActionListener) newMock(IActionListener.class);
32     }
33
34     public void testFindCancelListener()
35     {
36         IActionListener cancel = newListener();
37         IActionListener listener = newListener();
38
39         replayControls();
40
41         Form form = (Form) newInstance(Form.class, new Object JavaDoc[]
42         { "listener", listener, "cancel", cancel });
43
44         assertSame(cancel, form.findListener(FormConstants.SUBMIT_CANCEL));
45
46         verifyControls();
47     }
48
49     public void testFindCancelDefaultListener()
50     {
51         IActionListener listener = newListener();
52
53         replayControls();
54
55         Form form = (Form) newInstance(Form.class, "listener", listener);
56
57         assertSame(listener, form.findListener(FormConstants.SUBMIT_CANCEL));
58
59         verifyControls();
60     }
61
62     public void testFindRefreshListener()
63     {
64         IActionListener refresh = newListener();
65         IActionListener listener = newListener();
66
67         replayControls();
68
69         Form form = (Form) newInstance(Form.class, new Object JavaDoc[]
70         { "listener", listener, "refresh", refresh });
71
72         assertSame(refresh, form.findListener(FormConstants.SUBMIT_REFRESH));
73
74         verifyControls();
75     }
76
77     public void testFindRefreshListenerDefault()
78     {
79         IActionListener listener = newListener();
80
81         replayControls();
82
83         Form form = (Form) newInstance(Form.class, new Object JavaDoc[]
84         { "listener", listener });
85
86         assertSame(listener, form.findListener(FormConstants.SUBMIT_REFRESH));
87
88         verifyControls();
89     }
90
91     public void testFindListenerNormal()
92     {
93         IActionListener cancel = newListener();
94         IActionListener refresh = newListener();
95         IActionListener listener = newListener();
96
97         replayControls();
98
99         Form form = (Form) newInstance(Form.class, new Object JavaDoc[]
100         { "listener", listener, "cancel", cancel, "refresh", refresh });
101
102         assertSame(listener, form.findListener(FormConstants.SUBMIT_NORMAL));
103
104         verifyControls();
105     }
106 }
107
Popular Tags