Skip to content

Commit

Permalink
improve KeepaliveTest
Browse files Browse the repository at this point in the history
Signed-off-by: Oleh Dokuka <[email protected]>
  • Loading branch information
OlegDokuka committed Jan 31, 2025
1 parent 6ff8f71 commit 1501c76
Showing 1 changed file with 16 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@
import java.time.Duration;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -29,9 +32,21 @@ public class KeepaliveTest {
private static final Logger LOG = LoggerFactory.getLogger(KeepaliveTest.class);
private static final int PORT = 23200;

private CloseableChannel server;

@BeforeEach
void setUp() {
server = createServer().block();
}

@AfterEach
void tearDown() {
server.dispose();
server.onClose().block();
}

@Test
void keepAliveTest() {
createServer().block();
RSocketClient rsocketClient = createClient();

int expectedCount = 4;
Expand Down Expand Up @@ -64,7 +79,6 @@ void keepAliveTest() {

@Test
void keepAliveTestLazy() {
createServer().block();
Mono<RSocket> rsocketMono = createClientLazy();

int expectedCount = 4;
Expand Down Expand Up @@ -161,21 +175,6 @@ private static Mono<RSocket> createClientLazy() {
.reconnect(reconnectSpec.apply("connector-close"))
.keepAlive(Duration.ofMillis(100L), Duration.ofMillis(900L))
.connect(TcpClientTransport.create(TcpClient.create().host("localhost").port(PORT)));

// RSocketClient client = RSocketClient.from(rsocketMono);

// client
// .source()
// .doOnNext(r -> LOG.info("Got RSocket"))
// .flatMap(RSocket::onClose)
// .doOnError(err -> LOG.error("Error during onClose.", err))
// .retryWhen(reconnectSpec.apply("client-close"))
// .doFirst(() -> LOG.info("Connected on client side."))
// .doOnTerminate(() -> LOG.info("Connection closed on client side."))
// .repeat()
// .subscribe();

// return client;
}

public static class MyServerRsocket implements RSocket {
Expand Down

0 comments on commit 1501c76

Please sign in to comment.