当前位置: 首页>>代码示例>>Java>>正文


Java TestBuilder类代码示例

本文整理汇总了Java中org.jvnet.hudson.test.TestBuilder的典型用法代码示例。如果您正苦于以下问题:Java TestBuilder类的具体用法?Java TestBuilder怎么用?Java TestBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TestBuilder类属于org.jvnet.hudson.test包,在下文中一共展示了TestBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setup

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
@Before
public void setup() throws IOException {
    fails = new HashSet<>();
    project = j.createFreeStyleProject();
    project.getBuildersList().add(new TestBuilder() {

        @Override
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
            return !fails.contains(build.getNumber());
        }
    });

    redsReport = new RedtimeReportPortlet("RedsReport") {

        @Override
        protected List<Job> getDashboardJobs() {
            return Collections.singletonList((Job) project);
        }

    };
}
 
开发者ID:oliveiragabriel07,项目名称:redtime,代码行数:22,代码来源:RedtimeReportPortletTest.java

示例2: testSymlinks

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
@Issue("JENKINS-20546")
@Test
public void testSymlinks() throws Exception {
    FreeStyleProject p1 = rule.createFreeStyleProject("p1");
    p1.getBuildersList().add(new TestBuilder() {
        @Override public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
            build.getWorkspace().child("plain").write("text", null);
            build.getWorkspace().child("link1").symlinkTo("plain", listener);
            build.getWorkspace().child("link2").symlinkTo("nonexistent", listener);
            return true;
        }
    });
    p1.getPublishersList().add(new ArtifactArchiver("**", "", false, false));
    rule.buildAndAssertSuccess(p1);
    FreeStyleProject p2 = rule.createFreeStyleProject("p2");
    p2.getBuildersList().add(CopyArtifactUtil.createRunSelector("p1", null, new StatusRunSelector(StatusRunSelector.BuildStatus.STABLE), null, "", false, false, true));
    FreeStyleBuild b = rule.buildAndAssertSuccess(p2);
    FilePath ws = b.getWorkspace();
    assertEquals("text", ws.child("plain").readToString());
    assertEquals("plain", ws.child("link1").readLink());
    assertEquals("nonexistent", ws.child("link2").readLink());
}
 
开发者ID:jenkinsci,项目名称:run-selector-plugin,代码行数:23,代码来源:CopyArtifactTest.java

示例3: push_ciSkip

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
@Test
public void push_ciSkip() throws IOException, InterruptedException {
    final OneShotEvent buildTriggered = new OneShotEvent();
    FreeStyleProject project = jenkins.createFreeStyleProject();
    project.getBuildersList().add(new TestBuilder() {
        @Override
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
            buildTriggered.signal();
            return true;
        }
    });
    project.setQuietPeriod(0);
    pushHookTriggerHandler.handle(project, pushHook()
            .withCommits(Arrays.asList(commit().withMessage("some message").build(),
                                       commit().withMessage("[ci-skip]").build()))
            .build(), true, newBranchFilter(branchFilterConfig().build(BranchFilterType.All)),
                                  newMergeRequestLabelFilter(null));

    buildTriggered.block(10000);
    assertThat(buildTriggered.isSignaled(), is(false));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:22,代码来源:PushHookTriggerHandlerImplTest.java

示例4: pipeline_ciSkip

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
@Test
/**
 * always triggers since pipeline events do not contain ci skip message
 */
public void pipeline_ciSkip() throws IOException, InterruptedException {
    final OneShotEvent buildTriggered = new OneShotEvent();
    FreeStyleProject project = jenkins.createFreeStyleProject();
    project.getBuildersList().add(new TestBuilder() {
        @Override
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
            buildTriggered.signal();
            return true;
        }
    });
    project.setQuietPeriod(0);
    pipelineHookTriggerHandler.handle(project, pipelineHook , true, newBranchFilter(branchFilterConfig().build(BranchFilterType.All)),
        newMergeRequestLabelFilter(null));

    buildTriggered.block(10000);
    assertThat(buildTriggered.isSignaled(), is(true));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:22,代码来源:PipelineHookTriggerHandlerImplTest.java

