Package org.testng.reporters

Examples of org.testng.reporters.XMLStringBuffer


  private void ppp(String s) {
    System.out.println("[XmlMethodSelector] " + s);
  }

  public String toXml(String indent) {
    XMLStringBuffer xsb = new XMLStringBuffer(indent);

    xsb.push("method-selector");

    if (null != m_className) {
      Properties clsProp = new Properties();
      clsProp.setProperty("name", getClassName());
      if(getPriority() != -1) {
        clsProp.setProperty("priority", String.valueOf(getPriority()));
      }
      xsb.addEmptyElement("selector-class", clsProp);
    }
    else if (getLanguage() != null) {
      Properties scriptProp = new Properties();
      scriptProp.setProperty("language", getLanguage());
      xsb.push("script", scriptProp);
      xsb.addCDATA(getExpression());
      xsb.pop("script");
    }
    else {
      throw new TestNGException("Invalid Method Selector:  found neither class name nor language");
    }

    xsb.pop("method-selector");

    return xsb.toXML();
  }
View Full Code Here


        .add("class", m_name)
        .toString();
  }

  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();

  }
View Full Code Here

    return result;
  }

  public String toXml(String indent) {
    XMLStringBuffer xsb = new XMLStringBuffer(indent);
    Properties p = new Properties();
    p.setProperty("name", getName());

    if (getInclude().isEmpty() && getExclude().isEmpty()) {
      xsb.addEmptyElement("package", p);
    } else {
      xsb.push("package", p);

      for (String m : getInclude()) {
        Properties includeProp= new Properties();
        includeProp.setProperty("name", m);
        xsb.addEmptyElement("include", includeProp);
      }
      for (String m: getExclude()) {
        Properties excludeProp= new Properties();
        excludeProp.setProperty("name", m);
        xsb.addEmptyElement("exclude", excludeProp);
      }

      xsb.pop("package");
    }

    return xsb.toXML();
  }
View Full Code Here

          logLevel);
    }
  }

  public static String createSingleClassSuite(String className) {
    XMLStringBuffer xsb = new XMLStringBuffer();
    Properties p = new Properties();
    p.put("name", "Suite");
    p.put("parallel", "false");
    xsb.push("suite", p);

    p = new Properties();
    p.put("name", "Test");
    xsb.push("test", p);
    xsb.push("classes");
    p = new Properties();
    p.put("name", className);
    xsb.addEmptyElement("class", p);
    xsb.pop("classes");
    xsb.pop("test");
    xsb.pop("suite");

    return xsb.toXML();
  }
View Full Code Here

  public int getIndex() {
    return m_index;
  }

  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();
  }
View Full Code Here

import java.util.List;

public class XmlRun {

  public String toXml(String indent) {
    XMLStringBuffer xsb = new XMLStringBuffer(indent);
    boolean hasElements = hasElements(m_excludes) || hasElements(m_includes);
    if (hasElements) {
      xsb.push("run");
    }
    for (String s : m_includes) {
      xsb.addEmptyElement("include", "name", s);
    }
    for (String s : m_excludes) {
      xsb.addEmptyElement("exclude", "name", s);
    }
    if (hasElements) {
      xsb.pop("run");
    }

    return xsb.toXML();
  }
View Full Code Here

      return null;
    }
  }

  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 && ! XmlSuite.DEFAULT_PRESERVE_ORDER.equals(m_preserveOrder)) {
      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");
    }

    XmlUtils.dumpParameters(xsb, m_parameters);

    // groups
    if (!m_metaGroups.isEmpty() || !m_includedGroups.isEmpty() || !m_excludedGroups.isEmpty()
        || !m_xmlDependencyGroups.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");
      }

      // run
      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");
      }

      // group dependencies
      if (m_xmlDependencyGroups != null && ! m_xmlDependencyGroups.isEmpty()) {
        xsb.push("dependencies");
        for (Map.Entry<String, String> entry : m_xmlDependencyGroups.entrySet()) {
          xsb.addEmptyElement("group", "name", entry.getKey(), "depends-on", entry.getValue());
        }
        xsb.pop("dependencies");
      }

      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();
  }
View Full Code Here

  public String getName() {
    return m_name;
  }

  public String toXml(String indent) {
    XMLStringBuffer xsb = new XMLStringBuffer(indent);
    boolean hasElements = hasElements(m_includes);
    if (hasElements) {
      xsb.push("define", "name", m_name);
    }
    for (String s : m_includes) {
      xsb.addEmptyElement("include", "name", s);
    }
    if (hasElements) {
      xsb.pop("define");
    }

    return xsb.toXML();
  }
View Full Code Here

  public Map<String, String> getDependencies() {
    return m_xmlDependencyGroups;
  }

  public String toXml(String indent) {
    XMLStringBuffer xsb = new XMLStringBuffer(indent);
    boolean hasElements = hasElements(m_xmlDependencyGroups);
    if (hasElements) {
      xsb.push("dependencies");
    }
    for (Map.Entry<String, String> entry : m_xmlDependencyGroups.entrySet()) {
      xsb.addEmptyElement("include", "name", entry.getKey(), "depends-on", entry.getValue());
    }
    if (hasElements) {
      xsb.pop("dependencies");
    }

    return xsb.toXML();
  }
View Full Code Here

*/
public class SuiteBuilder {

  public static File createSuite(IJavaProject ijp, IType[] types, IJavaElement ije) {
   
    XMLStringBuffer xmlSuite = getSuiteBuffer(ije.getElementName());
   
    if(IJavaElement.COMPILATION_UNIT == ije.getElementType()) {
      createClassTest(types, ije, xmlSuite);
    }
    else if(IJavaElement.TYPE == ije.getElementType()) {
      createClassTest(types, ije, xmlSuite);
    }
    else if(IJavaElement.METHOD == ije.getElementType()) {
      createMethodTest(types, ije, xmlSuite);
    }

    xmlSuite.pop("suite");
    final String projectPath = ijp.getProject().getLocation().toOSString();
   
    File file = new File(projectPath, ije.getElementName() + ".xml");
    ppp("saving to file " + file.getAbsolutePath());

View Full Code Here

TOP

Related Classes of org.testng.reporters.XMLStringBuffer

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.