Fixed tests.

This commit is contained in:
Kusal Ekanayake
2017-09-12 16:52:26 +12:00
parent 9dad88e56a
commit ec7ee34305
4 changed files with 36 additions and 19 deletions
@@ -70,4 +70,7 @@ public class ChatHistory extends ScrollPane {
} }
} }
} }
@@ -68,9 +68,11 @@ public class ChatCommandsTest {
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
ie.printStackTrace(); ie.printStackTrace();
} }
mst.terminate();
host = null; host = null;
client = null; client = null;
mst = null; mst = null;
} catch (IOException ioe) { } catch (IOException ioe) {
ioe.printStackTrace(); ioe.printStackTrace();
} }
@@ -86,6 +88,11 @@ public class ChatCommandsTest {
new GameState("localhost"); new GameState("localhost");
mst = new MainServerThread(); mst = new MainServerThread();
host = null; host = null;
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
try { try {
host = new ClientToServerThread("localhost", 4942); host = new ClientToServerThread("localhost", 4942);
} catch (IOException ioe) { } catch (IOException ioe) {
@@ -97,7 +104,7 @@ public class ChatCommandsTest {
ie.printStackTrace(); ie.printStackTrace();
} }
mst.startGame(); mst.startGame();
host.sendChatterMessage("[time_prefix] <name_prefix> >speed 5.0"); host.sendChatterMessage("[time_prefix] <name_prefix> >speed 5");
try { try {
Thread.sleep(100); Thread.sleep(100);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
@@ -106,7 +113,7 @@ public class ChatCommandsTest {
Assert.assertEquals(5.0, GameState.getSpeedMultiplier(), 0.00001); Assert.assertEquals(5.0, GameState.getSpeedMultiplier(), 0.00001);
mst.terminate(); mst.terminate();
try { try {
Thread.sleep(2000); Thread.sleep(200);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
ie.printStackTrace(); ie.printStackTrace();
} }
+6
View File
@@ -5,6 +5,7 @@ import cucumber.api.java.en.Then;
import cucumber.api.java.en.When; import cucumber.api.java.en.When;
import javafx.util.Pair; import javafx.util.Pair;
import org.junit.Assert; import org.junit.Assert;
import seng302.gameServer.GameState;
import seng302.gameServer.MainServerThread; import seng302.gameServer.MainServerThread;
import seng302.model.stream.packets.StreamPacket; import seng302.model.stream.packets.StreamPacket;
import seng302.utilities.StreamParser; import seng302.utilities.StreamParser;
@@ -24,6 +25,11 @@ public class SendChatSteps {
@Given("^There are two games running$") @Given("^There are two games running$")
public void the_are_two_games_running() throws Throwable { public void the_are_two_games_running() throws Throwable {
mst = new MainServerThread(); mst = new MainServerThread();
try {
Thread.sleep(100);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
host = new ClientToServerThread("localhost", 4942); host = new ClientToServerThread("localhost", 4942);
try { try {
Thread.sleep(100); Thread.sleep(100);
+18 -17
View File
@@ -23,31 +23,32 @@ public class ToggleSailSteps {
@Given("^The game is running$") @Given("^The game is running$")
public void the_game_is_running() throws Throwable { public void the_game_is_running() throws Throwable {
// mst = new MainServerThread(); mst = new MainServerThread();
// client = new ClientToServerThread("localhost", 4942); client = new ClientToServerThread("localhost", 4942);
// GameState.setCurrentStage(GameStages.RACING); GameState.setCurrentStage(GameStages.RACING);
// Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other
// ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0);
// Assert.assertFalse(yacht.getSailIn()); Assert.assertFalse(yacht.getSailIn());
} }
@When("^the user has pressed \"([^\"]*)\"$") @When("^the user has pressed \"([^\"]*)\"$")
public void the_user_has_pressed(String arg1) throws Throwable { public void the_user_has_pressed(String arg1) throws Throwable {
// startTime = System.currentTimeMillis(); startTime = System.currentTimeMillis();
// if (arg1 == "shift") { if (arg1 == "shift") {
// client.sendBoatAction(BoatAction.SAILS_IN); client.sendBoatAction(BoatAction.SAILS_IN);
// } }
} }
@Then("^the sails are \"([^\"]*)\"$") @Then("^the sails are \"([^\"]*)\"$")
public void the_sails_are(String arg1) throws Throwable { public void the_sails_are(String arg1) throws Throwable {
// Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other Thread.sleep(200); // Sleep needed to help the threads all be up to speed with each other
// ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0); ServerYacht yacht = (new ArrayList<>(GameState.getYachts().values())).get(0);
// if (arg1 == "in") { if (arg1 == "in") {
// Assert.assertTrue(yacht.getSailIn()); Assert.assertTrue(yacht.getSailIn());
// } else { } else {
// Assert.assertFalse(yacht.getSailIn()); Assert.assertFalse(yacht.getSailIn());
// } }
mst.terminate();
} }
} }