XMLReader.readXMLFileToString no longer throws a Transformer exception.

main
fjc40 8 years ago
parent 61d18f85c5
commit b625b6ab05

@ -87,7 +87,7 @@ public class Event {
this.boatXML = XMLReader.readXMLFileToString(boatsXMLFile, StandardCharsets.UTF_8); this.boatXML = XMLReader.readXMLFileToString(boatsXMLFile, StandardCharsets.UTF_8);
this.regattaXML = XMLReader.readXMLFileToString(regattaXMLFile, StandardCharsets.UTF_8); this.regattaXML = XMLReader.readXMLFileToString(regattaXMLFile, StandardCharsets.UTF_8);
} catch (TransformerException | XMLReaderException e) { } catch (XMLReaderException e) {
throw new EventConstructionException("Could not read XML files.", e); throw new EventConstructionException("Could not read XML files.", e);
} }

@ -166,10 +166,9 @@ public abstract class XMLReader {
* @param path path of the XML * @param path path of the XML
* @param encoding encoding of the xml * @param encoding encoding of the xml
* @return A string containing the contents of the specified file. * @return A string containing the contents of the specified file.
* @throws TransformerException Issue with the XML format
* @throws XMLReaderException Thrown if file cannot be read for some reason. * @throws XMLReaderException Thrown if file cannot be read for some reason.
*/ */
public static String readXMLFileToString(String path, Charset encoding) throws TransformerException, XMLReaderException { public static String readXMLFileToString(String path, Charset encoding) throws XMLReaderException {
InputStream fileStream = XMLReader.class.getClassLoader().getResourceAsStream(path); InputStream fileStream = XMLReader.class.getClassLoader().getResourceAsStream(path);
@ -182,7 +181,11 @@ public abstract class XMLReader {
doc.getDocumentElement().normalize(); doc.getDocumentElement().normalize();
return XMLReader.getContents(doc); try {
return XMLReader.getContents(doc);
} catch (TransformerException e) {
throw new XMLReaderException("Could not get XML file contents.", e);
}
} }

@ -91,7 +91,7 @@ public class BinaryMessageDecoderTest {
XMLMessageDecoderTest.compareXMLMessages(xmlMessage, xmlMessageDecoded); XMLMessageDecoderTest.compareXMLMessages(xmlMessage, xmlMessageDecoded);
} catch (XMLReaderException | TransformerException e){ } catch (XMLReaderException e){
fail("couldn't read file" + e.getMessage()); fail("couldn't read file" + e.getMessage());
} }
} }

@ -53,7 +53,7 @@ public class XMLMessageDecoderTest {
compareXMLMessages(message, decodedMessage); compareXMLMessages(message, decodedMessage);
} catch (XMLReaderException | TransformerException e){ } catch (XMLReaderException e){
fail("couldn't read file" + e.getMessage()); fail("couldn't read file" + e.getMessage());
} }

@ -38,7 +38,7 @@ public class BoatXMLReaderTest {
try { try {
boatXMLString = XMLReader.readXMLFileToString("mock/mockXML/boatTest.xml", StandardCharsets.UTF_8); boatXMLString = XMLReader.readXMLFileToString("mock/mockXML/boatTest.xml", StandardCharsets.UTF_8);
} catch (TransformerException | XMLReaderException e) { } catch (XMLReaderException e) {
throw new InvalidBoatDataException("Could not read boat XML file into a string.", e); throw new InvalidBoatDataException("Could not read boat XML file into a string.", e);
} }

@ -18,7 +18,7 @@ public class RaceXMLReaderTest {
try { try {
raceXMLString = XMLReader.readXMLFileToString("mock/mockXML/raceTest.xml", StandardCharsets.UTF_8); raceXMLString = XMLReader.readXMLFileToString("mock/mockXML/raceTest.xml", StandardCharsets.UTF_8);
} catch (TransformerException | XMLReaderException e) { } catch (XMLReaderException e) {
throw new InvalidRaceDataException("Could not read race XML file into a string.", e); throw new InvalidRaceDataException("Could not read race XML file into a string.", e);
} }

@ -27,7 +27,7 @@ public class RegattaXMLReaderTest {
try { try {
regattaXMLString = XMLReader.readXMLFileToString("mock/mockXML/regattaTest.xml", StandardCharsets.UTF_8); regattaXMLString = XMLReader.readXMLFileToString("mock/mockXML/regattaTest.xml", StandardCharsets.UTF_8);
} catch (TransformerException | XMLReaderException e) { } catch (XMLReaderException e) {
throw new InvalidRegattaDataException("Could not read regatta XML file into a string.", e); throw new InvalidRegattaDataException("Could not read regatta XML file into a string.", e);
} }

Loading…
Cancel
Save