public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); String indent2 = indent + " "; boolean hasGroups = hasElements(m_defines) || m_run != null || hasElements(m_dependencies); if (hasGroups) { xsb.push("groups"); } for (XmlDefine d : m_defines) { xsb.getStringBuffer().append(d.toXml(indent2)); } if (null != m_run) { // XmlRun is optional and is not always available. So check if its available before running // toXml() xsb.getStringBuffer().append(m_run.toXml(indent2)); } for (XmlDependencies d : m_dependencies) { xsb.getStringBuffer().append(d.toXml(indent2)); } if (hasGroups) { xsb.pop("groups"); } return xsb.toXML(); }
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); Properties prop = new Properties(); prop.setProperty("name", getName()); boolean hasMethods = !m_includedMethods.isEmpty() || !m_excludedMethods.isEmpty(); boolean hasParameters = !m_parameters.isEmpty(); if (hasParameters || hasMethods) { xsb.push("class", prop); XmlUtils.dumpParameters(xsb, m_parameters); if (hasMethods) { xsb.push("methods"); for (XmlInclude m : getIncludedMethods()) { xsb.getStringBuffer().append(m.toXml(indent + " ")); } for (String m : getExcludedMethods()) { Properties p = new Properties(); p.setProperty("name", m); xsb.addEmptyElement("exclude", p); } xsb.pop("methods"); } xsb.pop("class"); } else { xsb.addEmptyElement("class", prop); } return xsb.toXML(); }
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); Properties p = new Properties(); p.setProperty("name", getName()); List<Integer> invocationNumbers = getInvocationNumbers(); if (invocationNumbers != null && invocationNumbers.size() > 0) { p.setProperty("invocation-numbers", XmlClass.listToString(invocationNumbers).toString()); } if (!m_parameters.isEmpty()) { xsb.push("include", p); XmlUtils.dumpParameters(xsb, m_parameters); xsb.pop("include"); } else { xsb.addEmptyElement("include", p); } return xsb.toXML(); }
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); Properties p = new Properties(); p.setProperty("name", getName()); p.setProperty("junit", m_isJUnit != null ? m_isJUnit.toString() : "false"); if (null != m_parallel && !"".equals(m_parallel)) { p.setProperty("parallel", m_parallel); } if (null != m_verbose) { p.setProperty("verbose", m_verbose.toString()); } if (null != m_annotations) { p.setProperty("annotations", m_annotations.toString()); } if (null != m_timeOut) { p.setProperty("time-out", m_timeOut.toString()); } 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"); } // HINT: don't call getXmlPackages() cause 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(); }
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"); } 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(); }