Skip to content
Permalink
Browse files

Merge pull request #92 from ikedam/feature/JENKINS-46700_AddTestsForS…

…ymbols

[JENKINS-46700] Add tests for symbols
  • Loading branch information
ikedam committed Oct 29, 2017
2 parents 1affa83 + 39df7cc commit 62c07a9b2477829e7ac608d83800b611e9bedc0d
Showing with 613 additions and 56 deletions.
  1. +50 −8 pom.xml
  2. +2 −1 src/main/java/hudson/plugins/copyartifact/CopyArtifact.java
  3. +2 −1 src/main/java/hudson/plugins/copyartifact/DownstreamBuildSelector.java
  4. +15 −4 src/main/java/hudson/plugins/copyartifact/LastCompletedBuildSelector.java
  5. +15 −4 src/main/java/hudson/plugins/copyartifact/ParameterizedBuildSelector.java
  6. +2 −1 src/main/java/hudson/plugins/copyartifact/PermalinkBuildSelector.java
  7. +15 −4 src/main/java/hudson/plugins/copyartifact/SavedBuildSelector.java
  8. +16 −4 src/main/java/hudson/plugins/copyartifact/SpecificBuildSelector.java
  9. +27 −5 src/main/java/hudson/plugins/copyartifact/StatusBuildSelector.java
  10. +2 −1 src/main/java/hudson/plugins/copyartifact/TriggeredBuildSelector.java
  11. +17 −4 src/main/java/hudson/plugins/copyartifact/WorkspaceSelector.java
  12. +0 −7 src/test/java/hudson/plugins/copyartifact/CopyArtifactTest.java
  13. +187 −12 src/test/java/hudson/plugins/copyartifact/CopyArtifactWorkflowTest.java
  14. +87 −0 src/test/java/hudson/plugins/copyartifact/testutils/CopyArtifactJenkinsRule.java
  15. BIN src/test/resources/hudson/plugins/copyartifact/CopyArtifactTest.zip
  16. +17 −0 ...resources/hudson/plugins/copyartifact/CopyArtifactTest/testPermissionWhenParameterized/config.xml
  17. +1 −0 ...ifactTest/testPermissionWhenParameterized/jobs/testJob/builds/2011-02-01_12-00-00/archive/foo.txt
  18. +12 −0 ...opyArtifactTest/testPermissionWhenParameterized/jobs/testJob/builds/2011-02-01_12-00-00/build.xml
  19. +19 −0 ...son/plugins/copyartifact/CopyArtifactTest/testPermissionWhenParameterized/jobs/testJob/config.xml
  20. +1 −0 ...actTest/testPermissionWhenParameterized/jobs/testJob2/builds/2011-02-01_13-00-00/archive/foo2.txt
  21. +12 −0 ...pyArtifactTest/testPermissionWhenParameterized/jobs/testJob2/builds/2011-02-01_13-00-00/build.xml
  22. +19 −0 ...on/plugins/copyartifact/CopyArtifactTest/testPermissionWhenParameterized/jobs/testJob2/config.xml
  23. +9 −0 ...hudson/plugins/copyartifact/CopyArtifactTest/testPermissionWhenParameterized/users/joe/config.xml
  24. +17 −0 ...n/plugins/copyartifact/CopyArtifactTest/testPermissionWhenParameterizedForMatrixConfig/config.xml
  25. +41 −0 ...tifact/CopyArtifactTest/testPermissionWhenParameterizedForMatrixConfig/jobs/testMatrix/config.xml
  26. +1 −0 ...trixConfig/jobs/testMatrix/configurations/axis-FOO/foo/builds/2011-04-12_09-00-00/archive/foo.txt
  27. +12 −0 ...dForMatrixConfig/jobs/testMatrix/configurations/axis-FOO/foo/builds/2011-04-12_09-00-00/build.xml
  28. +15 −0 ...PermissionWhenParameterizedForMatrixConfig/jobs/testMatrix/configurations/axis-FOO/foo/config.xml
58 pom.xml
@@ -4,7 +4,7 @@
<parent>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>2.5</version>
<version>2.35</version>
</parent>

