1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 package org.huihoo.jfox.soaf.util.filter;
18
19 import java.io.IOException;
20 import java.io.InputStream;
21
22 import javax.servlet.ServletInputStream;
23
24 /***
25 * Delegating implementation of ServletInputStream.
26 *
27 * <p>Used by MockHttpServletRequest; typically not
28 * necessary for testing application controllers.
29 *
30 * @author Juergen Hoeller
31 * @since 1.0.2
32 * @see org.springframework.mock.web.MockHttpServletRequest
33 */
34 public class MockServletInputStream extends ServletInputStream {
35
36 private final InputStream sourceStream;
37
38 /***
39 * Create a new DelegatingServletInputStream.
40 * @param sourceStream the sourceStream InputStream
41 */
42 public MockServletInputStream(InputStream sourceStream) {
43 this.sourceStream = sourceStream;
44 }
45
46 public InputStream getSourceStream() {
47 return sourceStream;
48 }
49
50 public int read() throws IOException {
51 return this.sourceStream.read();
52 }
53
54 public void close() throws IOException {
55 super.close();
56 this.sourceStream.close();
57 }
58
59 }