-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1483 from markusdlugi/main
fix: properly remove subscriptions in ReplayOperator
- Loading branch information
Showing
4 changed files
with
58 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
...mentation/src/test/java/io/smallrye/mutiny/operators/multi/replay/ReplayOperatorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package io.smallrye.mutiny.operators.multi.replay; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
|
||
import org.junit.jupiter.api.Test; | ||
|
||
import io.smallrye.mutiny.Multi; | ||
import io.smallrye.mutiny.helpers.test.AssertSubscriber; | ||
|
||
public class ReplayOperatorTest { | ||
|
||
@Test | ||
public void shouldRemoveSubscriptionAfterCompletion() { | ||
// given | ||
var upstream = Multi.createFrom().range(0, 3); | ||
var operator = new ReplayOperator<>(upstream, 3); | ||
|
||
// when | ||
var subscriber = operator.subscribe().withSubscriber(AssertSubscriber.create(3)); | ||
var subscriber2 = operator.subscribe().withSubscriber(AssertSubscriber.create(3)); | ||
|
||
// then | ||
subscriber.assertItems(0, 1, 2).assertCompleted(); | ||
subscriber2.assertItems(0, 1, 2).assertCompleted(); | ||
assertEquals(0, operator.subscriptions.size()); | ||
} | ||
} |