Search in sources :

Example 1 with ParameterizedTestWithName

use of reactor.test.ParameterizedTestWithName in project reactor-core by reactor.

the class FluxOnAssemblyTest method checkpointWithDescriptionIsLightForParallel.

@ParameterizedTestWithName
@ValueSource(booleans = { false, true })
void checkpointWithDescriptionIsLightForParallel(boolean debugModeOn) {
    if (debugModeOn) {
        Hooks.onOperatorDebug();
    }
    StringWriter sw = new StringWriter();
    Flux<Integer> tested = Flux.range(1, 10).parallel(2).transformGroups(g -> g.map(i -> (Integer) null)).checkpoint("light").sequential().doOnError(t -> t.printStackTrace(new PrintWriter(sw)));
    StepVerifier.create(tested).verifyError();
    String debugStack = sw.toString();
    if (debugModeOn) {
        // the traceback "error has been observed" contains both individual ops and light checkpoint,
        // assembly points to map, with no description
        assertThat(debugStack).contains("Assembly trace from producer [reactor.core.publisher.FluxMap] :").contains("*__ParallelFlux.transformGroups ⇢ at reactor.core.publisher.FluxOnAssemblyTest.checkpointWithDescriptionIsLightForParallel(").contains("checkpoint ⇢ light");
    } else {
        // the traceback "error has been observed" only contains the light checkpoint,
        // assembly is not present
        assertThat(debugStack).doesNotContain("Assembly trace from producer").contains("checkpoint ⇢ light").doesNotContain("ParallelFlux.transformGroups ⇢ at");
    }
}
Also used : Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Retry(reactor.util.retry.Retry) InstanceOfAssertFactories(org.assertj.core.api.InstanceOfAssertFactories) Scannable(reactor.core.Scannable) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot) CoreSubscriber(reactor.core.CoreSubscriber) Duration(java.time.Duration) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) PrintWriter(java.io.PrintWriter) ValueSource(org.junit.jupiter.params.provider.ValueSource) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) Iterator(java.util.Iterator) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName) StringWriter(java.io.StringWriter) Publisher(org.reactivestreams.Publisher) IOException(java.io.IOException) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) Stream(java.util.stream.Stream) Subscription(org.reactivestreams.Subscription) Exceptions(reactor.core.Exceptions) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName)

Example 2 with ParameterizedTestWithName

use of reactor.test.ParameterizedTestWithName in project reactor-core by reactor.

the class FluxOnAssemblyTest method checkpointEmptyForMono.

@ParameterizedTestWithName
@ValueSource(booleans = { false, true })
void checkpointEmptyForMono(boolean debugModeOn) {
    if (debugModeOn) {
        Hooks.onOperatorDebug();
    }
    StringWriter sw = new StringWriter();
    Mono<Object> tested = Mono.just(1).map(i -> null).filter(Objects::nonNull).checkpoint().doOnError(t -> t.printStackTrace(new PrintWriter(sw)));
    StepVerifier.create(tested).verifyError();
    String debugStack = sw.toString();
    if (debugModeOn) {
        // the traceback "error has been observed" contains both individual ops and checkpoint,
        // assembly points to map
        assertThat(debugStack).contains("Assembly trace from producer [reactor.core.publisher.MonoMap] :").contains("Mono.filter ⇢ at reactor.core.publisher.FluxOnAssemblyTest.checkpointEmptyForMono(").contains("checkpoint() ⇢ at reactor.core.publisher.FluxOnAssemblyTest.checkpointEmptyForMono(");
    } else {
        // the traceback "error has been observed" only contains the checkpoint, with callsite,
        // assembly points to filter
        assertThat(debugStack).contains("Assembly trace from producer [reactor.core.publisher.MonoFilterFuseable] :").contains("checkpoint() ⇢ at reactor.core.publisher.FluxOnAssemblyTest.checkpointEmptyForMono(").doesNotContain("Mono.filter ⇢ at");
    }
}
Also used : Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Retry(reactor.util.retry.Retry) InstanceOfAssertFactories(org.assertj.core.api.InstanceOfAssertFactories) Scannable(reactor.core.Scannable) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot) CoreSubscriber(reactor.core.CoreSubscriber) Duration(java.time.Duration) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) PrintWriter(java.io.PrintWriter) ValueSource(org.junit.jupiter.params.provider.ValueSource) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) Iterator(java.util.Iterator) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName) StringWriter(java.io.StringWriter) Publisher(org.reactivestreams.Publisher) IOException(java.io.IOException) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) Stream(java.util.stream.Stream) Subscription(org.reactivestreams.Subscription) Exceptions(reactor.core.Exceptions) StringWriter(java.io.StringWriter) Objects(java.util.Objects) PrintWriter(java.io.PrintWriter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName)

