10000 Step 3: Testing with StepVerifier · blackbeltcoder/reactive-spring@d6cbccd · GitHub
[go: up one dir, main page]

Skip to content

Commit d6cbccd

Browse files
committed
Step 3: Testing with StepVerifier
1 parent 04b2e4c commit d6cbccd

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright 2017 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package workshop;
17+
18+
import reactor.core.publisher.Flux;
19+
import reactor.core.publisher.Mono;
20+
21+
import java.time.Duration;
22+
import java.util.stream.Stream;
23+
24+
import org.junit.Test;
25+
26+
/**
27+
* Testing reactive sequences.
28+
*
29+
* @author Mark Paluch
30+
*/
31+
public class Step3StepVerifier {
32+
33+
@Test
34+
public void verifyMonoEmission() {
35+
36+
Mono<String> mono = Mono.just("Hello, World").doOnSuccess(System.out::println);
37+
38+
// Use StepVerifier to verify Mono emission
39+
}
40+
41+
@Test
42+
public void verifyFluxEmission() {
43+
44+
Flux<String> flux = Flux.just("Hello", "World").doOnNext(System.out::println);
45+
46+
// Use StepVerifier to verify Flux emission
47+
}
48+
49+
@Test
50+
public void verifyInfiniteStreamEmission() {
51+
52+
Flux<Double> flux = Flux.fromStream(Stream.generate(Math::random)).doOnNext(System.out::println);
53+
54+
// Use StepVerifier to verify Flux emission
55+
}
56+
57+
@Test
58+
public void verifyDelayedEmission() {
59+
60+
Flux<Long> flux = Flux.interval(Duration.ofSeconds(5)).take(10).doOnNext(System.out::println);
61+
62+
// Use StepVerifier to verify Flux emission, not spending 5 seconds per emission
63+
}
64+
}

0 commit comments

Comments
 (0)
0