Log Message
JENKINS-30369: Support specifying result file formats during result publishing
Modified Paths
- trunk/hudson/plugins/klaros-testmanagement/src/main/java/hudson/plugins/klaros/KlarosTestResultPublisher.java
- trunk/hudson/plugins/klaros-testmanagement/src/main/java/hudson/plugins/klaros/ResultSet.java
- trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config.jelly
- trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config.properties
- trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config_de.properties
Added Paths
Diff
Modified: trunk/hudson/plugins/klaros-testmanagement/src/main/java/hudson/plugins/klaros/KlarosTestResultPublisher.java (41393 => 41394)
--- trunk/hudson/plugins/klaros-testmanagement/src/main/java/hudson/plugins/klaros/KlarosTestResultPublisher.java 2015-09-08 11:09:12 UTC (rev 41393)
+++ trunk/hudson/plugins/klaros-testmanagement/src/main/java/hudson/plugins/klaros/KlarosTestResultPublisher.java 2015-09-09 15:20:58 UTC (rev 41394)
@@ -56,6 +56,7 @@
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.methods.FileRequestEntity;
+import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.commons.httpclient.methods.RequestEntity;
import org.apache.commons.httpclient.methods.StringRequestEntity;
@@ -78,6 +79,34 @@
private static final long serialVersionUID = -3220438013049857329L;
+ private static final ArrayList<ResultFormat> DEFAULT_FORMATS;
+
+ static {
+ DEFAULT_FORMATS = new ArrayList<ResultFormat>();
+ DEFAULT_FORMATS.add(new ResultFormat("aunit", "AUnit"));
+ DEFAULT_FORMATS.add(new ResultFormat("boosttest", "Boost Test"));
+ DEFAULT_FORMATS.add(new ResultFormat("check", "Check"));
+ DEFAULT_FORMATS.add(new ResultFormat("cpptestunit", "UnitTest++"));
+ DEFAULT_FORMATS.add(new ResultFormat("cppunit", "CppUnit"));
+ DEFAULT_FORMATS.add(new ResultFormat("ctest", "ctest"));
+ DEFAULT_FORMATS.add(new ResultFormat("cunit", "CUnit"));
+ DEFAULT_FORMATS.add(new ResultFormat("fpcunit", "Free Pascal Unit"));
+ DEFAULT_FORMATS.add(new ResultFormat("jubula", "Jubula/GUIDancer"));
+ DEFAULT_FORMATS.add(new ResultFormat("junit", "JUnit"));
+ DEFAULT_FORMATS.add(new ResultFormat("mbunit", "MbUnit"));
+ DEFAULT_FORMATS.add(new ResultFormat("mstest", "MSTest"));
+ DEFAULT_FORMATS.add(new ResultFormat("nunit", "NUnit"));
+ DEFAULT_FORMATS.add(new ResultFormat("phpunit", "PHPUnit"));
+ DEFAULT_FORMATS.add(new ResultFormat("qftest", "QFTest"));
+ DEFAULT_FORMATS.add(new ResultFormat("qtestlib", "QTestLib"));
+ DEFAULT_FORMATS.add(new ResultFormat("ranorex", "Ranorex"));
+ DEFAULT_FORMATS.add(new ResultFormat("tusar", "Tusar"));
+ DEFAULT_FORMATS.add(new ResultFormat("unittest", "UnitTest"));
+ DEFAULT_FORMATS.add(new ResultFormat("testcomplete", "Test Complete"));
+ DEFAULT_FORMATS.add(new ResultFormat("valgrind", "Valgrind"));
+ DEFAULT_FORMATS.add(new ResultFormat("xunitdotnet", "xUnit.net"));
+ }
+
/** The Klaros project id. */
private String config;
@@ -91,7 +120,7 @@
private String sut;
/** The type. */
- private String type = "junit";
+ private String type;
/**
* The path test results.
@@ -116,6 +145,8 @@
/** The create test suite flag. */
private boolean createTestSuite;
+ private ResultFormat[] types;
+
/**
* Instantiates a new Klaros test result publisher.
*
@@ -145,8 +176,43 @@
this.url = ""
this.username = username;
this.password = password;
+ this.type = type;
+ this.types = null;
}
+ private ResultFormat[] loadFormats() {
+
+ final String strURL = buildServletURL(url) + "/supportedFormats";
+
+ GetMethod get = new GetMethod(strURL);
+ StringBuffer query = new StringBuffer();
+ if (StringUtils.isNotEmpty(username)) {
+ query.append("username=").append(username).append("&password=").append(password);
+ }
+ get.setQueryString(query.toString());
+
+ try {
+ HttpClient client = new HttpClient();
+ int result = client.executeMethod(get);
+ if (result == HttpServletResponse.SC_OK) {
+ String response = get.getResponseBodyAsString();
+ if (StringUtils.isNotBlank(response)) {
+ String[] ids = response.split("=.*\\R");
+ String[] names = response.split(".*=\\R");
+ ResultFormat[] formats = new ResultFormat[ids.length];
+ for (int i=0; i< ids.length; i++ ) {
+ formats[i] = new ResultFormat(ids[i], names[i]);
+ }
+ }
+ }
+ } catch (Exception e) {
+ // ignore
+ } finally {
+ get.releaseConnection();
+ }
+ return DEFAULT_FORMATS.toArray(new ResultFormat[DEFAULT_FORMATS.size()]);
+ }
+
/**
* Descriptor.
*
@@ -297,17 +363,50 @@
sut = StringUtils.trim(value);
}
+ /**
+ * Checks if the create test suite flag is set.
+ *
+ * @return true, if set
+ */
public boolean isCreateTestSuite() {
return createTestSuite;
}
+ /**
+ * Sets the create test suite flag.
+ *
+ * @param createTestSuite the new create test suite flag
+ */
public void setCreateTestSuite(boolean createTestSuite) {
this.createTestSuite = createTestSuite;
}
/**
+ * Gets the valid result types.
+ *
+ * @return the valid result types
+ */
+ public ResultFormat[] getTypes() {
+
+ if (types == null) {
+ types = loadFormats();
+ }
+ return types;
+ }
+
+ /**
+ * Sets the valid result types.
+ *
+ * @param types the new result types
+ */
+ public void setTypes(ResultFormat[] types) {
+
+ this.types = types;
+ }
+
+ /**
* Gets the path test results.
*
* @return the path test results
@@ -337,7 +436,7 @@
private void migratePathTestResults() {
if (StringUtils.isNotEmpty(pathTestResults)) {
- resultSets = new ResultSet[]{new ResultSet(StringUtils.trim(pathTestResults)) };
+ resultSets = new ResultSet[]{new ResultSet(StringUtils.trim(pathTestResults), "") };
pathTestResults = null;
}
}
@@ -422,7 +521,7 @@
listener.getLogger().println(
"The test result(s) contained in target " + resultSet.getSpec()
+ " will be exported to the " + "Klaros-Testmanagement Server at "
- + getUrl(url) + ".");
+ + getUrl(url) + "using the " + resultSet.getFormat() + " format.");
listener.getLogger().print("With parameters Project[" + config + "]");
if (StringUtils.isNotBlank(iteration)) {
listener.getLogger().print(" Iteration[" + iteration + "]");
@@ -582,7 +681,8 @@
query.append("&iteration=").append(expandVariables(iteration, build));
}
query.append("&env=").append(expandVariables(env, build)).append("&sut=").append(
- expandVariables(sut, build)).append("&type=").append(expandVariables(type, build));
+ expandVariables(sut, build)).append("&type=").append(
+ expandVariables(resultSet.getFormat(), build));
if (createTestSuite) {
query.append("&createTestSuiteResults=true");
}
@@ -699,7 +799,7 @@
private List<String> urls = new ArrayList<String>();
/**
- * Instantiates a new descriptor impl.
+ * Instantiates a new descriptor implementation.
*/
public DescriptorImpl() {
@@ -795,8 +895,9 @@
if (findText(open(new URL(cooked)), "Klaros")) {
result = FormValidation.ok();
} else {
- result = FormValidation.error( //
- "This URL does not point to a running Klaros-Testmanagement installation");
+ result =
+ FormValidation
+ .error("This URL does not point to a running Klaros-Testmanagement installation");
}
} catch (IOException e) {
result = handleIOException(value, e);
Added: trunk/hudson/plugins/klaros-testmanagement/src/main/java/hudson/plugins/klaros/ResultFormat.java (0 => 41394)
--- trunk/hudson/plugins/klaros-testmanagement/src/main/java/hudson/plugins/klaros/ResultFormat.java (rev 0)
+++ trunk/hudson/plugins/klaros-testmanagement/src/main/java/hudson/plugins/klaros/ResultFormat.java 2015-09-09 15:20:58 UTC (rev 41394)
@@ -0,0 +1,41 @@
+package hudson.plugins.klaros;
+
+public class ResultFormat {
+
+ private final String id;
+ private final String name;
+
+ /**
+ * Instantiates a new result format.
+ *
+ * @param id the format id
+ * @param name the format name
+ * @param script the script to transform this format
+ */
+ ResultFormat(final String id, final String name) {
+
+ this.id = id;
+ this.name = name;
+ }
+
+ /**
+ * Gets the id.
+ *
+ * @return the id
+ */
+ public String getId() {
+
+ return id;
+ }
+
+ /**
+ * Gets the name.
+ *
+ * @return the name
+ */
+ public String getName() {
+
+ return name;
+ }
+
+}
\ No newline at end of file
Modified: trunk/hudson/plugins/klaros-testmanagement/src/main/java/hudson/plugins/klaros/ResultSet.java (41393 => 41394)
--- trunk/hudson/plugins/klaros-testmanagement/src/main/java/hudson/plugins/klaros/ResultSet.java 2015-09-08 11:09:12 UTC (rev 41393)
+++ trunk/hudson/plugins/klaros-testmanagement/src/main/java/hudson/plugins/klaros/ResultSet.java 2015-09-09 15:20:58 UTC (rev 41394)
@@ -1,3 +1,15 @@
+/*
+ * Copyright 2003 - 2015 verit Informationssysteme GmbH, Europaallee 10,
+ * 67657 Kaiserslautern, Germany, http://www.verit.de.
+ *
+ * All rights reserved.
+ *
+ * This product or document is protected by copyright and distributed
+ * under licenses restricting its use, copying, distribution, and
+ * decompilation. No part of this product or documentation may be
+ * reproduced in any form by any means without prior written authorization
+ * of verit Informationssysteme GmbH and its licensors, if any.
+ */
package hudson.plugins.klaros;
import org.apache.commons.lang.StringUtils;
@@ -3,23 +15,72 @@
import org.kohsuke.stapler.DataBoundConstructor;
+/**
+ * The result set specification.
+ */
public class ResultSet {
-
+
+ private static final String DEFAULT_FORMAT = "junit";
+
private String spec;
+ private String format;
- @DataBoundConstructor
+ public ResultSet() {
+
+ format = DEFAULT_FORMAT;
+ }
+
public ResultSet(String spec) {
-
- this.spec = StringUtils.trim(spec);
+
+ this(spec, DEFAULT_FORMAT);
}
+ @DataBoundConstructor
+ public ResultSet(String spec, String format) {
+
+ this.spec = StringUtils.strip(spec);
+ this.format = StringUtils.strip(format);
+ if (StringUtils.isBlank(format)) {
+ format = DEFAULT_FORMAT;
+ }
+ }
+
+ /**
+ * Gets the spec.
+ *
+ * @return the spec
+ */
public String getSpec() {
-
+
return spec;
}
-
+ /**
+ * Sets the spec.
+ *
+ * @param spec the new spec
+ */
public void setSpec(String spec) {
-
+
this.spec = StringUtils.trim(spec);
}
-}
\ No newline at end of file
+
+ /**
+ * Gets the format.
+ *
+ * @return the format
+ */
+ public String getFormat() {
+
+ return format;
+ }
+
+ /**
+ * Sets the format.
+ *
+ * @param format the new format
+ */
+ public void setFormat(String format) {
+
+ this.format = format;
+ }
+}
Modified: trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config.jelly (41393 => 41394)
--- trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config.jelly 2015-09-08 11:09:12 UTC (rev 41393)
+++ trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config.jelly 2015-09-09 15:20:58 UTC (rev 41394)
@@ -94,6 +94,15 @@
checkUrl="'descriptorByName/KlarosTestResultPublisher/check?value='+escape(this.value)" />
</f:entry>
+ <f:entry title="${%ResultFormat}" field="format"
+ description="${%ResultFormatDescription}">
+ <select name="format">
+ <j:forEach var="t" items="${instance.types}">
+ <f:option value="${t.id}" selected="${resultSet.format==t.id}">${t.name}</f:option>
+ </j:forEach>
+ </select>
+ </f:entry>
+
<f:entry title="">
<div align="right">
<f:repeatableDeleteButton />
Modified: trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config.properties (41393 => 41394)
--- trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config.properties 2015-09-08 11:09:12 UTC (rev 41393)
+++ trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config.properties 2015-09-09 15:20:58 UTC (rev 41394)
@@ -34,3 +34,5 @@
Password=Password
Test Connection=Test Connection
Testing...=Testing...
+ResultFormat=Result Format
+ResultFormatDescription=The format of the uploaded result files
Modified: trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config_de.properties (41393 => 41394)
--- trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config_de.properties 2015-09-08 11:09:12 UTC (rev 41393)
+++ trunk/hudson/plugins/klaros-testmanagement/src/main/resources/hudson/plugins/klaros/KlarosTestResultPublisher/config_de.properties 2015-09-09 15:20:58 UTC (rev 41394)
@@ -34,3 +34,5 @@
Password=Passwort
Test Connection=Verbindung testen
Testing...=Teste...
+ResultFormat=Ergebnisformat
+ResultFormatDescription=Das Format der \xFCbertragenen Ergebnisdateien
You received this message because you are subscribed to the Google Groups "Jenkins Commits" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