Example 3 with ParameterizedTestWithName

use of reactor.test.ParameterizedTestWithName in project reactor-core by reactor.

the class FluxOnAssemblyTest method checkpointWithDescriptionIsLightForMono.

@ParameterizedTestWithName
@ValueSource(booleans = { false, true })
void checkpointWithDescriptionIsLightForMono(boolean debugModeOn) {
    if (debugModeOn) {
        Hooks.onOperatorDebug();
    }
    StringWriter sw = new StringWriter();
    Mono<Object> tested = Mono.just(1).map(i -> null).filter(Objects::nonNull).checkpoint("light").doOnError(t -> t.printStackTrace(new PrintWriter(sw)));
    StepVerifier.create(tested).verifyError();
    String debugStack = sw.toString();
    if (debugModeOn) {
        // the traceback "error has been observed" contains both individual ops and light checkpoint,
        // assembly points to map, with no description
        assertThat(debugStack).contains("Assembly trace from producer [reactor.core.publisher.MonoMap] :").contains("Mono.filter ⇢ at reactor.core.publisher.FluxOnAssemblyTest.checkpointWithDescriptionIsLightForMono(").contains("checkpoint ⇢ light");
    } else {
        // the traceback "error has been observed" only contains the light checkpoint,
        // assembly is not present
        assertThat(debugStack).doesNotContain("Assembly trace from producer").contains("checkpoint ⇢ light").doesNotContain("Mono.filter ⇢ at");
    }
}
Also used : Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Retry(reactor.util.retry.Retry) InstanceOfAssertFactories(org.assertj.core.api.InstanceOfAssertFactories) Scannable(reactor.core.Scannable) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot) CoreSubscriber(reactor.core.CoreSubscriber) Duration(java.time.Duration) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) PrintWriter(java.io.PrintWriter) ValueSource(org.junit.jupiter.params.provider.ValueSource) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) Iterator(java.util.Iterator) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName) StringWriter(java.io.StringWriter) Publisher(org.reactivestreams.Publisher) IOException(java.io.IOException) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) Stream(java.util.stream.Stream) Subscription(org.reactivestreams.Subscription) Exceptions(reactor.core.Exceptions) StringWriter(java.io.StringWriter) Objects(java.util.Objects) PrintWriter(java.io.PrintWriter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName)

Example 4 with ParameterizedTestWithName

use of reactor.test.ParameterizedTestWithName in project reactor-core by reactor.

the class FluxOnAssemblyTest method checkpointEmptyForParallel.

@ParameterizedTestWithName
@ValueSource(booleans = { false, true })
void checkpointEmptyForParallel(boolean debugModeOn) {
    if (debugModeOn) {
        Hooks.onOperatorDebug();
    }
    StringWriter sw = new StringWriter();
    Flux<Integer> tested = Flux.range(1, 10).parallel(2).transformGroups(g -> g.map(i -> (Integer) null)).checkpoint().sequential().doOnError(t -> t.printStackTrace(new PrintWriter(sw)));
    StepVerifier.create(tested).verifyError();
    String debugStack = sw.toString();
    if (debugModeOn) {
        // the traceback "error has been observed" contains both individual ops and checkpoint,
        // assembly points to map
        assertThat(debugStack).contains("Assembly trace from producer [reactor.core.publisher.FluxMap] :").contains("*__ParallelFlux.transformGroups ⇢ at reactor.core.publisher.FluxOnAssemblyTest.checkpointEmptyForParallel(").contains("checkpoint() ⇢ at reactor.core.publisher.FluxOnAssemblyTest.checkpointEmptyForParallel(");
    } else {
        // the traceback "error has been observed" only contains the checkpoint, with callsite,
        // assembly points to parallelSource
        assertThat(debugStack).contains("Assembly trace from producer [reactor.core.publisher.ParallelSource] :").contains("checkpoint() ⇢ at reactor.core.publisher.FluxOnAssemblyTest.checkpointEmptyForParallel(").doesNotContain("ParallelFlux.transformGroups ⇢ at");
    }
}
Also used : Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Retry(reactor.util.retry.Retry) InstanceOfAssertFactories(org.assertj.core.api.InstanceOfAssertFactories) Scannable(reactor.core.Scannable) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot) CoreSubscriber(reactor.core.CoreSubscriber) Duration(java.time.Duration) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) PrintWriter(java.io.PrintWriter) ValueSource(org.junit.jupiter.params.provider.ValueSource) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) Iterator(java.util.Iterator) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName) StringWriter(java.io.StringWriter) Publisher(org.reactivestreams.Publisher) IOException(java.io.IOException) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) Stream(java.util.stream.Stream) Subscription(org.reactivestreams.Subscription) Exceptions(reactor.core.Exceptions) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName)

