2009/05/20 - Apache Shale has been retired.
For more information, please explore the Attic.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18 package org.apache.shale.test.base;
19
20 import java.util.Iterator;
21
22 /***
23 * <p>Abstract base class for testing <code>ViewController</code>
24 * implementations.</p>
25 *
26 * <p><strong>WARNING</strong> - If you choose to subclass this class, be sure
27 * your <code>setUp()</code> and <code>tearDown()</code> methods call
28 * <code>super.setUp()</code> and <code>super.tearDown()</code> respectively,
29 * and that you implement your own <code>suite()</code> method that exposes
30 * the test methods for your test case.</p>
31 */
32 public abstract class AbstractViewControllerTestCase extends AbstractJsfTestCase {
33
34
35
36
37 /***
38 * <p>Construct a new instance of this test case.</p>
39 *
40 * @param name Test case name
41 */
42 public AbstractViewControllerTestCase(String name) {
43 super(name);
44 }
45
46
47
48
49
50
51
52
53
54
55
56 /***
57 * <p>Test that the specified number of messages have been queued on the
58 * <code>FacesContext</code> instance, without regard to matching a
59 * particular client identifier.</p>
60 *
61 * @param expected The expected number of messages
62 */
63 protected void checkMessageCount(int expected) {
64
65 int actual = 0;
66 Iterator messages = facesContext.getMessages();
67 while (messages.hasNext()) {
68 messages.next();
69 actual++;
70 }
71 assertEquals("Complete message count", expected, actual);
72
73 }
74
75
76 /***
77 * <p>Test that the specified number of messages have been queued on the
78 * <code>FacesContext</code> instance, for the specified client id.</p>
79 *
80 * @param clientId Client identifier of the component for which to
81 * count queued messages
82 * @param expected The expected number of messages
83 */
84 protected void checkMessageCount(String clientId, int expected) {
85
86 int actual = 0;
87 Iterator messages = facesContext.getMessages(clientId);
88 while (messages.hasNext()) {
89 messages.next();
90 actual++;
91 }
92 assertEquals("Complete message count", expected, actual);
93
94 }
95
96
97 }