@Test public void parseWithSchemaListAndDifferentLocation() throws Exception { final Document schemaRefs = parseResourceDocument("/conf/schema-ref-log4j.xml"); final Document doc = parseResourceDocument("/ipo-schemaLoc.xml"); StringWriter strWriter = new StringWriter(); PrintWriter logger = new PrintWriter(strWriter); XMLValidatingParser iut = new XMLValidatingParser(); Document result = iut.parse(doc, schemaRefs.getDocumentElement(), logger); assertNull(result); assertNotEquals("Validation error(s) should be reported.", "", strWriter.toString()); }
public Document parse(URLConnection uc, Element instruction, PrintWriter logger) throws SSLProtocolException { if (null == uc) { throw new NullPointerException( "Unable to parse resource: URLConnection is null."); } jlogger.fine("Received URLConnection object for " + uc.getURL()); Document doc = null; try (InputStream inStream = URLConnectionUtils.getInputStream(uc)) { doc = parse(inStream, instruction, logger); } catch (SSLProtocolException sslep){ throw new SSLProtocolException("[SSL ERROR] Failed to connect with the requested URL due to \"Invalid server_name\" found!! :" + uc.getURL() +":" + sslep.getClass() +" : "+ sslep.getMessage()); } catch (Exception e) { throw new RuntimeException( String.format("Failed to parse resource from %s", uc.getURL()), e); } return doc; }
XMLValidatingParser { public Document parse(URLConnection uc, Element instruction, PrintWriter logger) throws SSLProtocolException { if (null == uc) { throw new NullPointerException( "Unable to parse resource: URLConnection is null."); } jlogger.fine("Received URLConnection object for " + uc.getURL()); Document doc = null; try (InputStream inStream = URLConnectionUtils.getInputStream(uc)) { doc = parse(inStream, instruction, logger); } catch (SSLProtocolException sslep){ throw new SSLProtocolException("[SSL ERROR] Failed to connect with the requested URL due to \"Invalid server_name\" found!! :" + uc.getURL() +":" + sslep.getClass() +" : "+ sslep.getMessage()); } catch (Exception e) { throw new RuntimeException( String.format("Failed to parse resource from %s", uc.getURL()), e); } return doc; } }
XMLValidatingParser { public Document parse(URLConnection uc, Element instruction, PrintWriter logger) throws SSLProtocolException { if (null == uc) { throw new NullPointerException( "Unable to parse resource: URLConnection is null."); } jlogger.fine("Received URLConnection object for " + uc.getURL()); Document doc = null; try (InputStream inStream = URLConnectionUtils.getInputStream(uc)) { doc = parse(inStream, instruction, logger); } catch (SSLProtocolException sslep){ throw new SSLProtocolException("[SSL ERROR] Failed to connect with the requested URL due to \"Invalid server_name\" found!! :" + uc.getURL() +":" + sslep.getClass() +" : "+ sslep.getMessage()); } catch (Exception e) { throw new RuntimeException( String.format("Failed to parse resource from %s", uc.getURL()), e); } return doc; } XMLValidatingParser();  XMLValidatingParser(Document schema_links); }
XMLValidatingParser { public Document parse(URLConnection uc, Element instruction, PrintWriter logger) throws SSLProtocolException { if (null == uc) { throw new NullPointerException( "Unable to parse resource: URLConnection is null."); } jlogger.fine("Received URLConnection object for " + uc.getURL()); Document doc = null; try (InputStream inStream = URLConnectionUtils.getInputStream(uc)) { doc = parse(inStream, instruction, logger); } catch (SSLProtocolException sslep){ throw new SSLProtocolException("[SSL ERROR] Failed to connect with the requested URL due to \"Invalid server_name\" found!! :" + uc.getURL() +":" + sslep.getClass() +" : "+ sslep.getMessage()); } catch (Exception e) { throw new RuntimeException( String.format("Failed to parse resource from %s", uc.getURL()), e); } return doc; } XMLValidatingParser();  XMLValidatingParser(Document schema_links); Document parse(URLConnection uc, Element instruction,
			PrintWriter logger); boolean checkXMLRules(Document doc, Document instruction); NodeList validate(Document doc, Document instruction); Element validateSingleResult(Document doc, Document instruction); }
XMLValidatingParser { public Document parse(URLConnection uc, Element instruction, PrintWriter logger) throws SSLProtocolException { if (null == uc) { throw new NullPointerException( "Unable to parse resource: URLConnection is null."); } jlogger.fine("Received URLConnection object for " + uc.getURL()); Document doc = null; try (InputStream inStream = URLConnectionUtils.getInputStream(uc)) { doc = parse(inStream, instruction, logger); } catch (SSLProtocolException sslep){ throw new SSLProtocolException("[SSL ERROR] Failed to connect with the requested URL due to \"Invalid server_name\" found!! :" + uc.getURL() +":" + sslep.getClass() +" : "+ sslep.getMessage()); } catch (Exception e) { throw new RuntimeException( String.format("Failed to parse resource from %s", uc.getURL()), e); } return doc; } XMLValidatingParser();  XMLValidatingParser(Document schema_links); Document parse(URLConnection uc, Element instruction,
			PrintWriter logger); boolean checkXMLRules(Document doc, Document instruction); NodeList validate(Document doc, Document instruction); Element validateSingleResult(Document doc, Document instruction);  }