Add: First version of a Client-side Networking Service
This commit is contained in:
committed by
Mathis Ginkel
parent
0d8f1ac4f7
commit
e533262c38
@@ -0,0 +1,35 @@
|
||||
package ch.unibas.dmi.dbis.cs108.casono.client.network;
|
||||
|
||||
import ch.unibas.dmi.dbis.cs108.casono.client.chat.Message;
|
||||
import ch.unibas.dmi.dbis.cs108.casono.server.Server;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
|
||||
public class ClientServiceTest {
|
||||
|
||||
Server server = null;
|
||||
private Thread serverThread;
|
||||
|
||||
@BeforeEach
|
||||
public void setUp() {
|
||||
server = new Server(5000);
|
||||
serverThread = new Thread(()-> server.simpleListenLoop());
|
||||
serverThread.start();
|
||||
}
|
||||
@AfterEach
|
||||
public void tearDown() {
|
||||
serverThread.interrupt();
|
||||
}
|
||||
@Test
|
||||
public void testClientService() throws ExecutionException, InterruptedException {
|
||||
ClientService client = new ClientService("localhost", 5000);
|
||||
Future<ArrayList<String>> future = client.sendMessage(new Message("bla", "name"));
|
||||
future.get();
|
||||
client.closeSocket();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user