Java Code Examples for org.jvnet.hudson.test.JenkinsRule.WebClient#goTo()

The following examples show how to use org.jvnet.hudson.test.JenkinsRule.WebClient#goTo() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TestResultLinksTest.java    From junit-plugin with MIT License 5 votes vote down vote up
@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

}
 
Example 2
Source File: JUnitResultArchiverTest.java    From junit-plugin with MIT License 5 votes vote down vote up
private void testSetDescription(String url, TestObject object) throws Exception {
    object.doSubmitDescription("description");

    // test the roundtrip
    final WebClient wc = j.createWebClient();
    HtmlPage page = wc.goTo(url);
    page.getAnchorByHref("editDescription").click();
    wc.waitForBackgroundJavaScript(10000L);
    HtmlForm form = findForm(page, "submitDescription");
    j.submit(form);

    assertEquals("description", object.getDescription());
}
 
Example 3
Source File: CaseResultTest.java    From junit-plugin with MIT License 5 votes vote down vote up
/**
 * Makes sure the summary page remains text/plain (see commit 7089a81 in JENKINS-1544) but
 * the index page must be in text/html.
 */
@Issue("JENKINS-21261")
@Test
public void testContentType() throws Exception {
    configureTestBuild("foo");
    WebClient wc = rule.createWebClient();
    wc.goTo("job/foo/1/testReport/org.twia.vendor/VendorManagerTest/testCreateAdjustingFirm/","text/html");

    wc.goTo("job/foo/1/testReport/org.twia.vendor/VendorManagerTest/testCreateAdjustingFirm/summary","text/plain");
}
 
Example 4
Source File: UserCreationListenerTest.java    From audit-log-plugin with MIT License 4 votes vote down vote up
private static WebClient logout(final WebClient wc) throws IOException, SAXException {
    wc.goTo("logout");
    return wc;
}
 
Example 5
Source File: UserLogoutListenerTest.java    From audit-log-plugin with MIT License 4 votes vote down vote up
private static WebClient logout(final WebClient wc) throws IOException, SAXException {
    wc.goTo("logout");
    return wc;
}
 
Example 6
Source File: UserLoginListenerTest.java    From audit-log-plugin with MIT License 4 votes vote down vote up
private static WebClient logout(final WebClient wc) throws IOException, SAXException {
    wc.goTo("logout");
    return wc;
}
 
Example 7
Source File: UseRecipesWithJenkinsRuleTest.java    From jenkins-test-harness with MIT License 4 votes vote down vote up
private void verifyNotError(WebClient wc) throws IOException, SAXException {
    HtmlPage p = wc.goTo("loginError");
    URL url = p.getUrl();
    System.out.println(url);
    assertFalse(url.toExternalForm().contains("login"));
}