mock.app.App now tells mock.app.Event that the xml file strings are XMLFileType.Contents.
Made network.MessageEncoders.RaceVisionByteEncoder methods static (they were effectively static already). shared.dataInput.XMLReader#readXMLFileToString(..) now throws an XMLReaderException if the file cannot be found. visualiser.Controllers.StartController assumed XML messages were resource paths instead of file contents - fixed. Testing: networking tests now work again.
This commit is contained in:
@@ -30,15 +30,15 @@ public class BoatXMLReader extends XMLReader implements BoatDataSource {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for Boat XML using a file read as a resource.
|
||||
* Constructor for Boat XML using a file.
|
||||
*
|
||||
* @param fileContents Contents of xml file.
|
||||
* @param file The file to read.
|
||||
* @param type How to read the file - e.g., load as resource.
|
||||
* @throws XMLReaderException Thrown if the file cannot be parsed.
|
||||
* @throws InvalidBoatDataException Thrown if the file cannot be parsed correctly.
|
||||
*/
|
||||
public BoatXMLReader(String fileContents, XMLFileType type) throws XMLReaderException, InvalidBoatDataException {
|
||||
super(fileContents, type);
|
||||
public BoatXMLReader(String file, XMLFileType type) throws XMLReaderException, InvalidBoatDataException {
|
||||
super(file, type);
|
||||
|
||||
//Attempt to read boat xml file.
|
||||
try {
|
||||
|
||||
@@ -83,14 +83,14 @@ public class RaceXMLReader extends XMLReader implements RaceDataSource {
|
||||
|
||||
/**
|
||||
* Constructor for Streamed Race XML
|
||||
* @param fileContents Contents of xml file.
|
||||
* @param file The file to read.
|
||||
* @param type How to read the file - e.g., load as resource.
|
||||
* @throws XMLReaderException Thrown if an XML reader cannot be constructed for the given file.
|
||||
* @throws InvalidRaceDataException Thrown if the XML file is invalid in some way.
|
||||
*/
|
||||
public RaceXMLReader(String fileContents, XMLFileType type) throws XMLReaderException, InvalidRaceDataException {
|
||||
public RaceXMLReader(String file, XMLFileType type) throws XMLReaderException, InvalidRaceDataException {
|
||||
|
||||
super(fileContents, type);
|
||||
super(file, type);
|
||||
|
||||
|
||||
//Attempt to read race xml file.
|
||||
|
||||
@@ -65,15 +65,15 @@ public class RegattaXMLReader extends XMLReader implements RegattaDataSource {
|
||||
|
||||
|
||||
/**
|
||||
* Constructor for Regatta XML using a file read as a resource.
|
||||
* Constructor for Regatta XML using a file.
|
||||
*
|
||||
* @param fileContents Contents of xml file.
|
||||
* @param file The file.
|
||||
* @param type How to read the file - e.g., load as resource.
|
||||
* @throws XMLReaderException Thrown if the file cannot be parsed.
|
||||
* @throws InvalidRegattaDataException Thrown if the file cannot be parsed correctly.
|
||||
*/
|
||||
public RegattaXMLReader(String fileContents, XMLFileType type) throws XMLReaderException, InvalidRegattaDataException {
|
||||
super(fileContents, type);
|
||||
public RegattaXMLReader(String file, XMLFileType type) throws XMLReaderException, InvalidRegattaDataException {
|
||||
super(file, type);
|
||||
|
||||
//Attempt to read boat xml file.
|
||||
try {
|
||||
|
||||
@@ -173,6 +173,11 @@ public abstract class XMLReader {
|
||||
|
||||
InputStream fileStream = XMLReader.class.getClassLoader().getResourceAsStream(path);
|
||||
|
||||
//Resource can't be found.
|
||||
if (fileStream == null) {
|
||||
throw new XMLReaderException("Could not open resource: " + path, new IOException());
|
||||
}
|
||||
|
||||
Document doc = XMLReader.parseInputStream(fileStream);
|
||||
|
||||
doc.getDocumentElement().normalize();
|
||||
|
||||
Reference in New Issue
Block a user