private static void toYaml(StringBuilder result, String sp2, XmlClass xc) { List<XmlInclude> im = xc.getIncludedMethods(); List<String> em = xc.getExcludedMethods(); String name = (im.isEmpty() && em.isEmpty()) ? "" : "name: "; result.append(sp2).append("- ").append(name).append(xc.getName()).append("\n"); if (!im.isEmpty()) { result.append(sp2).append(" includedMethods:\n"); for (XmlInclude xi : im) { toYaml(result, sp2 + " ", xi); } } if (!em.isEmpty()) { result.append(sp2).append(" excludedMethods:\n"); toYaml(result, sp2 + " ", em); } }
private static Collection<XmlClass> findClassesInSameTest(Class<?> cls, XmlTest xmlTest) { Collection<XmlClass> vResult = Sets.newHashSet(); String className = cls.getName(); for (XmlClass testClass : xmlTest.getXmlClasses()) { if (testClass.getName().equals(className)) { // Found it, add all the classes in this test in the result vResult.addAll(xmlTest.getXmlClasses()); break; } } return vResult; }
private static void toYaml(StringBuilder result, String sp2, XmlClass xc) { List<XmlInclude> im = xc.getIncludedMethods(); List<String> em = xc.getExcludedMethods(); String name = (im.isEmpty() && em.isEmpty()) ? "" : "name: "; result.append(sp2).append("- ").append(name).append(xc.getName()).append("\n"); if (!im.isEmpty()) { result.append(sp2).append(" includedMethods:\n"); for (XmlInclude xi : im) { toYaml(result, sp2 + " ", xi); } } if (!em.isEmpty()) { result.append(sp2).append(" excludedMethods:\n"); toYaml(result, sp2 + " ", em); } }
private static Collection<XmlClass> findClassesInSameTest(Class<?> cls, XmlTest xmlTest) { Collection<XmlClass> vResult = Sets.newHashSet(); String className = cls.getName(); for (XmlClass testClass : xmlTest.getXmlClasses()) { if (testClass.getName().equals(className)) { // Found it, add all the classes in this test in the result vResult.addAll(xmlTest.getXmlClasses()); break; } } return vResult; } }
public ClassInfoMap(List<XmlClass> classes, boolean includeNested) { includeNestedClasses = includeNested; for (XmlClass xmlClass : classes) { try { Class<?> c = xmlClass.getSupportClass(); registerClass(c, xmlClass); } catch (NoClassDefFoundError e) { Utils.log("[ClassInfoMap]", 1, "Unable to open class " + xmlClass.getName() + " - unable to resolve class reference " + e.getMessage()); if (xmlClass.loadClasses()) { throw e; } } } }
private String findDescription(ITestAnnotation testAnnotation, XmlTest xmlTest) { String result = testAnnotation.getDescription(); if (result == null) { List<XmlClass> classes = xmlTest.getXmlClasses(); for (XmlClass c : classes) { if (c.getName().equals(m_method.getMethod().getDeclaringClass().getName())) { for (XmlInclude include : c.getIncludedMethods()) { if (include.getName().equals(m_method.getName())) { result = include.getDescription(); if (result != null) { break; } } } } } } return result; }
/** * Convenience method to cache the ordering numbers for methods. */ public List<Integer> getInvocationNumbers(String method) { if (m_failedInvocationNumbers == null) { m_failedInvocationNumbers = Maps.newHashMap(); for (XmlClass c : getXmlClasses()) { for (XmlInclude xi : c.getIncludedMethods()) { List<Integer> invocationNumbers = xi.getInvocationNumbers(); if (invocationNumbers.size() > 0) { String methodName = c.getName() + "." + xi.getName(); m_failedInvocationNumbers.put(methodName, invocationNumbers); } } } } List<Integer> result = m_failedInvocationNumbers.get(method); if (result == null) { // Don't use emptyList here since this list might end up receiving values if // the test run fails. return Lists.newArrayList(); } else { return result; } }
@Override public Map<String, String> findMethodParameters(XmlTest test) { // Get the test+suite parameters Map<String, String> result = test.getAllParameters(); for (XmlClass xmlClass: test.getXmlClasses()) { if (xmlClass.getName().equals(getTestClass().getName())) { result.putAll(xmlClass.getLocalParameters()); for (XmlInclude include : xmlClass.getIncludedMethods()) { if (include.getName().equals(getMethodName())) { result.putAll(include.getLocalParameters()); break; } } } } return result; }
private String findDescription(ITestAnnotation testAnnotation, XmlTest xmlTest) { String result = testAnnotation.getDescription(); if (result == null) { List<XmlClass> classes = xmlTest.getXmlClasses(); for (XmlClass c : classes) { if (c.getName().equals(m_method.getMethod().getDeclaringClass().getName())) { for (XmlInclude include : c.getIncludedMethods()) { if (include.getName().equals(m_method.getName())) { result = include.getDescription(); if (result != null) { break; } } } } } } return result; }
public String toXml(String indent) { XMLStringBuffer xsb = new XMLStringBuffer(indent); Properties prop = new Properties(); prop.setProperty("name", getName());
public ClassInfoMap(List<XmlClass> classes, boolean includeNested) { includeNestedClasses = includeNested; for (XmlClass xmlClass : classes) { try { Class<?> c = xmlClass.getSupportClass(); registerClass(c, xmlClass); } catch (NoClassDefFoundError e) { Utils.log( "[ClassInfoMap]", 1, "Unable to open class " + xmlClass.getName() + " - unable to resolve class reference " + e.getMessage()); if (xmlClass.loadClasses()) { throw e; } } } }
@Override public Map<String, String> findMethodParameters(XmlTest test) { // Get the test+suite parameters Map<String, String> result = test.getAllParameters(); for (XmlClass xmlClass : test.getXmlClasses()) { if (xmlClass.getName().equals(getTestClass().getName())) { result.putAll(xmlClass.getLocalParameters()); for (XmlInclude include : xmlClass.getIncludedMethods()) { if (include.getName().equals(getMethodName())) { result.putAll(include.getLocalParameters()); break; } } } } return result; }
String[] split = splitMethod(m); String className = split[0]; if (xc.getName().equals(className)) { XmlInclude includedMethod = new XmlInclude(split[1]); xc.getIncludedMethods().add(includedMethod);
private static void extractClassNames( XmlSuite xmlSuite, List<String> testNames, List<String> classNames) { for (XmlTest xmlTest : xmlSuite.getTests()) { testNames.add(xmlTest.getName()); for (XmlClass xmlClass : xmlTest.getXmlClasses()) { classNames.add(xmlClass.getName()); } } }
/** * Clone an XmlClass by copying all its components. */ @Override public Object clone() { XmlClass result = new XmlClass(getName(), getIndex(), loadClasses()); result.setExcludedMethods(getExcludedMethods()); result.setIncludedMethods(getIncludedMethods()); return result; }
public void setXmlClasses(List<XmlClass> classes) { m_classes = classes; for (XmlClass c : classes) { for (XmlInclude m : c.getIncludedMethods()) { checkMethod(c.getSupportClass(), m.getName()); String methodName = makeMethodName(c.getName(), m.getName()); m_includedMethods.put(methodName, m); } } }
private XmlClass findClass(String className) { for(XmlClass cl : getTest().getXmlClasses()) { if(cl.getName().equals(className)) { return cl; } } return addClass(className); }
/** Clone an XmlClass by copying all its components. */ @Override public Object clone() { XmlClass result = new XmlClass(getName(), getIndex(), loadClasses()); result.setExcludedMethods(getExcludedMethods()); result.setIncludedMethods(getIncludedMethods()); return result; }
public void setXmlClasses(List<XmlClass> classes) { m_classes = classes; for (XmlClass c : classes) { for (XmlInclude m : c.getIncludedMethods()) { checkMethod(c.getSupportClass(), m.getName()); String methodName = makeMethodName(c.getName(), m.getName()); m_includedMethods.put(methodName, m); } } }