@Override public XmlSuite parse(String currentFile, InputStream inputStream, boolean loadClasses) { TestNGContentHandler contentHandler = new TestNGContentHandler(currentFile, loadClasses); try { parse(inputStream, contentHandler); return contentHandler.getSuite(); } catch (SAXException | IOException e) { throw new TestNGException(e); } }
@Override public void characters(char ch[], int start, int length) { if (null != m_currentLanguage && ! areWhiteSpaces(ch, start, length)) { m_currentExpression += new String(ch, start, length); } }
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if ("suite".equals(qName)) { xmlSuite(false, null); xmlSuiteFile(false, null); xmlTest(false, null); xmlDefine(false, null); xmlRun(false, null); xmlGroups(false, null); xmlMethod(false); xmlClasses(false, null); xmlPackages(false, null); popLocation(); xmlListeners(false, null); xmlMethodSelector(false, null); xmlMethodSelectors(false, null); xmlSelectorClass(false, null);
/** * Parse <suite-file> */ private void xmlSuiteFile(boolean start, Attributes attributes) { if (start) { String path = attributes.getValue("path"); pushLocation(Location.SUITE); m_suiteFiles.add(path); } else { m_currentSuite.setSuiteFiles(m_suiteFiles); popLocation(); } }
xmlSuite(true, attributes); xmlSuiteFile(true, attributes); xmlTest(true, attributes); xmlScript(true, attributes); xmlMethodSelector(true, attributes); xmlMethodSelectors(true, attributes); xmlSelectorClass(true, attributes); xmlClasses(true, attributes); xmlPackages(true, attributes); xmlListeners(true, attributes); xmlListener(true, attributes); m_currentClassParameters = Maps.newHashMap(); m_currentClasses.add(m_currentClass); pushLocation(Location.CLASS); xmlDefine(true, attributes); xmlRun(true, attributes);
public InputSource resolveEntity(String publicId, String systemId) throws SAXException, IOException { return new TestNGContentHandler(null, false).resolveEntity(publicId, systemId); } }
XmlInclude include; if (!Utils.isStringEmpty(in)) { include = new XmlInclude(name, stringToList(in), m_currentIncludeIndex++); } else { include = new XmlInclude(name, m_currentIncludeIndex++); popLocation(); m_currentInclude = null;
private void xmlExclude(boolean start, Attributes attributes) { if (start) { m_locations.push(Location.EXCLUDE); String name = attributes.getValue("name"); if (null != m_currentExcludedMethods) { m_currentExcludedMethods.add(name); } else if (null != m_currentRuns) { m_currentExcludedGroups.add(name); } else if (null != m_currentPackage) { m_currentPackage.getExclude().add(name); } } else { popLocation(); } }
xmlSuite(true, attributes); } else if ("suite-file".equals(qName)) { xmlSuiteFile(true, attributes); } else if ("test".equals(qName)) { xmlTest(true, attributes); } else if ("script".equals(qName)) { xmlScript(true, attributes); } else if ("method-selector".equals(qName)) { xmlMethodSelector(true, attributes); } else if ("method-selectors".equals(qName)) { xmlMethodSelectors(true, attributes); } else if ("selector-class".equals(qName)) { xmlSelectorClass(true, attributes); } else if ("classes".equals(qName)) { xmlClasses(true, attributes); } else if ("packages".equals(qName)) { xmlPackages(true, attributes); } else if ("listeners".equals(qName)) { xmlListeners(true, attributes); } else if ("listener".equals(qName)) { xmlListener(true, attributes); } else if ("class".equals(qName)) { m_currentClassParameters = Maps.newHashMap(); m_currentClasses.add(m_currentClass); pushLocation(Location.CLASS); xmlDefine(true, attributes); } else if ("run".equals(qName)) {
/** Parse <suite-file> */ private void xmlSuiteFile(boolean start, Attributes attributes) { if (start) { String path = attributes.getValue("path"); pushLocation(Location.SUITE); m_suiteFiles.add(path); } else { m_currentSuite.setSuiteFiles(m_suiteFiles); popLocation(); } }
XmlInclude include; if (!Utils.isStringEmpty(in)) { include = new XmlInclude(name, stringToList(in), m_currentIncludeIndex++); } else { include = new XmlInclude(name, m_currentIncludeIndex++); popLocation(); m_currentInclude = null;
private void xmlExclude(boolean start, Attributes attributes) { if (start) { m_locations.push(Location.EXCLUDE); String name = attributes.getValue("name"); if (null != m_currentExcludedMethods) { m_currentExcludedMethods.add(name); } else if (null != m_currentRuns) { m_currentExcludedGroups.add(name); } else if (null != m_currentPackage) { m_currentPackage.getExclude().add(name); } } else { popLocation(); } }
@Override public void endElement(String uri, String localName, String qName) throws SAXException { if ("suite".equals(qName)) { xmlSuite(false, null); } else if ("suite-file".equals(qName)) { xmlSuiteFile(false, null); } else if ("test".equals(qName)) { xmlTest(false, null); } else if ("define".equals(qName)) { xmlDefine(false, null); } else if ("run".equals(qName)) { xmlRun(false, null); } else if ("groups".equals(qName)) { xmlGroups(false, null); } else if ("methods".equals(qName)) { xmlMethod(false); } else if ("classes".equals(qName)) { xmlClasses(false, null); } else if ("packages".equals(qName)) { xmlPackages(false, null); } else if ("class".equals(qName)) { m_currentClass.setParameters(m_currentClassParameters); m_currentClassParameters = null; popLocation(); } else if ("listeners".equals(qName)) { xmlListeners(false, null); } else if ("method-selector".equals(qName)) { xmlMethodSelector(false, null); } else if ("method-selectors".equals(qName)) { xmlMethodSelectors(false, null);
@Override public XmlSuite parse(String currentFile, InputStream inputStream, boolean loadClasses) { TestNGContentHandler contentHandler = new TestNGContentHandler(currentFile, loadClasses); try { parse(inputStream, contentHandler); return contentHandler.getSuite(); } catch (SAXException | IOException e) { throw new TestNGException(e); } }
if (start) { m_currentTest = new XmlTest(m_currentSuite, m_currentTestIndex++); pushLocation(Location.TEST); m_currentTestParameters = Maps.newHashMap(); final String testName= attributes.getValue("name"); m_currentTest = null; m_currentTestParameters = null; popLocation(); if(!m_enabledTest) { List<XmlTest> tests= m_currentSuite.getTests();
@Override public void characters(char ch[], int start, int length) { if (null != m_currentLanguage && !areWhiteSpaces(ch, start, length)) { m_currentExpression += new String(ch, start, length); } }
@Test public void testDescriptionInclusion() throws Exception { final String xml = getPathToResource("xml/simple-suite-with-method-desc.xml"); SuiteXmlParser parser = new SuiteXmlParser(); TestNGContentHandler handler = new TestNGContentHandler(xml, false); parser.parse(new FileInputStream(xml), handler); List<XmlInclude> includes = handler.getSuite().getTests().get(0).getXmlClasses().get(0).getIncludedMethods(); String desc = includes.get(0).getDescription(); Assert.assertEquals("simple-description", desc); }
pushLocation(Location.SUITE); String name = attributes.getValue("name"); if (isStringBlank(name)) { m_suites.add(m_currentSuite); m_currentSuiteParameters = null; popLocation();
if (start) { m_currentTest = new XmlTest(m_currentSuite, m_currentTestIndex++); pushLocation(Location.TEST); m_currentTestParameters = Maps.newHashMap(); final String testName = attributes.getValue("name"); m_currentTest = null; m_currentTestParameters = null; popLocation(); if (!m_enabledTest) { List<XmlTest> tests = m_currentSuite.getTests();
pushLocation(Location.SUITE); String name = attributes.getValue("name"); if (isStringBlank(name)) { m_suites.add(m_currentSuite); m_currentSuiteParameters = null; popLocation();