KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > springframework > mock > web > DelegatingServletInputStream


1 /*
2  * Copyright 2002-2006 the original author or authors.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16
17 package org.springframework.mock.web;
18
19 import java.io.IOException JavaDoc;
20 import java.io.InputStream JavaDoc;
21
22 import javax.servlet.ServletInputStream JavaDoc;
23
24 /**
25  * Delegating implementation of {@link javax.servlet.ServletInputStream}.
26  *
27  * <p>Used by {@link MockHttpServletRequest}; typically not directly
28  * used for testing application controllers.
29  *
30  * @author Juergen Hoeller
31  * @since 1.0.2
32  * @see MockHttpServletRequest
33  */

34 public class DelegatingServletInputStream extends ServletInputStream JavaDoc {
35
36     private final InputStream JavaDoc sourceStream;
37
38
39     /**
40      * Create a new DelegatingServletInputStream.
41      * @param sourceStream the sourceStream InputStream
42      */

43     public DelegatingServletInputStream(InputStream JavaDoc sourceStream) {
44         this.sourceStream = sourceStream;
45     }
46
47     public InputStream JavaDoc getSourceStream() {
48         return sourceStream;
49     }
50
51
52     public int read() throws IOException JavaDoc {
53         return this.sourceStream.read();
54     }
55
56     public void close() throws IOException JavaDoc {
57         super.close();
58         this.sourceStream.close();
59     }
60
61 }
62
Popular Tags