rxjava-test-dsl

Useful things for RX on the JVM

License

License

Categories

Categories

RxJava Container Microservices Reactive libraries
GroupId

GroupId

uk.camsw
ArtifactId

ArtifactId

rxjava-test-dsl
Last Version

Last Version

5.0.1
Release Date

Release Date

Type

Type

jar
Description

Description

rxjava-test-dsl
Useful things for RX on the JVM

Download rxjava-test-dsl

How to add to project

<!-- https://jarcasting.com/artifacts/uk.camsw/rxjava-test-dsl/ -->
<dependency>
    <groupId>uk.camsw</groupId>
    <artifactId>rxjava-test-dsl</artifactId>
    <version>5.0.1</version>
</dependency>
// https://jarcasting.com/artifacts/uk.camsw/rxjava-test-dsl/
implementation 'uk.camsw:rxjava-test-dsl:5.0.1'
// https://jarcasting.com/artifacts/uk.camsw/rxjava-test-dsl/
implementation ("uk.camsw:rxjava-test-dsl:5.0.1")
'uk.camsw:rxjava-test-dsl:jar:5.0.1'
<dependency org="uk.camsw" name="rxjava-test-dsl" rev="5.0.1">
  <artifact name="rxjava-test-dsl" type="jar" />
</dependency>
@Grapes(
@Grab(group='uk.camsw', module='rxjava-test-dsl', version='5.0.1')
)
libraryDependencies += "uk.camsw" % "rxjava-test-dsl" % "5.0.1"
[uk.camsw/rxjava-test-dsl "5.0.1"]

Dependencies

compile (5)

Group / Artifact Type Version
org.assertj : assertj-core jar 3.2.0
io.reactivex : rxjava jar 1.0.14
com.jayway.awaitility : awaitility jar 1.6.5
com.google.guava : guava jar 18.0
org.slf4j : slf4j-api jar 1.7.12

Project Modules

There are no modules declared in this project.

A Collection of rx related libraries

rxjava-test-dsl

Overview

Rx is great, but testing your awesome sequences can be pain

rx-test aims to provide a simple, extensible DSL to enable easier, more declarative rx testing

A taster (see the tests for more examples)


   DualSourceScenario<String, Integer, String> testScenario = TestScenario.dualSources();

    testScenario
            .given()
                .theStreamUnderTest((s1, s2) -> s1.zipWith(s2, (z, n) -> z + n))
                .renderer(s -> s)
            .when()
                .theSubscriber().subscribes()
                .source1().emits("a")
                .source2().emits(1)
                .source1().emits("b")
                .source2().emits(2)
                .source1().completes()
            .then()
                .theSubscribers()
                    .eventCount().isEqualTo(2)
                    .renderedStream().isEqualTo("[a1]-[b2]-|");
                                                                       
    SingleSourceScenario<String, List<String>> testScenario = TestScenario.singleSource();

    testScenario
            .given()
            .theStreamUnderTest((source, scheduler) -> source.buffer(10, TimeUnit.SECONDS, scheduler))

            .when()
            .subscriber("s1").subscribes()
            .theSource().emits("1a")
            .theSource().emits("1b")
            .theSource().emits("1c")
            .time().advancesBy(Duration.ofSeconds(11))
            .theSource().emits("2a")
            .theSource().emits("2b")
            .theSource().completes()

            .then()
            .subscriber("s1")
            .eventCount().isEqualTo(2)
            .event(0).isEqualTo(asList("1a", "1b", "1c"))
            .event(1).isEqualTo(asList("2a", "2b"));

rxjava-test-kafka

Overview

An extension to rx-test that allows for the incorporation of kafka publisher/ consumers within the tests

A taster (see the tests for more examples)


    String group = UUID.randomUUID().toString();

    new KafkaSourceScenario<String, String, String>()
            .given()
                .aNewTopic()        // Create a randomly named topic on the fly
                .asyncTimeoutOf(Duration.ofSeconds(10))
                .theStreamUnderTest(topic -> KafkaStream.newBuilder(topic.getName(), group).newMergedStream().map(e -> e.getValue()))
            .when()
                .theSubscriber().subscribes()
                .thePublisher().publishes("1", "1")
                .thePublisher().publishes("2", "2")
                .theSubscriber().waitsForEvents(2)
            .then()
                .theSubscribers().renderedStream().isEqualTo("[1]-[2]");

rxjava-capture

Overview

Work in progress - come back later!

Binaries

Binaries and dependency information for Maven, Ivy, Gradle and others can be found at http://search.maven.org.

Example for Maven:

uk.camsw rxjava-test-dsl x.y.z

Versions

Version
5.0.1
5.0.0
4.1.1
4.1.0
4.0.0
3.0.0