Package io.clonecloudstore.test.stream
Class FakeInputStream
java.lang.Object
java.io.InputStream
io.clonecloudstore.test.stream.FakeInputStream
- All Implemented Interfaces:
Closeable
,AutoCloseable
Fake InputStream often used in various situation for testing:
It does not really allocate the space in memory so big InputStream can be tested.
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionFakeInputStream
(long len) Will generate a FakeInputStream with random valuesFakeInputStream
(long len, byte b) -
Method Summary
Modifier and TypeMethodDescriptionint
void
close()
static long
consumeAll
(InputStream inputStream) boolean
int
read()
int
read
(byte[] bytes) int
read
(byte[] bytes, int off, int len) long
skip
(long n) long
transferTo
(OutputStream out) Methods inherited from class java.io.InputStream
mark, nullInputStream, readAllBytes, readNBytes, readNBytes, reset, skipNBytes
-
Field Details
-
DEFAULT_BUFFER_SIZE
public static final int DEFAULT_BUFFER_SIZE- See Also:
-
toSend
protected long toSend
-
-
Constructor Details
-
FakeInputStream
public FakeInputStream(long len) Will generate a FakeInputStream with random values- Parameters:
len
- the length of the virtual InputStream
-
FakeInputStream
public FakeInputStream(long len, byte b) - Parameters:
len
- the length of the virtual InputStreamb
- the byte to use for each and every byte
-
-
Method Details
-
consumeAll
- Parameters:
inputStream
- the InputStream to consume completely- Returns:
- the length read
- Throws:
IOException
- if an error occurs
-
read
- Specified by:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
read
- Overrides:
read
in classInputStream
- Throws:
IOException
-
skip
- Overrides:
skip
in classInputStream
- Throws:
IOException
-
available
- Overrides:
available
in classInputStream
- Throws:
IOException
-
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupported
in classInputStream
-
transferTo
- Overrides:
transferTo
in classInputStream
- Throws:
IOException
-