From d805f907b87f61e2c2cb674256a4d90c68b6063b Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?= Date: Tue, 22 Oct 2013 08:11:07 +0200 Subject: [PATCH] Use a real XML file for testing. --- src/test/java/net/pterodactylus/sone/core/SoneParserTest.java | 6 +++++- src/test/resources/sone-parser/invalid-xml.xml | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/test/resources/sone-parser/invalid-xml.xml diff --git a/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java b/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java index 7029048..8acb2fa 100644 --- a/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java +++ b/src/test/java/net/pterodactylus/sone/core/SoneParserTest.java @@ -52,7 +52,7 @@ public class SoneParserTest { @Test public void verifyThatAnInvalidXmlDocumentIsNotParsed() throws UnsupportedEncodingException { - Optional sone = soneParser.parseSone(database, originalSone, getInputStream("This is not valid XML.")); + Optional sone = soneParser.parseSone(database, originalSone, getXml("invalid-xml")); assertThat(sone, notNullValue()); assertThat(sone.isPresent(), is(false)); } @@ -110,6 +110,10 @@ public class SoneParserTest { return new ByteArrayInputStream(content.getBytes("UTF-8")); } + private InputStream getXml(String name) { + return getClass().getResourceAsStream(format("/sone-parser/%s.xml", name)); + } + private static class SoneXmlBuilder { private Optional time = of(1000L); diff --git a/src/test/resources/sone-parser/invalid-xml.xml b/src/test/resources/sone-parser/invalid-xml.xml new file mode 100644 index 0000000..805f3b7 --- /dev/null +++ b/src/test/resources/sone-parser/invalid-xml.xml @@ -0,0 +1,4 @@ + + + + -- 2.7.4