Skip to content

Commit

Permalink
Improved saridb with client integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bbambozzi committed Feb 6, 2024
1 parent 4dbec8c commit 688280e
Showing 1 changed file with 6 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

import SariDB.db.SariDB;
import client.SariDBClient;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.*;

import java.io.IOException;
import java.net.Socket;

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

public class SariDBWithClientTest {
@Nested
Expand All @@ -19,23 +17,22 @@ public class ClientQueriesStandaloneSariDB {
private Socket socket;
private SariDB sariDB;

@BeforeEach
@DisplayName("Sets up correctly")
public void setup() throws Exception {
ClientQueriesStandaloneSariDB() throws IOException {
sariDB = SariDB
.builder()
.isEmbedded(false)
.reconstruct(false)
.portNumber(1338)
.build();
sariDB.start();
Thread.sleep(100);
this.socket = new Socket("localhost", 1338);
this.client = new SariDBClient(socket.getInputStream(), socket.getOutputStream());
}

@Test
@DisplayName("SET commands are registered correctly")
public void shouldSetCorrectly() throws Exception {
assertFalse(sariDB.isEmbedded());
String answer = client.sendSetRequest("one", "one");
assertEquals("OK", answer);
}
Expand Down

0 comments on commit 688280e

Please sign in to comment.