|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
MockServletInputStream.java | - | 20% | 20% | 20% |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.test.mock;
|
|
16 |
|
|
17 |
import java.io.FileInputStream;
|
|
18 |
import java.io.IOException;
|
|
19 |
import java.io.InputStream;
|
|
20 |
|
|
21 |
import javax.servlet.ServletInputStream;
|
|
22 |
|
|
23 |
/**
|
|
24 |
* Implementation of {@link ServletInputStream} used in mock object testing.
|
|
25 |
* The data in the stream is provided by a binary file. The implemenation
|
|
26 |
* wraps around a {@link java.io.FileInputStream} redirecting all method
|
|
27 |
* invocations to the inner stream.
|
|
28 |
*
|
|
29 |
* @author Howard Lewis Ship
|
|
30 |
* @since 4.0
|
|
31 |
*/
|
|
32 |
|
|
33 |
public class MockServletInputStream extends ServletInputStream |
|
34 |
{ |
|
35 |
private InputStream _inner;
|
|
36 |
|
|
37 | 5 |
public MockServletInputStream(String path) throws IOException |
38 |
{ |
|
39 | 5 |
_inner = new FileInputStream(path);
|
40 |
} |
|
41 |
|
|
42 | 0 |
public int read() throws IOException |
43 |
{ |
|
44 | 0 |
return _inner.read();
|
45 |
} |
|
46 |
|
|
47 | 0 |
public int available() throws IOException |
48 |
{ |
|
49 | 0 |
return _inner.available();
|
50 |
} |
|
51 |
|
|
52 | 0 |
public void close() throws IOException |
53 |
{ |
|
54 | 0 |
_inner.close(); |
55 |
} |
|
56 |
|
|
57 | 0 |
public synchronized void mark(int readlimit) |
58 |
{ |
|
59 | 0 |
_inner.mark(readlimit); |
60 |
} |
|
61 |
|
|
62 | 0 |
public boolean markSupported() |
63 |
{ |
|
64 | 0 |
return _inner.markSupported();
|
65 |
} |
|
66 |
|
|
67 | 7 |
public int read(byte[] b, int off, int len) throws IOException |
68 |
{ |
|
69 | 7 |
return _inner.read(b, off, len);
|
70 |
} |
|
71 |
|
|
72 | 0 |
public int read(byte[] b) throws IOException |
73 |
{ |
|
74 | 0 |
return _inner.read(b);
|
75 |
} |
|
76 |
|
|
77 | 0 |
public synchronized void reset() throws IOException |
78 |
{ |
|
79 | 0 |
_inner.reset(); |
80 |
} |
|
81 |
|
|
82 | 0 |
public long skip(long n) throws IOException |
83 |
{ |
|
84 | 0 |
return _inner.skip(n);
|
85 |
} |
|
86 |
|
|
87 |
} |
|
88 |
|
|