Skip to content

Commit

Permalink
[JENKINS-26192] Demonstrating @grab support in a realistic class load…
Browse files Browse the repository at this point in the history
…er environment.
  • Loading branch information
jglick committed Aug 19, 2016
1 parent 0732769 commit 5e60b00
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion src/test/java/plugins/WorkflowPluginTest.java
Expand Up @@ -24,10 +24,15 @@

package plugins;

import java.io.File;
import java.util.concurrent.Callable;
import javax.inject.Inject;
import org.apache.commons.io.FileUtils;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;
import static org.jenkinsci.test.acceptance.Matchers.hasContent;
import org.jenkinsci.test.acceptance.controller.JenkinsController;
import org.jenkinsci.test.acceptance.controller.LocalController;
import org.jenkinsci.test.acceptance.docker.DockerContainerHolder;
import org.jenkinsci.test.acceptance.docker.fixtures.GitContainer;
import org.jenkinsci.test.acceptance.junit.AbstractJUnitTest;
Expand All @@ -44,8 +49,8 @@
import org.jenkinsci.test.acceptance.po.DumbSlave;
import org.jenkinsci.test.acceptance.po.WorkflowJob;
import org.jenkinsci.test.acceptance.slave.SlaveController;
import static org.junit.Assert.*;

import org.junit.Assume;
import org.junit.Rule;
import org.junit.Test;
import org.junit.experimental.categories.Category;
Expand All @@ -62,6 +67,7 @@ public class WorkflowPluginTest extends AbstractJUnitTest {
@Inject private SlaveController slaveController;
@Inject DockerContainerHolder<GitContainer> gitServer;
@Rule public TemporaryFolder tmp = new TemporaryFolder();
@Inject JenkinsController controller;

@WithPlugins("workflow-aggregator@1.1")
@Test public void helloWorld() throws Exception {
Expand Down Expand Up @@ -209,4 +215,22 @@ public class WorkflowPluginTest extends AbstractJUnitTest {
job.startBuild().shouldSucceed();
}

@WithPlugins({"workflow-cps-global-lib@2.3-SNAPSHOT", "workflow-basic-steps@2.1", "workflow-job@2.5"})
@Issue("JENKINS-26192")
@Test public void grapeLibrary() throws Exception {
Assume.assumeThat("TODO otherwise we would need to set up SSH access to push via Git, which seems an awful hassle", controller, instanceOf(LocalController.class));
File workflowLibs = /* WorkflowLibRepository.workspace() */ new File(((LocalController) controller).getJenkinsHome(), "workflow-libs");
// Cf. GrapeTest.useBinary using JenkinsRule:
FileUtils.write(new File(workflowLibs, "src/pkg/Lists.groovy"),
"package pkg\n" +
"@Grab('commons-primitives:commons-primitives:1.0')\n" +
"import org.apache.commons.collections.primitives.ArrayIntList\n" +
"static def arrayInt() {new ArrayIntList()}");
WorkflowJob job = jenkins.jobs.create(WorkflowJob.class);
job.script.set("echo(/got ${pkg.Lists.arrayInt()}/)");
job.sandbox.check();
job.save();
assertThat(job.startBuild().shouldSucceed().getConsole(), containsString("got []"));
}

}

0 comments on commit 5e60b00

Please sign in to comment.