KettleSystemListener implements IPentahoSystemListener { @VisibleForTesting Node getSlaveServerConfigNode( InputStream is ) throws SAXException, IOException, ParserConfigurationException { Document document = XMLParserFactoryProducer.createSecureDocBuilderFactory().newDocumentBuilder().parse( is ); return XMLHandler.getSubNode( document, SlaveServerConfig.XML_TAG ); }  boolean startup( final IPentahoSession session ); static Map readProperties( final IPentahoSession session ); static void environmentInit( final IPentahoSession session ); void shutdown(); void setUsePlatformLogFile( final boolean usePlatformLogFile );  }
@Test( timeout = 2000, expected = SAXException.class ) public void shouldNotFailAndReturnNullWhenMaliciousXmlIsGiven() throws IOException, ParserConfigurationException, SAXException { KettleSystemListener ksl = new KettleSystemListener(); ksl.getSlaveServerConfigNode( new StringBufferInputStream( XmlTestConstants.MALICIOUS_XML ) ); fail(); }
@Test public void shouldNotFailAndReturnNotNullWhenLegalXmlIsGiven() throws Exception { String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<slave_config>" + "</slave_config>"; KettleSystemListener ksl = new KettleSystemListener(); assertNotNull( ksl.getSlaveServerConfigNode( new StringBufferInputStream( xml ) ) ); }