The Git road along this issue
Flux suscribe(Consumer <? super String>consumer)
Running this Test
17:38:54.700 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
Elemento1
Elemento2
Elemento3
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
05:38:54 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxTest"'.
Flux
suscribe(Consumer <? super String> consumer, Consumer <? super Throwable> errorConsumer)
class FluxMonoTest { @Test
void fluxTest() { Flux<String> fluxString = Flux.just("Elemento1", "Elemento2", "Elemento3") .concatWith( Flux.error( new RuntimeException("Exception generated voluntarily")));
fluxString.subscribe(System.out::println, ex -> System.err.println(ex));
}
}
Running this Test
17:47:38.429 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
Elemento1
Elemento2
Elemento3
java.lang.RuntimeException: Exception generated voluntarily
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 3s
5 actionable tasks: 3 executed, 2 up-to-date
05:47:38 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxTest"'.
Flux
suscribe(Consumer <? super String> consumer, Consumer <? super Throwable> errorConsumer)
class FluxMonoTest { @Test
void fluxTest() { Flux<String> fluxString = Flux.just("Elemento1", "Elemento2", "Elemento3") .concatWith( Flux.error( new RuntimeException("Exception generated voluntarily")));
fluxString.subscribe(System.out::println, System.err::println);
} }
Running this test
17:51:06.333 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
Elemento1
Elemento2
Elemento3
java.lang.RuntimeException: Exception generated voluntarily
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
05:51:06 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxTest"'.
Add .Log()
class FluxMonoTest { @Test
void fluxTest() { Flux<String> fluxString = Flux.just("Elemento1", "Elemento2", "Elemento3") .concatWith( Flux.error( new RuntimeException("Exception generated voluntarily"))) .log();
fluxString.subscribe(System.out::println, System.err::println);
} }
Running this test
17:58:56.906 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
17:58:56.918 [Test worker] INFO reactor.Flux.ConcatArray.1 - onSubscribe(FluxConcatArray.ConcatArraySubscriber)
17:58:56.920 [Test worker] INFO reactor.Flux.ConcatArray.1 - request(unbounded)
17:58:56.921 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento1)
Elemento1
17:58:56.921 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento2)
Elemento2
17:58:56.921 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento3)
Elemento3
17:58:56.922 [Test worker] ERROR reactor.Flux.ConcatArray.1 - onError(java.lang.RuntimeException: Exception generated voluntarily)
17:58:56.926 [Test worker] ERROR reactor.Flux.ConcatArray.1 -
java.lang.RuntimeException: Exception generated voluntarily
at com.bext.fluxmonoroad.FluxMonoTest.fluxTest(FluxMonoTest.java:10)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at ....
.... java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:834)
java.lang.RuntimeException: Exception generated voluntarily
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
05:58:57 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxTest"'.
concatWith( Flux.just("...")....concatWith( Flux.just() ... if Exception flux stopped
class FluxMonoTest { @Test
void fluxTest() { Flux<String> fluxString = Flux.just("Elemento1", "Elemento2", "Elemento3") .concatWith( Flux.just("Esto se Mostrara")) .concatWith( Flux.error( new RuntimeException("Exception generated voluntarily"))) .concatWith( Flux.just("Esto NO se Mostara")) .log();
fluxString.subscribe(System.out::println, ex ->System.err.println("El error es :" + ex));
}
}
Run this test
18:07:26.059 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:07:26.071 [Test worker] INFO reactor.Flux.ConcatArray.1 - onSubscribe(FluxConcatArray.ConcatArraySubscriber)
18:07:26.074 [Test worker] INFO reactor.Flux.ConcatArray.1 - request(unbounded)
18:07:26.075 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento1)
Elemento1
18:07:26.075 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento2)
Elemento2
18:07:26.076 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento3)
Elemento3
18:07:26.076 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Esto se Mostrara)
Esto se Mostrara
18:07:26.077 [Test worker] ERROR reactor.Flux.ConcatArray.1 - onError(java.lang.RuntimeException: Exception generated voluntarily)
18:07:26.080 [Test worker] ERROR reactor.Flux.ConcatArray.1 -
java.lang.RuntimeException: Exception generated voluntarily
at com.bext.fluxmonoroad.FluxMonoTest.fluxTest(FluxMonoTest.java:11)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at ... at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:834)
El error es :java.lang.RuntimeException: Exception generated voluntarily
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
06:07:26 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxTest"'.
If Exception, flux stopped, also in subscribe(Consumer...,...errorConsumer, Runnable)
class FluxMonoTest { @Test
void fluxTest() { Flux<String> fluxString = Flux.just("Elemento1", "Elemento2", "Elemento3") .concatWith( Flux.just("Esto se Mostrara")) .concatWith( Flux.error( new RuntimeException("Exception generated voluntarily"))) .concatWith( Flux.just("Esto NO se Mostara")) .log();
fluxString.subscribe(System.out::println,
ex -> System.err.println("El error es :" + ex),
() -> System.out.println("Completado"));
} }
Running this test
18:13:05.861 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:13:05.872 [Test worker] INFO reactor.Flux.ConcatArray.1 - onSubscribe(FluxConcatArray.ConcatArraySubscriber)
18:13:05.874 [Test worker] INFO reactor.Flux.ConcatArray.1 - request(unbounded)
18:13:05.875 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento1)
Elemento1
18:13:05.875 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento2)
Elemento2
18:13:05.875 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento3)
Elemento3
18:13:05.876 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Esto se Mostrara)
Esto se Mostrara
18:13:05.877 [Test worker] ERROR reactor.Flux.ConcatArray.1 - onError(java.lang.RuntimeException: Exception generated voluntarily)
18:13:05.879 [Test worker] ERROR reactor.Flux.ConcatArray.1 -
java.lang.RuntimeException: Exception generated voluntarily
at com.bext.fluxmonoroad.FluxMonoTest.fluxTest(FluxMonoTest.java:11)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at ....
org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:834)
El error es :java.lang.RuntimeException: Exception generated voluntarily
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 3s
5 actionable tasks: 3 executed, 2 up-to-date
06:13:06 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxTest"'.
Exception is suprimed, then all the Flux is showed including in subscribe(.... Runnable)
class FluxMonoTest { @Test
void fluxTest() { Flux<String> fluxString = Flux.just("Elemento1", "Elemento2", "Elemento3") .concatWith( Flux.just("Esto se Mostrara")) //.concatWith( Flux.error( new RuntimeException("Exception generated voluntarily")))
.concatWith( Flux.just("Esto NO se Mostara, Se muestra ya no hay exception")) .log();
fluxString.subscribe(System.out::println,
ex -> System.err.println("El error es :" + ex),
() -> System.out.println("Completado"));
}
}
Running this Test
18:17:18.160 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:17:18.171 [Test worker] INFO reactor.Flux.ConcatArray.1 - onSubscribe(FluxConcatArray.ConcatArraySubscriber)
18:17:18.173 [Test worker] INFO reactor.Flux.ConcatArray.1 - request(unbounded)
18:17:18.174 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento1)
Elemento1
18:17:18.174 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento2)
Elemento2
18:17:18.174 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento3)
Elemento3
18:17:18.175 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Esto se Mostrara)
Esto se Mostrara
18:17:18.175 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Esto NO se Mostara, Se muestra ya no hay exception)
Esto NO se Mostara, Se muestra ya no hay exception
18:17:18.175 [Test worker] INFO reactor.Flux.ConcatArray.1 - onComplete()
Completado
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
06:17:18 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxTest"'.
JUnit Test .expectedNext("ElementX") ... verifyComplete()
@Test
void fluxElements_WithoutError(){ Flux<String> fluxString = Flux.just("Elemento1","Elemento2","Elemento3") .log();
StepVerifier.create( fluxString) .expectNext("Elemento1") .expectNext("Elemento2") .expectNext("Elemento3") .verifyComplete();
}
Running this test
18:24:27.641 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:24:27.672 [Test worker] INFO reactor.Flux.Array.1 - | onSubscribe([Synchronous Fuseable] FluxArray.ArraySubscription)
18:24:27.676 [Test worker] INFO reactor.Flux.Array.1 - | request(unbounded)
18:24:27.676 [Test worker] INFO reactor.Flux.Array.1 - | onNext(Elemento1)
18:24:27.676 [Test worker] INFO reactor.Flux.Array.1 - | onNext(Elemento2)
18:24:27.676 [Test worker] INFO reactor.Flux.Array.1 - | onNext(Elemento3)
18:24:27.677 [Test worker] INFO reactor.Flux.Array.1 - | onComplete()
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
06:24:27 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxElements_WithoutError"'.
JUnit Test Not Passed elements not in order expected
@Test
void fluxElements_WithoutError(){ Flux<String> fluxString = Flux.just("Elemento1","Elemento2","Elemento3") .log();
StepVerifier.create( fluxString) .expectNext("Elemento3") .expectNext("Elemento2") .expectNext("Elemento1") .verifyComplete();
}
Running this test
18:25:20.284 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:25:20.305 [Test worker] INFO reactor.Flux.Array.1 - | onSubscribe([Synchronous Fuseable] FluxArray.ArraySubscription)
18:25:20.307 [Test worker] INFO reactor.Flux.Array.1 - | request(unbounded)
18:25:20.308 [Test worker] INFO reactor.Flux.Array.1 - | onNext(Elemento1)
18:25:20.311 [Test worker] INFO reactor.Flux.Array.1 - | cancel()
expectation "expectNext(Elemento3)" failed (expected value: Elemento3; actual value: Elemento1)
java.lang.AssertionError: expectation "expectNext(Elemento3)" failed (expected value: Elemento3; actual value: Elemento1)
at reactor.test.MessageFormatter.assertionError(MessageFormatter.java:115)
at reactor.test.MessageFormatter.failPrefix(MessageFormatter.java:104)
at reactor.test.MessageFormatter.fail(MessageFormatter.java:73)
at reactor.test.MessageFormatter.failOptional(MessageFormatter.java:88)
at.......org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:834)
com.bext.fluxmonoroad.FluxMonoTest > fluxElements_WithoutError() FAILED
java.lang.AssertionError at FluxMonoTest.java:29
1 test completed, 1 failed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///D:/proy/roadReactiveSpring/build/reports/tests/test/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 3s
5 actionable tasks: 3 executed, 2 up-to-date
JUnit Test, StepVerifier without .verifyComplete dont is executed at all, (Lazy execution)
@Test
void fluxElements_WithoutError(){ Flux<String> fluxString = Flux.just("Elemento1","Elemento2","Elemento3") .log();
StepVerifier.create( fluxString) .expectNext("Elemento1") .expectNext("Elemento2") .expectNext("Elemento3");
//.verifyComplete();
}
Running this Test
18:30:32.775 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
06:30:32 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxElements_WithoutError"'.
JUnit Test, RuntimeException .verifyComplete() Dont Pass
@Test
void fluxElements_WithError(){ Flux<String> fluxString = Flux.just("Elemento1","Elemento2","Elemento3") .concatWith( Flux.error( new RuntimeException("Exception generated voluntarily"))) .log();
StepVerifier.create( fluxString) .expectNext("Elemento1") .expectNext("Elemento2") .expectNext("Elemento3") .verifyComplete();
}
Running this test
18:34:43.775 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:34:43.795 [Test worker] INFO reactor.Flux.ConcatArray.1 - onSubscribe(FluxConcatArray.ConcatArraySubscriber)
18:34:43.798 [Test worker] INFO reactor.Flux.ConcatArray.1 - request(unbounded)
18:34:43.799 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento1)
18:34:43.799 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento2)
18:34:43.799 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento3)
18:34:43.800 [Test worker] ERROR reactor.Flux.ConcatArray.1 - onError(java.lang.RuntimeException: Exception generated voluntarily)
18:34:43.802 [Test worker] ERROR reactor.Flux.ConcatArray.1 -
java.lang.RuntimeException: Exception generated voluntarily
....
com.bext.fluxmonoroad.FluxMonoTest > fluxElements_WithError() FAILED
java.lang.AssertionError at FluxMonoTest.java:41
1 test completed, 1 failed
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':test'.
> There were failing tests. See the report at: file:///D:/proy/roadReactiveSpring/build/reports/tests/test/index.html
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD FAILED in 3s
5 actionable tasks: 3 executed, 2 up-to-date
JUnit Test, RuntimeException .expectError(...).verify(); PASS
@Test
void fluxElements_WithError(){ Flux<String> fluxString = Flux.just("Elemento1","Elemento2","Elemento3") .concatWith( Flux.error( new RuntimeException("Exception generated voluntarily"))) .log();
StepVerifier.create( fluxString) .expectNext("Elemento1") .expectNext("Elemento2") .expectNext("Elemento3") .expectError(RuntimeException.class) .verify();
}
Running this test
18:36:55.313 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:36:55.333 [Test worker] INFO reactor.Flux.ConcatArray.1 - onSubscribe(FluxConcatArray.ConcatArraySubscriber)
18:36:55.336 [Test worker] INFO reactor.Flux.ConcatArray.1 - request(unbounded)
18:36:55.337 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento1)
18:36:55.337 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento2)
18:36:55.337 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento3)
18:36:55.338 [Test worker] ERROR reactor.Flux.ConcatArray.1 - onError(java.lang.RuntimeException: Exception generated voluntarily)
18:36:55.339 [Test worker] ERROR reactor.Flux.ConcatArray.1 -
java.lang.RuntimeException: Exception generated voluntarily
at com.bext.fluxmonoroad.FluxMonoTest.fluxElements_WithError(FluxMonoTest.java:34)
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at ... at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:56)
at java.base/java.lang.Thread.run(Thread.java:834)
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
06:36:55 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxElements_WithError"'.
JUnit Test, RuntimeException .expectErrorMessage("...").verify(); PASS
@Test
void fluxElements_WithError(){ Flux<String> fluxString = Flux.just("Elemento1","Elemento2","Elemento3") .concatWith( Flux.error( new RuntimeException("Exception generated voluntarily"))) .log();
StepVerifier.create( fluxString) .expectNext("Elemento1") .expectNext("Elemento2") .expectNext("Elemento3") .expectErrorMessage("Exception generated voluntarily") .verify();
}
Running this test
18:42:13.106 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:42:13.128 [Test worker] INFO reactor.Flux.ConcatArray.1 - onSubscribe(FluxConcatArray.ConcatArraySubscriber)
18:42:13.131 [Test worker] INFO reactor.Flux.ConcatArray.1 - request(unbounded)
18:42:13.132 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento1)
18:42:13.132 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento2)
18:42:13.132 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento3)
18:42:13.133 [Test worker] ERROR reactor.Flux.ConcatArray.1 - onError(java.lang.RuntimeException: Exception generated voluntarily)
18:42:13.136 [Test worker] ERROR reactor.Flux.ConcatArray.1 -
java.lang.RuntimeException: Exception generated voluntarily
at com.bext.fluxmonoroad.FluxMonoTest.fluxElements_WithError(FluxMonoTest.java:34)
...Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
06:42:13 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxElements_WithError"'.
JUnit Test, .expectNextCount(number) PASS
@Test
void fluxElementsCount_WithError(){ Flux<String> fluxString = Flux.just("Elemento1","Elemento2","Elemento3") .concatWith( Flux.error( new RuntimeException("Exception generated voluntarily"))) .log();
StepVerifier.create( fluxString) .expectNextCount(3) .expectErrorMessage("Exception generated voluntarily") .verify();
}
Running this test
18:44:04.457 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:44:04.477 [Test worker] INFO reactor.Flux.ConcatArray.1 - onSubscribe(FluxConcatArray.ConcatArraySubscriber)
18:44:04.480 [Test worker] INFO reactor.Flux.ConcatArray.1 - request(unbounded)
18:44:04.481 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento1)
18:44:04.482 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento2)
18:44:04.482 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento3)
18:44:04.483 [Test worker] ERROR reactor.Flux.ConcatArray.1 - onError(java.lang.RuntimeException: Exception generated voluntarily)
18:44:04.485 [Test worker] ERROR reactor.Flux.ConcatArray.1 -
java.lang.RuntimeException: Exception generated voluntarily
...
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
06:44:04 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxElementsCount_WithError"'.
JUnit Test, .expectNext(element1, element2,...,elementN) PASS
@Test
void fluxElements_WithError1(){ Flux<String> fluxString = Flux.just("Elemento1","Elemento2","Elemento3") .concatWith( Flux.error( new RuntimeException("Exception generated voluntarily"))) .log();
StepVerifier.create( fluxString) .expectNext("Elemento1","Elemento2","Elemento3") .expectErrorMessage("Exception generated voluntarily") .verify();
}
Running this test
18:48:04.825 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:48:04.848 [Test worker] INFO reactor.Flux.ConcatArray.1 - onSubscribe(FluxConcatArray.ConcatArraySubscriber)
18:48:04.851 [Test worker] INFO reactor.Flux.ConcatArray.1 - request(unbounded)
18:48:04.852 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento1)
18:48:04.852 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento2)
18:48:04.852 [Test worker] INFO reactor.Flux.ConcatArray.1 - onNext(Elemento3)
18:48:04.853 [Test worker] ERROR reactor.Flux.ConcatArray.1 - onError(java.lang.RuntimeException: Exception generated voluntarily)
18:48:04.856 [Test worker] ERROR reactor.Flux.ConcatArray.1 -
java.lang.RuntimeException: Exception generated voluntarily
at com.bext.fluxmonoroad.FluxMonoTest.fluxElements_WithError1(FluxMonoTest.java:58)
....
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
06:48:04 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.fluxElements_WithError1"'.
JUnit Mono Test PASS
@Test
void monoTest(){ Mono<String> monoString = Mono.just("unico"); StepVerifier.create( monoString.log()) .expectNext("unico") .verifyComplete();
}
Running this Test
18:50:05.634 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:50:05.660 [Test worker] INFO reactor.Mono.Just.1 - | onSubscribe([Synchronous Fuseable] Operators.ScalarSubscription)
18:50:05.664 [Test worker] INFO reactor.Mono.Just.1 - | request(unbounded)
18:50:05.664 [Test worker] INFO reactor.Mono.Just.1 - | onNext(unico)
18:50:05.664 [Test worker] INFO reactor.Mono.Just.1 - | onComplete()
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
06:50:05 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.monoTest"'.
JUnit Mono Test with RuntimeException PASS
@Test
void monoTest_WithError(){ StepVerifier.create( Mono.error(new RuntimeException("Exception generated voluntarily")).log()) .expectError(RuntimeException.class) .verify();
}
look at the .log() that permit see all the events between the suscriber an the mono.
Running this Test
18:51:54.761 [Test worker] DEBUG reactor.util.Loggers$LoggerFactory - Using Slf4j logging framework
18:51:54.780 [Test worker] INFO reactor.Mono.Error.1 - onSubscribe([Fuseable] Operators.EmptySubscription)
18:51:54.782 [Test worker] INFO reactor.Mono.Error.1 - request(unbounded)
18:51:54.783 [Test worker] ERROR reactor.Mono.Error.1 - onError(java.lang.RuntimeException: Exception generated voluntarily)
18:51:54.785 [Test worker] ERROR reactor.Mono.Error.1 -
java.lang.RuntimeException: Exception generated voluntarily
...
Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See https://docs.gradle.org/6.0.1/userguide/command_line_interface.html#sec:command_line_warnings
BUILD SUCCESSFUL in 2s
5 actionable tasks: 3 executed, 2 up-to-date
06:51:54 p. m.: Tasks execution finished ':cleanTest :test --tests "com.bext.fluxmonoroad.FluxMonoTest.monoTest_WithError"'.
Ref code with Dilip
eot
No hay comentarios:
Publicar un comentario