/** Fill the top of the XML suiteBuffer with the top of the XML template file */ private void createXmlFileFromTemplate(XMLStringBuffer suiteBuffer, String fileName) { try { Parser parser = new Parser(fileName); parser.setLoadClasses(false); // we don't want to load the classes from the template file Collection<XmlSuite> suites = parser.parse(); if (suites.size() > 0) { XmlSuite s = suites.iterator().next(); // Retrieve the <suite> attributes from the template file and transfer // them in the suite we are creating. Properties attr = new Properties(); put(attr, "name", s.getName()); put(attr, "junit", s.isJUnit()); put(attr, "verbose", s.getVerbose()); put(attr, "parallel", s.getParallel()); put(attr, "thread-count", s.getThreadCount()); // put(attr, "annotations", s.getAnnotations()); put(attr, "time-out", s.getTimeOut()); put(attr, "skipfailedinvocationcounts", s.skipFailedInvocationCounts()); put(attr, "configfailurepolicy", s.getConfigFailurePolicy()); put(attr, "data-provider-thread-count", s.getDataProviderThreadCount()); put(attr, "object-factory", s.getObjectFactory()); put(attr, "allow-return-values", s.getAllowReturnValues()); put(attr, "preserve-order", s.getPreserveOrder()); put(attr, "group-by-instances", s.getGroupByInstances()); suiteBuffer.push("suite", attr); // Children of <suite> // Listeners if (s.getListeners().size() > 0) { suiteBuffer.push("listeners"); for (String l : s.getListeners()) { Properties p = new Properties(); p.put("class-name", l); suiteBuffer.addEmptyElement("listener", p); } suiteBuffer.pop("listeners"); } // Parameters for (Map.Entry<String, String> parameter : s.getParameters().entrySet()) { Properties p = new Properties(); p.put("name", parameter.getKey()); p.put("value", parameter.getValue()); suiteBuffer.addEmptyElement("parameter", p); } // Method selectors if (s.getMethodSelectors().size() > 0) { suiteBuffer.push("method-selectors"); for (XmlMethodSelector ms : s.getMethodSelectors()) { String cls = ms.getClassName(); if (cls != null && cls.length() > 0) { suiteBuffer.push("method-selector"); Properties p = new Properties(); p.put("name", cls); p.put("priority", ms.getPriority()); suiteBuffer.addEmptyElement("selector-class", p); suiteBuffer.pop("method-selector"); } // TODO: <script> tag of method-selector } suiteBuffer.pop("method-selectors"); } } } catch (IOException e) { throw new TestNGException(e); } }