Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||||||
AbstractViewControllerTestCase |
|
| 1.6666666666666667;1.667 |
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to you under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * http://www.apache.org/licenses/LICENSE-2.0 |
|
10 | * |
|
11 | * Unless required by applicable law or agreed to in writing, software |
|
12 | * distributed under the License is distributed on an "AS IS" BASIS, |
|
13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
|
14 | * See the License for the specific language governing permissions and |
|
15 | * limitations under the License. |
|
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 | // ------------------------------------------------------------ Constructors |
|
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 | 0 | super(name); |
44 | 0 | } |
45 | ||
46 | ||
47 | // ---------------------------------------------------- Overall Test Methods |
|
48 | ||
49 | ||
50 | // ------------------------------------------------------ Instance Variables |
|
51 | ||
52 | ||
53 | // ------------------------------------------------------- Protected Methods |
|
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 | 0 | int actual = 0; |
66 | 0 | Iterator messages = facesContext.getMessages(); |
67 | 0 | while (messages.hasNext()) { |
68 | 0 | messages.next(); |
69 | 0 | actual++; |
70 | } |
|
71 | 0 | assertEquals("Complete message count", expected, actual); |
72 | ||
73 | 0 | } |
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 | 0 | int actual = 0; |
87 | 0 | Iterator messages = facesContext.getMessages(clientId); |
88 | 0 | while (messages.hasNext()) { |
89 | 0 | messages.next(); |
90 | 0 | actual++; |
91 | } |
|
92 | 0 | assertEquals("Complete message count", expected, actual); |
93 | ||
94 | 0 | } |
95 | ||
96 | ||
97 | } |