示例5: pipeline_build

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
@Test
public void pipeline_build() throws IOException, InterruptedException, GitAPIException, ExecutionException {

    final OneShotEvent buildTriggered = new OneShotEvent();
    FreeStyleProject project = jenkins.createFreeStyleProject();
    project.getBuildersList().add(new TestBuilder() {
        @Override
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
            buildTriggered.signal();
            return true;
        }
    });
    project.setQuietPeriod(0);

    pipelineHookTriggerHandler.handle(project, pipelineHook, false, newBranchFilter(branchFilterConfig().build(BranchFilterType.All)),
                                  newMergeRequestLabelFilter(null));

    buildTriggered.block(10000);
    assertThat(buildTriggered.isSignaled(), is(true));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:21,代码来源:PipelineHookTriggerHandlerImplTest.java

示例6: mergeRequest_ciSkip

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
@Test
public void mergeRequest_ciSkip() throws IOException, InterruptedException {
    final OneShotEvent buildTriggered = new OneShotEvent();
    FreeStyleProject project = jenkins.createFreeStyleProject();
    project.getBuildersList().add(new TestBuilder() {
        @Override
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
            buildTriggered.signal();
            return true;
        }
    });
    project.setQuietPeriod(0);
    MergeRequestHookTriggerHandler mergeRequestHookTriggerHandler = new MergeRequestHookTriggerHandlerImpl(Arrays.asList(State.opened, State.reopened), false);
    mergeRequestHookTriggerHandler.handle(project, mergeRequestHook()
            .withObjectAttributes(mergeRequestObjectAttributes().withDescription("[ci-skip]").build())
            .build(), true, BranchFilterFactory.newBranchFilter(branchFilterConfig().build(BranchFilterType.All)),
                                          newMergeRequestLabelFilter(null));

    buildTriggered.block(10000);
    assertThat(buildTriggered.isSignaled(), is(false));
}
 
开发者ID:jenkinsci,项目名称:gitlab-plugin,代码行数:22,代码来源:MergeRequestHookTriggerHandlerImplTest.java

示例7: subscribeProject

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
protected void subscribeProject(final ProjectFixture fixture) throws Exception {
    String name = UUID.randomUUID().toString();

    final FreeStyleProject job = jenkinsRule.getInstance().createProject(FreeStyleProject.class, name);
    job.setScm(new NullSCM());
    if (fixture.getScm() != null) {
        job.setScm(fixture.getScm());
    }

    final String uuid = this.sqsQueue.getUuid();

    SQSTrigger trigger = null;

    if (fixture.isHasTrigger()) {
        trigger = new SQSTrigger(uuid, fixture.isSubscribeInternalScm(), fixture.getScmConfigs());
    }

    final OneShotEvent event = new OneShotEvent();
    job.getBuildersList().add(new TestBuilder() {

        @Override
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
            event.signal();
            fixture.setLastBuild(job.getLastBuild());
            return true;
        }
    });
    job.setQuietPeriod(0);

    if (trigger != null) {
        trigger.start(job, false);
        job.addTrigger(trigger);
    }

    fixture.setEvent(event);
}
 
开发者ID:riboseinc,项目名称:aws-codecommit-trigger-plugin,代码行数:37,代码来源:AbstractFreestyleIT.java

示例8: createMarathonFileBuilder

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
private TestBuilder createMarathonFileBuilder(final String payload) {
    return new TestBuilder() {
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
                               BuildListener listener) throws InterruptedException, IOException {
            build.getWorkspace().child("marathon.json").write(payload, "UTF-8");
            return true;
        }
    };
}
 
开发者ID:jenkinsci,项目名称:marathon-plugin,代码行数:10,代码来源:MarathonRecorderTest.java

