Class Reactive3TestUtils
- java.lang.Object
-
- org.apache.hc.core5.testing.reactive.Reactive3TestUtils
-
@Internal public class Reactive3TestUtils extends java.lang.Object
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classReactive3TestUtils.StreamDescription
-
Field Summary
Fields Modifier and Type Field Description private static byte[]RANGEThe range from which to generate random data.
-
Constructor Summary
Constructors Constructor Description Reactive3TestUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static io.reactivex.rxjava3.core.Single<Reactive3TestUtils.StreamDescription>consumeStream(org.reactivestreams.Publisher<java.nio.ByteBuffer> publisher)Consumes the given stream and returns a data structure containing its length and digest.static java.lang.StringgetStreamHash(long length)Computes the hash of the deterministic stream (as produced byproduceStream(long)).private static java.security.MessageDigestnewMessageDigest()static io.reactivex.rxjava3.core.Flowable<java.nio.ByteBuffer>produceStream(long length)Produces a deterministic stream of bytes, in randomly sized chunks of up to 128kB.static io.reactivex.rxjava3.core.Flowable<java.nio.ByteBuffer>produceStream(long length, int maximumBlockSize, java.util.concurrent.atomic.AtomicReference<java.lang.String> hash)Produces a deterministic stream of bytes, in randomly sized chunks, while computing the hash of the random data.static io.reactivex.rxjava3.core.Flowable<java.nio.ByteBuffer>produceStream(long length, java.util.concurrent.atomic.AtomicReference<java.lang.String> hash)Produces a deterministic stream of bytes, in randomly sized chunks of up to 128kB, while computing the hash of the random data.
-
-
-
Method Detail
-
produceStream
public static io.reactivex.rxjava3.core.Flowable<java.nio.ByteBuffer> produceStream(long length)
Produces a deterministic stream of bytes, in randomly sized chunks of up to 128kB.- Parameters:
length- the number of bytes in the stream- Returns:
- a reactive stream of bytes
-
produceStream
public static io.reactivex.rxjava3.core.Flowable<java.nio.ByteBuffer> produceStream(long length, java.util.concurrent.atomic.AtomicReference<java.lang.String> hash)Produces a deterministic stream of bytes, in randomly sized chunks of up to 128kB, while computing the hash of the random data.- Parameters:
length- the number of bytes in the streamhash- an output argument for the hash, set when the end of the stream is reached; ifnull, the hash will not be computed- Returns:
- a reactive stream of bytes
-
produceStream
public static io.reactivex.rxjava3.core.Flowable<java.nio.ByteBuffer> produceStream(long length, int maximumBlockSize, java.util.concurrent.atomic.AtomicReference<java.lang.String> hash)Produces a deterministic stream of bytes, in randomly sized chunks, while computing the hash of the random data.- Parameters:
length- the number of bytes in the streammaximumBlockSize- the maximum size of anyByteBuffer in the streamhash- an output argument for the hash, set when the end of the stream is reached; ifnull, the hash will not be computed- Returns:
- a reactive stream of bytes
-
getStreamHash
public static java.lang.String getStreamHash(long length)
Computes the hash of the deterministic stream (as produced byproduceStream(long)).
-
consumeStream
public static io.reactivex.rxjava3.core.Single<Reactive3TestUtils.StreamDescription> consumeStream(org.reactivestreams.Publisher<java.nio.ByteBuffer> publisher)
Consumes the given stream and returns a data structure containing its length and digest.
-
newMessageDigest
private static java.security.MessageDigest newMessageDigest()
-
-