Skip to content

Commit

Permalink
Refactored the integration test to have a small sleep to wait for the…
Browse files Browse the repository at this point in the history
… server to start
  • Loading branch information
bbambozzi committed Feb 6, 2024
1 parent 1deb4e4 commit 7a0dcbb
Showing 1 changed file with 14 additions and 13 deletions.
27 changes: 14 additions & 13 deletions src/test/java/integration/SariDBAndClient/SariDBWithClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,34 @@
import SariDB.db.SariDB;
import client.SariDBClient;
import org.junit.jupiter.api.*;
import org.junit.jupiter.api.parallel.Execution;
import org.junit.jupiter.api.parallel.ExecutionMode;

import java.io.IOException;
import java.net.Socket;
import java.util.concurrent.atomic.AtomicInteger;

import static org.junit.jupiter.api.Assertions.*;

public class SariDBWithClientTest {
private static AtomicInteger count = new AtomicInteger(5759);
@Nested
@DisplayName("When a SariDB client connects to a standalone SariDB instance")
public class ClientQueriesStandaloneSariDB {
SariDBClient client;
private Socket socket;
private SariDB sariDB;

ClientQueriesStandaloneSariDB() throws Exception {
public class setup {
private static SariDBClient client;
private static Socket socket;
private static SariDB sariDB;

@BeforeAll
public static void setup() throws Exception {
int portNumber = count.getAndAdd(1);
sariDB = SariDB
.builder()
.isEmbedded(false)
.reconstruct(false)
.portNumber(5789)
.portNumber(portNumber)
.build();
sariDB.start();
this.socket = new Socket("localhost", 5789);
this.client = new SariDBClient(socket.getInputStream(), socket.getOutputStream());
Thread.sleep(1500);
Thread.sleep(2000); // Wait for server to start.
socket = new Socket("localhost", portNumber);
client = new SariDBClient(socket.getInputStream(), socket.getOutputStream());
}

@Test
Expand Down

0 comments on commit 7a0dcbb

Please sign in to comment.