示例9: runProjectWithWrapper

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
private FreeStyleProject runProjectWithWrapper(boolean useFirefox, boolean useChrome, boolean retainBuildOnFailure, DockerClient client, boolean failBuild) throws Exception {
    if (client == null) {
        dockerClient = mock(DockerClient.class);
    }
    FreeStyleProject p = jenkins.createFreeStyleProject();
    List<BrowserInstance> instances = new ArrayList<BrowserInstance>();
    if (useFirefox) {
        instances.add(new BrowserInstance(firefoxImage));
    }
    if (useChrome) {
        instances.add(new BrowserInstance(chromeImage));
    }
    
    TestgridBuildWrapper wrapper = new TestgridBuildWrapper(instances, retainBuildOnFailure);
    TestgridBuildWrapper.DescriptorImpl descriptor = wrapper.getDescriptor();
    descriptor.setHubImage(hubImage);
    
    p.getBuildWrappersList().add(wrapper.setDockerClient(dockerClient));
    when(dockerClient.getIpAddress(any(String.class))).thenReturn(ipAddress);
    p.getBuildersList().add(new GridUrlEnvBuilder());
    if (failBuild) {
        p.getBuildersList().add(new TestBuilder() {
            @Override
            public boolean perform(AbstractBuild<?, ?> abstractBuild, Launcher launcher, BuildListener buildListener) throws InterruptedException, IOException {
                return false;
            }
        });
    }
    jenkins.getInstance().rebuildDependencyGraph();
    p.scheduleBuild(new Cause.UserIdCause());
    jenkins.waitUntilNoActivity();

    return p;
}
 
开发者ID:DevOnGlobal,项目名称:testgrid-plugin,代码行数:35,代码来源:TestgridBuildWrapperTest.java

示例10: addCopyBuildStep

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
public static void addCopyBuildStep(FreeStyleProject p, final String fileName, final Class resourceClass, final String resourceName) {
    p.getBuildersList().add(new TestBuilder() {
        @Override
        public boolean perform(AbstractBuild build, Launcher launcher, BuildListener buildListener) throws InterruptedException, IOException {
            build.getWorkspace().child(fileName).copyFrom(resourceClass.getResourceAsStream(resourceName));
            return true;
        }
    });
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:10,代码来源:TestUtils.java

示例11: echoBuilder

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
private Builder echoBuilder(final String fileName, final String content) {
    return new TestBuilder() {
        @Override
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
            build.getWorkspace().child(fileName).write(content, "UTF-8");
            return true;
        }
    };
}
 
开发者ID:uber,项目名称:phabricator-jenkins-plugin,代码行数:10,代码来源:BuildResultProcessorTest.java

示例12: testGetZipWithZip

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
@Test
public void testGetZipWithZip() throws Exception {
    final OneShotEvent buildEnded = new OneShotEvent();

    FreeStyleProject p = j.createFreeStyleProject();
    p.getBuildersList().add(new TestBuilder() {
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
                               BuildListener listener) throws InterruptedException, IOException {
            build.getWorkspace().child("echo.zip").copyFrom(new FileInputStream(testUtil.getResource("echo.zip")));
            buildEnded.signal();
            return true;
        }
    });

    p.scheduleBuild2(0);
    buildEnded.block();

    JenkinsLogger logger = new JenkinsLogger(System.out);
    WorkSpaceZipper workSpaceZipper = new WorkSpaceZipper(p.getSomeWorkspace(), logger);
    File zip = workSpaceZipper.getZip("echo.zip");

    assertTrue(zip.exists());
    assertTrue(zip.getAbsolutePath().contains("awslambda-"));

    ZipFile zipFile = new ZipFile(zip);
    assertNotNull(zipFile);
    assertNotNull(zipFile.getEntry("index.js"));
}
 
开发者ID:XT-i,项目名称:aws-lambda-jenkins-plugin,代码行数:29,代码来源:WorkSpaceZipperTest.java

