Top Description Fields Constructors Methods
org.testng.xml.internal

public Class Parser

extends Object
Class Inheritance
Annotations
@SuppressWarnings:unused
Imports
java.io.File, .FileInputStream, .IOException, .InputStream, java.net.URI, java.util.ArrayDeque, .Collection, .List, .Map, .Queue, .ServiceLoader, org.testng.collections.Lists, .Maps, org.testng.xml.IFileParser, .IPostProcessor, .ISuiteParser, .SuiteXmlParser, .XmlSuite

Parser is a parser for a TestNG XML test suite file.

Field Summary

Modifier and TypeField and Description
private static final ISuiteParser
public static final String
DEFAULT_FILENAME

The default file name for the TestNG test suite if none is specified (testng.xml).

public static final String
private String
m_fileName

The file name of the xml suite being parsed.

private InputStream
private boolean
private IPostProcessor
public static final String
OLD_TESTNG_DTD_URL

The URL to the deprecated TestNG DTD.

private static final List<ISuiteParser>
public static final String
TESTNG_DTD

The name of the TestNG DTD.

public static final String
TESTNG_DTD_URL

The URL to the TestNG DTD.

Constructor Summary

AccessConstructor and Description
public
Parser(String
the filename corresponding to the inputStream or null if unknown.
fileName
)

Constructs a Parser to use the inputStream as the source of the xml test suite to parse.

public
Parser()

Creates a parser that will try to find the DEFAULT_FILENAME from the jar.

public

Method Summary

Modifier and TypeMethod and Description
public static boolean
canParse(String fileName)

private static URI
private static IFileParser<T>
getParser(String fileName)

public static boolean

Returns:

- true if the uri has "file:" as its scheme.
hasFileScheme
(String
- The uri to be verified.
uri
)

private void
init(String fileName, InputStream is)

private static Parser
newParser(String path, IPostProcessor processor)

private static Parser
public Collection<XmlSuite>

Returns:

the parsed TestNG test suite.
parse
()

Parses the TestNG test suite and returns the corresponding XmlSuite, and possibly, other XmlSuite that are pointed to by <suite-files> tags.

public static Collection<XmlSuite>
parse(String suite, IPostProcessor processor)

public static Collection<XmlSuite>
public List<XmlSuite>
public void
setLoadClasses(boolean
If false, don't try to load the classes during the parsing.
loadClasses
)

public void
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

DEFAULT_FILE_PARSERback to summary
private static final ISuiteParser DEFAULT_FILE_PARSER
DEFAULT_FILENAMEback to summary
public static final String DEFAULT_FILENAME

The default file name for the TestNG test suite if none is specified (testng.xml).

HTTPS_TESTNG_DTD_URLback to summary
public static final String HTTPS_TESTNG_DTD_URL
m_fileNameback to summary
private 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_inputStreamback to summary
private InputStream m_inputStream
m_loadClassesback to summary
private boolean m_loadClasses
m_postProcessorback to summary
private IPostProcessor m_postProcessor
OLD_TESTNG_DTD_URLback to summary
public static final String OLD_TESTNG_DTD_URL

The URL to the deprecated TestNG DTD.

PARSERSback to summary
private static final List<ISuiteParser> PARSERS
TESTNG_DTDback to summary
public static final String TESTNG_DTD

The name of the TestNG DTD.

TESTNG_DTD_URLback to summary
public static final String TESTNG_DTD_URL

The URL to the TestNG DTD.

Constructor Detail

Parserback to summary
public Parser(String fileName)

Constructs a Parser to use the inputStream as the source of the xml test suite to parse.

Parameters
fileName:String

the filename corresponding to the inputStream or null if unknown.

Parserback to summary
public Parser()

Creates a parser that will try to find the DEFAULT_FILENAME from the jar.

Parserback to summary
public Parser(InputStream is)

Method Detail

canParseback to summary
public static boolean canParse(String fileName)
constructURIback to summary
private static URI constructURI(String text)
getParserback to summary
private static IFileParser<T> getParser(String fileName)
hasFileSchemeback to summary
public static boolean hasFileScheme(String uri)
Parameters
uri:String

- The uri to be verified.

Returns:boolean

- true if the uri has "file:" as its scheme.

initback to summary
private void init(String fileName, InputStream is)
newParserback to summary
private static Parser newParser(String path, IPostProcessor processor)
newParserback to summary
private static Parser newParser(InputStream is, IPostProcessor processor)
parseback to summary
public Collection<XmlSuite> parse() throws IOException

Parses the TestNG test suite and returns the corresponding XmlSuite, and possibly, other XmlSuite that are pointed to by <suite-files> tags.

Returns:Collection<XmlSuite>

the parsed TestNG test suite.

Exceptions
IOException:
if an I/O error occurs while parsing the test suite file or if the default testng.xml file is not found.
parseback to summary
public static Collection<XmlSuite> parse(String suite, IPostProcessor processor) throws IOException
parseback to summary
public static Collection<XmlSuite> parse(InputStream is, IPostProcessor processor) throws IOException
parseToListback to summary
public List<XmlSuite> parseToList() throws IOException
setLoadClassesback to summary
public void setLoadClasses(boolean loadClasses)
Parameters
loadClasses:boolean

If false, don't try to load the classes during the parsing.

setPostProcessorback to summary
public void setPostProcessor(IPostProcessor processor)