/** * @return A String representation of this XML suite. */ public String toXml() { return XmlWeaver.asXml(this); }
private static IWeaveXml getInstance() { if (testMode) { //Donot resort to caching when running Unit tests for TestNG, because we have to check //both implementations. If we cache the instance, then its not possible to do that. return attemptDefaultImplementationInstantiation(); } return instantiateIfRequired(); }
private static IWeaveXml instantiateIfRequired() { if (instance != null) { return instance; } instance = attemptDefaultImplementationInstantiation(); if (instance != null) { return instance; } Class<?> clazz = ClassHelper.forName(getClassName()); boolean isValid = ReflectionRecipes.isOrImplementsInterface(IWeaveXml.class, clazz); if (!isValid) { String msg = "In order for " + getClassName() + " to be used by TestNG for generating suite/test xmls, " + getClassName() + " needs to implement " + IWeaveXml.class.getName(); throw new TestNGException(msg); } instance = (IWeaveXml) ClassHelper.newInstance(clazz); return instance; }
/** * Helps represent the contents of {@link XmlSuite} as a String. * * @param suite - The {@link XmlSuite} that needs to be transformed to a String. * @return - The String representation */ static String asXml(XmlSuite suite) { return getInstance().asXml(suite); }
private static IWeaveXml attemptDefaultImplementationInstantiation() { String clazz = getClassName(); if (clazz.equals(DefaultXmlWeaver.class.getName())) { return new DefaultXmlWeaver(); } if (clazz.equals(CommentDisabledXmlWeaver.class.getName())) { return new CommentDisabledXmlWeaver(); } return null; } }
private static IWeaveXml instantiateIfRequired() { if (instance != null) { return instance; } instance = attemptDefaultImplementationInstantiation(); if (instance != null) { return instance; } Class<?> clazz = ClassHelper.forName(getClassName()); boolean isValid = ReflectionRecipes.isOrImplementsInterface(IWeaveXml.class, clazz); if (!isValid) { String msg = "In order for " + getClassName() + " to be used by TestNG for generating suite/test xmls, " + getClassName() + " needs to implement " + IWeaveXml.class.getName(); throw new TestNGException(msg); } instance = (IWeaveXml) ClassHelper.newInstance(clazz); return instance; }
/** * Helps represent the contents of {@link XmlTest} as a String. * @param xmlTest - The {@link XmlTest} that needs to be transformed to a String. * @param indent - The indentation. * @return - The String representation */ static String asXml(XmlTest xmlTest, String indent) { return getInstance().asXml(xmlTest, indent); }
private static IWeaveXml attemptDefaultImplementationInstantiation() { String clazz = getClassName(); if (clazz.equals(DefaultXmlWeaver.class.getName())) { return new DefaultXmlWeaver(); } if (clazz.equals(CommentDisabledXmlWeaver.class.getName())) { return new CommentDisabledXmlWeaver(); } if (testMode) { return null; } Class<?> clazzName = ClassHelper.forName(clazz); if (ReflectionRecipes.isOrExtends(IWeaveXml.class, clazzName)) { return ClassHelper.newInstance((Class<IWeaveXml>) clazzName); } throw new IllegalArgumentException(clazz + " does not implement " + IWeaveXml.class.getName()); } }
private static IWeaveXml getInstance() { if (testMode) { // Donot resort to caching when running Unit tests for TestNG, because we have to check // both implementations. If we cache the instance, then its not possible to do that. return attemptDefaultImplementationInstantiation(); } return instantiateIfRequired(); }
/** * Helps represent the contents of {@link XmlTest} as a String. * * @param xmlTest - The {@link XmlTest} that needs to be transformed to a String. * @param indent - The indentation. * @return - The String representation */ static String asXml(XmlTest xmlTest, String indent) { return getInstance().asXml(xmlTest, indent); }
public String toXml(String indent) { return XmlWeaver.asXml(this, indent); }
/** * Helps represent the contents of {@link XmlSuite} as a String. * * @param suite - The {@link XmlSuite} that needs to be transformed to a String. * @return - The String representation */ static String asXml(XmlSuite suite) { return getInstance().asXml(suite); }
/** @return A String representation of this XML suite. */ public String toXml() { return XmlWeaver.asXml(this); }
public String toXml(String indent) { return XmlWeaver.asXml(this, indent); }