com.atlassian.confluence.htmlunit
Class WebTesterAssertions

java.lang.Object
  extended by com.atlassian.confluence.htmlunit.WebTesterAssertions

public class WebTesterAssertions
extends Object

Assertions that revolve around a WebTester


Constructor Summary
WebTesterAssertions()
           
 
Method Summary
static void assertAtDashboardPage(String message)
           
static void assertAtLoginPage(String message)
           
static void assertDoesNotContain(String unexpectedSubstring, String actual)
           
static void assertImageIsPresentWithSrcUrlThatContains(String imageName)
          Provide our own implementation of JWebUnit.assertImagePresent(String, String) that asserts the image name with a contains check rather than equals.
static void assertIsLoggedInAs(User user)
           
static void assertLinkNotPresentWithHrefContaining(String urlSubstring)
           
static void assertLinkPresentWithHref(String url)
           
static void assertLinkPresentWithHrefContaining(String urlSubstring)
           
static void assertLinkPresentWithTextAndHref(String text, String href)
           
static void assertNotAtLoginPage(String message)
           
static void assertPageAndSpaceTitle(String pageTitle, String spaceTitle)
          Asserts that the title equals the passed pageTitle plus separator plus spaceTitle plus site suffix (usually SITE_TITLE_SUFFIX).
static void assertPageTitle(String pageTitle)
          Asserts that the title equals the passed pageTitle plus the site suffix (usually SITE_TITLE_SUFFIX)
e.g.
static void assertPageTitleEquals(net.sourceforge.jwebunit.junit.WebTester webTester, String pageTitle)
          Asserts that the title equals the passed pageTitle plus the site suffix (usually SITE_TITLE_SUFFIX)
e.g.
static void assertServerResponseContains(String string)
           
static void assertStartsWith(String expectedPrefix, String actual)
           
static void assertStatusCode(int expectedStatus)
           
static void assertStatusCode(int expectedStatus, String failureMessage)
          Assert the status code and should the assertion fail then include the supplied failure message.
static void assertTextPresentInPageSource(String text)
          Asserts that the given text is in the page source.
static void assertTextsPresentInOrder(String... texts)
          Asserts that all the given texts appear in the current response in the order in which they appear in the array.
static void assertTextsPresentInOrder(String[] expected, String[] unexpected)
          Asserts that all the given expected texts appear in the current response in the order in which they appear in the array, with none of the unexpected Strings occurring in-between.
static void assertTitleEquals(net.sourceforge.jwebunit.junit.WebTester webTester, String pageTitle, String spaceTitle)
          Asserts that the title equals the passed pageTitle plus separator plus spaceTitle plus site suffix (usually SITE_TITLE_SUFFIX).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WebTesterAssertions

public WebTesterAssertions()
Method Detail

assertPageTitleEquals

public static void assertPageTitleEquals(net.sourceforge.jwebunit.junit.WebTester webTester,
                                         String pageTitle)
Asserts that the title equals the passed pageTitle plus the site suffix (usually SITE_TITLE_SUFFIX)
e.g. "Dashboard - Confluence"

Parameters:
webTester - The WebTester
pageTitle - The title displayed before the first separator

assertTitleEquals

public static void assertTitleEquals(net.sourceforge.jwebunit.junit.WebTester webTester,
                                     String pageTitle,
                                     String spaceTitle)
Asserts that the title equals the passed pageTitle plus separator plus spaceTitle plus site suffix (usually SITE_TITLE_SUFFIX).
e.g. "Home - Test Space - Confluence"

Parameters:
webTester - The WebTester
pageTitle - The title displayed before the first separator
spaceTitle - The title displayed for the tested space

assertPageTitle

public static void assertPageTitle(String pageTitle)
Asserts that the title equals the passed pageTitle plus the site suffix (usually SITE_TITLE_SUFFIX)
e.g. "Dashboard - Confluence"

Parameters:
pageTitle - The title displayed before the first separator

assertPageAndSpaceTitle

public static void assertPageAndSpaceTitle(String pageTitle,
                                           String spaceTitle)
Asserts that the title equals the passed pageTitle plus separator plus spaceTitle plus site suffix (usually SITE_TITLE_SUFFIX).
e.g. "Home - Test Space - Confluence"

Parameters:
pageTitle - The title displayed before the first separator
spaceTitle - The title displayed for the tested space

assertTextsPresentInOrder

public static void assertTextsPresentInOrder(String... texts)
Asserts that all the given texts appear in the current response in the order in which they appear in the array.

Parameters:
texts - an array of strings expected to appear in the response

assertTextsPresentInOrder

public static void assertTextsPresentInOrder(String[] expected,
                                             String[] unexpected)
Asserts that all the given expected texts appear in the current response in the order in which they appear in the array, with none of the unexpected Strings occurring in-between.

Parameters:
expected - an array of strings expected to appear in the response
unexpected - an array of string unexpected to appear in the response

assertTextPresentInPageSource

public static void assertTextPresentInPageSource(String text)
Asserts that the given text is in the page source. Useful for testing non-html responses where assertTextPresent doesn't work.

Parameters:
text - the text to look for

assertLinkPresentWithHref

public static void assertLinkPresentWithHref(String url)

assertLinkPresentWithHrefContaining

public static void assertLinkPresentWithHrefContaining(String urlSubstring)

assertLinkNotPresentWithHrefContaining

public static void assertLinkNotPresentWithHrefContaining(String urlSubstring)

assertLinkPresentWithTextAndHref

public static void assertLinkPresentWithTextAndHref(String text,
                                                    String href)

assertStatusCode

public static void assertStatusCode(int expectedStatus)

assertStatusCode

public static void assertStatusCode(int expectedStatus,
                                    String failureMessage)
Assert the status code and should the assertion fail then include the supplied failure message.

Parameters:
expectedStatus - the status to assert for
failureMessage - the message to include should the assertion fail

assertServerResponseContains

public static void assertServerResponseContains(String string)

assertDoesNotContain

public static void assertDoesNotContain(String unexpectedSubstring,
                                        String actual)

assertStartsWith

public static void assertStartsWith(String expectedPrefix,
                                    String actual)

assertIsLoggedInAs

public static void assertIsLoggedInAs(User user)

assertAtDashboardPage

public static void assertAtDashboardPage(String message)
                                  throws URISyntaxException
Throws:
URISyntaxException

assertNotAtLoginPage

public static void assertNotAtLoginPage(String message)
                                 throws URISyntaxException
Throws:
URISyntaxException

assertAtLoginPage

public static void assertAtLoginPage(String message)
                              throws URISyntaxException
Throws:
URISyntaxException

assertImageIsPresentWithSrcUrlThatContains

public static void assertImageIsPresentWithSrcUrlThatContains(String imageName)
Provide our own implementation of JWebUnit.assertImagePresent(String, String) that asserts the image name with a contains check rather than equals.

Parameters:
imageName - The path to the image (i.e. the src attribute value)


Copyright © 2003-2013 Atlassian. All Rights Reserved.