Merge branch 'master' into story_61
Also got client-server handshake working. Multiple clients can connect and control their own boat. The client's boat has a larger black triangle drawn around it. Probably needs tidying up. Added isClientBoat boolean to VisualiserBoat. WindGenerator is now an interface, implemented by ConstantWindGenerator (useful for testing) and RandomWindGenerator. Added ConstantWindGeneratorTest. RandomWindGenerator was formerly WindGenerator. The WindGenerator is passed in to MockRace. CommandFactory throws a CommandConstructionException if it cannot create a command. MessageSerialiser and MessageDeserialiser correctly terminate on error. Readded VisualiserInput's switch statement in the main loop, pending a refactor. Removed the sleep statement from LobbyController - it was blocking javaFX thread. Lobby.fxml: moved buttons and text input into grid panes, so they don't break when you resize screen. Added some test object creation functions in several test classes (MockRaceTest.createMockRace(), BoatXMLReaderTest.createBoatDataSource(), etc...). #story[1095]
This commit is contained in:
@@ -31,31 +31,40 @@ public class BoatXMLReaderTest {
|
||||
private List<Mark> marks;
|
||||
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
public static BoatDataSource createBoatDataSource() throws InvalidBoatDataException {
|
||||
|
||||
String boatXMLString = null;
|
||||
|
||||
try {
|
||||
boatXMLString = XMLReader.readXMLFileToString("mock/mockXML/boatTest.xml", StandardCharsets.UTF_8);
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail("could not read boat xml file into a string");
|
||||
} catch (TransformerException | XMLReaderException e) {
|
||||
throw new InvalidBoatDataException("Could not read boat XML file into a string.", e);
|
||||
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
|
||||
boatData = new BoatXMLReader(boatXMLString, XMLFileType.Contents);
|
||||
BoatDataSource boatData = new BoatXMLReader(boatXMLString, XMLFileType.Contents);
|
||||
return boatData;
|
||||
|
||||
boats = new ArrayList<>(boatData.getBoats().values());
|
||||
marks = new ArrayList<>(boatData.getMarkerBoats().values());
|
||||
|
||||
} catch (XMLReaderException | InvalidBoatDataException e) {
|
||||
e.printStackTrace();
|
||||
assertTrue(false);
|
||||
} catch (XMLReaderException e) {
|
||||
throw new InvalidBoatDataException("Could not parse boat XML file.", e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Before
|
||||
public void setUp() throws InvalidBoatDataException {
|
||||
|
||||
boatData = createBoatDataSource();
|
||||
|
||||
boats = new ArrayList<>(boatData.getBoats().values());
|
||||
marks = new ArrayList<>(boatData.getMarkerBoats().values());
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -1,5 +1,39 @@
|
||||
package shared.dataInput;
|
||||
|
||||
import shared.enums.XMLFileType;
|
||||
import shared.exceptions.InvalidRaceDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class RaceXMLReaderTest {
|
||||
//TODO
|
||||
|
||||
|
||||
|
||||
public static RaceDataSource createRaceDataSource() throws InvalidRaceDataException {
|
||||
|
||||
String raceXMLString = null;
|
||||
|
||||
try {
|
||||
raceXMLString = XMLReader.readXMLFileToString("mock/mockXML/raceTest.xml", StandardCharsets.UTF_8);
|
||||
|
||||
} catch (TransformerException | XMLReaderException e) {
|
||||
throw new InvalidRaceDataException("Could not read race XML file into a string.", e);
|
||||
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
|
||||
RaceXMLReader raceData = new RaceXMLReader(raceXMLString, XMLFileType.Contents);
|
||||
return raceData;
|
||||
|
||||
|
||||
} catch (XMLReaderException e) {
|
||||
throw new InvalidRaceDataException("Could not parse race XML file.", e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,6 +3,11 @@ package shared.dataInput;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import shared.enums.XMLFileType;
|
||||
import shared.exceptions.InvalidRegattaDataException;
|
||||
import shared.exceptions.XMLReaderException;
|
||||
|
||||
import javax.xml.transform.TransformerException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
@@ -14,6 +19,34 @@ import static org.junit.Assert.fail;
|
||||
public class RegattaXMLReaderTest {
|
||||
private RegattaXMLReader regatta;
|
||||
|
||||
|
||||
public static RegattaDataSource createRegattaDataSource() throws InvalidRegattaDataException {
|
||||
|
||||
String regattaXMLString = null;
|
||||
|
||||
try {
|
||||
regattaXMLString = XMLReader.readXMLFileToString("mock/mockXML/regattaTest.xml", StandardCharsets.UTF_8);
|
||||
|
||||
} catch (TransformerException | XMLReaderException e) {
|
||||
throw new InvalidRegattaDataException("Could not read regatta XML file into a string.", e);
|
||||
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
|
||||
RegattaDataSource raceData = new RegattaXMLReader(regattaXMLString, XMLFileType.Contents);
|
||||
return raceData;
|
||||
|
||||
|
||||
} catch (XMLReaderException e) {
|
||||
throw new InvalidRegattaDataException("Could not parse regatta XML file.", e);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Before
|
||||
public void findFile() {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user