示例13: testGetZipFolder

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
@Test
public void testGetZipFolder() throws Exception {
    final OneShotEvent buildEnded = new OneShotEvent();

    FreeStyleProject p = j.createFreeStyleProject();
    p.getBuildersList().add(new TestBuilder() {
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
                               BuildListener listener) throws InterruptedException, IOException {
            build.getWorkspace().child("echo").child("index.js").copyFrom(new FileInputStream(testUtil.getResource("echo/index.js")));
            buildEnded.signal();
            return true;
        }
    });

    p.scheduleBuild2(0);
    buildEnded.block();

    JenkinsLogger logger = new JenkinsLogger(System.out);
    WorkSpaceZipper workSpaceZipper = new WorkSpaceZipper(p.getSomeWorkspace(), logger);
    File zip = workSpaceZipper.getZip("echo");

    assertTrue(zip.exists());
    assertTrue(zip.getAbsolutePath().contains("awslambda-"));

    ZipFile zipFile = new ZipFile(zip);
    assertNotNull(zipFile);
    assertNotNull(zipFile.getEntry("index.js"));
}
 
开发者ID:XT-i,项目名称:aws-lambda-jenkins-plugin,代码行数:29,代码来源:WorkSpaceZipperTest.java

示例14: testGetZipFolderEmpty

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
@Test
public void testGetZipFolderEmpty() throws Exception {
    final OneShotEvent buildEnded = new OneShotEvent();

    FreeStyleProject p = j.createFreeStyleProject();
    p.getBuildersList().add(new TestBuilder() {
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher,
                               BuildListener listener) throws InterruptedException, IOException {
            build.getWorkspace().child("echo").mkdirs();
            buildEnded.signal();
            return true;
        }
    });

    p.scheduleBuild2(0);
    buildEnded.block();

    JenkinsLogger logger = new JenkinsLogger(System.out);
    WorkSpaceZipper workSpaceZipper = new WorkSpaceZipper(p.getSomeWorkspace(), logger);
    File zip = workSpaceZipper.getZip("echo");

    assertTrue(zip.exists());
    assertTrue(zip.getAbsolutePath().contains("awslambda-"));

    ZipFile zipFile = new ZipFile(zip);
    assertNotNull(zipFile);
    assertFalse(zipFile.entries().hasMoreElements());
}
 
开发者ID:XT-i,项目名称:aws-lambda-jenkins-plugin,代码行数:29,代码来源:WorkSpaceZipperTest.java

示例15: testBasicMerge

import org.jvnet.hudson.test.TestBuilder; //导入依赖的package包/类
@Test
public void testBasicMerge() throws Exception {
    FreeStyleProject p = j.createFreeStyleProject();
    List<UserRemoteConfig> remotes = new ArrayList<UserRemoteConfig>();
    remotes.add(new UserRemoteConfig(repo.getPath(), "origin", "master", null));
    List<BranchSpec> branches = new ArrayList<BranchSpec>();
    branches.add(new BranchSpec("master"));
    p.setScm(new GitSCM(remotes, branches, false, null, null, null, null));

    // Init repo with release and feature branch.
    GitClient client = g.gitClient(repo);
    client.init();
    g.touchAndCommit(repo, "init");
    client.checkout("HEAD", "r1336");
    g.touchAndCommit(repo, "r1336");
    client.checkout("HEAD", "c3");
    g.touchAndCommit(repo, "c3");

    // Custom builder that merges feature branch with release branch using AdvancedSCMManager.
    p.getBuildersList().add(new TestBuilder() {
        @Override
        public boolean perform(AbstractBuild<?, ?> build, Launcher launcher, BuildListener listener) throws InterruptedException, IOException {
            try {
                AdvancedSCMManager amm = SCMManagerFactory.getManager(build, launcher, listener);
                amm.update("r1336");
                amm.mergeWorkspaceWith("c3", null);
                amm.commit("merge c3", "test <[email protected]>");
                return true;
            } catch (Exception e) {
                e.printStackTrace(listener.getLogger());
                return false;
            }
        }
    });

    // Assert file is here (should be after successful merge)
    g.buildAndCheck(p, "c3");
}
 
开发者ID:jenkinsci,项目名称:gatekeeper-plugin,代码行数:39,代码来源:BasicGitTest.java


注:本文中的org.jvnet.hudson.test.TestBuilder类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。