Package org.testng.xml
Class Parser
- java.lang.Object
-
- org.testng.xml.Parser
-
public class Parser extends java.lang.ObjectParseris a parser for a TestNG XML test suite file.
-
-
Field Summary
Fields Modifier and Type Field Description private static ISuiteParserDEFAULT_FILE_PARSERstatic java.lang.StringDEFAULT_FILENAMEThe default file name for the TestNG test suite if none is specified (testng.xml).private static java.lang.StringHTTPS_OLD_TESTNG_DTD_URLstatic java.lang.StringHTTPS_TESTNG_DTD_URLprivate java.lang.Stringm_fileNameThe file name of the xml suite being parsed.private java.io.InputStreamm_inputStreamprivate booleanm_loadClassesprivate IPostProcessorm_postProcessorstatic java.lang.StringOLD_TESTNG_DTD_URLThe URL to the deprecated TestNG DTD.private static java.util.List<ISuiteParser>PARSERSstatic java.lang.StringTESTNG_DTDThe name of the TestNG DTD.static java.lang.StringTESTNG_DTD_URLThe URL to the TestNG DTD.private static java.util.List<java.lang.String>URLS
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static booleancanParse(java.lang.String fileName)private static java.net.URIconstructURI(java.lang.String text)private static IFileParsergetParser(java.lang.String fileName)static booleanhasFileScheme(java.lang.String uri)private voidinit(java.lang.String fileName, java.io.InputStream is)(package private) static booleanisUnRecognizedPublicId(java.lang.String publicId)private static ParsernewParser(java.io.InputStream is, IPostProcessor processor)private static ParsernewParser(java.lang.String path, IPostProcessor processor)java.util.Collection<XmlSuite>parse()Parses the TestNG test suite and returns the corresponding XmlSuite, and possibly, other XmlSuite that are pointed to by<suite-files>tags.static java.util.Collection<XmlSuite>parse(java.io.InputStream is, IPostProcessor processor)static java.util.Collection<XmlSuite>parse(java.lang.String suite, IPostProcessor processor)java.util.List<XmlSuite>parseToList()voidsetLoadClasses(boolean loadClasses)voidsetPostProcessor(IPostProcessor processor)
-
-
-
Field Detail
-
TESTNG_DTD
public static final java.lang.String TESTNG_DTD
The name of the TestNG DTD.- See Also:
- Constant Field Values
-
OLD_TESTNG_DTD_URL
public static final java.lang.String OLD_TESTNG_DTD_URL
The URL to the deprecated TestNG DTD.- See Also:
- Constant Field Values
-
HTTPS_OLD_TESTNG_DTD_URL
private static final java.lang.String HTTPS_OLD_TESTNG_DTD_URL
- See Also:
- Constant Field Values
-
TESTNG_DTD_URL
public static final java.lang.String TESTNG_DTD_URL
The URL to the TestNG DTD.- See Also:
- Constant Field Values
-
HTTPS_TESTNG_DTD_URL
public static final java.lang.String HTTPS_TESTNG_DTD_URL
- See Also:
- Constant Field Values
-
URLS
private static final java.util.List<java.lang.String> URLS
-
DEFAULT_FILENAME
public static final java.lang.String DEFAULT_FILENAME
The default file name for the TestNG test suite if none is specified (testng.xml).- See Also:
- Constant Field Values
-
DEFAULT_FILE_PARSER
private static final ISuiteParser DEFAULT_FILE_PARSER
-
PARSERS
private static final java.util.List<ISuiteParser> PARSERS
-
m_fileName
private java.lang.String m_fileName
The file name of the xml suite being parsed. This may be null if the Parser has not been initialized with a file name. TODO CQ This member is never used.
-
m_inputStream
private java.io.InputStream m_inputStream
-
m_postProcessor
private IPostProcessor m_postProcessor
-
m_loadClasses
private boolean m_loadClasses
-
-
Constructor Detail
-
Parser
public Parser(java.lang.String fileName)
Constructs aParserto use the inputStream as the source of the xml test suite to parse.- Parameters:
fileName- the filename corresponding to the inputStream or null if unknown.
-
Parser
public Parser()
Creates a parser that will try to find the DEFAULT_FILENAME from the jar.
-
Parser
public Parser(java.io.InputStream is)
-
-
Method Detail
-
isUnRecognizedPublicId
static boolean isUnRecognizedPublicId(java.lang.String publicId)
-
init
private void init(java.lang.String fileName, java.io.InputStream is)
-
setPostProcessor
public void setPostProcessor(IPostProcessor processor)
-
setLoadClasses
public void setLoadClasses(boolean loadClasses)
- Parameters:
loadClasses- If false, don't try to load the classes during the parsing.
-
getParser
private static IFileParser getParser(java.lang.String fileName)
-
parse
public java.util.Collection<XmlSuite> parse() throws java.io.IOException
Parses the TestNG test suite and returns the corresponding XmlSuite, and possibly, other XmlSuite that are pointed to by<suite-files>tags.- Returns:
- the parsed TestNG test suite.
- Throws:
java.io.IOException- if an I/O error occurs while parsing the test suite file or if the default testng.xml file is not found.
-
hasFileScheme
public static boolean hasFileScheme(java.lang.String uri)
- Parameters:
uri- - The uri to be verified.- Returns:
- -
trueif the uri has "file:" as its scheme.
-
parseToList
public java.util.List<XmlSuite> parseToList() throws java.io.IOException
- Throws:
java.io.IOException
-
parse
public static java.util.Collection<XmlSuite> parse(java.lang.String suite, IPostProcessor processor) throws java.io.IOException
- Throws:
java.io.IOException
-
parse
public static java.util.Collection<XmlSuite> parse(java.io.InputStream is, IPostProcessor processor) throws java.io.IOException
- Throws:
java.io.IOException
-
canParse
public static boolean canParse(java.lang.String fileName)
-
newParser
private static Parser newParser(java.lang.String path, IPostProcessor processor)
-
newParser
private static Parser newParser(java.io.InputStream is, IPostProcessor processor)
-
constructURI
private static java.net.URI constructURI(java.lang.String text)
-
-