Skip to content
Permalink
Browse files
JENKINS-15638 Xvfb 'display name offset' defaults to 0, not 1 as
described, if unset
  • Loading branch information
Zoran Regvart committed Oct 30, 2012
1 parent 87997f1 commit fd33fe3d2da6690259b19126c2ba2c689b58186a
Showing with 38 additions and 2 deletions.
  1. +38 −2 src/main/java/org/jenkinsci/plugins/xvfb/XvfbBuildWrapper.java
@@ -42,13 +42,15 @@
import hudson.tasks.BuildWrapperDescriptor;
import hudson.tools.ToolInstallation;
import hudson.util.ArgumentListBuilder;
import hudson.util.FormValidation;

import java.io.IOException;
import java.util.Map;

import net.sf.json.JSONObject;

import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
import org.kohsuke.stapler.StaplerRequest;

public class XvfbBuildWrapper extends BuildWrapper {
@@ -64,6 +66,18 @@ public XvfbBuildWrapperDescriptor() {
load();
}

public FormValidation doCheckDisplayName(@QueryParameter final String value) throws IOException {
return validateOptionalNonNegativeInteger(value);
}

public FormValidation doCheckDisplayNameOffset(@QueryParameter final String value) throws IOException {
return validateOptionalPositiveInteger(value);
}

public FormValidation doCheckTimeout(@QueryParameter final String value) throws IOException {
return validateOptionalNonNegativeInteger(value);
}

@Override
public String getDisplayName() {
return Messages.XvfbBuildWrapper_DisplayName();
@@ -91,6 +105,22 @@ public void setInstallations(final XvfbInstallation... installations) {
this.installations = installations;
save();
}

private FormValidation validateOptionalNonNegativeInteger(final String value) {
if (value == null || value.trim().isEmpty()) {
return FormValidation.ok();
}

return FormValidation.validateNonNegativeInteger(value);
}

private FormValidation validateOptionalPositiveInteger(final String value) {
if (value == null || value.trim().isEmpty()) {
return FormValidation.ok();
}

return FormValidation.validatePositiveInteger(value);
}
}

private static final int MILLIS_IN_SECOND = 1000;
@@ -120,7 +150,8 @@ public void setInstallations(final XvfbInstallation... installations) {
private final String additionalOptions;

@DataBoundConstructor
public XvfbBuildWrapper(final String installationName, final Integer displayName, final String screen, final Boolean debug, final int timeout, int displayNameOffset, final String additionalOptions) {
public XvfbBuildWrapper(final String installationName, final Integer displayName, final String screen, final Boolean debug, final int timeout, final int displayNameOffset,
final String additionalOptions) {
this.installationName = installationName;
this.displayName = displayName;

@@ -133,7 +164,12 @@ public XvfbBuildWrapper(final String installationName, final Integer displayName

this.debug = Boolean.TRUE.equals(debug);
this.timeout = timeout;
this.displayNameOffset = displayNameOffset;
if (displayNameOffset <= 0) {
this.displayNameOffset = 1;
}
else {
this.displayNameOffset = displayNameOffset;
}
this.additionalOptions = additionalOptions;
}

0 comments on commit fd33fe3

Please sign in to comment.