Package org.jvnet.hudson.test

Examples of org.jvnet.hudson.test.CaptureEnvironmentBuilder


  /**
   * Launches project on this node, waits for the result, and returns the environment that is used
   */
  private Map<String, String> executeBuild(Node node) throws Exception {
    CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();

    project.getBuildersList().add(builder);
    project.setAssignedLabel(node.getSelfLabel());

    // use a timeout so we don't wait infinitely in case of failure
    FreeStyleBuild build = project.scheduleBuild2(0).get(/*10, TimeUnit.SECONDS*/);
   
    System.out.println(build.getLog());
    Assert.assertEquals(Result.SUCCESS, build.getResult());

    return builder.getEnvVars();
  }
View Full Code Here


                new StringParameterDefinition("string", "defaultValue", "string description"),
                new BooleanParameterDefinition("boolean", true, "boolean description"),
                new ChoiceParameterDefinition("choice", "Choice 1\nChoice 2", "choice description"),
                new RunParameterDefinition("run", otherProject.getName(), "run description"));
        project.addProperty(pdp);
        CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
        project.getBuildersList().add(builder);

        WebClient wc = new WebClient();
        wc.setThrowExceptionOnFailingStatusCode(false);
        HtmlPage page = wc.goTo("/job/" + project.getName() + "/build?delay=0sec");

        HtmlForm form = page.getFormByName("parameters");

        HtmlElement element = (HtmlElement) form.selectSingleNode("//tr[td/div/input/@value='string']");
        assertNotNull(element);
        assertEquals("string description", ((HtmlElement) element.selectSingleNode("td/div")).getAttribute("description"));
        HtmlTextInput stringParameterInput = (HtmlTextInput) element.selectSingleNode(".//input[@name='value']");
        assertEquals("defaultValue", stringParameterInput.getAttribute("value"));
        assertEquals("string", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent());
        stringParameterInput.setAttribute("value", "newValue");

        element = (HtmlElement) form.selectSingleNode("//tr[td/div/input/@value='boolean']");
        assertNotNull(element);
        assertEquals("boolean description", ((HtmlElement) element.selectSingleNode("td/div")).getAttribute("description"));
        Object o = element.selectSingleNode(".//input[@name='value']");
        System.out.println(o);
        HtmlCheckBoxInput booleanParameterInput = (HtmlCheckBoxInput) o;
        assertEquals(true, booleanParameterInput.isChecked());
        assertEquals("boolean", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent());

        element = (HtmlElement) form.selectSingleNode(".//tr[td/div/input/@value='choice']");
        assertNotNull(element);
        assertEquals("choice description", ((HtmlElement) element.selectSingleNode("td/div")).getAttribute("description"));
        assertEquals("choice", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent());

        element = (HtmlElement) form.selectSingleNode(".//tr[td/div/input/@value='run']");
        assertNotNull(element);
        assertEquals("run description", ((HtmlElement) element.selectSingleNode("td/div")).getAttribute("description"));
        assertEquals("run", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent());

        submit(form);
        Queue.Item q = hudson.getQueue().getItem(project);
        if (q != null) q.getFuture().get();
        else Thread.sleep(1000);

        assertEquals("newValue", builder.getEnvVars().get("STRING"));
        assertEquals("true", builder.getEnvVars().get("BOOLEAN"));
        assertEquals("Choice 1", builder.getEnvVars().get("CHOICE"));
        assertEquals(hudson.getRootUrl() + otherProject.getLastBuild().getUrl(), builder.getEnvVars().get("RUN"));
    }
View Full Code Here

    public void testChoiceWithLTGT() throws Exception {
        FreeStyleProject project = createFreeStyleProject();
        ParametersDefinitionProperty pdp = new ParametersDefinitionProperty(
                new ChoiceParameterDefinition("choice", "Choice 1\nChoice <2>", "choice description"));
        project.addProperty(pdp);
        CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
        project.getBuildersList().add(builder);

        WebClient wc = new WebClient();
        wc.setThrowExceptionOnFailingStatusCode(false);
        HtmlPage page = wc.goTo("/job/" + project.getName() + "/build?delay=0sec");
        HtmlForm form = page.getFormByName("parameters");

        HtmlElement element = (HtmlElement) form.selectSingleNode(".//tr[td/div/input/@value='choice']");
        assertNotNull(element);
        assertEquals("choice description", ((HtmlElement) element.selectSingleNode("td/div")).getAttribute("description"));
        assertEquals("choice", ((HtmlElement) element.selectSingleNode("td[@class='setting-name']")).getTextContent());
        HtmlOption opt = (HtmlOption)element.selectSingleNode("td/div/select/option[@value='Choice <2>']");
        assertNotNull(opt);
        assertEquals("Choice <2>", opt.asText());
        opt.setSelected(true);

        submit(form);
        Queue.Item q = hudson.getQueue().getItem(project);
        if (q != null) q.getFuture().get();
        else Thread.sleep(1000);

        assertNotNull(builder.getEnvVars());
        assertEquals("Choice <2>", builder.getEnvVars().get("CHOICE"));
    }
