Package hudson.model

Examples of hudson.model.Project


     */
    @LocalData
    public void testOpenJUnitPublishing() throws IOException, SAXException {
        List<Project> projects = this.hudson.getProjects();
        // Make sure there's a project named TEST_PROJECT_WITH_HISTORY
        Project proj = null;
        for (Project p : projects) {
            if (p.getName().equals(TEST_PROJECT_WITH_HISTORY)) proj = p;
        }
        assertNotNull("We should have a project named " + TEST_PROJECT_WITH_HISTORY, proj);

        // Validate that there are test results where I expect them to be:
        HudsonTestCase.WebClient wc = new HudsonTestCase.WebClient();

        // On the project page:
        HtmlPage projectPage = wc.getPage(proj);
        //      we should have a link that reads "Latest Test Result"
        //      that link should go to http://localhost:8080/job/breakable/lastBuild/testReport/
        assertXPath(projectPage, "//a[@href='lastCompletedBuild/testReport/']");
        assertXPathValue(projectPage, "//a[@href='lastCompletedBuild/testReport/']", "Latest Test Result");
        assertXPathValueContains(projectPage, "//a[@href='lastCompletedBuild/testReport/']", "Latest Test Result");
        //      after "Latest Test Result" it should say "no failures"
        assertXPathResultsContainText(projectPage, "//td", "(no failures)");
        //      there should be a test result trend graph
        assertXPath(projectPage, "//img[@src='test/trend']");
        // the trend graph should be served up with a good http status
        Page trendGraphPage = wc.goTo(proj.getUrl() + "/test/trend", "image/png");
        assertGoodStatus(trendGraphPage);

        // The trend graph should be clickable and take us to a run details page
        Object imageNode = projectPage.getFirstByXPath("//img[@src='test/trend']");
        assertNotNull("couldn't find any matching nodes", imageNode);
        assertTrue("image node should be an HtmlImage object", imageNode instanceof HtmlImage);
        // TODO: Check that we can click on the graph and get to a particular run. How do I do this with HtmlUnit?

        XmlPage xmlProjectPage = wc.goToXml(proj.getUrl() + "/lastBuild/testReport/api/xml");
        assertXPath(xmlProjectPage, "/testResult");
        assertXPath(xmlProjectPage, "/testResult/suite");
        assertXPath(xmlProjectPage, "/testResult/failCount");
        assertXPathValue(xmlProjectPage, "/testResult/failCount", "0");
        assertXPathValue(xmlProjectPage, "/testResult/passCount", "4");
        assertXPathValue(xmlProjectPage, "/testResult/skipCount", "0");
        String[] packages = {"org.jvnet.hudson.examples.small.AppTest", "org.jvnet.hudson.examples.small.MiscTest", "org.jvnet.hudson.examples.small.deep.DeepTest"};
        for (String packageName : packages) {
            assertXPath(xmlProjectPage, "/testResult/suite/case/className[text()='" + packageName + "']");
        }

        // Go to a page that we know has a failure
        HtmlPage buildPage = wc.getPage(proj.getBuildByNumber(3));
        assertGoodStatus(buildPage);
        // We expect to see one failure, for com.yahoo.breakable.misc.UglyTest.becomeUglier
        // which should link to http://localhost:8080/job/wonky/3/testReport/org.jvnet.hudson.examples.small/MiscTest/testEleanor/
        assertXPathResultsContainText(buildPage, "//a", "org.jvnet.hudson.examples.small.MiscTest.testEleanor");
        HtmlAnchor failingTestLink = buildPage.getFirstAnchorByText("org.jvnet.hudson.examples.small.MiscTest.testEleanor");
        assertNotNull(failingTestLink);
        Page failingTestPage = failingTestLink.click();
        assertGoodStatus(failingTestPage);

        // Go to the xml page for a build we know has failures
        XmlPage xmlBuildPage = wc.goToXml(proj.getBuildByNumber(3).getUrl() + "/api/xml");
        assertXPathValue(xmlBuildPage, "//failCount", "2");
        assertXPathValue(xmlBuildPage, "//skipCount", "0");
        assertXPathValue(xmlBuildPage, "//totalCount", "4");
        assertXPathValue(xmlBuildPage, "//result", "FAILURE");

        // Check overall test result counts
        XmlPage xmlTestReportPage = wc.goToXml(proj.getBuildByNumber(3).getUrl() + "/testReport/api/xml");
        assertXPathValue(xmlTestReportPage, "/testResult/failCount", "2");
        assertXPathValue(xmlTestReportPage, "/testResult/passCount", "2");
        assertXPathValue(xmlTestReportPage, "/testResult/skipCount", "0");

        // Make sure the right tests passed and failed
        assertXPathValue(xmlTestReportPage, "/testResult/suite/case[className/text()='org.jvnet.hudson.examples.small.AppTest']/status", "PASSED");
        assertXPathValue(xmlTestReportPage, "/testResult/suite/case[name/text()='testEleanor']/status", "FAILED");


        // TODO: implement more of these tests
        // On the lastBuild/testReport page:
        //      Breadcrumbs should read #6 > Test Result  where Test Result is a link to this page
        //      inside of div id="main-panel" we should find the text "0 failures (-1)"
        //      we should have a blue bar which is blue all the way across: div style="width: 100%; height: 1em; background-color: rgb(114, 159, 207);
        //      we should find the words "7 tests (?0)"
        //      we should find the words "All Tests"
        //      we should find a table

        //      Inside that table, there should be the following rows:
        //           org.jvnet.hudson.examples.small   0ms   0 -1 0   3
        //          org.jvnet.hudson.examples.small.deep   4ms 0 0 0  1
        Run theRun = proj.getBuildByNumber(7);
        assertTestResultsAsExpected(wc, theRun, "/testReport",
                "org.jvnet.hudson.examples.small", "0 ms", "SUCCESS",
                /* total tests expected, diff */ 3, 0,
                /* fail count expected, diff */ 0, -1,
                /* skip count expected, diff */ 0, 0);
View Full Code Here


    @Bug(5246)
    @LocalData
    public void testInterBuildDiffs() throws IOException, SAXException {
        List<Project> projects = this.hudson.getProjects();
        // Make sure there's a project named TEST_PROJECT_WITH_HISTORY
        Project proj = null;
        for (Project p : projects) {
            if (p.getName().equals(TEST_PROJECT_WITH_HISTORY)) proj = p;
        }
        assertNotNull("We should have a project named " + TEST_PROJECT_WITH_HISTORY, proj);

        // Validate that there are test results where I expect them to be:
        HudsonTestCase.WebClient wc = new HudsonTestCase.WebClient();
        Run theRun = proj.getBuildByNumber(4);
        assertTestResultsAsExpected(wc, theRun, "/testReport",
                        "org.jvnet.hudson.examples.small", "12 ms", "FAILURE",
                        /* total tests expected, diff */ 3, 0,
                        /* fail count expected, diff */ 1, 0,
                        /* skip count expected, diff */ 0, 0);
View Full Code Here

     */
    @LocalData
    public void testHistoryPageOpenJunit() throws IOException, SAXException {
        List<Project> projects = this.hudson.getProjects();
        // Make sure there's a project named breakable
        Project proj = null;
        for (Project p : projects) {
            if (p.getName().equals(TEST_PROJECT_WITH_HISTORY)) {
                proj = p;
                break;
            }
        }
        assertNotNull("We should have a project named " + TEST_PROJECT_WITH_HISTORY, proj);

        // Validate that there are test results where I expect them to be:
        HudsonTestCase.WebClient wc = new HudsonTestCase.WebClient();

        HtmlPage historyPage = wc.getPage(proj.getBuildByNumber(7),"/testReport/history/");
        assertGoodStatus(historyPage);
        assertXPath(historyPage, "//img[@id='graph']");
        assertXPath(historyPage, "//table[@id='testresult']");
        HtmlElement wholeTable = historyPage.getElementById("testresult");
        assertNotNull("table with id 'testresult' exists", wholeTable);
View Full Code Here

    @Override
    protected void setUp() throws Exception {
        super.setUp();

        List<Project> projects = this.hudson.getProjects();
        Project theProject = null;
        for (Project p : projects) {
            if (p.getName().equals(PROJECT_NAME)) theProject = p;
        }
        assertNotNull("We should have a project named " + PROJECT_NAME, theProject);
View Full Code Here

  @Before
  public void configure(){
    descriptor = new DescriptorImpl();
    descriptor.hudsonUrl = "http://localhost:8080/";
   
    Project project = mock(Project.class);
    when(project.getName()).thenReturn("ProjectName");

    build = mock(AbstractBuild.class);
    when(build.getProject()).thenReturn(project);
    when(build.getResult()).thenReturn(Result.SUCCESS);
    when(build.getUrl()).thenReturn("jobs/ProjectName");
View Full Code Here

public class PredefinedPropertiesBuildTriggerConfigTest extends HudsonTestCase {

  public void test() throws Exception {

    Project projectA = createFreeStyleProject("projectA");
    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();
View Full Code Here

    assertEquals("value", builder.getEnvVars().get("KEY"));
  }
 
    public void testNonAscii() throws Exception {

        Project projectA = createFreeStyleProject("projectA");
        String properties = "KEY=123\n" // 123 in multibytes
                + "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();
View Full Code Here

        new BuildTrigger(new BuildTriggerConfig("projectB", ResultCondition.SUCCESS, new NodeParameters())));

    projectA.setAssignedNode(slave0);
   
    CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
    Project projectB = createFreeStyleProject("projectB");
    projectB.getBuildersList().add(builder);
    projectB.setQuietPeriod(1);
    // set to build on slave1
    projectB.setAssignedNode(slave1);
    hudson.rebuildDependencyGraph();

    AbstractBuild buildA = projectA.scheduleBuild2(0).get();
    waitUntilNoActivity();
//    hudson.getQueue().getItem(projectB).getFuture().get();
View Full Code Here

        new BuildTrigger(new BuildTriggerConfig("projectB", ResultCondition.SUCCESS, new NodeParameters())));

    projectA.setAssignedNode(slave0);
   
    CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
    Project projectB = createFreeStyleProject("projectB");
    projectB.getBuildersList().add(builder);
    projectB.setQuietPeriod(10);
    // set to build on slave1
    projectB.setAssignedNode(slave1);
    hudson.rebuildDependencyGraph();

    AbstractBuild buildA = projectA.scheduleBuild2(0).get();
    AbstractBuild buildA2 = projectA.scheduleBuild2(0).get();
    waitUntilNoActivity();
//    hudson.getQueue().getItem(projectB).getFuture().get();
    assertEquals(2, projectA.getBuilds().size());
   
    assertEquals(slave0, buildA.getBuiltOn());
    assertEquals(slave0, buildA2.getBuiltOn());
    assertNotNull("builder should record environment", builder.getEnvVars());
    // ProjectB will be built on slave 0 regardless of assigned node.
    assertEquals("slave0", builder.getEnvVars().get("NODE_NAME"));
    // should only be a single build of projectB
    assertEquals(1, projectB.getBuilds().size());
  }
View Full Code Here

        new BuildTrigger(new BuildTriggerConfig("projectB", ResultCondition.SUCCESS, new NodeParameters())));

    projectA.setAssignedNode(slave0);
   
    CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
    Project projectB = createFreeStyleProject("projectB");
   
    int firstBuildNumber = projectB.getNextBuildNumber();
    projectB.getBuildersList().add(builder);
    projectB.setQuietPeriod(5);
    // set to build on slave1
    projectB.setAssignedNode(slave1);
    hudson.rebuildDependencyGraph();

    AbstractBuild buildA = projectA.scheduleBuild2(0).get();
    // Now trigger on another slave
    projectA.setAssignedNode(slave2);
    AbstractBuild buildA2 = projectA.scheduleBuild2(0).get();
    waitUntilNoActivity();
   
    assertEquals(slave0, buildA.getBuiltOn());
    assertEquals(slave2, buildA2.getBuiltOn());

    // should have two builds of projectB
    assertEquals(2, projectB.getBuilds().size());

    AbstractBuild buildB = (AbstractBuild)projectB.getBuildByNumber(firstBuildNumber);
    assertNotNull("ProjectB failed to build", buildB);
    assertEquals(slave0, buildB.getBuiltOn());

    // get the second build of projectB
    AbstractBuild buildB2 = (AbstractBuild)buildB.getNextBuild();
View Full Code Here

TOP

Related Classes of hudson.model.Project

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.