This commit is contained in:
James Agnew 2018-05-30 09:57:41 -04:00
parent 554653d883
commit d819d685ee
3 changed files with 9 additions and 11 deletions

View File

@ -1757,8 +1757,8 @@ public class XmlUtil {
private static void throwUnitTestExceptionIfConfiguredToDoSo() throws FactoryConfigurationError, XMLStreamException { private static void throwUnitTestExceptionIfConfiguredToDoSo() throws FactoryConfigurationError, XMLStreamException {
if (ourNextException != null) { if (ourNextException != null) {
if (ourNextException instanceof FactoryConfigurationError) { if (ourNextException instanceof javax.xml.stream.FactoryConfigurationError) {
throw ((FactoryConfigurationError)ourNextException); throw ((javax.xml.stream.FactoryConfigurationError)ourNextException);
} }
throw (XMLStreamException)ourNextException; throw (XMLStreamException)ourNextException;
} }

View File

@ -2,7 +2,7 @@ package ca.uhn.fhir.util;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
import javax.xml.parsers.FactoryConfigurationError; import javax.xml.stream.FactoryConfigurationError;
import javax.xml.stream.XMLStreamException; import javax.xml.stream.XMLStreamException;
import org.hl7.fhir.dstu3.model.Patient; import org.hl7.fhir.dstu3.model.Patient;
@ -37,7 +37,8 @@ public class XmlUtilDstu3Test {
// good // good
} }
} }
@Test
public void testXmlFactoryThrowsXmlStreamException() { public void testXmlFactoryThrowsXmlStreamException() {
XmlUtil.setThrowExceptionForUnitTest(new XMLStreamException("FOO")); XmlUtil.setThrowExceptionForUnitTest(new XMLStreamException("FOO"));
@ -54,19 +55,14 @@ public class XmlUtilDstu3Test {
// good // good
} }
} }
@Test
public void testXmlFactoryThrowsFactoryConfigurationError() { public void testXmlFactoryThrowsFactoryConfigurationError() {
XmlUtil.setThrowExceptionForUnitTest(new FactoryConfigurationError("FOO")); XmlUtil.setThrowExceptionForUnitTest(new FactoryConfigurationError("FOO"));
try { try {
ourCtx.newXmlParser().parseResource("AAAAA"); ourCtx.newXmlParser().parseResource("AAAAA");
fail(); fail();
} catch (DataFormatException e) {
// good
}
try {
ourCtx.newXmlParser().encodeResourceToString(myPatient);
fail();
} catch (ConfigurationException e) { } catch (ConfigurationException e) {
// good // good
} }

View File

@ -204,6 +204,8 @@
<groupId>org.apache.httpcomponents</groupId> <groupId>org.apache.httpcomponents</groupId>
<artifactId>httpclient</artifactId> <artifactId>httpclient</artifactId>
</dependency> </dependency>
</dependencies> </dependencies>
<reporting> <reporting>