Example 5 with ParameterizedTestWithName

use of reactor.test.ParameterizedTestWithName in project reactor-core by reactor.

the class FluxOnAssemblyTest method checkpointEmpty.

@ParameterizedTestWithName
@ValueSource(booleans = { false, true })
void checkpointEmpty(boolean debugModeOn) {
    if (debugModeOn) {
        Hooks.onOperatorDebug();
    }
    StringWriter sw = new StringWriter();
    Flux<Integer> tested = Flux.range(1, 10).map(i -> i < 3 ? i : null).filter(i -> i % 2 == 0).checkpoint().doOnError(t -> t.printStackTrace(new PrintWriter(sw)));
    StepVerifier.create(tested).expectNext(2).verifyError();
    String debugStack = sw.toString();
    if (debugModeOn) {
        // the traceback "error has been observed" contains both individual ops and checkpoint,
        // assembly points to map
        assertThat(debugStack).contains("Assembly trace from producer [reactor.core.publisher.FluxMapFuseable] :").contains("Flux.filter ⇢ at reactor.core.publisher.FluxOnAssemblyTest.checkpointEmpty(").contains("checkpoint() ⇢ at reactor.core.publisher.FluxOnAssemblyTest.checkpointEmpty(");
    } else {
        // the traceback "error has been observed" only contains the checkpoint, with callsite,
        // assembly points to filter
        assertThat(debugStack).contains("Assembly trace from producer [reactor.core.publisher.FluxFilterFuseable] :").contains("checkpoint() ⇢ at reactor.core.publisher.FluxOnAssemblyTest.checkpointEmpty(").doesNotContain("Flux.filter ⇢ at");
    }
}
Also used : Arrays(java.util.Arrays) StepVerifier(reactor.test.StepVerifier) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Retry(reactor.util.retry.Retry) InstanceOfAssertFactories(org.assertj.core.api.InstanceOfAssertFactories) Scannable(reactor.core.Scannable) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) AssemblySnapshot(reactor.core.publisher.FluxOnAssembly.AssemblySnapshot) CoreSubscriber(reactor.core.CoreSubscriber) Duration(java.time.Duration) ObjectOutputStream(java.io.ObjectOutputStream) OutputStream(java.io.OutputStream) PrintWriter(java.io.PrintWriter) ValueSource(org.junit.jupiter.params.provider.ValueSource) Assertions.assertThatIllegalStateException(org.assertj.core.api.Assertions.assertThatIllegalStateException) Iterator(java.util.Iterator) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName) StringWriter(java.io.StringWriter) Publisher(org.reactivestreams.Publisher) IOException(java.io.IOException) Objects(java.util.Objects) Test(org.junit.jupiter.api.Test) Stream(java.util.stream.Stream) Subscription(org.reactivestreams.Subscription) Exceptions(reactor.core.Exceptions) StringWriter(java.io.StringWriter) PrintWriter(java.io.PrintWriter) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTestWithName(reactor.test.ParameterizedTestWithName)

Aggregations

ParameterizedTestWithName (reactor.test.ParameterizedTestWithName)29 Test (org.junit.jupiter.api.Test)28 Subscription (org.reactivestreams.Subscription)25 StepVerifier (reactor.test.StepVerifier)25 Stream (java.util.stream.Stream)24 CoreSubscriber (reactor.core.CoreSubscriber)24 Exceptions (reactor.core.Exceptions)21 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)20 Scannable (reactor.core.Scannable)20 Arrays (java.util.Arrays)18 AtomicReference (java.util.concurrent.atomic.AtomicReference)17 Context (reactor.util.context.Context)17 Duration (java.time.Duration)15 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)15 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)14 Function (java.util.function.Function)14 Arguments (org.junit.jupiter.params.provider.Arguments)14 Arguments.arguments (org.junit.jupiter.params.provider.Arguments.arguments)14 MethodSource (org.junit.jupiter.params.provider.MethodSource)14 Publisher (org.reactivestreams.Publisher)14