Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adds class check for discarded values
Signed-off-by: OlegDokuka <odokuka@vmware.com>
- Loading branch information
1 parent
5547cb1
commit aaa087b
Showing
4 changed files
with
70 additions
and
12 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
31 changes: 31 additions & 0 deletions
31
rsocket-core/src/test/java/io/rsocket/core/SendUtilsTest.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,31 @@ | ||
package io.rsocket.core; | ||
|
||
import static org.mockito.Mockito.*; | ||
|
||
import io.netty.util.ReferenceCounted; | ||
import java.util.function.Consumer; | ||
import org.junit.jupiter.api.Test; | ||
|
||
public class SendUtilsTest { | ||
|
||
@Test | ||
void droppedElementsConsumerShouldAcceptOtherTypesThanReferenceCounted() { | ||
Consumer value = extractDroppedElementConsumer(); | ||
value.accept(new Object()); | ||
} | ||
|
||
@Test | ||
void droppedElementsConsumerReleaseReference() { | ||
ReferenceCounted referenceCounted = mock(ReferenceCounted.class); | ||
when(referenceCounted.release()).thenReturn(true); | ||
|
||
Consumer value = extractDroppedElementConsumer(); | ||
value.accept(referenceCounted); | ||
|
||
verify(referenceCounted).release(); | ||
} | ||
|
||
private static Consumer<?> extractDroppedElementConsumer() { | ||
return (Consumer<?>) SendUtils.DISCARD_CONTEXT.stream().findAny().get().getValue(); | ||
} | ||
} |