• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 package org.testng.xml;
2 
3 import org.testng.reporters.XMLStringBuffer;
4 
5 import java.util.Map;
6 import java.util.Map.Entry;
7 import java.util.Properties;
8 
9 public class XmlUtils {
10 
11   /**
12    * Don't add this property if it's equal to its default value.
13    */
setProperty(Properties p, String name, String value, String def)14   public static void setProperty(Properties p, String name, String value, String def) {
15     if (! def.equals(value) && value != null) {
16       p.setProperty(name, value);
17     }
18   }
19 
dumpParameters(XMLStringBuffer xsb, Map<String, String> parameters)20   public static void dumpParameters(XMLStringBuffer xsb, Map<String, String> parameters) {
21     // parameters
22     if (!parameters.isEmpty()) {
23       for(Map.Entry<String, String> para: parameters.entrySet()) {
24         Properties paramProps= new Properties();
25         paramProps.setProperty("name", para.getKey());
26         paramProps.setProperty("value", para.getValue());
27         xsb.addEmptyElement("parameter", paramProps); // BUGFIX: TESTNG-27
28       }
29     }
30   }
31 
32 }
33