<artifactId>copyartifact</artifactId>
@@ -22,9 +22,9 @@
</licenses>

<properties>
<jenkins.version>1.580.1</jenkins.version>
<java.level>6</java.level>
<workflow.version>1.4.2</workflow.version>
<!-- To support (and test) @Symbol annotations (requires workflow-cps >= 2.10) -->
<jenkins.version>1.642.3</jenkins.version>
<java.level>7</java.level>
</properties>

<dependencies>
@@ -53,6 +53,11 @@
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>structs</artifactId>
<version>1.6</version>
</dependency>
<!-- Used for UI test -->
<dependency>
<groupId>org.jenkins-ci.main</groupId>
@@ -92,25 +97,62 @@
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-job</artifactId>
<version>${workflow.version}</version>
<version>2.11.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-basic-steps</artifactId>
<version>${workflow.version}</version>
<version>2.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-cps</artifactId>
<version>${workflow.version}</version>
<version>2.32</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-durable-task-step</artifactId>
<version>${workflow.version}</version>
<version>2.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-step-api</artifactId>
<version>2.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-support</artifactId>
<version>2.14</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins.workflow</groupId>
<artifactId>workflow-api</artifactId>
<version>2.20</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>pipeline-build-step</artifactId>
<version>2.5.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>mailer</artifactId>
<version>1.20</version>
<scope>test</scope>
</dependency>
<dependency>
<!-- Required by maven-plugin -->
<groupId>org.apache.ant</groupId>
<artifactId>ant</artifactId>
<version>1.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
@@ -68,6 +68,7 @@
import org.acegisecurity.GrantedAuthority;
import org.acegisecurity.providers.UsernamePasswordAuthenticationToken;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
@@ -573,7 +574,7 @@ public String resolve(String name) {
return expected.equals(expanded);
}

@Extension
@Extension @Symbol("copyArtifacts")
public static final class DescriptorImpl extends BuildStepDescriptor<Builder> {

public FormValidation doCheckProjectName(
@@ -30,6 +30,7 @@
import jenkins.model.Jenkins;

import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
@@ -178,7 +179,7 @@ protected boolean isSelectable(Run<?, ?> run, EnvVars env) {
return false;
}

@Extension
@Extension @Symbol("downstream")
public static final class DescriptorImpl extends Descriptor<BuildSelector> {
@Override
public String getDisplayName() {
@@ -28,6 +28,8 @@
import hudson.model.Descriptor;
import hudson.model.Result;
import hudson.model.Run;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -44,8 +46,17 @@ public boolean isSelectable(Run<?,?> run, EnvVars env) {
return true;
}

@Extension
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
LastCompletedBuildSelector.class, Messages._LastCompletedBuildSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension @Symbol("lastCompleted")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(LastCompletedBuildSelector.class, Messages._LastCompletedBuildSelector_DisplayName());
DESCRIPTOR = this;
}
}
}
@@ -32,7 +32,9 @@
import hudson.model.Job;
import hudson.model.Run;

import jenkins.model.Jenkins;
import org.apache.commons.lang.StringUtils;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -102,8 +104,17 @@ private String resolveParameter(EnvVars env) {
return xml;
}

@Extension(ordinal=-20)
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
ParameterizedBuildSelector.class, Messages._ParameterizedBuildSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension(ordinal=-20) @Symbol("buildParameter")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(ParameterizedBuildSelector.class, Messages._ParameterizedBuildSelector_DisplayName());
DESCRIPTOR = this;
}
}
}
@@ -32,6 +32,7 @@
import hudson.model.Run;
import hudson.util.ComboBoxModel;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.AncestorInPath;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.QueryParameter;
@@ -57,7 +58,7 @@ public PermalinkBuildSelector(String id) {
return (run != null && filter.isSelectable(run, env)) ? run : null;
}

