File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -20,7 +20,24 @@ public void example() {
2020
2121 // 0
2222 }
23+
24+ public void examplePrintCompletion () {
25+ Subject <Integer , Integer > values = ReplaySubject .create ();
26+ values .subscribe (
27+ v -> System .out .println (v ),
28+ e -> System .out .println (e ),
29+ () -> System .out .println ("Completed" )
30+ );
31+ values .onNext (0 );
32+ values .onNext (1 );
33+ values .onCompleted ();
34+ values .onNext (2 );
35+
36+ // 0
37+ // 1
38+ }
2339
40+
2441 //
2542 // Test
2643 //
@@ -40,5 +57,21 @@ public void test() {
4057 tester .assertTerminalEvent ();
4158 tester .assertNoErrors ();
4259 }
60+
61+ @ Test
62+ public void testPrintCompletion () {
63+ TestSubscriber <Integer > tester = new TestSubscriber <Integer >();
64+
65+ Subject <Integer , Integer > values = ReplaySubject .create ();
66+ values .subscribe (tester );
67+ values .onNext (0 );
68+ values .onNext (1 );
69+ values .onCompleted ();
70+ values .onNext (2 );
71+
72+ tester .assertReceivedOnNext (Arrays .asList (0 ,1 ));
73+ tester .assertTerminalEvent ();
74+ tester .assertNoErrors ();
75+ }
4376
4477}
You can’t perform that action at this time.
0 commit comments