@Test(expected = DocumentNotLoadedException.class) public void should_fail_with_other_type_than_xml() throws Exception { String fileUrl = ClasspathFiles.getAbsolutePathFile("simple-text-file.txt"); documentLoader.loadFromUrl(fileUrl); }
public Document loadFromUrl(String strUrl) throws fr.norad.visuwall.providers.common.DocumentNotLoadedException { Preconditions.checkNotNull(strUrl, "strUrl is mandatory"); InputStream stream = null; try { URL url = new URL(strUrl); stream = url.openStream(); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder(); return documentBuilder.parse(stream); } catch (MalformedURLException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (IOException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (SAXException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (ParserConfigurationException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } finally { closeQuietly(stream); } }
DocumentLoader { public Document loadFromUrl(String strUrl) throws fr.norad.visuwall.providers.common.DocumentNotLoadedException { Preconditions.checkNotNull(strUrl, "strUrl is mandatory"); InputStream stream = null; try { URL url = new URL(strUrl); stream = url.openStream(); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder(); return documentBuilder.parse(stream); } catch (MalformedURLException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (IOException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (SAXException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (ParserConfigurationException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } finally { closeQuietly(stream); } } }
DocumentLoader { public Document loadFromUrl(String strUrl) throws fr.norad.visuwall.providers.common.DocumentNotLoadedException { Preconditions.checkNotNull(strUrl, "strUrl is mandatory"); InputStream stream = null; try { URL url = new URL(strUrl); stream = url.openStream(); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder(); return documentBuilder.parse(stream); } catch (MalformedURLException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (IOException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (SAXException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (ParserConfigurationException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } finally { closeQuietly(stream); } }  }
DocumentLoader { public Document loadFromUrl(String strUrl) throws fr.norad.visuwall.providers.common.DocumentNotLoadedException { Preconditions.checkNotNull(strUrl, "strUrl is mandatory"); InputStream stream = null; try { URL url = new URL(strUrl); stream = url.openStream(); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder(); return documentBuilder.parse(stream); } catch (MalformedURLException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (IOException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (SAXException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (ParserConfigurationException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } finally { closeQuietly(stream); } }  Document loadFromUrl(String strUrl); Document loadFromContent(String pomContent); }
DocumentLoader { public Document loadFromUrl(String strUrl) throws fr.norad.visuwall.providers.common.DocumentNotLoadedException { Preconditions.checkNotNull(strUrl, "strUrl is mandatory"); InputStream stream = null; try { URL url = new URL(strUrl); stream = url.openStream(); DocumentBuilderFactory builderFactory = DocumentBuilderFactory.newInstance(); DocumentBuilder documentBuilder = builderFactory.newDocumentBuilder(); return documentBuilder.parse(stream); } catch (MalformedURLException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (IOException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (SAXException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } catch (ParserConfigurationException e) { throw new fr.norad.visuwall.providers.common.DocumentNotLoadedException("Can't load document from url: " + strUrl, e); } finally { closeQuietly(stream); } }  Document loadFromUrl(String strUrl); Document loadFromContent(String pomContent);  }