parent
21804927e3
commit
08da9be666
|
@ -7,6 +7,11 @@ import javax.xml.parsers.ParserConfigurationException;
|
|||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import java.io.IOException;
|
||||
import java.net.URI;
|
||||
import java.net.URISyntaxException;
|
||||
import java.net.URL;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.List;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
@ -14,12 +19,13 @@ import static org.junit.Assert.*;
|
|||
public class SaxParserMainUnitTest {
|
||||
|
||||
@Test
|
||||
public void parse_baeldung_xml_document() throws IOException, SAXException, ParserConfigurationException {
|
||||
public void parse_baeldung_xml_document() throws IOException, SAXException, ParserConfigurationException, URISyntaxException {
|
||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
SAXParser saxParser = factory.newSAXParser();
|
||||
|
||||
SaxParserMain.BaeldungHandler baeldungHandler = new SaxParserMain.BaeldungHandler();
|
||||
saxParser.parse("src\\test\\resources\\sax\\baeldung.xml", baeldungHandler);
|
||||
Path path = Paths.get(new URL("src\\test\\resources\\sax\\baeldung.xml").toURI());
|
||||
saxParser.parse(path.toFile(), baeldungHandler);
|
||||
|
||||
SaxParserMain.Baeldung result = baeldungHandler.getWebsite();
|
||||
|
||||
|
|
Loading…
Reference in New Issue