com.atlassian.crowd.acceptance.utils
Class CrowdWebTestCase

java.lang.Object
  extended by junit.framework.Assert
      extended by junit.framework.TestCase
          extended by net.sourceforge.jwebunit.junit.WebTestCase
              extended by com.atlassian.crowd.acceptance.utils.CrowdWebTestCase
All Implemented Interfaces:
junit.framework.Test
Direct Known Subclasses:
ApplicationAcceptanceTestCase, CrowdAcceptanceTestCase

public class CrowdWebTestCase
extends net.sourceforge.jwebunit.junit.WebTestCase

Base Crowd test case, with extra assertions on top of WebTestCase.


Field Summary
 
Fields inherited from class net.sourceforge.jwebunit.junit.WebTestCase
customTester, tester
 
Constructor Summary
CrowdWebTestCase()
           
 
Method Summary
 void addRequestHeader(String header, String value)
          Adds a request header for all subsequent requests.
 void assertErrorNotPresent()
          Makes sure the page does not contain an error, as when an exception has occurred.
 void assertErrorPresent()
          Makes sure the page does contain an error, as when an exception has occurred.
 void assertErrorPresentWithKey(String keyName)
          Makes sure the page does contain an error and that it also contains the text of the key.
 void assertKeyInElement(String elementID, String key)
          Assert that a given element contains a specific web resource's value.
 void assertKeyPresent(String key)
          Assert that a web resource's value is present.
 void assertKeyPresent(String key, List args)
          Assert that a web resource's value is present.
 void assertKeyPresent(String key, String... args)
           
 void assertKeyPresentOnce(String key)
          Checks that the text of a given key only occurs once on the page, such as validation error messages
 void assertLinkPresentWithKey(String keyName)
          Assert that a link containing the text of the key is present.
 void assertServerResponseContains(String string)
          Ensures the server's response (HTTP header + body) contains a string.
 void assertServerResponseDoesNotContain(String string)
          Ensures the server's response (HTTP header + body) dos not contain a string.
 void assertSuccessPresent()
          Makes sure the page contains a success message
 void assertTextPresent(String text, boolean suppressMessage)
          Assert that supplied text is present.
 void assertWarningAndErrorNotPresent()
          assertWarningNotPresent assertErrorNotPresent
 void assertWarningNotPresent()
          Makes sure the page doesn't contain a warning, as when an exception has occurred.
 void assertWarningPresent()
          Makes sure the page does contain a warning
 void clickLinkWithKey(String key)
          Clicks a link
 String getElementTextById(String elementId)
           
protected  String getPageText()
           
 boolean isTextPresent(String text)
          Checks if text is present on the page
protected  void log(String message)
           
protected
<T> List<T>
scrapeTable(String id, com.google.common.base.Function<List<String>,T> mapper)
           
protected
<T> List<T>
scrapeTable(String id, List<String> headings, com.google.common.base.Function<List<String>,T> mapper)
           
 void setRadioButton(String radioButtonName, String value)
          Sets a specific radio button.
 void setTester(net.sourceforge.jwebunit.junit.WebTester tester)
          Required so tester can be manually set externally when required.
protected  boolean waitFor(Callable<Boolean> isPresent)
           
 void waitForElementById(String id)
           
 void waitForElementByXPath(String xpath)
           
 void waitForText(String text)
           
 void waitForText(String text, long interval, long maxInterval)
          Waits for the specified key to appear on the page.
 
