So I'm writing some unit tests using JUnit for an RSS parser application. The part I'm trying to test takes a URL and opens a connection to it (HttpURLConnection), then passes an inputStream of this into a parser (connection.getInputStream()). Once in the parser, creates a new XMLEventReader from the input stream.
I'm trying to replicate this process within my JUnit tests by having a local XML file of the same structure as the RSS feed would be. When I try to load this in using:
this.getClass().getResourceAsStream("/localXmlFile.xml");
I get a MalformedURLException thrown when this line of the parser is hit:
XMLEventReader xmlEventReader = inputFactory.createXMLEventReader(inputStream);
Can anyone shed any light as to how I would correctly replicate the functionality within my tests? Is this something we would use EasyMock for (I don't know as I've never used it).
Thanks in advance.