Class ModuleTestBase

java.lang.Object
junit.framework.Assert
junit.framework.TestCase
org.openxava.tests.ModuleTestBase
All Implemented Interfaces:
junit.framework.Test

public abstract class ModuleTestBase extends junit.framework.TestCase
Base class for creating a junit test that runs against an OpenXava module.

Look at Automated testing with OpenXava.

Author:
Javier Paniza
  • Constructor Details

    • ModuleTestBase

      public ModuleTestBase(String nameTest, String application, String module)
      To test the specified module of the specified application.

      You can send null for null in such a case you must use changeModule(java.lang.String) at the very first of your test methods.

    • ModuleTestBase

      public ModuleTestBase(String nameTest, String module)
      To test the specified module of the default application.

      In this case the application is obtained from the application property in xava-junit.properties file.
      You can send null for null in such a case you must use changeModule(java.lang.String) at the very first of your test methods.

    • ModuleTestBase

      public ModuleTestBase(String module)
      Constructor for JUnit 4 style tests.

      The module must be set in the subclass constructor by calling the appropriate constructor with module parameter.

      Since:
      7.6.2
  • Method Details

    • setUp

      protected void setUp() throws Exception
      Overrides:
      setUp in class junit.framework.TestCase
      Throws:
      Exception
    • tearDown

      protected void tearDown() throws Exception
      Overrides:
      tearDown in class junit.framework.TestCase
      Throws:
      Exception
    • login

      protected void login(String user, String password) throws Exception
      Throws:
      Exception
    • logout

      protected void logout() throws Exception
      User logout.

      Throws:
      Exception
    • resetModule

      protected void resetModule() throws Exception
      Like close navigator, open again, and reexecute the module.
      Throws:
      Exception
    • getBrowserVersion

      protected org.htmlunit.BrowserVersion getBrowserVersion() throws Exception
      The browser emulation used for the test.

      If you overwrite this method maybe some methods of ModuleTestBase would not work correctly. Usually you overwrite it to test using directly the HtmlUnit API.
      The use of this method is discouraged because binds your test to a HTML implementation. Before to use this method look for another more abstract method in this class.

      Throws:
      Exception
      Since:
      5.5
    • reload

      protected void reload() throws Exception
      Like clicking on the reload button of the browser.
      Throws:
      Exception
      Since:
      4.1.2
    • selectModuleInPage

      protected void selectModuleInPage(String module) throws Exception
      Throws:
      Exception
    • changeModule

      protected void changeModule(String module) throws Exception
      Throws:
      Exception
    • changeModule

      protected void changeModule(String application, String module) throws Exception
      Throws:
      Exception
    • getModuleURL

      protected String getModuleURL() throws XavaException
      Throws:
      XavaException
    • setModel

      protected void setModel(String defaultModel)
      Deprecated.
      Now the model is deduced automatically
      The model used as prefix to method like getValue, assertValue, etc.

      By default is the model of module. The effect of the this setting is only for the life of one test.

    • setModelToModuleSetting

      protected void setModelToModuleSetting()
      Deprecated.
      Now this is done automatically
      Put the model of the module as the default model of the test.

      This is the default setting, hence this method is called to restore the original setting.

    • execute

      protected void execute(String action) throws Exception
      Execute the action clicking in the link or button.
      Throws:
      Exception
    • waitAJAX

      protected void waitAJAX() throws Exception
      Wait until the current AJAX request is done and update the page if needed.

      Usually is only needed to call this method when you use directly HtmlUnit APIs.

      Throws:
      Exception
      Since:
      5.7
    • decorateId

      protected String decorateId(String name)
      Decorate the name to produced an unique identifier as the used by OX for HTML elements.
    • assertFocusOn

      protected void assertFocusOn(String name) throws Exception
      Throws:
      Exception
    • executeClicking

      @Deprecated protected void executeClicking(String action, String arguments) throws Exception
      Deprecated.
      Since 7.2 the regular execute() uses clicking always, so you can use execute() instead
      Executes an action simulating a real click in the button or link.

      In addition to execute the action this method throws the corresponding events of clicking the real link, like the focus lost of the current editor, for example.

      Throws:
      Exception
    • execute

      protected void execute(String action, String arguments) throws Exception
      Throws:
      Exception
    • executeDefaultAction

      protected void executeDefaultAction() throws Exception
      Throws:
      Exception
    • assertExists

      protected void assertExists(String name) throws Exception
      Throws:
      Exception
    • assertNotExists

      protected void assertNotExists(String name) throws Exception
      Throws:
      Exception
    • getDescriptionValue

      protected String getDescriptionValue(String name) throws Exception
      In the case of combo (descriptionsEditor.jsp) (or his read only version) the value that is visualized to user.
      Returns:
      Throws:
      Exception
    • getValue

      protected String getValue(String name) throws Exception
      Throws:
      Exception
    • getValues

      protected String[] getValues(String name) throws Exception
      For properties with multiple values
      Throws:
      Exception
    • getLabel

      protected String getLabel(String name) throws Exception
      Throws:
      Exception
    • getValue

      protected String getValue(String model, String name) throws Exception
      Deprecated.
      The model is automatically deduced, so you can use just getValue(String name)
      In case we does not work with main view.
      Throws:
      Exception
    • printHtml

      protected void printHtml() throws Exception
      Only for debug.
      Throws:
      Exception
    • assertContentType

      protected void assertContentType(String type)
      Util for web applications, but using it make the test web dependent.
      Parameters:
      type - text/html, application/pdf, etc.
    • assertContentTypeForPopup

      protected void assertContentTypeForPopup(int popup, String type)
      Util for web applications, but using it makes the test web dependent.
      Parameters:
      popup - The window number
      type - text/html, application/pdf, etc.
      Since:
      4.3
    • assertContentTypeForPopup

      protected void assertContentTypeForPopup(String type)
      Util for web applications, but using it makes the test web dependent.
      Parameters:
      type - text/html, application/pdf, etc.
    • assertPopupCount

      protected void assertPopupCount(int count) throws Exception
      Throws:
      Exception
      Since:
      4.3
    • assertNoPopup

      protected void assertNoPopup() throws Exception
      Throws:
      Exception
    • getHtml

      protected String getHtml() throws Exception
      Current HTML code.

      It is not very advisable because this will cause dependency to HTML and it will be difficult migrate to another presentation technology.

      Throws:
      Exception
    • getText

      protected String getText() throws IOException
      The text of the response.
      Throws:
      IOException
    • getPopupText

      protected String getPopupText() throws Exception
      The text of the response for popup window.
      Throws:
      Exception
    • getPopupContentAsStream

      protected InputStream getPopupContentAsStream() throws Exception
      The content of the response for popup window.
      Throws:
      Exception
      Since:
      6.4.2
    • getPopupPDFAsText

      protected String getPopupPDFAsText() throws Exception
      The content of the PDF in the popup window as text.
      Throws:
      Exception
      Since:
      4.6
    • printPopupPDFAsText

      protected void printPopupPDFAsText() throws Exception
      Only for debug.
      Throws:
      Exception
      Since:
      4.6
    • getPopupPDFPageCount

      protected int getPopupPDFPageCount() throws Exception
      Number of pages of the PDF in the popup window
      Throws:
      Exception
      Since:
      5.0
    • getPopupPDFLine

      protected String getPopupPDFLine(int lineNumber) throws Exception
      The specified line as text of PDF in the popup window.
      Throws:
      Exception
      Since:
      4.6
    • assertPopupPDFLine

      protected void assertPopupPDFLine(int lineNumber, String expectedContent) throws Exception
      Assert the value for the specified line as text of PDF in the popup window.
      Throws:
      Exception
      Since:
      4.6
    • assertPopupPDFLinesCount

      protected void assertPopupPDFLinesCount(int expectedCount) throws Exception
      Assert the count of lines of the PDF in the popup window.
      Throws:
      Exception
      Since:
      4.6
    • getPopupPDFLinesCount

      protected int getPopupPDFLinesCount() throws Exception
      The count of lines of the PDF in the popup window.
      Throws:
      Exception
      Since:
      4.6
    • setConditionValues

      protected void setConditionValues(String... values) throws Exception
      Parameters:
      Varargs - since 4m5.
      Throws:
      Exception
    • setConditionValuesTo

      protected void setConditionValuesTo(String... values) throws Exception
      Throws:
      Exception
      Since:
      4.4
    • setConditionValues

      protected void setConditionValues(List values) throws Exception
      To be used from Groovy, that does not work with setConditionValues(String ... values).
      Throws:
      Exception
      Since:
      4.0.1
    • setConditionComparators

      protected void setConditionComparators(List values) throws Exception
      To be used from Groovy, that does not work with setConditionComparators(String ... values).
      Throws:
      Exception
      Since:
      4.0.1
    • clearCondition

      protected void clearCondition() throws Exception
      Throws:
      Exception
      Since:
      5.6
    • setConditionComparators

      protected void setConditionComparators(String... values) throws Exception
      Parameters:
      values - varargs since 4m5
      Throws:
      Exception
    • setConditionValues

      protected void setConditionValues(String collection, String[] values) throws Exception
      Throws:
      Exception
    • setConditionComparators

      protected void setConditionComparators(String collection, String[] values) throws Exception
      Throws:
      Exception
    • setValueNotNotify

      protected void setValueNotNotify(String name, String value) throws Exception
      Throws:
      Exception
    • setValue

      protected void setValue(String name, String value) throws Exception
      Throws:
      Exception
    • setValues

      protected void setValues(String name, String[] values) throws Exception
      For multiple values properties
      Throws:
      Exception
    • setFileValue

      protected void setFileValue(String name, String filePath) throws Exception
      Throws:
      Exception
    • setValue

      protected void setValue(String model, String name, String value) throws Exception
      Deprecated.
      Now model is deduced automatically, so you can use setValue(String model, String value)
      In case we do not work with main view.

      Throws:
      Exception
    • assertLabel

      protected void assertLabel(String name, String expectedLabel) throws Exception
      Throws:
      Exception
    • assertLabel

      protected void assertLabel(int sectionIndex, String expectedLabel) throws Exception
      Throws:
      Exception
      Since:
      6.4
    • assertNoLabel

      protected void assertNoLabel(String name) throws Exception
      Throws:
      Exception
    • assertValue

      protected void assertValue(String name, String value) throws Exception
      Throws:
      Exception
    • assertValues

      protected void assertValues(String name, String[] values) throws Exception
      For multiple values property.
      Throws:
      Exception
    • assertValueIgnoringCase

      protected void assertValueIgnoringCase(String name, String value) throws Exception
      Throws:
      Exception
    • assertValue

      protected void assertValue(String model, String name, String value) throws Exception
      Throws:
      Exception
    • assertDescriptionValue

      protected void assertDescriptionValue(String name, String value) throws Exception
      Throws:
      Exception
    • existsAction

      protected boolean existsAction(String action) throws Exception
      Throws:
      Exception
    • assertAction

      protected void assertAction(String action) throws Exception
      Throws:
      Exception
    • assertAction

      protected void assertAction(String action, String arguments) throws Exception
      Throws:
      Exception
    • assertNoAction

      protected void assertNoAction(String action) throws Exception
      Throws:
      Exception
    • assertNoAction

      protected void assertNoAction(String action, String arguments) throws Exception
      Throws:
      Exception
    • assertActions

      protected void assertActions(String[] expectedActions) throws Exception
      Throws:
      Exception
    • getValueInList

      protected String getValueInList(int row, String name) throws Exception
      Throws:
      Exception
    • getValueInList

      protected String getValueInList(int row, int column) throws Exception
      Throws:
      Exception
    • getValueInList

      protected String getValueInList(int row) throws Exception
      Throws:
      Exception
      Since:
      5.7
    • getValueInCollection

      protected String getValueInCollection(String collection, int row, String name) throws Exception
      Throws:
      Exception
    • setValueInList

      protected void setValueInList(int row, String name, String value) throws Exception
      Sets the value of a property in a specific row of the list. This method allows you to modify the value of a property directly in the list view, simulating the user editing the cell in-place. Works with properties that are configured as editable in the list. For reference properties using @DescriptionsList, note that even though the list displays the description or name of the reference, when setting a value you must use the key property of the reference. For example, if you have a family reference that shows descriptions in the list, you would read the value using family.description but set it using family.number. Example:
       // Simple property
       setValueInList(0, "unitPrice", "17.00"); // Sets the first row's unitPrice to 17.00
       
       // Reference property with @DescriptionsList
       assertValueInList(1, "family.description", "HARDWARE"); // Reading shows the description
       setValueInList(1, "family.number", "3");    // Setting uses the key property
       
       // Reference property with multiple keys
       Warehouse warehouse = new Warehouse();
       warehouse.setZoneNumber(4);
       warehouse.setNumber(13);
       setValueInList(1, "warehouse.KEY", toKeyString(warehouse)); // For composite keys
       
      Parameters:
      row - The row number (0-based) in the list
      name - The property name to set, can be a simple property or a qualified property (e.g. "family.number")
      value - The value to set for the property
      Throws:
      Exception
      Since:
      7.6
    • setValueInList

      protected void setValueInList(int row, int column, String value) throws Exception
      Sets the value of a property in a specific row and column of the list. This method allows you to modify the value of a property directly in the list view by specifying the column index instead of the property name. The column index corresponds to the order of properties displayed in the list. Example:
       setValueInList(0, 2, "17.00"); // Sets the first row's third column to 17.00
       
      Parameters:
      row - The row number (0-based) in the list
      column - The column number (0-based) in the list
      value - The value to set for the property
      Throws:
      Exception
      Since:
      7.6
    • assertEditableInList

      protected void assertEditableInList(int row, String name) throws Exception
      Asserts that a property in a specific row of the list is editable. This method verifies that a property in the list can be edited in-place by the user. It fails the test if the property is not editable in the specified row. Example:
       assertEditableInList(0, "unitPrice"); // Verifies the unitPrice in first row is editable
       assertEditableInList(1, "family.description"); // Verifies a reference property is editable
       
      Parameters:
      row - The row number (0-based) in the list
      name - The property name to check, can be a simple property or a qualified property
      Throws:
      Exception - If the property is not editable or if any error occurs during verification
      Since:
      7.6
    • assertNoEditableInList

      protected void assertNoEditableInList(int row, String name) throws Exception
      Asserts that a property in a specific row of the list is NOT editable. This method verifies that a property in the list cannot be edited in-place by the user. It fails the test if the property is editable in the specified row when it should not be. Example:
       assertNoEditableInList(0, "extendedDescription"); // Verifies the property is not editable
       assertNoEditableInList(1, "id"); // Verifies a key property is not editable
       
      This is particularly useful for testing properties that should be read-only in the list, such as calculated fields, formula properties, or properties explicitly excluded from the editable properties configuration.
      Parameters:
      row - The row number (0-based) in the list
      name - The property name to check, can be a simple property or a qualified property
      Throws:
      Exception - If the property is editable or if any error occurs during verification
      Since:
      7.6
    • assertEditableInList

      protected void assertEditableInList(int row, int column) throws Exception
      Asserts that a property in a specific row and column of the list is editable. This method verifies that a property in the list can be edited in-place by the user, using column index instead of property name. The column index corresponds to the order of properties displayed in the list. Example:
       assertEditableInList(0, 2); // Verifies the third column in first row is editable
       
      Parameters:
      row - The row number (0-based) in the list
      column - The column number (0-based) in the list
      Throws:
      Exception - If the property is not editable or if any error occurs during verification
      Since:
      7.6
    • assertNoEditableInList

      protected void assertNoEditableInList(int row, int column) throws Exception
      Asserts that a property in a specific row and column of the list is NOT editable. This method verifies that a property in the list cannot be edited in-place by the user, using column index instead of property name. It fails the test if the property is editable in the specified row and column when it should not be. Example:
       assertNoEditableInList(0, 3); // Verifies the fourth column in first row is not editable
       
      This is particularly useful for testing properties that should be read-only in the list, such as calculated fields, formula properties, or properties explicitly excluded from the editable properties configuration.
      Parameters:
      row - The row number (0-based) in the list
      column - The column number (0-based) in the list
      Throws:
      Exception - If the property is editable or if any error occurs during verification
      Since:
      7.6
    • setValueInCollection

      protected void setValueInCollection(String collection, int row, String name, String value) throws Exception
      Throws:
      Exception
      Since:
      5.0
    • setValueInCollection

      protected void setValueInCollection(String collection, int row, int column, String value) throws Exception
      Throws:
      Exception
      Since:
      5.0
    • getValueInCollection

      protected String getValueInCollection(String collection, int row, int column) throws Exception
      Throws:
      Exception
    • assertRowStyleInList

      protected void assertRowStyleInList(int row, String expectedStyle) throws Exception
      Throws:
      Exception
    • assertRowStyleInCollection

      protected void assertRowStyleInCollection(String collection, int row, String expectedStyle) throws Exception
      Throws:
      Exception
    • assertNoRowStyleInList

      protected void assertNoRowStyleInList(int row) throws Exception
      Throws:
      Exception
    • assertNoRowStyleInCollection

      protected void assertNoRowStyleInCollection(String collection, int row) throws Exception
      Throws:
      Exception
    • _collectionHasFilterHeader

      protected boolean _collectionHasFilterHeader(String collection) throws Exception
      Throws:
      Exception
    • getListRowCount

      protected int getListRowCount() throws Exception
      Rows count displayed with data.

      Exclude heading and footing, and the not displayed data (maybe in cache).

      Throws:
      Exception
    • getListColumnCount

      protected int getListColumnCount() throws Exception
      Throws:
      Exception
    • getCollectionColumnCount

      protected int getCollectionColumnCount(String collection) throws Exception
      Throws:
      Exception
    • getCollectionRowCount

      protected int getCollectionRowCount(String collection) throws Exception
      Row count displayed with data.

      Excludes heading and footing, and not displayed data (but cached).

      Throws:
      Exception
    • assertCollectionRowCount

      protected void assertCollectionRowCount(String collection, int expectedCount) throws Exception
      Row count displayed with data.

      Excludes heading and footing, and not displayed data (but cached).

      Throws:
      Exception
    • assertListRowCount

      protected void assertListRowCount(int expected) throws Exception
      Rows count displayed with data.

      Exclude headers and footing, and the not displayed data (maybe cached).

      Throws:
      Exception
    • assertListColumnCount

      protected void assertListColumnCount(int expected) throws Exception
      Throws:
      Exception
    • assertCollectionColumnCount

      protected void assertCollectionColumnCount(String collection, int expected) throws Exception
      Throws:
      Exception
    • assertValueInList

      protected void assertValueInList(int row, String name, String value) throws Exception
      Throws:
      Exception
    • assertValueInList

      protected void assertValueInList(int row, String value) throws Exception
      Throws:
      Exception
      Since:
      5.7
    • assertValuesInList

      protected void assertValuesInList(int row, String... values) throws Exception
      Throws:
      Exception
      Since:
      5.8
    • assertValueInList

      protected void assertValueInList(int row, int column, String value) throws Exception
      Throws:
      Exception
    • assertValueInCollection

      protected void assertValueInCollection(String collection, int row, String name, String value) throws Exception
      Throws:
      Exception
    • assertValueInCollection

      protected void assertValueInCollection(String collection, int row, int column, String value) throws Exception
      Throws:
      Exception
    • assertValueInCollectionIgnoringCase

      protected void assertValueInCollectionIgnoringCase(String collection, int row, int column, String value) throws Exception
      Throws:
      Exception
    • assertLabelInCollection

      protected void assertLabelInCollection(String collection, int column, String label) throws Exception
      Throws:
      Exception
    • assertLabelInList

      protected void assertLabelInList(int column, String label) throws Exception
      Throws:
      Exception
    • assertTotalInList

      protected void assertTotalInList(int column, String total) throws Exception
      Throws:
      Exception
      Since:
      4.1
    • assertTotalInList

      protected void assertTotalInList(String name, String total) throws Exception
      Throws:
      Exception
      Since:
      4.1
    • assertTotalInCollection

      protected void assertTotalInCollection(String collection, int column, String total) throws Exception
      Throws:
      Exception
      Since:
      4.1
    • assertTotalInCollection

      protected void assertTotalInCollection(String collection, int row, int column, String total) throws Exception
      Throws:
      Exception
      Since:
      4.1
    • assertTotalInCollection

      protected void assertTotalInCollection(String collection, String name, String total) throws Exception
      Throws:
      Exception
      Since:
      4.1
    • assertTotalInCollection

      protected void assertTotalInCollection(String collection, int row, String name, String total) throws Exception
      Throws:
      Exception
      Since:
      4.3
    • checkRow

      protected void checkRow(int row) throws Exception
      Throws:
      Exception
    • checkAll

      protected void checkAll() throws Exception
      Throws:
      Exception
    • uncheckRow

      protected void uncheckRow(int row) throws Exception
      Throws:
      Exception
    • uncheckAll

      protected void uncheckAll() throws Exception
      Throws:
      Exception
    • checkRowCollection

      protected void checkRowCollection(String collection, int row) throws Exception
      Throws:
      Exception
    • checkAllCollection

      protected void checkAllCollection(String collection) throws Exception
      Throws:
      Exception
    • uncheckAllCollection

      protected void uncheckAllCollection(String collection) throws Exception
      Throws:
      Exception
    • uncheckRowCollection

      protected void uncheckRowCollection(String collection, int row) throws Exception
      Throws:
      Exception
    • checkRow

      protected void checkRow(String id, String value) throws Exception
      Throws:
      Exception
    • assertRowChecked

      protected void assertRowChecked(int row)
    • assertAllChecked

      protected void assertAllChecked()
    • assertRowCollectionChecked

      protected void assertRowCollectionChecked(String collection, int row) throws Exception
      Throws:
      Exception
    • assertAllCollectionChecked

      protected void assertAllCollectionChecked(String collection) throws Exception
      Throws:
      Exception
    • assertRowsChecked

      protected void assertRowsChecked(int f1, int f2)
    • assertRowsChecked

      protected void assertRowsChecked(int[] rows)
    • assertRowUnchecked

      protected void assertRowUnchecked(int row)
    • assertAllUnchecked

      protected void assertAllUnchecked()
    • assertRowCollectionUnchecked

      protected void assertRowCollectionUnchecked(String collection, int row) throws Exception
      Throws:
      Exception
    • assertAllCollectionUnchecked

      protected void assertAllCollectionUnchecked(String collection) throws Exception
      Throws:
      Exception
    • assertError

      protected void assertError(String message) throws Exception
      Throws:
      Exception
    • assertMessage

      protected void assertMessage(String message) throws Exception
      Throws:
      Exception
    • assertInfo

      protected void assertInfo(String message) throws Exception
      Throws:
      Exception
      Since:
      4.3
    • assertWarning

      protected void assertWarning(String message) throws Exception
      Throws:
      Exception
      Since:
      4.3
    • assertErrorsCount

      protected void assertErrorsCount(int expectedCount) throws Exception
      Throws:
      Exception
    • assertMessagesCount

      protected void assertMessagesCount(int expectedCount) throws Exception
      Throws:
      Exception
    • assertInfosCount

      protected void assertInfosCount(int expectedCount) throws Exception
      Throws:
      Exception
      Since:
      4.3
    • assertWarningsCount

      protected void assertWarningsCount(int expectedCount) throws Exception
      Throws:
      Exception
      Since:
      4.3
    • assertNoError

      protected void assertNoError(String message) throws Exception
      Throws:
      Exception
    • assertNoMessage

      protected void assertNoMessage(String message) throws Exception
      Throws:
      Exception
    • assertNoInfo

      protected void assertNoInfo(String message) throws Exception
      Throws:
      Exception
      Since:
      4.3
    • assertNoWarning

      protected void assertNoWarning(String message) throws Exception
      Throws:
      Exception
      Since:
      4.3
    • getMessage

      protected String getMessage() throws Exception
      The first message
      Throws:
      Exception
    • assertNoErrors

      protected void assertNoErrors() throws Exception
      Throws:
      Exception
    • assertNoMessages

      protected void assertNoMessages() throws Exception
      Throws:
      Exception
    • assertNoWarnings

      protected void assertNoWarnings() throws Exception
      Throws:
      Exception
      Since:
      5.4
    • assertNoInfos

      protected void assertNoInfos() throws Exception
      Throws:
      Exception
      Since:
      5.4
    • assertValidValuesInCollection

      protected void assertValidValuesInCollection(String collection, int row, String name, String[][] values) throws Exception
      Throws:
      Exception
      Since:
      5.1
    • assertValidValuesCountInCollection

      protected void assertValidValuesCountInCollection(String collection, int row, String name, int count) throws Exception
      Throws:
      Exception
      Since:
      5.1
    • assertValidValueNotExists

      protected void assertValidValueNotExists(String name, String key) throws Exception
      Throws:
      Exception
    • assertValidValues

      protected void assertValidValues(String name, String[][] values) throws Exception
      Throws:
      Exception
    • assertValidValuesCount

      protected void assertValidValuesCount(String name, int count) throws Exception
      Throws:
      Exception
    • getKeysValidValues

      protected String[] getKeysValidValues(String name) throws Exception
      Throws:
      Exception
    • assertEditable

      protected void assertEditable(String name) throws Exception
      Throws:
      Exception
    • assertNoEditable

      protected void assertNoEditable(String name) throws Exception
      Throws:
      Exception
    • assertEditableInCollection

      protected void assertEditableInCollection(String collection, int row, String name) throws Exception
      Throws:
      Exception
      Since:
      5.0
    • assertNoEditableInCollection

      protected void assertNoEditableInCollection(String collection, int row, String name) throws Exception
      Throws:
      Exception
      Since:
      5.0
    • assertEditableInCollection

      protected void assertEditableInCollection(String collection, int row, int column) throws Exception
      Throws:
      Exception
      Since:
      5.0
    • assertNoEditableInCollection

      protected void assertNoEditableInCollection(String collection, int row, int column) throws Exception
      Throws:
      Exception
      Since:
      5.0
    • assertListTitle

      protected void assertListTitle(String expectedTitle) throws Exception
      Throws:
      Exception
    • assertNoListTitle

      protected void assertNoListTitle() throws Exception
      Throws:
      Exception
    • assertListNotEmpty

      protected void assertListNotEmpty() throws Exception
      Throws:
      Exception
    • assertCollectionNotEmpty

      protected void assertCollectionNotEmpty(String collection) throws Exception
      Throws:
      Exception
    • assertValidValueExists

      protected void assertValidValueExists(String name, String key, String description) throws Exception
      Throws:
      Exception
      Since:
      5.3
    • getPort

      protected static String getPort()
    • getHost

      protected static String getHost()
    • getContextPath

      protected String getContextPath()
      Since:
      6.3
    • getXavaJUnitProperty

      public static String getXavaJUnitProperty(String id)
      From file xava-junit.properties
      Since:
      4m6 Before it was called getProperty()
    • getXavaJUnitProperty

      public static String getXavaJUnitProperty(String id, String defaultValue)
      From file xava-junit.properties
      Since:
      4m6 Before it was called getProperty()
    • getForm

      protected org.htmlunit.html.HtmlForm getForm()
      Current HtmlForm (of HtmlUnit).

      This allow you to access directly to html form elements, but it is not very advisable because this will cause dependency to HTML and HtmlUnit so it will be difficult migrate to another presentation technology.

    • getWebClient

      protected org.htmlunit.WebClient getWebClient()
      This allows you testing using HtmlUnit APIs directly.

      The use of this method is discoraged because binds your test to a HTML implementation. Before to use this method look for another more abstract method in this class.
      By default CSS is disabled for performance, if you need that CSS works for your test, write this line:

       getWebClient().setCssEnabled(true);
       
    • createWebClient

      protected org.htmlunit.WebClient createWebClient() throws Exception
      It creates and returns a new WebClient each time you call it.

      Also, it's the method used to create the WebClient used for the test, so you can overwrite it to refine the WebClient used for your test.
      This allows you testing using HtmlUnit APIs directly.
      The use of this method is discoraged because binds your test to a HTML implementation. Before to use this method look for another more abstract method in this class.
      By default CSS is disabled for performance, if you need that CSS works for your test, write this line:

       WebClient webClient = createWebClient();
       webClient.setCssEnabled(true);
       
      Throws:
      Exception
      Since:
      7.3
    • getLocale

      protected String getLocale()
    • setLocale

      protected void setLocale(String locale) throws Exception
      Throws:
      Exception
    • toKeyString

      protected String toKeyString(Object pojo) throws Exception
      Returns a string representations of the key of a POJO from the POJO itself.

      Useful for obtaining the value to put into a combo (a descriptions list) from a POJO object.

      Throws:
      Exception
    • assertNotEquals

      protected void assertNotEquals(String msg, String value1, String value2)
    • assertDialog

      protected void assertDialog() throws Exception
      Throws:
      Exception
      Since:
      4m1
    • assertNoDialog

      protected void assertNoDialog() throws Exception
      Throws:
      Exception
      Since:
      4m1
    • closeDialog

      protected void closeDialog() throws Exception
      Throws:
      Exception
      Since:
      4m1
    • assertDialogTitle

      protected void assertDialogTitle(String expectedTitle) throws Exception
      Throws:
      Exception
      Since:
      4m1
    • getHtmlPage

      protected org.htmlunit.html.HtmlPage getHtmlPage()
      This allows you testing using HtmlUnit APIs directly.

      The use of this method is discouraged because binds your test to a HTML implementation. Before to use this method look for another more abstract method in this class.

      Since:
      4m4
    • assertDiscussionCommentText

      protected void assertDiscussionCommentText(String name, int row, String extendedText)
      Assert the content of a comment of DISCUSSION property as text, including header data like user and date.

      Since:
      5.6
    • getDiscussionCommentText

      protected String getDiscussionCommentText(String name, int row)
      Get the content of a comment of DISCUSSION property as text, including header data like user and date.

      Since:
      5.7
    • getDiscussionCommentContentText

      protected String getDiscussionCommentContentText(String name, int row)
      Get the content of a comment of DISCUSSION property as text, just the content of the comment excluding header data.

      Since:
      5.7
    • assertDiscussionCommentContentText

      protected void assertDiscussionCommentContentText(String name, int row, String expectedText)
      Assert the content of a comment of DISCUSSION property as text, just the content of the comment excluding header data.

      Since:
      5.7
    • assertDiscussionCommentsCount

      protected void assertDiscussionCommentsCount(String name, int expectedCount)
      Assert the amount of comments in a DISCUSSION property.

      Since:
      5.6
    • postDiscussionComment

      protected void postDiscussionComment(String name, String commentContent) throws Exception
      Post a new comment into a DISCUSSION property.

      Throws:
      Exception
      Since:
      5.6
    • selectListConfiguration

      protected void selectListConfiguration(String title) throws Exception
      Throws:
      Exception
      Since:
      5.6
    • assertListSelectedConfiguration

      protected void assertListSelectedConfiguration(String expectedTitle)
      Since:
      5.6
    • assertListAllConfigurations

      protected void assertListAllConfigurations(String... expectedTitles) throws Exception
      Throws:
      Exception
      Since:
      5.6
    • selectGroupBy

      protected void selectGroupBy(String title) throws Exception
      Throws:
      Exception
      Since:
      5.8
    • assertAllGroupBys

      protected void assertAllGroupBys(String... expectedTitles) throws Exception
      Throws:
      Exception
      Since:
      5.8
    • assertFile

      protected void assertFile(String property, String contentType) throws Exception
      Assert if the property with an upload editor of has a file associated. For properties with stereotypes IMAGE, PHOTO, FILE, etc. Example:
       assertFile("photo", "image");
       
      It tries to recover the file from the server and verify if it is of contentType.
      Parameters:
      property - The property name of the current view with an upload editor
      contentType - The content type, such as image, image/png, text/html, etc.
      Throws:
      Exception
      Since:
      6.2
    • assertFile

      protected void assertFile(String property) throws Exception
      Assert if the property with an upload editor has a file associated. For properties with stereotypes IMAGE, PHOTO, FILE, etc. Example:
       assertFile("photo");
       
      It tries to recover the file from the server.
      Parameters:
      property - The property name of the current view with an upload editor
      Throws:
      Exception
      Since:
      6.2
    • assertFile

      protected void assertFile(String property, int index, String expectedType) throws Exception
      Assert if the property with an upload editor with multiple files has a file associated in certain position. For properties with stereotypes IMAGES_GALLERY, FILES, etc. Example:
       assertFile("attachments", 2, "text/html");
       
      It tries to recover the file from the server and verify if it is of contentType.
      Parameters:
      property - The property name of the current view with an upload editor
      index - Position of the file
      contentType - The content type, such as image, image/png, text/html, etc.
      Throws:
      Exception
      Since:
      6.2
    • assertNoFile

      protected void assertNoFile(String property) throws Exception
      Assert if the property with an upload editor has not a file associated. For properties with stereotypes IMAGE, PHOTO, FILE, etc. Example:
       assertNoFile("photo");
       
      Parameters:
      property - The property name of the current view with an upload editor
      Throws:
      Exception
      Since:
      6.2
    • uploadFile

      protected void uploadFile(String property, String fileURL) throws Exception
      Upload a file in a property with an upload editor. For properties with stereotypes IMAGE, PHOTO, IMAGES_GALLERY, FILE, FILES, etc. Example:
       uploadFile("photo", "test-images/cake.gif");
       
      Parameters:
      property - The property name of the current view with an upload editor
      fileURL - If the URL is relative it starts from the current project, if it is absolute (starts with /) it is used 'as is'.
      Throws:
      Exception
      Since:
      6.2
    • removeFile

      protected void removeFile(String property) throws Exception
      Remove the current file from a property with an upload editor. For properties with stereotypes IMAGE, PHOTO, FILE, etc. Example:
       removeFile("photo");
       
      It's like clicking in the X button of the file, if the file is actually deleted from database depends on the concrete editor.
      Parameters:
      property - The property name of the current view with an upload editor
      Throws:
      Exception
      Since:
      6.2
    • assertFilesCount

      protected void assertFilesCount(String property, int expectedCount) throws Exception
      Assert the amount of files in a property with an upload multiple editor. For properties with stereotypes IMAGES_GALLERY, FILES, etc. Example:
       assertFilesCount("screenshots", 5);
       
      Parameters:
      property - The property name of the current view with an upload multiple editor
      expectedCount - The expected number of files
      Throws:
      Exception
      Since:
      6.2
    • removeFile

      protected void removeFile(String property, int index) throws Exception
      Remove a file from a property with an upload multiple editor. For properties with stereotypes IMAGES_GALLERY, FILES, etc. Example:
       removeFile("screenshots", 2);
       
      It's like clicking in the X button of the file, if the file is actually deleted from database depends on the concrete editor.
      Parameters:
      property - The property name of the current view with an upload multiple editor
      index - The position (0 based) of the file to remove
      Throws:
      Exception
      Since:
      6.2
    • moveRow

      protected void moveRow(String collection, int from, int to) throws Exception
      Move an element of collection from a row to another.

      It is for @OrderColumn collection where the user can reorder the rows with the mouse.
      WARNING! This method does not work for all "from, to" combinations, so if it does not work just try with other combination. Example:

       moveRow("details", 2, 0);
       
      Parameters:
      collection - The name of the collection
      from - Index of the origin row
      to - Index of the target row
      Throws:
      Exception
      Since:
      6.6
    • moveRow

      protected void moveRow(String collection, int from, int to, boolean classRequired) throws Exception
      Move an element of collection from a row to another.

      It is for @OrderColumn collection where the user can reorder the rows with the mouse.
      WARNING! This method does not work for all "from, to" combinations, so if it does not work just try with other combination. Example:

       moveRow("details", 2, 0);
       
      Parameters:
      collection - The name of the collection
      from - Index of the origin row
      to - Index of the target row
      classRequired - If true it verifies the CSS class of target row to assures it is sortable
      Throws:
      Exception
      Since:
      6.6