Skip to content
Permalink
Browse files
[JENKINS-26192] Demonstrating @grab support in a realistic class load…
…er environment.
  • Loading branch information
jglick committed Aug 19, 2016
1 parent 0732769 commit 5e60b00fd4750fb0dd6c0ec28516f6ee57b88d90
Showing with 25 additions and 1 deletion.
  1. +25 −1 src/test/java/plugins/WorkflowPluginTest.java
@@ -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;
@@ -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;
@@ -62,6 +67,7 @@
@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 {
@@ -209,4 +215,22 @@
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.