Delete: unused test

This commit is contained in:
2026-06-12 19:15:55 +02:00
parent 3494581c0e
commit 961d7d9f70
6 changed files with 12 additions and 17 deletions
@@ -69,7 +69,7 @@ public class GameController {
* *
* @return the game model managed by this controller. * @return the game model managed by this controller.
*/ */
public Game getModel() { public synchronized Game getModel() {
return model; return model;
} }
@@ -78,7 +78,7 @@ public class GameController {
* *
* @param model the new game model managed by this controller. * @param model the new game model managed by this controller.
*/ */
public void setModel(Game model) { public synchronized void setModel(Game model) {
this.model = model; this.model = model;
} }
@@ -415,6 +415,8 @@ public class Game implements Serializable {
case 5: case 5:
orderLogicCard=new Order5(playersList); orderLogicCard=new Order5(playersList);
break; break;
default:
throw new IllegalStateException("nPlayers must be 25, got: " + nPlayers);
} }
for(Player player : playersList) for(Player player : playersList)
{ {
@@ -27,6 +27,7 @@ public class RMIClient implements IClient {
/** Scheduler that fires ping() every {@value NetworkConfig#KEEPALIVE_INTERVAL_MS} ms. */ /** Scheduler that fires ping() every {@value NetworkConfig#KEEPALIVE_INTERVAL_MS} ms. */
private ScheduledExecutorService pingSender; private ScheduledExecutorService pingSender;
private ExecutorService executor;
/** /**
* Constructs an RMI client and initializes its connection parameters. * Constructs an RMI client and initializes its connection parameters.
@@ -94,7 +95,7 @@ public class RMIClient implements IClient {
return t; return t;
}); });
ExecutorService executor = Executors.newSingleThreadExecutor(); executor = Executors.newSingleThreadExecutor();
pingSender.scheduleAtFixedRate(() -> { pingSender.scheduleAtFixedRate(() -> {
Future<?> future = executor.submit(() -> { Future<?> future = executor.submit(() -> {
try { try {
@@ -126,6 +127,7 @@ public class RMIClient implements IClient {
if (!running) return; if (!running) return;
running = false; running = false;
if (pingSender != null) pingSender.shutdownNow(); if (pingSender != null) pingSender.shutdownNow();
if (executor != null) executor.shutdownNow();
controller.setModel(null); controller.setModel(null);
controller.setClient(null); controller.setClient(null);
} }
@@ -248,7 +250,8 @@ public class RMIClient implements IClient {
* the keep-alive scheduler. * the keep-alive scheduler.
*/ */
public void notifyDisconnection() { public void notifyDisconnection() {
pingSender.shutdownNow(); if (pingSender != null) pingSender.shutdownNow();
if (executor != null) executor.shutdownNow();
try{ try{
stub.disconnectPlayer(username); stub.disconnectPlayer(username);
} }
@@ -348,7 +348,7 @@ public class RMIServer extends UnicastRemoteObject implements IGameServer {
*/ */
public void disconnectPlayer(String username) { public void disconnectPlayer(String username) {
RMIHeartbeat wd = watchdogs.get(username); RMIHeartbeat wd = watchdogs.get(username);
wd.disconnect(); if (wd != null) wd.disconnect();
} }
@@ -112,6 +112,7 @@ public class ClientHandler implements Runnable {
out.writeObject(event); out.writeObject(event);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
disconnect();
} }
} }
@@ -127,6 +128,7 @@ public class ClientHandler implements Runnable {
out.writeObject(game); out.writeObject(game);
} catch (IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
disconnect();
} }
} }
@@ -1,12 +0,0 @@
package it.polimi.ingsw.gc14;
import junit.framework.TestCase;
import org.junit.jupiter.api.Test;
public class AppTest extends TestCase {
@Test
public void testApp()
{
assertTrue(12+1==13);
}
}