public String getExpression() {
return m_expression;
}
public String toXml(String indent) {
XMLStringBuffer xsb = new XMLStringBuffer(indent);
Properties p = new Properties();
p.setProperty("name", getName());
if (m_isJUnit != null) {
XmlUtils.setProperty(p, "junit", m_isJUnit.toString(), XmlSuite.DEFAULT_JUNIT.toString());
}
if (m_parallel != null) {
XmlUtils.setProperty(p, "parallel", m_parallel, XmlSuite.DEFAULT_PARALLEL);
}
if (m_verbose != null) {
XmlUtils.setProperty(p, "verbose", m_verbose.toString(), XmlSuite.DEFAULT_VERBOSE.toString());
}
if (null != m_timeOut) {
p.setProperty("time-out", m_timeOut.toString());
}
if (m_preserveOrder != null) {
p.setProperty("preserve-order", m_preserveOrder.toString());
}
if (m_threadCount != -1) {
p.setProperty("thread-count", Integer.toString(m_threadCount));
}
xsb.push("test", p);
if (null != getMethodSelectors() && !getMethodSelectors().isEmpty()) {
xsb.push("method-selectors");
for (XmlMethodSelector selector: getMethodSelectors()) {
xsb.getStringBuffer().append(selector.toXml(indent + " "));
}
xsb.pop("method-selectors");
}
// parameters
if (!m_parameters.isEmpty()) {
for(Map.Entry<String, String> para: m_parameters.entrySet()) {
Properties paramProps= new Properties();
paramProps.setProperty("name", para.getKey());
paramProps.setProperty("value", para.getValue());
xsb.addEmptyElement("parameter", paramProps); // BUGFIX: TESTNG-27
}
}
// groups
if (!m_metaGroups.isEmpty() || !m_includedGroups.isEmpty() || !m_excludedGroups.isEmpty()) {
xsb.push("groups");
// define
for (String metaGroupName: m_metaGroups.keySet()) {
Properties metaGroupProp= new Properties();
metaGroupProp.setProperty("name", metaGroupName);
xsb.push("define", metaGroupProp);
for (String groupName: m_metaGroups.get(metaGroupName)) {
Properties includeProps = new Properties();
includeProps.setProperty("name", groupName);
xsb.addEmptyElement("include", includeProps);
}
xsb.pop("define");
}
if (!m_includedGroups.isEmpty() || !m_excludedGroups.isEmpty()) {
xsb.push("run");
for (String includeGroupName: m_includedGroups) {
Properties includeProps = new Properties();
includeProps.setProperty("name", includeGroupName);
xsb.addEmptyElement("include", includeProps);
}
for (String excludeGroupName: m_excludedGroups) {
Properties excludeProps = new Properties();
excludeProps.setProperty("name", excludeGroupName);
xsb.addEmptyElement("exclude", excludeProps);
}
xsb.pop("run");
}
xsb.pop("groups");
}
// Don't call getXmlPackages() or you will retrieve the suite packages too
if (null != m_xmlPackages && !m_xmlPackages.isEmpty()) {
xsb.push("packages");
for (XmlPackage pack: m_xmlPackages) {
xsb.getStringBuffer().append(pack.toXml(" "));
}
xsb.pop("packages");
}
// classes
if (null != getXmlClasses() && !getXmlClasses().isEmpty()) {
xsb.push("classes");
for (XmlClass cls : getXmlClasses()) {
xsb.getStringBuffer().append(cls.toXml(indent + " "));
}
xsb.pop("classes");
}
xsb.pop("test");
return xsb.toXML();
}