Skip to content

Commit

Permalink
Reenable tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sheikah45 committed Oct 14, 2023
1 parent c88aa46 commit bde9b3b
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/test/java/com/faforever/client/remote/ServerAccessorTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@
import lombok.extern.slf4j.Slf4j;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.io.TempDir;
import org.mockito.ArgumentCaptor;
Expand All @@ -72,7 +71,7 @@
import reactor.core.publisher.Mono;
import reactor.core.publisher.Sinks;
import reactor.netty.DisposableServer;
import reactor.netty.tcp.TcpServer;
import reactor.netty.http.server.HttpServer;
import reactor.test.StepVerifier;

import java.net.InetAddress;
Expand Down Expand Up @@ -102,7 +101,6 @@
import static org.mockito.Mockito.when;

@Slf4j
@Disabled
public class ServerAccessorTest extends ServiceTest {

private static final long TIMEOUT = 5000;
Expand All @@ -112,7 +110,6 @@ public class ServerAccessorTest extends ServiceTest {
@TempDir
public Path tempDirectory;


@Mock
private UidService uidService;
@Mock
Expand Down Expand Up @@ -152,7 +149,7 @@ public void setUp() throws Exception {
startFakeFafLobbyServer();

clientProperties.getServer()
.setUrl(disposableServer.host());
.setUrl("http://%s:%d".formatted(disposableServer.host(), disposableServer.port()));
clientProperties.setUserAgent("downlords-faf-client");

instance = new FafServerAccessor(notificationService, i18n, taskScheduler, tokenRetriever, uidService, eventBus, clientProperties, new FafLobbyClient(objectMapper));
Expand All @@ -173,16 +170,16 @@ private ServerMessage parseServerString(String json) throws JsonProcessingExcept
}

private void startFakeFafLobbyServer() {
this.disposableServer = TcpServer.create()
this.disposableServer = HttpServer.create()
.doOnConnection(connection -> {
log.info("New Client connected to server");
connection.addHandler(new LineEncoder(LineSeparator.UNIX)) // TODO: This is not working. Raise a bug ticket! Workaround below
.addHandler(new LineBasedFrameDecoder(1024 * 1024));
connection.addHandlerFirst(new LineEncoder(LineSeparator.UNIX)) // TODO: This is not working. Raise a bug ticket! Workaround below
.addHandlerLast(new LineBasedFrameDecoder(1024 * 1024));
})
.doOnBound(disposableServer -> log.info("Fake server listening at {} on port {}", disposableServer.host(), disposableServer.port()))
.noSSL()
.host(LOOPBACK_ADDRESS.getHostAddress())
.handle((inbound, outbound) -> {
.route(routes -> routes.ws("/", (inbound, outbound) -> {
Mono<Void> inboundMono = inbound.receive()
.asString(StandardCharsets.UTF_8)
.doOnNext(message -> {
Expand All @@ -196,8 +193,8 @@ private void startFakeFafLobbyServer() {
return message + "\n";
}), StandardCharsets.UTF_8).then();

return inboundMono.mergeWith(outboundMono);
})
return Flux.firstWithSignal(inboundMono, outboundMono);
}))
.bindNow();
}

Expand Down

0 comments on commit bde9b3b

Please sign in to comment.