Search in sources :

Example 26 with TestLogger

use of reactor.test.util.TestLogger in project reactor-core by reactor.

the class FluxZipTest method failDoubleErrorHide.

// FIXME use Violation.NO_CLEANUP_ON_TERMINATE
@Test
public void failDoubleErrorHide() {
    TestLogger testLogger = new TestLogger();
    LoggerUtils.enableCaptureWith(testLogger);
    try {
        StepVerifier.create(Flux.zip(obj -> 0, Flux.just(1).hide(), Flux.never(), s -> {
            s.onSubscribe(Operators.emptySubscription());
            s.onError(new Exception("test"));
            s.onError(new Exception("test2"));
        })).verifyErrorMessage("test");
        Assertions.assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains("test2");
    } finally {
        LoggerUtils.disableCapture();
    }
}
Also used : TestLogger(reactor.test.util.TestLogger) FluxOperatorTest(reactor.test.publisher.FluxOperatorTest) Test(org.junit.jupiter.api.Test)

Example 27 with TestLogger

use of reactor.test.util.TestLogger in project reactor-core by reactor.

the class LambdaMonoSubscriberTest method noErrorHookThrowsCallbackNotImplemented.

@Test
public void noErrorHookThrowsCallbackNotImplemented() {
    TestLogger testLogger = new TestLogger();
    LoggerUtils.enableCaptureWith(testLogger);
    try {
        RuntimeException boom = new IllegalArgumentException("boom");
        Mono.error(boom).subscribe(v -> {
        });
        assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains("reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalArgumentException: boom");
    } finally {
        LoggerUtils.disableCapture();
    }
}
Also used : TestLogger(reactor.test.util.TestLogger) Test(org.junit.jupiter.api.Test)

Example 28 with TestLogger

use of reactor.test.util.TestLogger in project reactor-core by reactor.

the class BaseSubscriberTest method finallyExecutesWhenHookOnErrorFails.

@Test
public void finallyExecutesWhenHookOnErrorFails() {
    TestLogger testLogger = new TestLogger();
    LoggerUtils.enableCaptureWith(testLogger);
    try {
        RuntimeException error = new IllegalArgumentException("hookOnError");
        AtomicReference<SignalType> checkFinally = new AtomicReference<>();
        Flux.<String>error(new IllegalStateException("someError")).subscribe(new BaseSubscriber<String>() {

            @Override
            protected void hookOnSubscribe(Subscription subscription) {
                requestUnbounded();
            }

            @Override
            protected void hookOnNext(String value) {
            }

            @Override
            protected void hookOnError(Throwable throwable) {
                throw error;
            }

            @Override
            protected void hookFinally(SignalType type) {
                checkFinally.set(type);
            }
        });
        Assertions.assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains(error.getMessage());
        assertThat(checkFinally).hasValue(SignalType.ON_ERROR);
    } finally {
        LoggerUtils.disableCapture();
    }
}
Also used : AtomicReference(java.util.concurrent.atomic.AtomicReference) Subscription(org.reactivestreams.Subscription) TestLogger(reactor.test.util.TestLogger) Test(org.junit.jupiter.api.Test)

Example 29 with TestLogger

use of reactor.test.util.TestLogger in project reactor-core by reactor.

the class BaseSubscriberTest method onErrorCallbackNotImplemented.

@Test
public void onErrorCallbackNotImplemented() {
    TestLogger testLogger = new TestLogger();
    LoggerUtils.enableCaptureWith(testLogger);
    try {
        Flux<String> flux = Flux.error(new IllegalStateException());
        flux.subscribe(new BaseSubscriber<String>() {

            @Override
            protected void hookOnSubscribe(Subscription subscription) {
                request(1);
            }

            @Override
            protected void hookOnNext(String value) {
            // NO-OP
            }
        });
        Assertions.assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains("reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.IllegalStateException");
    } finally {
        LoggerUtils.disableCapture();
    }
}
Also used : Subscription(org.reactivestreams.Subscription) TestLogger(reactor.test.util.TestLogger) Test(org.junit.jupiter.api.Test)

Example 30 with TestLogger

use of reactor.test.util.TestLogger in project reactor-core by reactor.

the class MonoPeekTest method testErrorWithDoOnSuccess.

@Test
public void testErrorWithDoOnSuccess() {
    TestLogger testLogger = new TestLogger();
    LoggerUtils.enableCaptureWith(testLogger);
    try {
        Mono.error(new NullPointerException("boom")).doOnSuccess(aValue -> {
        }).subscribe();
        Assertions.assertThat(testLogger.getErrContent()).contains("Operator called default onErrorDropped").contains("reactor.core.Exceptions$ErrorCallbackNotImplemented: java.lang.NullPointerException: boom");
    } finally {
        LoggerUtils.disableCapture();
    }
}
Also used : Test(org.junit.jupiter.api.Test) StepVerifier(reactor.test.StepVerifier) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) LoggerUtils(reactor.test.util.LoggerUtils) Scannable(reactor.core.Scannable) Subscription(org.reactivestreams.Subscription) TestLogger(reactor.test.util.TestLogger) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) Assertions.assertThatExceptionOfType(org.assertj.core.api.Assertions.assertThatExceptionOfType) Assertions(org.assertj.core.api.Assertions) AtomicReference(java.util.concurrent.atomic.AtomicReference) TestLogger(reactor.test.util.TestLogger) Test(org.junit.jupiter.api.Test)

Aggregations

TestLogger (reactor.test.util.TestLogger)39 Test (org.junit.jupiter.api.Test)38 AtomicReference (java.util.concurrent.atomic.AtomicReference)13 Subscription (org.reactivestreams.Subscription)12 Assertions.assertThat (org.assertj.core.api.Assertions.assertThat)10 StepVerifier (reactor.test.StepVerifier)10 CountDownLatch (java.util.concurrent.CountDownLatch)9 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)9 CoreSubscriber (reactor.core.CoreSubscriber)9 Fuseable (reactor.core.Fuseable)9 Duration (java.time.Duration)8 TimeUnit (java.util.concurrent.TimeUnit)8 Function (java.util.function.Function)8 Awaitility (org.awaitility.Awaitility)8 Publisher (org.reactivestreams.Publisher)8 TestPublisher (reactor.test.publisher.TestPublisher)8 Loggers (reactor.util.Loggers)8 Context (reactor.util.context.Context)8 LongAdder (java.util.concurrent.atomic.LongAdder)7 FluxOperatorTest (reactor.test.publisher.FluxOperatorTest)7