View Full Code Here

        FreeStyleProject project = createFreeStyleProject();
        ParametersDefinitionProperty pdb = new ParametersDefinitionProperty(
                new PasswordParameterDefinition("password", "12345", "password description"));
        project.addProperty(pdb);

        CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
        project.getBuildersList().add(builder);

        FreeStyleBuild build = project.scheduleBuild2(0).get();
        Set<String> sensitiveVars = build.getSensitiveBuildVariables();
View Full Code Here

        FreeStyleProject project = createFreeStyleProject();
        ParametersDefinitionProperty pdb = new ParametersDefinitionProperty(
                new StringParameterDefinition("string", "defaultValue", "string description"));
        project.addProperty(pdb);

        CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
        project.getBuildersList().add(builder);

        FreeStyleBuild build = project.scheduleBuild2(0).get();
        Set<String> sensitiveVars = build.getSensitiveBuildVariables();
View Full Code Here

                new PasswordParameterDefinition("password", "12345", "password description"),
                new StringParameterDefinition("string2", "Value2", "string description")
        );
        project.addProperty(pdb);

        CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
        project.getBuildersList().add(builder);

        FreeStyleBuild build = project.scheduleBuild2(0).get();
        Set<String> sensitiveVars = build.getSensitiveBuildVariables();
View Full Code Here

            createRemoteRepositories(relativeTargetDir),
            Collections.singletonList(new BranchSpec(branchString)),
            new PreBuildMergeOptions(), false, Collections.<SubmoduleConfig>emptyList(), false,
            false, new DefaultBuildChooser(), null, null, authorOrCommitter, relativeTargetDir,
            excludedRegions, excludedUsers, localBranch, false, false, null, null, false));
        project.getBuildersList().add(new CaptureEnvironmentBuilder());
        return project;
    }
View Full Code Here

            createRemoteRepositories(relativeTargetDir),
            Collections.singletonList(new BranchSpec(branchString)),
            new PreBuildMergeOptions(), false, Collections.<SubmoduleConfig>emptyList(), false,
            false, new DefaultBuildChooser(), null, null, authorOrCommitter,
            excludedRegions, excludedUsers, localBranch, false, false, null, null, false, includedRegions));
        project.getBuildersList().add(new CaptureEnvironmentBuilder());
        return project;
    }
View Full Code Here

    String properties = "KEY=value";
    projectA.getPublishersList().add(
        new BuildTrigger(new BuildTriggerConfig("projectB", ResultCondition.SUCCESS,
            new PredefinedBuildParameters(properties))));

    CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
    Project projectB = createFreeStyleProject("projectB");
    projectB.getBuildersList().add(builder);
    projectB.setQuietPeriod(1);
    hudson.rebuildDependencyGraph();

    projectA.scheduleBuild2(0).get();
    hudson.getQueue().getItem(projectB).getFuture().get();

    assertNotNull("builder should record environment", builder.getEnvVars());
    assertEquals("value", builder.getEnvVars().get("KEY"));
  }
View Full Code Here

                + "KEY=value\n";    // "KEY" in multibytes
        projectA.getPublishersList().add(
                new BuildTrigger(new BuildTriggerConfig("projectB", ResultCondition.SUCCESS,
                        new PredefinedBuildParameters(properties))));

        CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
        Project projectB = createFreeStyleProject("projectB");
        projectB.getBuildersList().add(builder);
        projectB.setQuietPeriod(1);
        hudson.rebuildDependencyGraph();

        projectA.scheduleBuild2(0).get();
        hudson.getQueue().getItem(projectB).getFuture().get();

        assertNotNull("builder should record environment", builder.getEnvVars());
        assertEquals("123", builder.getEnvVars().get("KEY"));
        assertEquals("value", builder.getEnvVars().get("KEY"));
    }
View Full Code Here

TOP

Related Classes of org.jvnet.hudson.test.CaptureEnvironmentBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.