Methods inherited from class net.sourceforge.jwebunit.junit.WebTestCase
assertButtonNotPresent, assertButtonNotPresentWithText, assertButtonPresent, assertButtonPresentWithText, assertCheckboxNotPresent, assertCheckboxNotPresent, assertCheckboxNotSelected, assertCheckboxNotSelected, assertCheckboxPresent, assertCheckboxPresent, assertCheckboxSelected, assertCheckboxSelected, assertCommentNotPresent, assertCommentPresent, assertCookiePresent, assertCookieValueEquals, assertCookieValueMatch, assertDownloadedFileEquals, assertElementNotPresent, assertElementNotPresentByXPath, assertElementPresent, assertElementPresentByXPath, assertFormElementEmpty, assertFormElementEquals, assertFormElementMatch, assertFormElementNotPresent, assertFormElementPresent, assertFormNotPresent, assertFormNotPresent, assertFormPresent, assertFormPresent, assertFramePresent, assertHeaderEquals, assertHeaderMatches, assertHeaderNotPresent, assertHeaderPresent, assertHiddenFieldPresent, assertImagePresent, assertImagePresentPartial, assertImageValid, assertImageValidAndStore, assertKeyInTable, assertKeyInTable, assertKeyNotInTable, assertKeyNotPresent, assertKeyNotPresent, assertKeyPresent, assertKeysInTable, assertKeysInTable, assertLabeledFieldEquals, assertLabelMatches, assertLabelPresent, assertLinkNotPresent, assertLinkNotPresentWithExactText, assertLinkNotPresentWithExactText, assertLinkNotPresentWithImage, assertLinkNotPresentWithImage, assertLinkNotPresentWithText, assertLinkNotPresentWithText, assertLinkPresent, assertLinkPresentWithExactText, assertLinkPresentWithExactText, assertLinkPresentWithImage, assertLinkPresentWithImage, assertLinkPresentWithText, assertLinkPresentWithText, assertMatch, assertMatch, assertMatch, assertMatchInElement, assertMatchInTable, assertMatchInTable, assertNoMatch, assertNoMatchInElement, assertNoMatchInTable, assertNoMatchInTable, assertNotMatch, assertNotMatch, assertRadioOptionNotPresent, assertRadioOptionNotSelected, assertRadioOptionPresent, assertRadioOptionSelected, assertResetButtonNotPresent, assertResetButtonNotPresent, assertResetButtonPresent, assertResetButtonPresent, assertResponseCode, assertResponseCodeBetween, assertSelectedOptionEquals, assertSelectedOptionEquals, assertSelectedOptionMatches, assertSelectedOptionMatches, assertSelectedOptionsEqual, assertSelectedOptionsEqual, assertSelectedOptionsMatch, assertSelectedOptionsMatch, assertSelectedOptionValueEquals, assertSelectedOptionValueEquals, assertSelectedOptionValuesEqual, assertSelectedOptionValuesEqual, assertSelectOptionNotPresent, assertSelectOptionNotPresent, assertSelectOptionPresent, assertSelectOptionPresent, assertSelectOptionsEqual, assertSelectOptionsEqual, assertSelectOptionsNotEqual, assertSelectOptionsNotEqual, assertSelectOptionsPresent, assertSelectOptionsPresent, assertSelectOptionValueNotPresent, assertSelectOptionValueNotPresent, assertSelectOptionValuePresent, assertSelectOptionValuePresent, assertSelectOptionValuesEqual, assertSelectOptionValuesEqual, assertSelectOptionValuesNotEqual, assertSelectOptionValuesNotEqual, assertSelectOptionValuesPresent, assertSelectOptionValuesPresent, assertSubmitButtonNotPresent, assertSubmitButtonNotPresent, assertSubmitButtonPresent, assertSubmitButtonPresent, assertSubmitButtonPresent, assertTableEquals, assertTableEquals, assertTableMatch, assertTableMatch, assertTableNotPresent, assertTablePresent, assertTableRowCountEquals, assertTableRowsEqual, assertTableRowsEqual, assertTableRowsMatch, assertTableRowsMatch, assertTextFieldEquals, assertTextInElement, assertTextInTable, assertTextInTable, assertTextNotInElement, assertTextNotInTable, assertTextNotInTable, assertTextNotPresent, assertTextPresent, assertTitleEquals, assertTitleEqualsKey, assertTitleEqualsKey, assertTitleMatch, assertTitleNotEquals, assertTitleNotSame, assertWindowCountEquals, assertWindowPresent, assertWindowPresent, assertWindowPresentWithTitle, beginAt, checkCheckbox, checkCheckbox, clickButton, clickButtonWithText, clickElementByXPath, clickLink, clickLinkWithExactText, clickLinkWithExactText, clickLinkWithImage, clickLinkWithImage, clickLinkWithText, clickLinkWithText, clickRadioOption, closeBrowser, closeWindow, dumpCookies, dumpHtml, dumpHtml, dumpTable, dumpTable, getAllHeaders, getComments, getDialog, getElementAttributByXPath, getElementAttributeByXPath, getElementById, getElementByXPath, getElementsByXPath, getElementTextByXPath, getFieldsForLabel, getFormElementValue, getHeader, getImage, getLabeledFieldValue, getMessage, getMessage, getPageSource, getResponseHeaders, getServerResponse, getServeurResponse, getTable, getTestContext, getTester, getTestingEngine, getTestingEngineKey, gotoFrame, gotoPage, gotoRootWindow, gotoWindow, gotoWindow, gotoWindowByTitle, reset, runBare, saveAs, selectOption, selectOption, selectOptionByValue, selectOptionByValue, selectOptions, selectOptions, selectOptionsByValues, selectOptionsByValues, setBaseUrl, setBaseUrl, setDialog, setExpectedJavaScriptAlert, setExpectedJavaScriptAlert, setExpectedJavaScriptConfirm, setExpectedJavaScriptConfirm, setExpectedJavaScriptPrompt, setExpectedJavaScriptPrompt, setFormElement, setHiddenField, setIgnoreFailingStatusCodes, setLabeledFormElementField, setScriptingEnabled, setTestContext, setTestingEngineKey, setTextField, setTimeout, setWorkingForm, setWorkingForm, setWorkingForm, submit, submit, submit, tearDown, uncheckCheckbox, uncheckCheckbox
 
