shared.dataInput:
Added shared.enums.XMLFileType, which is used to specify if a string contains a file path or file contents. Updated the XML readers to use it. Testing: Moved the networking tests and resources into racevisionGame module. Moved the remaining tests from visualiser into racevisionGame, and added a few empty tests to implement later.
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
//package seng302.Mock;
|
||||
//
|
||||
//import org.junit.Before;
|
||||
//import org.junit.Test;
|
||||
//
|
||||
//import java.util.HashMap;
|
||||
//import java.util.Map;
|
||||
//
|
||||
//import static org.junit.Assert.assertEquals;
|
||||
//
|
||||
///**
|
||||
// * Created by jjg64 on 21/04/17.
|
||||
// */
|
||||
//public class BoatsXMLTest {
|
||||
// private BoatXMLReader boatXMLReader;
|
||||
//
|
||||
// @Before
|
||||
// public void setup() {
|
||||
// try {
|
||||
// boatXMLReader = new BoatXMLReader("mockXML/boatXML/boatTest.xml", false);
|
||||
// } catch (Exception e) {
|
||||
// e.printStackTrace();
|
||||
// //fail("Cannot find mockXML/raceXML/raceTest.xml in the resources folder");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testInvalidParticipant() {
|
||||
// Map<Integer, StreamedBoat> inputParticipants = new HashMap<>();
|
||||
// inputParticipants.put(420, new StreamedBoat(420));
|
||||
// boatXMLReader.setParticipants(inputParticipants);
|
||||
// boatXMLReader.read();
|
||||
// assertEquals(boatXMLReader.getBoats().size(), 0);
|
||||
// }
|
||||
//
|
||||
// @Test
|
||||
// public void testValidParticipant() {
|
||||
// Map<Integer, StreamedBoat> inputParticipants = new HashMap<>();
|
||||
// inputParticipants.put(101, new StreamedBoat(101));
|
||||
// boatXMLReader.setParticipants(inputParticipants);
|
||||
// boatXMLReader.read();
|
||||
// assertEquals(boatXMLReader.getBoats().size(), 1);
|
||||
// StreamedBoat boat = (StreamedBoat) boatXMLReader.getBoats().get(0);
|
||||
// assertEquals(boat.getSourceID(), 101);
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,26 @@
|
||||
//package seng302.Mock;
|
||||
//
|
||||
//import org.junit.Test;
|
||||
//import org.xml.sax.SAXException;
|
||||
//
|
||||
//import javax.xml.parsers.ParserConfigurationException;
|
||||
//import java.io.IOException;
|
||||
//import java.text.ParseException;
|
||||
//
|
||||
///**
|
||||
// * Created by jjg64 on 1/05/17.
|
||||
// */
|
||||
//public class FailBoatXMLTest {
|
||||
// private final String path = "mockXML/boatXML/";
|
||||
//
|
||||
// @Test(expected = NumberFormatException.class)
|
||||
// public void invalidSourceID() throws SAXException, ParserConfigurationException, ParseException, IOException {
|
||||
// new BoatXMLReader(path + "invalidSourceID.xml");
|
||||
// }
|
||||
//
|
||||
// @Test(expected = NullPointerException.class)
|
||||
// public void insufficientInformation() throws SAXException, ParserConfigurationException, ParseException, IOException {
|
||||
// new BoatXMLReader(path + "insufficientInformation.xml");
|
||||
// }
|
||||
//
|
||||
//}
|
||||
@@ -0,0 +1,5 @@
|
||||
package shared.dataInput;
|
||||
|
||||
public class RaceXMLReaderTest {
|
||||
//TODO
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package shared.dataInput;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
/**
|
||||
* Created by jjg64 on 19/04/17.
|
||||
* Tests RegattaXMLReader
|
||||
*/
|
||||
public class RegattaXMLReaderTest {
|
||||
private RegattaXMLReader regatta;
|
||||
|
||||
@Before
|
||||
public void findFile() {
|
||||
try {
|
||||
regatta = new RegattaXMLReader("mockXML/regattaXML/regattaTest.xml");
|
||||
} catch (Exception e) {
|
||||
fail("Cannot find mockXML/regattaXML/regattaTest.xml in the resources folder");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void correctValuesTest() {
|
||||
assertEquals(regatta.getRegattaID(), 3);
|
||||
assertEquals(regatta.getRegattaName(), "New Zealand Test");
|
||||
assertEquals(regatta.getCourseName(), "North Head");
|
||||
assertEquals(regatta.getCentralLatitude(), -36.82791529, 0.00000001);
|
||||
assertEquals(regatta.getCentralLongitude(), 174.81218919, 0.00000001);
|
||||
assertEquals(regatta.getCentralAltitude(), 0.00, 0.00000001);
|
||||
assertEquals(regatta.getUtcOffset(), 12.0, 0.001);
|
||||
assertEquals(regatta.getMagneticVariation(), 14.1, 0.001);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package shared.dataInput;
|
||||
|
||||
public class XMLReaderTest {
|
||||
//TODO
|
||||
}
|
||||
Reference in New Issue
Block a user