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 TypeMethodDescriptionintvoidclose()static longconsumeAll(InputStream inputStream) booleanintread()intread(byte[] bytes) intread(byte[] bytes, int off, int len) longskip(long n) longtransferTo(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:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
read
- Overrides:
readin classInputStream- Throws:
IOException
-
skip
- Overrides:
skipin classInputStream- Throws:
IOException
-
available
- Overrides:
availablein classInputStream- Throws:
IOException
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Overrides:
closein classInputStream- Throws:
IOException
-
markSupported
public boolean markSupported()- Overrides:
markSupportedin classInputStream
-
transferTo
- Overrides:
transferToin classInputStream- Throws:
IOException
-