@Extension
@Extension @Symbol("permalink")
public static class DescriptorImpl extends Descriptor<BuildSelector> {
@Override
public String getDisplayName() {
@@ -27,6 +27,8 @@
import hudson.Extension;
import hudson.model.Descriptor;
import hudson.model.Run;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -42,8 +44,17 @@ protected boolean isSelectable(Run<?,?> run, EnvVars env) {
return run.isKeepLog();
}

@Extension(ordinal=50)
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
SavedBuildSelector.class, Messages._SavedBuildSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension(ordinal=50) @Symbol("latestSavedBuild")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(SavedBuildSelector.class, Messages._SavedBuildSelector_DisplayName());
DESCRIPTOR = this;
}
}
}
@@ -31,6 +31,9 @@
import hudson.model.Run;
import java.util.logging.Level;
import java.util.logging.Logger;

import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -94,8 +97,17 @@ public String getBuildNumber() {
return run;
}

@Extension(ordinal=-10)
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
SpecificBuildSelector.class, Messages._SpecificBuildSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension(ordinal=-10) @Symbol("specific")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(SpecificBuildSelector.class, Messages._SpecificBuildSelector_DisplayName());
DESCRIPTOR = this;
}
}
}
@@ -28,7 +28,10 @@
import hudson.model.Descriptor;
import hudson.model.Result;
import hudson.model.Run;
import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;

/**
* Copy artifacts from the latest successful or stable build.
@@ -37,11 +40,21 @@
public class StatusBuildSelector extends BuildSelector {
private Boolean stable;

@DataBoundConstructor
@Deprecated
public StatusBuildSelector(boolean stable) {
setStable(stable);
}

@DataBoundConstructor
public StatusBuildSelector() {
}

@DataBoundSetter
public void setStable(boolean stable) {
this.stable = stable ? Boolean.TRUE : null;
}


public boolean isStable() {
return stable != null && stable.booleanValue();
}
@@ -51,8 +64,17 @@ public boolean isSelectable(Run<?,?> run, EnvVars env) {
return isBuildResultBetterOrEqualTo(run, isStable() ? Result.SUCCESS : Result.UNSTABLE);
}

@Extension(ordinal=100)
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
StatusBuildSelector.class, Messages._StatusBuildSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension(ordinal=100) @Symbol("lastSuccessful")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(StatusBuildSelector.class, Messages._StatusBuildSelector_DisplayName());
DESCRIPTOR = this;
}
}
}
@@ -41,6 +41,7 @@
import hudson.model.Run;
import net.sf.json.JSONObject;

import org.jenkinsci.Symbol;
import org.jvnet.localizer.Localizable;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.StaplerRequest;
@@ -218,7 +219,7 @@ protected boolean isSelectable(Run<?,?> run, EnvVars env) {
return isFallbackToLastSuccessful() && isBuildResultBetterOrEqualTo(run, Result.SUCCESS);
}

@Extension(ordinal=25)
@Extension(ordinal=25) @Symbol("upstream")
public static class DescriptorImpl extends SimpleBuildSelectorDescriptor {
private UpstreamFilterStrategy globalUpstreamFilterStrategy;

@@ -31,6 +31,10 @@
import hudson.model.Run;
import java.io.IOException;
import java.io.PrintStream;

import jenkins.model.Jenkins;
import org.jenkinsci.Symbol;
import org.jvnet.localizer.Localizable;
import org.kohsuke.stapler.DataBoundConstructor;

/**
@@ -62,8 +66,17 @@ public boolean isSelectable(Run<?,?> run, EnvVars env) {
}
}

@Extension(ordinal=-20)
public static final Descriptor<BuildSelector> DESCRIPTOR =
new SimpleBuildSelectorDescriptor(
WorkspaceSelector.class, Messages._WorkspaceSelector_DisplayName());
/**
* @deprecated
* here for backward compatibility. Get it from {@link Jenkins#getDescriptor(Class)}
*/
public static /*almost final*/ Descriptor<BuildSelector> DESCRIPTOR;

@Extension(ordinal=-20) @Symbol("workspace")
public static final class DescriptorImpl extends SimpleBuildSelectorDescriptor {
public DescriptorImpl() {
super(WorkspaceSelector.class, Messages._WorkspaceSelector_DisplayName());
DESCRIPTOR = this;
}
}
}

0 comments on commit 62c07a9

Please sign in to comment.