Fixed NPE when parsing SoapUI junit xml file. (issue #1463)

git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@8028 71c3de6d-444a-0410-be80-ed276b4c234a
This commit is contained in:
redsolo committed 2008-03-27 15:27:13 +00:00
1 parent a264f1d897
commit 774fa7c090
4 files changed
+148 -1

No files matched your search

@@ -72,10 +72,26 @@ public final class SuiteResult implements Serializable {
// see http://www.nabble.com/More-JUnit-test-report-problems...-tf4267020.html#a12143611
for (Element suite : (List<Element>)root.elements("testsuite")) {
for (Element e : (List<Element>)suite.elements("testcase")) {
// https://hudson.dev.java.net/issues/show_bug.cgi?id=1233 indicates that
// when <testsuites> is present, we are better off using @classname on the
// individual testcase class.
addCase(new CaseResult(this,e.attributeValue("classname"),e));
// https://hudson.dev.java.net/issues/show_bug.cgi?id=1463 indicates that
// @classname may not exist in individual testcase elements. We now
// also test if the testsuite element has a package name that can be used
// as the class name instead of the file name which is default.
String classname = e.attributeValue("classname");
if (classname == null) {
classname = suite.attributeValue("name");
}
if (classname == null) {
addCase(new CaseResult(this,e));
} else {
addCase(new CaseResult(this,classname,e));
}
}
}
}
+53
View File
@@ -0,0 +1,53 @@
package hudson.tasks.junit;
import java.io.File;
import java.util.List;
import junit.framework.TestCase;
/**
* Test cases for parsing JUnit report XML files.
* As there are no XML schema for JUnit xml files, Hudson needs to handle
* varied xml files.
*
* @author Erik Ramfelt
*/
public class SuiteResultTest extends TestCase {
/**
* Verifying fix for issue #1233.
* https://hudson.dev.java.net/issues/show_bug.cgi?id=1233
*/
public void testIssue1233() throws Exception {
File file = new File(SuiteResultTest.class.getResource("junit-report-1233.xml").toURI());
SuiteResult result = new SuiteResult(file);
List<CaseResult> cases = result.getCases();
assertEquals("Class name is incorrect", "test.foo.bar.DefaultIntegrationTest", cases.get(0).getClassName());
assertEquals("Class name is incorrect", "test.foo.bar.BundleResolverIntegrationTest", cases.get(1).getClassName());
assertEquals("Class name is incorrect", "test.foo.bar.BundleResolverIntegrationTest", cases.get(2).getClassName());
assertEquals("Class name is incorrect", "test.foo.bar.ProjectSettingsTest", cases.get(3).getClassName());
assertEquals("Class name is incorrect", "test.foo.bar.ProjectSettingsTest", cases.get(4).getClassName());
}
/**
* Verifying fix for issue #1463.
* JUnit report file is generated by SoapUI Pro 1.7.6
* https://hudson.dev.java.net/issues/show_bug.cgi?id=1463
*/
public void testIssue1463() throws Exception {
File file = new File(SuiteResultTest.class.getResource("junit-report-1463.xml").toURI());
SuiteResult result = new SuiteResult(file);
List<CaseResult> cases = result.getCases();
for (CaseResult caseResult : cases) {
assertEquals("Test class name is incorrect in " + caseResult.getDisplayName(), "WLI-FI-Tests-Fake", caseResult.getClassName());
}
assertEquals("Test name is incorrect", "IF_importTradeConfirmationToDwh", cases.get(0).getName());
assertEquals("Test name is incorrect", "IF_getAmartaDisbursements", cases.get(1).getName());
assertEquals("Test name is incorrect", "IF_importGLReconDataToDwh", cases.get(2).getName());
assertEquals("Test name is incorrect", "IF_importTradeInstructionsToDwh", cases.get(3).getName());
assertEquals("Test name is incorrect", "IF_getDeviationTradeInstructions", cases.get(4).getName());
assertEquals("Test name is incorrect", "IF_getDwhGLData", cases.get(5).getName());
}
}
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8" ?>
<testsuites>
<testsuite errors="0" failures="0" hostname="archbuild" id="0"
name="StudioAllTests" package="test.infor.clearux.studio.integration"
tests="456" time="107.824" timestamp="2008-01-23T10:49:26">
<testcase classname="test.foo.bar.DefaultIntegrationTest" name="experimentsWithJavaElements" time="0.0" />
<testcase classname="test.foo.bar.BundleResolverIntegrationTest" name="testGetBundle" time="0.0" />
<testcase classname="test.foo.bar.BundleResolverIntegrationTest" name="testGetBundleLocation" time="0.656" />
<testcase classname="test.foo.bar.ProjectSettingsTest" name="testNatureAddition" time="0.125" />
<testcase classname="test.foo.bar.ProjectSettingsTest" name="testNatureRemoval" time="0.11" />
</testsuite>
</testsuites>
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="utf-8"?>
<testsuites>
<testsuite name="WLI-FI-Tests-Fake" tests="6" failures="0" errors="0" time="1426" package="IT-Interface-WLI-FI" id="1">
<properties>
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
<property name="sun.boot.library.path" value="C:\Program Files\Java\jdk1.6.0_02\jre\bin"/>
<property name="java.vm.version" value="1.6.0_02-b06"/>
<property name="java.vm.vendor" value="Sun Microsystems Inc."/>
<property name="java.vendor.url" value="http://java.sun.com/"/>
<property name="path.separator" value=";"/>
<property name="java.vm.name" value="Java HotSpot(TM) Client VM"/>
<property name="file.encoding.pkg" value="sun.io"/>
<property name="sun.java.launcher" value="SUN_STANDARD"/>
<property name="user.country" value="NO"/>
<property name="sun.os.patch.level" value="Service Pack 2"/>
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
<property name="user.dir" value="C:\CI\hudson\jobs\Interface_WLI-FI-Fake\workspace"/>
<property name="java.runtime.version" value="1.6.0_02-b06"/>
<property name="java.awt.graphicsenv" value="sun.awt.Win32GraphicsEnvironment"/>
<property name="java.endorsed.dirs" value="C:\Program Files\Java\jdk1.6.0_02\jre\lib\endorsed"/>
<property name="os.arch" value="x86"/>
<property name="java.io.tmpdir" value="C:\Documents and Settings\e5274\Local Settings\Temp\"/>
<property name="line.separator" value="
"/>
<property name="java.vm.specification.vendor" value="Sun Microsystems Inc."/>
<property name="user.variant" value=""/>
<property name="os.name" value="Windows XP"/>
<property name="sun.jnu.encoding" value="Cp1252"/>
<property name="java.library.path" value="C:\Program Files\Java\jdk1.6.0_02\bin;.;C:\WINDOWS\Sun\Java\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\Program Files\Java\jdk1.6.0_02\bin;C:\PROGRA~1\COMPUW~1\FILE-A~1\Dme;C:\PROGRA~1\COMPUW~1\FILE-A~1;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\oracle\ora92\jre\1.4.2\bin\client\;C:\oracle\ora92\jre\1.4.2\bin;c:\oracle\ora92\bin;C:\Program Files\Oracle\jre\1.1.8\bin;C:\Program Files\IBM\Personal Communications\;C:\Program Files\IBM\Trace Facility\;C:\Groovy\groovy-1.1-RC1\bin;C:\Program Files\Subversion\bin;C:\Program Files\GnuWin32\bin;C:\Program Files\putty;C:\Program Files\Common Files\Compuware"/>
<property name="java.specification.name" value="Java Platform API Specification"/>
<property name="java.class.version" value="50.0"/>
<property name="sun.management.compiler" value="HotSpot Client Compiler"/>
<property name="os.version" value="5.1"/>
<property name="user.home" value="C:\Documents and Settings\e5274"/>
<property name="user.timezone" value="Europe/Berlin"/>
<property name="java.awt.printerjob" value="sun.awt.windows.WPrinterJob"/>
<property name="file.encoding" value="Cp1252"/>
<property name="java.specification.version" value="1.6"/>
<property name="java.class.path" value="C:\eviware\soapUI-Pro-1.7.6\bin\soapui-pro-1.7.6.jar;C:\eviware\soapUI-Pro-1.7.6\lib\activation-1.1.jar;C:\eviware\soapUI-Pro-1.7.6\lib\javamail-1.4.jar;C:\eviware\soapUI-Pro-1.7.6\lib\wsdl4j-1.6.2-fixed.jar;C:\eviware\soapUI-Pro-1.7.6\lib\junit-3.8.1.jar;C:\eviware\soapUI-Pro-1.7.6\lib\log4j-1.2.14.jar;C:\eviware\soapUI-Pro-1.7.6\lib\looks-2.1.2.jar;C:\eviware\soapUI-Pro-1.7.6\lib\forms-1.0.7.jar;C:\eviware\soapUI-Pro-1.7.6\lib\jcalendar-1.3.2.jar;C:\eviware\soapUI-Pro-1.7.6\lib\commons-logging-1.1.jar;C:\eviware\soapUI-Pro-1.7.6\lib\not-yet-commons-ssl-0.3.8.jar;C:\eviware\soapUI-Pro-1.7.6\lib\commons-cli-1.0.jar;C:\eviware\soapUI-Pro-1.7.6\lib\commons-beanutils-1.7.0.jar;C:\eviware\soapUI-Pro-1.7.6\lib\commons-httpclient-3.0.1-soapui.jar;C:\eviware\soapUI-Pro-1.7.6\lib\swingx-SNAPSHOT.jar;C:\eviware\soapUI-Pro-1.7.6\lib\l2fprod-common-fontchooser-0.2-dev.jar;C:\eviware\soapUI-Pro-1.7.6\lib\commons-codec-1.3.jar;C:\eviware\soapUI-Pro-1.7.6\lib\groovy-all-1.0.jar;C:\eviware\soapUI-Pro-1.7.6\lib\jetty-6.1.5.jar;C:\eviware\soapUI-Pro-1.7.6\lib\jetty-util-6.1.5.jar;C:\eviware\soapUI-Pro-1.7.6\lib\servlet-api-2.5-6.1.5.jar;C:\eviware\soapUI-Pro-1.7.6\lib\jxl-2.6.5.jar;C:\eviware\soapUI-Pro-1.7.6\lib\idw-1.5.0.jar;C:\eviware\soapUI-Pro-1.7.6\lib\ant-1.6.1.jar;C:\eviware\soapUI-Pro-1.7.6\lib\xbean-2.3.0.jar;C:\eviware\soapUI-Pro-1.7.6\lib\xbean_xpath-2.3.0.jar;C:\eviware\soapUI-Pro-1.7.6\lib\xmlpublic-2.3.0.jar;C:\eviware\soapUI-Pro-1.7.6\lib\jsr173_1.0_api-xmlbeans-2.3.0.jar;C:\eviware\soapUI-Pro-1.7.6\lib\soapui-xmlbeans-1.7.6.jar;C:\eviware\soapUI-Pro-1.7.6\lib\license4j-1.3.jar;C:\eviware\soapUI-Pro-1.7.6\lib\soapui-1.7.6.jar;C:\eviware\soapUI-Pro-1.7.6\lib\soap-xmlbeans-1.2.jar;C:\eviware\soapUI-Pro-1.7.6\lib\j2ee-xmlbeans-1.4.jar;C:\eviware\soapUI-Pro-1.7.6\lib\ext-xmlbeans-1.0.jar;C:\eviware\soapUI-Pro-1.7.6\lib\saxon-8.8.jar;C:\eviware\soapUI-Pro-1.7.6\lib\saxon-dom-8.8.jar;C:\eviware\soapUI-Pro-1.7.6\lib\xmlunit-1.1.jar;C:\eviware\soapUI-Pro-1.7.6\lib\xmlsec-1.2.1.jar;C:\eviware\soapUI-Pro-1.7.6\lib\xalan-2.6.0.jar;C:\eviware\soapUI-Pro-1.7.6\lib\dtd-xercesImpl-2.9.1.jar;C:\eviware\soapUI-Pro-1.7.6\lib\wss4j-1.5.0.jar;C:\eviware\soapUI-Pro-1.7.6\lib\bcprov-jdk15-133.jar"/>
<property name="user.name" value="e5274"/>
<property name="java.vm.specification.version" value="1.0"/>
<property name="java.home" value="C:\Program Files\Java\jdk1.6.0_02\jre"/>
<property name="sun.arch.data.model" value="32"/>
<property name="user.language" value="no"/>
<property name="java.specification.vendor" value="Sun Microsystems Inc."/>
<property name="awt.toolkit" value="sun.awt.windows.WToolkit"/>
<property name="java.vm.info" value="mixed mode"/>
<property name="java.version" value="1.6.0_02"/>
<property name="java.ext.dirs" value="C:\Program Files\Java\jdk1.6.0_02\jre\lib\ext;C:\WINDOWS\Sun\Java\lib\ext"/>
<property name="sun.boot.class.path" value="C:\Program Files\Java\jdk1.6.0_02\jre\lib\resources.jar;C:\Program Files\Java\jdk1.6.0_02\jre\lib\rt.jar;C:\Program Files\Java\jdk1.6.0_02\jre\lib\sunrsasign.jar;C:\Program Files\Java\jdk1.6.0_02\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.6.0_02\jre\lib\jce.jar;C:\Program Files\Java\jdk1.6.0_02\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.6.0_02\jre\classes"/>
<property name="java.vendor" value="Sun Microsystems Inc."/>
<property name="file.separator" value="\"/>
<property name="java.vendor.url.bug" value="http://java.sun.com/cgi-bin/bugreport.cgi"/>
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
<property name="sun.cpu.endian" value="little"/>
<property name="sun.desktop" value="windows"/>
<property name="sun.cpu.isalist" value=""/>
</properties>
<testcase name="IF_importTradeConfirmationToDwh" time="198.0"/>
<testcase name="IF_getAmartaDisbursements" time="119.0"/>
<testcase name="IF_importGLReconDataToDwh" time="423.0"/>
<testcase name="IF_importTradeInstructionsToDwh" time="278.0"/>
<testcase name="IF_getDeviationTradeInstructions" time="408.0"/>
<testcase name="IF_getDwhGLData" time="0.0"/>
</testsuite>
</testsuites>