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.mock;
19
20 import java.util.HashMap;
21 import java.util.Iterator;
22 import java.util.Map;
23
24 import javax.faces.context.FacesContext;
25 import javax.faces.render.RenderKit;
26 import javax.faces.render.RenderKitFactory;
27
28 /***
29 * <p>Mock implementation of <code>RenderKitFactory</code>.</p>
30 *
31 * $Id$
32 */
33
34 public class MockRenderKitFactory extends RenderKitFactory {
35
36
37
38
39
40 /***
41 * <p>Return a default instance.</p>
42 */
43 public MockRenderKitFactory() {
44
45 renderKits = new HashMap();
46
47 }
48
49
50
51
52
53
54
55
56 /***
57 * <p>The set of render kits that have been registered here.</p>
58 */
59 private Map renderKits = new HashMap();
60
61
62
63
64
65 /*** {@inheritDoc} */
66 public void addRenderKit(String renderKitId, RenderKit renderKit) {
67
68 if ((renderKitId == null) || (renderKit == null)) {
69 throw new NullPointerException();
70 }
71 if (renderKits.containsKey(renderKitId)) {
72 throw new IllegalArgumentException(renderKitId);
73 }
74 renderKits.put(renderKitId, renderKit);
75
76 }
77
78
79 /*** {@inheritDoc} */
80 public RenderKit getRenderKit(FacesContext context, String renderKitId) {
81
82 if (renderKitId == null) {
83 throw new NullPointerException();
84 }
85 RenderKit renderKit = (RenderKit) renderKits.get(renderKitId);
86 if (renderKit == null) {
87
88
89
90
91
92
93 if (RenderKitFactory.HTML_BASIC_RENDER_KIT.equals(renderKitId)) {
94 renderKit = new MockRenderKit();
95 renderKits.put(RenderKitFactory.HTML_BASIC_RENDER_KIT,
96 renderKit);
97 return renderKit;
98 }
99 throw new IllegalArgumentException(renderKitId);
100 }
101 return renderKit;
102
103 }
104
105
106 /*** {@inheritDoc} */
107 public Iterator getRenderKitIds() {
108
109 return renderKits.keySet().iterator();
110
111 }
112
113
114 }