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.io.IOException;
21 import java.io.OutputStream;
22 import java.io.Writer;
23 import java.util.HashMap;
24 import java.util.Map;
25
26 import javax.faces.context.ResponseStream;
27 import javax.faces.context.ResponseWriter;
28 import javax.faces.render.RenderKit;
29 import javax.faces.render.Renderer;
30 import javax.faces.render.ResponseStateManager;
31
32 /***
33 * <p>Mock implementation of <code>RenderKit</code>.</p>
34 *
35 * $Id$
36 */
37
38 public class MockRenderKit extends RenderKit {
39
40
41
42
43
44 /***
45 * <p>Return a default instance.</p>
46 */
47 public MockRenderKit() {
48 }
49
50
51
52
53
54
55
56
57 /***
58 * <p>The set of renderers registered here.</p>
59 */
60 private Map renderers = new HashMap();
61
62
63
64
65
66 /*** {@inheritDoc} */
67 public void addRenderer(String family, String rendererType,
68 Renderer renderer) {
69
70 if ((family == null) || (rendererType == null) || (renderer == null)) {
71 throw new NullPointerException();
72 }
73 renderers.put(family + "|" + rendererType, renderer);
74
75 }
76
77
78 /*** {@inheritDoc} */
79 public Renderer getRenderer(String family, String rendererType) {
80
81 if ((family == null) || (rendererType == null)) {
82 throw new NullPointerException();
83 }
84 return (Renderer) renderers.get(family + "|" + rendererType);
85
86 }
87
88
89 /*** {@inheritDoc} */
90 public ResponseWriter createResponseWriter(Writer writer,
91 String contentTypeList,
92 String characterEncoding) {
93
94 return new MockResponseWriter(writer, contentTypeList, characterEncoding);
95
96 }
97
98
99 /*** {@inheritDoc} */
100 public ResponseStream createResponseStream(OutputStream out) {
101
102 final OutputStream stream = out;
103 return new ResponseStream() {
104
105 public void close() throws IOException {
106 stream.close();
107 }
108
109 public void flush() throws IOException {
110 stream.flush();
111 }
112
113 public void write(byte[] b) throws IOException {
114 stream.write(b);
115 }
116
117 public void write(byte[] b, int off, int len) throws IOException {
118 stream.write(b, off, len);
119 }
120
121 public void write(int b) throws IOException {
122 stream.write(b);
123 }
124
125 };
126
127
128 }
129
130
131 /*** {@inheritDoc} */
132 public ResponseStateManager getResponseStateManager() {
133
134 throw new UnsupportedOperationException();
135
136 }
137
138
139 }