Methods inherited from class junit.framework.TestCase
assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertEquals, assertFalse, assertFalse, assertNotNull, assertNotNull, assertNotSame, assertNotSame, assertNull, assertNull, assertSame, assertSame, assertTrue, assertTrue, countTestCases, createResult, fail, fail, failNotEquals, failNotSame, failSame, format, getName, run, run, runTest, setName, setUp, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CrowdWebTestCase

public CrowdWebTestCase()
Method Detail

assertKeyPresent

public void assertKeyPresent(String key)
Assert that a web resource's value is present.

Overrides:
assertKeyPresent in class net.sourceforge.jwebunit.junit.WebTestCase
Parameters:
key - web resource name

assertKeyPresent

public void assertKeyPresent(String key,
                             List args)
Assert that a web resource's value is present.

Parameters:
key - web resource name
args -

assertKeyPresent

public void assertKeyPresent(String key,
                             String... args)

assertTextPresent

public void assertTextPresent(String text,
                              boolean suppressMessage)
Assert that supplied text is present.

Parameters:
text -

assertSuccessPresent

public void assertSuccessPresent()
Makes sure the page contains a success message


assertWarningNotPresent

public void assertWarningNotPresent()
Makes sure the page doesn't contain a warning, as when an exception has occurred.


assertErrorNotPresent

public void assertErrorNotPresent()
Makes sure the page does not contain an error, as when an exception has occurred.


assertWarningAndErrorNotPresent

public void assertWarningAndErrorNotPresent()
assertWarningNotPresent assertErrorNotPresent


assertErrorPresent

public void assertErrorPresent()
Makes sure the page does contain an error, as when an exception has occurred.


assertErrorPresentWithKey

public void assertErrorPresentWithKey(String keyName)
Makes sure the page does contain an error and that it also contains the text of the key. Note: it does not (yet) verify that the text is within the error.

Parameters:
keyName -

assertWarningPresent

public void assertWarningPresent()
Makes sure the page does contain a warning


assertLinkPresentWithKey

public void assertLinkPresentWithKey(String keyName)
Assert that a link containing the text of the key is present.

Parameters:
keyName - The key whose associated text will be searched for.

assertKeyInElement

public void assertKeyInElement(String elementID,
                               String key)
Assert that a given element contains a specific web resource's value.

Parameters:
elementID - id of element to be inspected
key - the web resource's key

setRadioButton

public void setRadioButton(String radioButtonName,
                           String value)
Sets a specific radio button.

Parameters:
radioButtonName - The name of the radio button.
value - The value to set it too.

clickLinkWithKey

public void clickLinkWithKey(String key)
Clicks a link

Parameters:
key - The value of this key is the link clicked

getElementTextById

public String getElementTextById(String elementId)

addRequestHeader

public void addRequestHeader(String header,
                             String value)
Adds a request header for all subsequent requests.

Parameters:
header - header paramater.
value - parameter value.

assertServerResponseContains

public void assertServerResponseContains(String string)
Ensures the server's response (HTTP header + body) contains a string.

Parameters:
string - string to search for.

assertServerResponseDoesNotContain

public void assertServerResponseDoesNotContain(String string)
Ensures the server's response (HTTP header + body) dos not contain a string.

Parameters:
string - string to search for.

setTester

public void setTester(net.sourceforge.jwebunit.junit.WebTester tester)
Required so tester can be manually set externally when required.

Parameters:
tester - new tester.

log

protected void log(String message)

getPageText

protected String getPageText()

waitForText

public void waitForText(String text,
                        long interval,
                        long maxInterval)
                 throws Exception
Waits for the specified key to appear on the page.

Parameters:
text -
interval -
maxInterval -
Throws:
Exception

waitForElementByXPath

public void waitForElementByXPath(String xpath)
                           throws Exception
Throws:
Exception

waitForElementById

public void waitForElementById(String id)
                        throws Exception
Throws:
Exception

waitFor

protected boolean waitFor(Callable<Boolean> isPresent)
                   throws Exception
Throws:
Exception

isTextPresent

public boolean isTextPresent(String text)
Checks if text is present on the page

Parameters:
text - the text to match for
Returns:
true if the text is found. false otherwise

waitForText

public void waitForText(String text)
                 throws Exception
Throws:
Exception

assertKeyPresentOnce

public void assertKeyPresentOnce(String key)
Checks that the text of a given key only occurs once on the page, such as validation error messages

Parameters:
key - the key to check occurrences of

scrapeTable

protected <T> List<T> scrapeTable(String id,
                                  com.google.common.base.Function<List<String>,T> mapper)

scrapeTable

protected <T> List<T> scrapeTable(String id,
                                  List<String> headings,
                                  com.google.common.base.Function<List<String>,T> mapper)


Copyright © 2014 Atlassian. All Rights Reserved.