@Test public void canStillProvideTheCommitNotifyAction() throws Exception { j.jenkins.setCrumbIssuer(null); String uuid = "12345678-1234-1234-1234-123456789012"; JenkinsRule.WebClient wc = j.createWebClient(); String relativeUrl = "subversion/" + uuid + "/notifyCommit/"; try { // protected against GET request wc.goTo(relativeUrl); fail(); } catch (FailingHttpStatusCodeException e) { assertEquals(405, e.getStatusCode()); } WebRequest request = new WebRequest(new URL(j.getURL() + relativeUrl), HttpMethod.POST); HtmlPage page = wc.getPage(request); j.assertGoodStatus(page); }
@LocalData @Test public void testFailureLinks() throws Exception { FreeStyleBuild build = project.scheduleBuild2(0).get(10, TimeUnit.SECONDS); rule.assertBuildStatus(Result.UNSTABLE, build); TestResult theOverallTestResult = build.getAction(TestResultAction.class).getResult(); CaseResult theFailedTestCase = theOverallTestResult.getFailedTests().get(0); String relativePath = theFailedTestCase.getRelativePathFrom(theOverallTestResult); System.out.println("relative path seems to be: " + relativePath); WebClient wc = rule.createWebClient(); String testReportPageUrl = project.getLastBuild().getUrl() + "/testReport"; HtmlPage testReportPage = wc.goTo( testReportPageUrl ); Page packagePage = testReportPage.getAnchorByText("tacoshack.meals").click(); rule.assertGoodStatus(packagePage); // I expect this to work; just checking that my use of the APIs is correct. // Now we're on that page. We should be able to find a link to the failed test in there. HtmlAnchor anchor = testReportPage.getAnchorByText("tacoshack.meals.NachosTest.testBeanDip"); String href = anchor.getHrefAttribute(); System.out.println("link is : " + href); Page failureFromLink = anchor.click(); rule.assertGoodStatus(failureFromLink); // Now check the >>> link -- this is harder, because we can't do the javascript click handler properly // The summary page is just tack on /summary to the url for the test }
rule.assertGoodStatus(historyPage); rule.assertXPath(historyPage, "//img[@id='graph']"); rule.assertXPath(historyPage, "//table[@id='testresult']");
/** * Tests that configuring an existing project via jenkins http rest doesn't produce duplicated triggers * and that the trigger is configured for the new project pattern. * * @throws Exception if so */ @Test @LocalData public void testReconfigureUsingRestApi() throws Exception { assertNrOfEventListeners(0); TopLevelItem testProj = j.jenkins.getItem("testProj"); String gerritProjectPattern = "someotherproject"; XmlPage xmlPage = loadConfigXmlViaHttp(testProj); Document document = xmlPage.getXmlDocument(); String xml = changeConfigXml(gerritProjectPattern, document); URL url = UrlUtils.toUrlUnsafe(j.getURL().toExternalForm() + testProj.getUrl() + "config.xml"); WebRequest request = new WebRequest(url, HttpMethod.POST); request.setRequestBody(xml); j.jenkins.setCrumbIssuer(null); Page page = j.createWebClient().getPage(request); j.assertGoodStatus(page); assertNrOfEventListeners(0); assertEventListenerWithSomeOtherProjectSet(gerritProjectPattern); }
rule.assertGoodStatus(trendGraphPage); rule.assertGoodStatus(buildPage); assertNotNull(failingTestLink); Page failingTestPage = failingTestLink.click(); rule.assertGoodStatus(failingTestPage);