Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ea2662f
commit ea51f37
Showing
10 changed files
with
324 additions
and
7 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
src/main/java/org/jenkinsci/plugins/xunit/types/CheckInputMetric.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.jenkinsci.plugins.xunit.types; | ||
|
||
import com.thalesgroup.dtkit.junit.model.JUnitModel; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetricXSL; | ||
import com.thalesgroup.dtkit.metrics.model.InputType; | ||
import com.thalesgroup.dtkit.metrics.model.OutputMetric; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CheckInputMetric extends InputMetricXSL { | ||
|
||
@Override | ||
public InputType getToolType() { | ||
return InputType.TEST; | ||
} | ||
|
||
@Override | ||
public String getToolVersion() { | ||
return "N/A"; | ||
} | ||
|
||
@Override | ||
public String getToolName() { | ||
return "Check"; | ||
} | ||
|
||
@Override | ||
public boolean isDefault() { | ||
return true; | ||
} | ||
|
||
@Override | ||
public String getXslName() { | ||
return "check-to-junit-4.xsl"; | ||
} | ||
|
||
@Override | ||
public String[] getInputXsdNameList() { | ||
return null; | ||
} | ||
|
||
@Override | ||
public OutputMetric getOutputFormatType() { | ||
return JUnitModel.OUTPUT_JUNIT_4; | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/org/jenkinsci/plugins/xunit/types/CheckType.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package org.jenkinsci.plugins.xunit.types; | ||
|
||
import com.thalesgroup.dtkit.metrics.hudson.api.descriptor.TestTypeDescriptor; | ||
import com.thalesgroup.dtkit.metrics.hudson.api.type.TestType; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetric; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetricException; | ||
import com.thalesgroup.dtkit.metrics.model.InputMetricFactory; | ||
import com.thalesgroup.hudson.plugins.xunit.types.CustomInputMetric; | ||
import hudson.Extension; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CheckType extends TestType { | ||
|
||
@DataBoundConstructor | ||
public CheckType(String pattern, boolean failureIfNotNew, boolean deleteOutputFiles, boolean stopProcessingIfError) { | ||
super(pattern, failureIfNotNew, deleteOutputFiles, stopProcessingIfError); | ||
} | ||
|
||
@Extension | ||
public static class CheckInputMetricDescriptor extends TestTypeDescriptor<CheckType> { | ||
|
||
public CheckInputMetricDescriptor() { | ||
super(CheckType.class, null); | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return this.getClass().getName(); | ||
} | ||
|
||
@Override | ||
public InputMetric getInputMetric() { | ||
try { | ||
return InputMetricFactory.getInstance(CheckInputMetric.class); | ||
} catch (InputMetricException e) { | ||
throw new RuntimeException("Can't create the inputMetric object for the class " + CustomInputMetric.class); | ||
} | ||
} | ||
} | ||
} |
49 changes: 49 additions & 0 deletions
49
src/main/resources/org/jenkinsci/plugins/xunit/types/check-to-junit-4.xsl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<xsl:stylesheet version="1.0" | ||
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" | ||
xmlns:ck="http://check.sourceforge.net/ns" | ||
exclude-result-prefixes="ck"> | ||
<xsl:output method="xml" indent="yes"/> | ||
|
||
<xsl:variable name="checkCount" select="count(//ck:suite/ck:test)"/> | ||
<xsl:variable name="checkCountFailure" | ||
select="count(//ck:suite/ck:test[@result='failure'])"/> | ||
<xsl:variable name="suitename" select="//ck:suite/ck:title"/> | ||
|
||
<xsl:template match="/"> | ||
<testsuite> | ||
<xsl:attribute name="errors">0</xsl:attribute> | ||
<xsl:attribute name="tests"> | ||
<xsl:value-of select="$checkCount"/> | ||
</xsl:attribute> | ||
<xsl:attribute name="failures"> | ||
<xsl:value-of select="$checkCountFailure"/> | ||
</xsl:attribute> | ||
<xsl:attribute name="name"> | ||
<xsl:value-of select="$suitename"/> | ||
</xsl:attribute> | ||
<xsl:apply-templates/> | ||
</testsuite> | ||
</xsl:template> | ||
|
||
<xsl:template match="//ck:suite/ck:test"> | ||
<testcase> | ||
<xsl:attribute name="name"> | ||
<xsl:value-of select="./ck:id"/> | ||
</xsl:attribute> | ||
<xsl:attribute name="classname"> | ||
<xsl:value-of select="$suitename"/> | ||
</xsl:attribute> | ||
<xsl:attribute name="time">0</xsl:attribute> | ||
<xsl:if test="@result = 'failure'"> | ||
<error type="error"> | ||
<xsl:attribute name="message"> | ||
<xsl:value-of select="./ck:message"/> | ||
</xsl:attribute> | ||
</error> | ||
</xsl:if> | ||
</testcase> | ||
</xsl:template> | ||
|
||
<!-- this swallows all unmatched text --> | ||
<xsl:template match="text()|@*"/> | ||
</xsl:stylesheet> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 19 additions & 0 deletions
19
src/test/java/org/jenkinsci/plugins/xunit/types/CheckTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.jenkinsci.plugins.xunit.types; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CheckTypeTest extends AbstractTest { | ||
|
||
@Test | ||
public void testTestCase1() throws Exception { | ||
convertAndValidate(CheckInputMetric.class, "check/testcase1/input.xml", "check/testcase1/result.xml"); | ||
} | ||
|
||
@Test | ||
public void testTestCase2() throws Exception { | ||
convertAndValidate(CheckInputMetric.class, "check/testcase2/input.xml", "check/testcase2/result.xml"); | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/test/java/org/jenkinsci/plugins/xunit/types/CustomTypeTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package org.jenkinsci.plugins.xunit.types; | ||
|
||
import org.junit.Test; | ||
|
||
/** | ||
* @author Gregory Boissinot | ||
*/ | ||
public class CustomTypeTest extends AbstractTest { | ||
|
||
@Test | ||
public void testTestCase1() throws Exception { | ||
convertAndValidate("customTool/testcase1/input.xml", "customTool/testcase1/input.xsl", "customTool/testcase1/result.xml"); | ||
} | ||
|
||
} |
48 changes: 48 additions & 0 deletions
48
src/test/resources/org/jenkinsci/plugins/xunit/types/check/testcase1/input.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0"?> | ||
<testsuites xmlns="http://check.sourceforge.net/ns"> | ||
<datetime>2011-09-08 09:40:32</datetime> | ||
<suite> | ||
<title>test_check1.c</title> | ||
<test result="success"> | ||
<path>.</path> | ||
<fn>test_check1.c:23</fn> | ||
<id>test_list_3</id> | ||
<iteration>0</iteration> | ||
<description>Core</description> | ||
<message>Passed</message> | ||
</test> | ||
<test result="success"> | ||
<path>.</path> | ||
<fn>test_check1.c:33</fn> | ||
<id>test_single_entry</id> | ||
<iteration>0</iteration> | ||
<description>Core</description> | ||
<message>Passed</message> | ||
</test> | ||
<test result="success"> | ||
<path>.</path> | ||
<fn>test_check1.c:46</fn> | ||
<id>test_allow_spaces</id> | ||
<iteration>0</iteration> | ||
<description>Core</description> | ||
<message>Passed</message> | ||
</test> | ||
<test result="success"> | ||
<path>.</path> | ||
<fn>test_check1.c:60</fn> | ||
<id>test_only_first_entries</id> | ||
<iteration>0</iteration> | ||
<description>Core</description> | ||
<message>Passed</message> | ||
</test> | ||
<test result="success"> | ||
<path>.</path> | ||
<fn>test_check1.c:69</fn> | ||
<id>test_empty</id> | ||
<iteration>0</iteration> | ||
<description>Core</description> | ||
<message>Passed</message> | ||
</test> | ||
</suite> | ||
<duration>0.399376</duration> | ||
</testsuites> |
8 changes: 8 additions & 0 deletions
8
src/test/resources/org/jenkinsci/plugins/xunit/types/check/testcase1/result.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<testsuite errors="0" tests="5" failures="0" name="test_check1.c"> | ||
<testcase name="test_list_3" classname="test_check1.c" time="0"/> | ||
<testcase name="test_single_entry" classname="test_check1.c" time="0"/> | ||
<testcase name="test_allow_spaces" classname="test_check1.c" time="0"/> | ||
<testcase name="test_only_first_entries" classname="test_check1.c" time="0"/> | ||
<testcase name="test_empty" classname="test_check1.c" time="0"/> | ||
</testsuite> |
48 changes: 48 additions & 0 deletions
48
src/test/resources/org/jenkinsci/plugins/xunit/types/check/testcase2/input.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?xml version="1.0"?> | ||
<testsuites xmlns="http://check.sourceforge.net/ns"> | ||
<datetime>2011-09-08 09:43:11</datetime> | ||
<suite> | ||
<title>test_check1.c</title> | ||
<test result="failure"> | ||
<path>.</path> | ||
<fn>test_check1.c:19</fn> | ||
<id>test_list_3</id> | ||
<iteration>0</iteration> | ||
<description>Core</description> | ||
<message>Should have found 3 hosts</message> | ||
</test> | ||
<test result="success"> | ||
<path>.</path> | ||
<fn>test_check1.c:33</fn> | ||
<id>test_single_entry</id> | ||
<iteration>0</iteration> | ||
<description>Core</description> | ||
<message>Passed</message> | ||
</test> | ||
<test result="failure"> | ||
<path>.</path> | ||
<fn>test_check1.c:42</fn> | ||
<id>test_allow_spaces</id> | ||
<iteration>0</iteration> | ||
<description>Core</description> | ||
<message>Should have found 3 hosts</message> | ||
</test> | ||
<test result="failure"> | ||
<path>.</path> | ||
<fn>test_check1.c:58</fn> | ||
<id>test_only_first_entries</id> | ||
<iteration>0</iteration> | ||
<description>Core</description> | ||
<message>Assertion 'strcmp("bbb", mylist[1]) == 0' failed</message> | ||
</test> | ||
<test result="success"> | ||
<path>.</path> | ||
<fn>test_check1.c:69</fn> | ||
<id>test_empty</id> | ||
<iteration>0</iteration> | ||
<description>Core</description> | ||
<message>Passed</message> | ||
</test> | ||
</suite> | ||
<duration>0.759352</duration> | ||
</testsuites> |
14 changes: 14 additions & 0 deletions
14
src/test/resources/org/jenkinsci/plugins/xunit/types/check/testcase2/result.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<testsuite errors="0" tests="5" failures="3" name="test_check1.c"> | ||
<testcase name="test_list_3" classname="test_check1.c" time="0"> | ||
<error type="error" message="Should have found 3 hosts"/> | ||
</testcase> | ||
<testcase name="test_single_entry" classname="test_check1.c" time="0"/> | ||
<testcase name="test_allow_spaces" classname="test_check1.c" time="0"> | ||
<error type="error" message="Should have found 3 hosts"/> | ||
</testcase> | ||
<testcase name="test_only_first_entries" classname="test_check1.c" time="0"> | ||
<error type="error" message="Assertion 'strcmp("bbb", mylist[1]) == 0' failed"/> | ||
</testcase> | ||
<testcase name="test_empty" classname="test_check1.c" time="0"/> | ||
</testsuite> |