Class WebTesterAssertions
- java.lang.Object
-
- com.atlassian.confluence.htmlunit.WebTesterAssertions
-
public class WebTesterAssertions extends Object
Assertions that revolve around a WebTester
-
-
Constructor Summary
Constructors Constructor Description WebTesterAssertions()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static voidassertAtLoginPage(String reason)static voidassertAtLoginPage(String reason, net.sourceforge.jwebunit.junit.WebTester tester)static voidassertDoesNotContain(String unexpectedSubstring, String actual)static voidassertImageIsPresentWithSrcUrlThatContains(String imageName)Provide our own implementation ofJWebUnit.assertImagePresent(String, String)that asserts the image name with a contains check rather than equals.static voidassertIsLoggedInAs(User user)static voidassertLinkNotPresentWithAttribute(String name)static voidassertLinkNotPresentWithHrefContaining(String urlSubstring)static voidassertLinkPresentWithAttribute(String name)static voidassertLinkPresentWithAttribute(String name, String value)static voidassertLinkPresentWithHref(String url)static voidassertLinkPresentWithHrefContaining(String urlSubstring)static voidassertLinkPresentWithTextAndHref(String text, String href)static voidassertPageAndSpaceTitle(String pageTitle, String spaceTitle)Asserts that the title equals the passed pageTitle plus separator plus spaceTitle plus site suffix (usually SITE_TITLE_SUFFIX).static voidassertPageAndSpaceTitle(String reason, String pageTitle, String spaceTitle)Asserts that the title equals the passed pageTitle plus separator plus spaceTitle plus site suffix (usually SITE_TITLE_SUFFIX).static voidassertPageTitle(String pageTitle)Asserts that the title equals the passed pageTitle plus the site suffix (usually SITE_TITLE_SUFFIX)
e.g.static voidassertPageTitle(String reason, String pageTitle)Asserts that the title equals the passed pageTitle plus the site suffix (usually SITE_TITLE_SUFFIX)
e.g.static voidassertPageTitleAnyOf(List<String> pageTitles)Asserts that the title is found within the specified collection of titles plus the site suffix (usually SITE_TITLE_SUFFIX).static voidassertPageTitleEquals(String reason, 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 voidassertPageTitleEquals(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 voidassertServerResponseContains(String string)static voidassertStartsWith(String expectedPrefix, String actual)static voidassertStatusCode(int expectedStatus)static voidassertStatusCode(int expectedStatus, String failureMessage)Assert the status code and should the assertion fail then include the supplied failure message.static voidassertTextNotPresentInPageSource(String text)static voidassertTextPresentInPageSource(String text)Asserts that the given text is in the page source.static voidassertTextsPresentInOrder(String... texts)Asserts that all the given texts appear in the current response in the order in which they appear in the array.static voidassertTextsPresentInOrder(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 voidassertTitleEquals(String reason, 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).static voidassertTitleEquals(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).
-
-
-
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 WebTesterpageTitle- The title displayed before the first separator
-
assertPageTitleEquals
public static void assertPageTitleEquals(String reason, 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:
reason- additional information about any assertion failurewebTester- The WebTesterpageTitle- 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 WebTesterpageTitle- The title displayed before the first separatorspaceTitle- The title displayed for the tested space
-
assertTitleEquals
public static void assertTitleEquals(String reason, 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:
reason- additional information about any assertion failurewebTester- The WebTesterpageTitle- The title displayed before the first separatorspaceTitle- 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
-
assertPageTitleAnyOf
public static void assertPageTitleAnyOf(List<String> pageTitles)
Asserts that the title is found within the specified collection of titles plus the site suffix (usually SITE_TITLE_SUFFIX).
e.g. "Dashboard - Confluence"- Parameters:
pageTitles- The list of possible titles displayed before the first separator
-
assertPageTitle
public static void assertPageTitle(String reason, String pageTitle)
Asserts that the title equals the passed pageTitle plus the site suffix (usually SITE_TITLE_SUFFIX)
e.g. "Dashboard - Confluence"- Parameters:
reason- additional information about any assertion failurepageTitle- 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 separatorspaceTitle- The title displayed for the tested space
-
assertPageAndSpaceTitle
public static void assertPageAndSpaceTitle(String reason, 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:
reason- additional information about any assertion failurepageTitle- The title displayed before the first separatorspaceTitle- 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 responseunexpected- 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
-
assertTextNotPresentInPageSource
public static void assertTextNotPresentInPageSource(String text)
-
assertLinkPresentWithHref
public static void assertLinkPresentWithHref(String url)
-
assertLinkPresentWithAttribute
public static void assertLinkPresentWithAttribute(String name)
-
assertLinkNotPresentWithAttribute
public static void assertLinkNotPresentWithAttribute(String name)
-
assertLinkPresentWithAttribute
public static void assertLinkPresentWithAttribute(String name, String value)
-
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 forfailureMessage- the message to include should the assertion fail
-
assertServerResponseContains
public static void assertServerResponseContains(String string)
-
assertDoesNotContain
public static void assertDoesNotContain(String unexpectedSubstring, String actual)
-
assertIsLoggedInAs
public static void assertIsLoggedInAs(User user)
-
assertAtLoginPage
public static void assertAtLoginPage(String reason) throws URISyntaxException
- Throws:
URISyntaxException
-
assertAtLoginPage
public static void assertAtLoginPage(String reason, net.sourceforge.jwebunit.junit.WebTester tester) throws URISyntaxException
- Throws:
URISyntaxException
-
assertImageIsPresentWithSrcUrlThatContains
public static void assertImageIsPresentWithSrcUrlThatContains(String imageName)
Provide our own implementation ofJWebUnit.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)
-
-