Package org.springframework.mock.web
Class DelegatingServletInputStream
- java.lang.Object
- java.io.InputStream
- javax.servlet.ServletInputStream
- org.springframework.mock.web.DelegatingServletInputStream
- All Implemented Interfaces:
Closeable,AutoCloseable
public class DelegatingServletInputStream extends ServletInputStream
Delegating implementation ofServletInputStream.Used by
MockHttpServletRequest; typically not directly used for testing application controllers.- Since:
- 1.0.2
- Author:
- Juergen Hoeller
- See Also:
MockHttpServletRequest
Constructor Summary
Constructors Constructor Description DelegatingServletInputStream(InputStream sourceStream)Create a DelegatingServletInputStream for the given source stream.
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intavailable()voidclose()InputStreamgetSourceStream()Return the underlying source stream (nevernull).booleanisFinished()Returns true when all the data from the stream has been read else it returns false.booleanisReady()Returns true if data can be read without blocking else returns false.intread()voidsetReadListener(ReadListener readListener)Instructs theServletInputStreamto invoke the providedReadListenerwhen it is possible to readMethods inherited from class javax.servlet.ServletInputStream
readLine
Methods inherited from class java.io.InputStream
mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
Constructor Detail
DelegatingServletInputStream
public DelegatingServletInputStream(InputStream sourceStream)
Create a DelegatingServletInputStream for the given source stream.- Parameters:
sourceStream- the source stream (nevernull)
Method Detail
getSourceStream
public final InputStream getSourceStream()
Return the underlying source stream (nevernull).
read
public int read() throws IOException
- Specified by:
readin classInputStream- Throws:
IOException
available
public int available() throws IOException
- Overrides:
availablein classInputStream- Throws:
IOException
close
public void close() throws IOException
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
isFinished
public boolean isFinished()
Description copied from class:javax.servlet.ServletInputStreamReturns true when all the data from the stream has been read else it returns false.- Specified by:
isFinishedin classServletInputStream- Returns:
truewhen all data for this particular request has been read, otherwise returnsfalse.
isReady
public boolean isReady()
Description copied from class:javax.servlet.ServletInputStreamReturns true if data can be read without blocking else returns false.- Specified by:
isReadyin classServletInputStream- Returns:
trueif data can be obtained without blocking, otherwise returnsfalse.
setReadListener
public void setReadListener(ReadListener readListener)
Description copied from class:javax.servlet.ServletInputStreamInstructs theServletInputStreamto invoke the providedReadListenerwhen it is possible to read- Specified by:
setReadListenerin classServletInputStream- Parameters:
readListener- theReadListenerthat should be notified when it's possible to read.