Author: vrockai
Date: 2009-04-08 12:14:49 -0400 (Wed, 08 Apr 2009)
New Revision: 13193
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortletUserCreationTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PageCoordinationTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java
Log:
[selenium] - more javadoc, more more...
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-04-08
15:43:04 UTC (rev 13192)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-04-08
16:14:49 UTC (rev 13193)
@@ -123,7 +123,7 @@
* Click on an element only in case element is present on the screen.
*
* @param id
- * the id
+ * element locator
*/
public void clickIfVisible(String id) {
@@ -168,12 +168,12 @@
// TODO refactor
/**
- * Safe select.
+ * Selects a value only if the value is present in the select. If the value is not
present, selection fails.
*
* @param locator
- * the locator
+ * the locator of the select tag
* @param value
- * the value
+ * the value which should be selected
*/
public void safeSelect(String locator, String value) {
waitForElement(locator);
@@ -204,9 +204,9 @@
}
/**
- * Click and wait.
+ * Click and wait. Substitution for two selenium commands click and waitForPageToLoad.
*
- * @param locator the locator
+ * @param locator the locator of the element to be clicked on
*/
public void clickAndWait(String locator) {
waitForElement(locator);
@@ -215,9 +215,9 @@
}
/**
- * Open and wait.
+ * Open and wait. Substitution for two selenium commands open and waitForPageToLoad.
*
- * @param locator the locator
+ * @param locator the address to be opened
*/
public void openAndWait(String locator) {
selenium.open(locator);
@@ -225,10 +225,10 @@
}
/**
- * Select if not selected.
+ * Select if not selected. If the value is already selected, the method does nothing.
*
- * @param selector the selector
- * @param label the label
+ * @param selector the selector locator
+ * @param label the label to be selected
*/
public void selectIfNotSelected(String selector, String label) {
waitForElement(selector);
@@ -239,11 +239,12 @@
}
/**
- * Assert text order.
+ * Asserts the text order on the page. The messages which order is to be determined are
inputed in a comma separated way. i.e. "string1;string2;string3". The method
+ * asserts that they appear on the page in the same order as typed in the input string.
It returns true if the order is the same or false otherwise.
*
- * @param text the text
+ * @param text input text in comma separated format which order is to be asserted
*
- * @return true, if successful
+ * @return true if the order is the same or false otherwise
*/
public boolean assertTextOrder(String text) {
return Boolean.valueOf(selenium.getEval("selenium.assertTextOrder(\"" +
text + "\")"));
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-04-08
15:43:04 UTC (rev 13192)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-04-08
16:14:49 UTC (rev 13193)
@@ -11,6 +11,40 @@
import com.thoughtworks.selenium.Selenium;
import com.thoughtworks.selenium.SeleniumException;
+/**
+ * The listener interface for receiving JBossSeleniumTest events.
+ * The class that is interested in processing a JBossSeleniumTest
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addJBossSeleniumTestListener<code> method. When
+ * the JBossSeleniumTest event occurs, that object's appropriate
+ * method is invoked. <br/>
+ * JBossSeleniumTestListener is responsible for decoding most of the parameters which are
passed to selenium tests.
+ * <table>
+ * <thead>
+ * <tr>
+ * <th>parameter name</th>
+ * <th>valid values</th>
+ * <th>default value</th>
+ * <th>description</th>
+ * </tr>
+ * </thead>
+ * <tr>
+ * <td>screenshot</td>
+ * <td>true/false</td>
+ * <td>false</td>
+ * <td>If true, screenshots are taken after the test failure. They are saved into
directory specified by the "output" parameter.</td>
+ * </tr><tr>
+ *
<td>html-src</td><td>true/false</td><td>false</td><td>If
true, html sources are taken after the test failure. They are saved into directory
specified by the "output" parameter.</td>
+ * </tr><tr>
+ *
<td>debug</td><td>true/false</td><td>false</td><td>If
true, debug screenshots are taken and debug messages are turned on. Debug screenshot are
saved into debug directory.</td>
+ * </tr><tr>
+ *
<td>output-dir</td><td><path-to-dir></td><td>""</td><td>Path
to the directory where html sources and screenshots are saved.</td>
+ * </tr>
+ * </table>
+ *
+ * @see JBossSeleniumTestEvent
+ */
public class JBossSeleniumTestListener extends TestListenerAdapter {
protected static Selenium selenium;
@@ -42,6 +76,9 @@
}
}
+ /* (non-Javadoc)
+ * @see org.testng.TestListenerAdapter#onTestFailure(org.testng.ITestResult)
+ */
@Override
public void onTestFailure(ITestResult tr) {
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortletUserCreationTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortletUserCreationTestCase.java 2009-04-08
15:43:04 UTC (rev 13192)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortletUserCreationTestCase.java 2009-04-08
16:14:49 UTC (rev 13193)
@@ -3,27 +3,53 @@
import org.testng.Assert;
import org.testng.annotations.Test;
+// TODO: Auto-generated Javadoc
/**
+ * PortletUserCreationTestCase was used for registering new user with portlet on a
default homepage of portal. Because of captcha this test had to be disabled.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
@Test(groups = { "portlet_user_creation" }, enabled = true)
public class PortletUserCreationTestCase extends JBossPortalSeleniumTestCase {
+ /** prefix for locator properties = user.crea.port.*/
public String casePfx = "user.crea.port.";
+ /** The SUBMI t_ creat e_ conf. */
private final String SUBMIT_CREATE_CONF =
getProp(casePfx+"submit.create.conf","//input[contains(@id,'confirm-form:user')]");
+
+ /** The SUBMI t_ creat e_ con f_ edit. */
public final String SUBMIT_CREATE_CONF_EDIT =
getProp(casePfx+"submit.create.conf.edit","//input[contains(@id,'//input[contains(@id,'confirm-form:revise')]");
+
+ /** The SUBMI t_ creat e_ user. */
private final String SUBMIT_CREATE_USER =
getProp(casePfx+"submit.create.user","//input[contains(@id,'register-form:submit')]");
+
+ /** The SUBMI t_ creat e_ use r_ cancel. */
private final String SUBMIT_CREATE_USER_CANCEL =
getProp(casePfx+"submit.create.user.cancel","//input[contains(@id,'register-form:cancel')]");
+
+ /** The INPU t_ userpasswdconf. */
private final String INPUT_USERPASSWDCONF =
getProp(casePfx+"input.userpasswdconf","//input[contains(@id,'register-form:passwordCheckv");
+
+ /** The INPU t_ userpasswd. */
private final String INPUT_USERPASSWD =
getProp(casePfx+"input.userpasswd","//input[contains(@id,'register-form:password')]");
+
+ /** The INPU t_ usermail. */
private final String INPUT_USERMAIL =
getProp(casePfx+"input.usermail","//input[contains(@id,'register-form:email')]");
+
+ /** The INPU t_ username. */
private final String INPUT_USERNAME =
getProp(casePfx+"input.username","//input[contains(@id,'register-form:username')]");
+
+ /** The LIN k_ creat e_ user. */
private final String LINK_CREATE_USER =
getProp(casePfx+"link.create.user","//a[contains(@id,'create-account-form:register')]");
+
+ /** The TA b_ welcome. */
private final String TAB_WELCOME =
getProp(casePfx+"tab.welcome","//a[contains(@id,'register-temp-form:start-link')]");
+ /**
+ * User creation test.
+ */
@Test(enabled = true, description = "Simple user creation.")
public void userCreationTest() {
selenium.open("/portal");
@@ -49,6 +75,9 @@
Assert.assertTrue((selenium.isTextPresent("Your account has been successfully
created. You may want to login now.")));
}
+ /**
+ * User creation long test.
+ */
@Test(enabled = true, description = "User creation using most of the active
elements on page.")
public void userCreationLongTest() {
@@ -104,6 +133,9 @@
Assert.assertTrue((selenium.isTextPresent("Your account has been successfully
created. You may want to login now.")));
}
+ /**
+ * User creation cancel edit test.
+ */
@Test(enabled = true, description = "Canceling of editing during the user
creation.")
public void userCreationCancelEditTest() {
selenium.open("/portal");
@@ -131,6 +163,9 @@
Assert.assertTrue(selenium.isTextPresent("You can create an account."));
}
+ /**
+ * Existing user creation test.
+ */
@Test(enabled = true, description = "Creation of already existing user.")
public void existingUserCreationTest() {
selenium.open("/portal");
@@ -147,6 +182,9 @@
Assert.assertTrue(selenium.isTextPresent("This username is already taken.
user"));
}
+ /**
+ * Invalid email.
+ */
@Test(enabled = false, description = "Using invalid e-mail within user
creation.")
public void invalidEmail() {
selenium.open("/portal");
@@ -164,6 +202,9 @@
}
+ /**
+ * Password not match.
+ */
@Test(enabled = true, description = "Not matching password confirmation.")
public void passwordNotMatch() {
selenium.open("/portal");
@@ -180,6 +221,9 @@
Assert.assertTrue(selenium.isTextPresent("The passwords doesn't
match."));
}
+ /**
+ * Short pass.
+ */
@Test(enabled = true, description = "Using short password.")
public void shortPass() {
selenium.open("/portal");
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java 2009-04-08
15:43:04 UTC (rev 13192)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java 2009-04-08
16:14:49 UTC (rev 13193)
@@ -6,7 +6,10 @@
import org.testng.Assert;
import org.testng.annotations.Test;
+
/**
+ * The Class UserInterceptorPortletTestCase is responsible for testing the log of logging
of users.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
@Test(groups = { "cms_user_interceptor" }, enabled = true, description =
"Checking the log of logging of users.")
@@ -15,12 +18,21 @@
private static final String LNK_USER_DETAILS = "link=UsersDetailPage";
private static final String DIV_LOGINFO =
"//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div";
+ /**
+ * Test test user logger. The user is logged in two times, asserting, that the time of
second logging was after the first login.
+ *
+ * @throws ParseException the parse exception
+ */
@Test(enabled = true, description = "Checking the logging dates for user.")
public void testTestUserLogger() throws ParseException {
-
Assert.assertTrue(dateDiff("user", "user", 1) > 0, "Second
logging was not after the first for user.");
}
+ /**
+ * Test test admin logger. The admin is logged in two times, asserting, that the time of
second logging was after the first login.
+ *
+ * @throws ParseException the parse exception
+ */
@Test(enabled = true, description = "Checking the logging dates for admin.")
public void testTestAdminLogger() throws ParseException {
Assert.assertTrue(dateDiff("admin", "admin", 3) > 0,
"Second logging was not after the first for user.");
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PageCoordinationTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PageCoordinationTestCase.java 2009-04-08
15:43:04 UTC (rev 13192)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PageCoordinationTestCase.java 2009-04-08
16:14:49 UTC (rev 13193)
@@ -8,6 +8,10 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+/**
+ * The Class PageCoordinationTestCase is responsible for testing of basic coordination
configuration on "/portal/auth/portal/default/Coordination+Samples" page.
+ */
+//TODO refactoring needed
public class PageCoordinationTestCase extends JBossPortalSeleniumTestCase {
private final String INP_ALIAS_REN =
"//input[contains(@name,'renameForm:newName')]";
private final String SUB_ALIAS_RENAME_SUBMIT =
"//input[contains(@name,'renameForm:j_id35')]";
@@ -24,6 +28,7 @@
private final String INP_ALIAS_NAME =
"//input[contains(@id,'create-alias-form:aliasName')]";
private final String LIS_RENDER_PAR =
"//select[contains(@id,'create-alias-form:alias')]";
+ /** prefix for locator properties = portal.admin.*/
public final String casePfx = "portal.admin.";
private final String TAB_PORTALOBJ_ID = getProp(casePfx + "tab.portalobj.id",
"Link=Admin");
@@ -35,16 +40,57 @@
private final String PAG_TL_COORDINATION = getProp(casePfx + "pag.tl.coord",
"//a[contains(@id,''pages-datatable:{0}:edit-coord'')]");
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ private void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ private void logoutAfterTest() {
}
+ /**
+ * Tests default page coordination. Four URLs are opened and depending on used
parameters the output of coordination portlet is asserted.
+ * <table>
+ * <tr>
+ * <td>1.</td>
+ * <td>"/portal/auth/portal/default/Coordination+Samples"</td>
+ * <td>
+ * "Weather for (my_zipcode):null"
+ * <br/>
+ * "Map for (your_zipcode):null"
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>2.</td>
+ *
<td>"/portal/auth/portal/default/Coordination+Samples?zipcode=10101"</td>
+ * <td>
+ * "Weather for (my_zipcode):null"
+ * <br/>
+ * "Map for (your_zipcode):10101"
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>3.</td>
+ *
<td>"/portal/auth/portal/default/Coordination+Samples?zip=10102"</td>
+ * <td>
+ * "Weather for (my_zipcode):10102"
+ * <br/>
+ * "Map for (your_zipcode):10102"
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>4.</td>
+ *
<td>"/portal/auth/portal/default/Coordination+Samples?zipcode=10103"</td>
+ * <td>
+ * "Weather for (my_zipcode):null"
+ * <br/>
+ * "Map for (your_zipcode):10103"
+ * </td>
+ * </tr>
+ * </table>
+ */
@Test(enabled = true)
public void testDefaultPageCoordination(){
openAndWait("/portal/auth/portal/default/Coordination+Samples");
@@ -64,6 +110,15 @@
Assert.assertTrue(selenium.isTextPresent("Map for (your_zipcode):10103"));
}
+ /**
+ * Tests page coordination. New alias is created on "Coordination Samples"
page on "default" portal. It is named "aliasBindTest" and it is bind
to "zipcode". At first attempt the creation is canceled,
+ * on the second attpemt it is submited. The final assert is made on
"/portal/auth/portal/default/Coordination+Samples?aliasBindTest=222333" and
it's asserting this text:
+ * <pre>
+ * "Weather for (my_zipcode):null"
+ * "Map for (your_zipcode):222333"
+ * </pre>
+ *
+ */
@Test(enabled = true, dependsOnMethods ={"testDefaultPageCoordination"})
public void testPageCoordination(){
String portalName = "default";
@@ -104,6 +159,14 @@
}
+ /**
+ * Tests delete alias. New alias is created on "Coordination Samples" page on
"default" portal. It is named "aliasBindDelete" and it is bind to
"{urn:jboss:portal:samples:coor}zipcode" similar way as in
+ * {@link PageCoordinationTestCase#testPageCoordination()}. The alias is next deleted
and it is asserted, that the alias doesnt exist by opening
+ * "/portal/auth/portal/default/Coordination+Samples?aliasBindDelete=222333"
+ * and asserting
+ * "Weather for (my_zipcode):null"
+ * "Map for (your_zipcode):null"
+ */
@Test(enabled = true, dependsOnMethods ={"testDefaultPageCoordination"})
public void testDeleteAlias(){
int count = 0;
@@ -176,6 +239,26 @@
Assert.assertTrue(selenium.isTextPresent("Map for (your_zipcode):null"));
}
+ /**
+ * Tests renaming of an alias. New alias is created on "Coordination Samples"
page on "default" portal. It is named "aliasBingRename" and it is bind
to "{urn:jboss:portal:samples:coor}zipcode" similar way as in
+ * {@link PageCoordinationTestCase#testPageCoordination()}. The alias is renamed to
"aliasBindWasRenamed" and it is asserted, that the previously named alias doesnt
exist by opening
+ *
+ * "/portal/auth/portal/default/Coordination+Samples?aliasBingRename=222333"
+ * and asserting
+ * <pre>
+ * "Weather for (my_zipcode):null"
+ * "Map for (your_zipcode):null"
+ * </pre>
+ *
+ * and that the new name is working by opening
+ *
"/portal/auth/portal/default/Coordination+Samples?aliasBindWasRenamed=222333"
+ * and asserting
+ * <pre>
+ * "Weather for (my_zipcode):222334"
+ * "Map for (your_zipcode):null"
+ * </pre>
+ */
+ //TODO deeper logic needed
@Test(enabled = true, dependsOnMethods ={"testDefaultPageCoordination"})
public void testRenameAlias(){
String portalName = "default";
@@ -234,6 +317,9 @@
Assert.assertTrue(selenium.isTextPresent("Map for (your_zipcode):null"));
}
+ /**
+ * Tests parameter binding. Parameter bindings flag is turned on and the coordination
samples coordination settings page is reloaded. It is asserted that the checkbox is still
turned on.
+ */
@Test(enabled = true, dependsOnMethods ={"testDefaultPageCoordination"})
public void testParamBinding(){
String portalName = "default";
@@ -279,6 +365,10 @@
Assert.assertTrue(selenium.isChecked(CHK_PARAM_BIND));
}
+ /**
+ * Tests explicit wiring. Explicit wiring flag is turned on and the coordination samples
coordination settings page is reloaded. It is asserted that the checkbox is still turned
on.
+ */
+ //TODO deeper logic needed
@Test(enabled = true, dependsOnMethods ={"testDefaultPageCoordination"})
public void testExplicitWiring(){
String portalName = "default";
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java 2009-04-08
15:43:04 UTC (rev 13192)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java 2009-04-08
16:14:49 UTC (rev 13193)
@@ -8,8 +8,12 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+/**
+ * The Class PortletDefinitionsTestCase is responsible for testing portlet definitions
testing in JBoss Portal.
+ */
public class PortletDefinitionsTestCase extends JBossPortalSeleniumTestCase{
+ /** prefix for locator properties = portal.port.def.*/
public final String casePfx = "portal.port.def.";
private final String T_LINK_PREF =
getProp(casePfx+"t.link.pref","//a[contains(@id,''def-list:portlet-pref-{0}'')]");
@@ -27,17 +31,21 @@
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ private void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
goToPD();
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ private void logoutAfterTest() {
logout();
}
+ /**
+ * Tests showing of information for portlet definition. In portlet definitions table,
test clicks on admin portlet link. Various infomartion about portlet is shown. This
+ * test assert some of them to appear on the screen.
+ */
@Test(enabled = true)
public void testShowInfo(){
selenium.click(LINK_ADMIN_PORT);
@@ -49,6 +57,11 @@
Assert.assertTrue(selenium.isTextPresent("Portlet Modes"));
}
+ /**
+ * Testing of creating an instance. In portlet definitions table, test clicks on admin
portlet "create instance" button. The instance is named
"littleAdmin".
+ * Final assertion is made by the presence of "littleAdmin portlet details" on
the screen (after filling the name and clicking "create new instance").
+ */
+ //TODO final assert - better to find it in portlet instances table
@Test(enabled = true)
public void testCreateInstance(){
@@ -63,6 +76,10 @@
Assert.assertTrue(selenium.isTextPresent("littleAdmin portlet details"));
}
+ /**
+ * Testing of creating an instance with uncommon string defining its name. This test
does the same as {@link PortletDefinitionsTestCase#testCreateInstance()}.
+ * The only diffenence is in the name of created instance. In this test the string
"str.nge.n.me" is used.
+ */
@Test(enabled = true)
public void testCreateInstanceUncommonName(){
@@ -77,6 +94,11 @@
Assert.assertTrue(selenium.isTextPresent("str.nge.n.me"+" portlet
details"));
}
+ /**
+ * Tests preferences screen of portlet definition. It clicks on preferences link for
"Current Users Portlet" definition and asserts that the string
"guestNumber"
+ * is appearing on the screen.
+ */
+ //TODO more asserts needed
@Test(enabled = true)
public void testPreferences(){
@@ -88,6 +110,10 @@
Assert.assertTrue(selenium.isTextPresent("guestNumber"));
}
+ /**
+ * Tests switching the provider. After switching the provider to "self"
it's asserted that "Administration portlet" is not present in the portlet
definitions table.
+ * After switching th provider to "local" it is asserted, that
"Administration portlet" is present in the portlet definitions table.
+ */
@Test(enabled = true)
public void testSwitchProvider(){
selenium.select(SELECT_PROVIDER, "label=self");
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java 2009-04-08
15:43:04 UTC (rev 13192)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java 2009-04-08
16:14:49 UTC (rev 13193)
@@ -1,5 +1,9 @@
package org.jboss.portal.test.selenium.portal;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.text.MessageFormat;
import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
@@ -8,8 +12,13 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+/**
+ * The Class PortletInstancesTestCase is responsible for testing
+ * "portlet instance" configuration features
+ */
public class PortletInstancesTestCase extends JBossPortalSeleniumTestCase {
+ /** prefix for locator properties = portal.port.ins. */
public final String casePfx = "portal.port.ins.";
private final String TAB_PORTLET_INSTANCES = getProp(casePfx +
"tab.portlet.instances",
"//table[contains(@id,'instancesTable2')]");
@@ -27,12 +36,15 @@
private final String INPUT_PREF_UPDATE = getProp(casePfx +
"input.pref.update",
"//input[contains(@id,'common-edit-exisiting-form:update')]");
private final String INPUT_PREF_APPEND = getProp(casePfx +
"input.pref.append",
"//input[contains(@id,'common-edit-exisiting-form:pref-input-0')]");
private final String SUBMIT_PREF_CANCEL = getProp(casePfx +
"submit.pref.cancel", "//input[contains(@id,':cancel')]");
- private final String LINK_CURUSER_PREFERENCES = getProp(casePfx +
"link.curuser.preferences","//a[contains(@id,'instances-form:preference-CurrentUsersPortletInstance')]");
+ private final String LINK_CURUSER_PREFERENCES = getProp(casePfx +
"link.curuser.preferences",
+ "//a[contains(@id,'instances-form:preference-CurrentUsersPortletInstance')]");
private final String LINK_DEL_EXCEPTPORT = getProp(casePfx +
"link.del.exceptport",
"//a[contains(@id,'instances-form:delete-GoogleMapPortletInstance')]");
private final String SUBMIT_PI_DELETE_CONF = getProp(casePfx +
"submit.pi.delete.conf",
"//input[contains(@id,'confirm-delete-form1:delete')]");
private final String SUBMIT_PI_DELETE_CANC = getProp(casePfx +
"submit.pi.delete.canc",
"//input[contains(@id,'confirm-delete-form1:cancel')]");
- private final String T_LINK_DELETENAME = getProp(casePfx +
"t.link.deletename","//a[contains(@id,''instance-display-form:locale-datatable:{0}:delete-link'')]");
- private final String T_LINK_MODIFYNAME = getProp(casePfx +
"t.link.modifyname","//a[contains(@id,''instance-display-form:locale-datatable:{0}:edit-link'')]");
+ private final String T_LINK_DELETENAME = getProp(casePfx +
"t.link.deletename",
+ "//a[contains(@id,''instance-display-form:locale-datatable:{0}:delete-link'')]");
+ private final String T_LINK_MODIFYNAME = getProp(casePfx +
"t.link.modifyname",
+ "//a[contains(@id,''instance-display-form:locale-datatable:{0}:edit-link'')]");
private final String LINK_COUNTPORT = getProp(casePfx + "link.countport",
"//a[contains(@id,'instances-form:CurrentUsersPortletInstance')]");
private final String NAME_COUNTPORT = getProp(casePfx + "name.countport",
"CurrentUsersPortletInstance");
private final String SUBMIT_MODIFY_NAME = getProp(casePfx +
"submit.modify.name",
"//input[contains(@id,'add-display-name-form:addDisplay')]");
@@ -42,26 +54,31 @@
private final String LINK_TAB_PI = getProp(casePfx + "link.tab.pi",
"//a[contains(@id,'admin-subtab-form:portlet-instance-link')]");
private final String LINK_PI_MAIN = getProp(casePfx + "link.pi.main",
"//a[contains(@id,'instance-form1:instance-link')]");
private final String TABLE_DISPNAMES = getProp(casePfx + "table.dispnames",
"//table[contains(@id,'instance-display-form:locale-datatable')]");
- private final String LNK_SEC_BUTTON = getProp(casePfx +
"lnk.sec.button","//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''Security'')]");
- private final String LNK_PREF_BUTTON = getProp(casePfx +
"lnk.pref.button","//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''actionPreferences'')]");
- private final String LNK_DEL_BUTTON = getProp(casePfx +
"lnk.del.button","//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''actionDeleteInstance'')]");
+ private final String LNK_SEC_BUTTON = getProp(casePfx + "lnk.sec.button",
+ "//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''Security'')]");
+ private final String LNK_PREF_BUTTON = getProp(casePfx + "lnk.pref.button",
+ "//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''actionPreferences'')]");
+ private final String LNK_DEL_BUTTON = getProp(casePfx + "lnk.del.button",
+ "//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''actionDeleteInstance'')]");
private final String LNK_INSTANCE_BUTTON = getProp(casePfx +
"lnk.instance.button",
"//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td[1]/a[1]");
- // private final String LNK_PREF_WELCOMEPORT =
- // "//a[contains(@id,'security-JSPPortletInstance')]";
-
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ private void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
goToPI();
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ private void logoutAfterTest() {
}
+ /**
+ * Tests adding name for portlet instance. Adds a name "Administracning" for
+ * CurrentUsersPortletInstance in "English" language. The existence of new
+ * name is then asserted in names table.
+ */
@Test(enabled = true)
public void testAddName() {
int r = traversePortlets(NAME_COUNTPORT, 0);
@@ -75,6 +92,13 @@
Assert.assertTrue(findTableRow(TABLE_DISPNAMES, name, 1) >= 0);
}
+ /**
+ * Tests deleting a name for portlet instance.A new name "Aduminu" in
+ * "Japanese" language is added for CurrentUsersPortletInstance similar way
+ * as in {@link PortletInstancesTestCase#testAddName()}. The name is then
+ * deleted and it is asserted that it is no longer present in portlet
+ * instance languages table.
+ */
@Test(enabled = true)
public void testDeleteName() {
// adding the name
@@ -98,6 +122,14 @@
Assert.assertFalse(findTableRow(TABLE_DISPNAMES, name, r) >= 0);
}
+ /**
+ * Tests modifying a name for portlet instance.A new name "Adminisimo" in
+ * "Japanese" language is added for CurrentUsersPortletInstance similar way
+ * as in {@link PortletInstancesTestCase#testAddName()}. The name is then
+ * modified to new name "Adminisimo" and it is asserted that the new name is
+ * present in portlet instance languages table.
+ */
+ // TODO assert that old name is not present
@Test(enabled = true)
public void testModifyName() {
int r = traversePortlets(NAME_COUNTPORT, 0);
@@ -125,15 +157,234 @@
Assert.assertTrue(findTableRow(TABLE_DISPNAMES, nameNew, 1) >= 0);
}
+ /**
+ * Tests security of portlet instance. Portlet JSPPortletInstance is set to
+ * two different security states. The first state is:
+ * <table class="datatable full-width">
+ * <thead class="portlet-section-header">
+ * <tr>
+ * <th>Roles</th>
+ * <th>Permissions</th>
+ * </tr>
+ * </thead> <tbody>
+ * <tr class="portlet-section-body">
+ * <td><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * >
+ *
+ * Role Administrators:</label></td>
+ * <td>
+ * <table
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" value="view"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:0"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" value="admin"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:1"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-alternate">
+ * <td><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * >
+ *
+ * Role Users:</label></td>
+ * <td>
+ * <table
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" value="view"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:0"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" value="admin"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:1"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-body">
+ * <td><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * >
+ *
+ * Role Unchecked:</label></td>
+ * <td>
+ * <table
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" checked="checked"
value="view"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:0"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" value="admin"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:1"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-alternate">
+ * <td><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * >
+ *
+ * Role secRoleDisp:</label></td>
+ * <td>
+ * <table
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" value="view"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:0"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" value="admin"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:1"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * </tbody>
+ * </table>
+ *
+ * and it is asserted that the portlet is visible after it. Then the
+ * security is changed to:
+ *
+ * <table class="datatable full-width">
+ * <thead class="portlet-section-header">
+ * <tr>
+ * <th>Roles</th>
+ * <th>Permissions</th>
+ * </tr>
+ * </thead> <tbody>
+ * <tr class="portlet-section-body">
+ * <td><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * >
+ *
+ * Role Administrators:</label></td>
+ * <td>
+ * <table
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" checked="checked"
value="view"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:0"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" checked="checked"
value="admin"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:1"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-alternate">
+ * <td><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * >
+ *
+ * Role Users:</label></td>
+ * <td>
+ * <table
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" checked="checked"
value="view"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:0"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" checked="checked"
value="admin"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:1"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-body">
+ * <td><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * >
+ *
+ * Role Unchecked:</label></td>
+ * <td>
+ * <table
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" value="view"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:0"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" checked="checked"
value="admin"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:1"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-alternate">
+ * <td><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * >
+ *
+ * Role secRoleDisp:</label></td>
+ * <td>
+ * <table
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" value="view"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:0"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" value="admin"
id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:1"
+ *
name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * /><label
for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * </tbody>
+ * </table>
+ *
+ * and it is asserted, that portlet instance is not visible. Canceling of setting of
permissions is tested, too.
+ *
+ */
+ //TODO reconsider adding more security tests
@Test(enabled = true)
public void testSecure() {
String instance_name = "JSPPortletInstance";
- // String table = TAB_PORTLET_INSTANCES;
- // selenium.click(LINK_20_PAGE);
- // selenium.waitForPageToLoad(PAGE_LOAD);
+ int c = 0;
- // int r = findTableRow(table, instance_name, 0);
int r = traversePortlets(instance_name, 0);
selenium.click(MessageFormat.format(LNK_SEC_BUTTON, r));
@@ -154,10 +405,6 @@
// then cancel
goToPI();
- // selenium.click(LINK_20_PAGE);
- // selenium.waitForPageToLoad(PAGE_LOAD);
-
- // r = findTableRow(table, instance_name, 0);
r = traversePortlets(instance_name, 0);
selenium.click(MessageFormat.format(LNK_SEC_BUTTON, r));
@@ -167,6 +414,7 @@
selenium.click("//input[contains(@name,'common-edit-security-form:cars_0')
and @value='admin']");
selenium.click("//input[contains(@name,'common-edit-security-form:cars_2')
and @value='admin']");
selenium.click("//input[contains(@name,'common-edit-security-form:cars_1')]");
+
selenium.click(SUBMIT_SECURITY_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.open("/portal/auth/portal/default/");
@@ -175,10 +423,7 @@
// then really stop the greetings portlet
goToPI();
- // selenium.setSpeed("5000");
- // selenium.click(LINK_20_PAGE);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- // r = findTableRow(table, instance_name, 0);
+
r = traversePortlets(instance_name, 0);
selenium.click(MessageFormat.format(LNK_SEC_BUTTON, r));
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -187,6 +432,7 @@
selenium.click("//input[contains(@name,'common-edit-security-form:cars_0')
and @value='admin']");
selenium.click("//input[contains(@name,'common-edit-security-form:cars_2')
and @value='admin']");
selenium.click("//input[contains(@name,'common-edit-security-form:cars_1')]");
+
selenium.click(SUBMIT_SECURITY_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -195,11 +441,14 @@
Assert.assertFalse(selenium.isTextPresent("Greetings !"));
}
+ /**
+ * Tests deleting of an instance. The instance WeatherPortletInstance is canceled at 1st
attempt and deleted at 2nd from the list of instances. It is asserted
+ * that instance is no longer in instances list (with a use of paginator).
+ */
@Test(enabled = true)
public void testDeleteInstance() {
// cancel first
- String instance_name = "WeatherPortletInstance";
- // selenium.setSpeed("5000");
+ String instance_name = "WeatherPortletInstance";
int r = traversePortlets(instance_name, 1);
Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(LNK_INSTANCE_BUTTON,
r)), instance_name + " portlet not found.");
@@ -225,7 +474,10 @@
Assert.assertFalse(selenium.isElementPresent(MessageFormat.format(LNK_INSTANCE_BUTTON,
r)), "previously deleted " + instance_name + " portlet found.");
}
-
+
+ /**
+ * Tests paginator of user instances. Every link on paginator is clicked and it is
asserted, that the number of portlet instances on the screen is positive.
+ */
@Test(enabled = true)
public void testPaginator() {
@@ -238,12 +490,18 @@
selenium.click("link=" + page);
selenium.waitForPageToLoad(PAGE_LOAD);
r = countTableRows(TAB_PORTLET_INSTANCES);
-
- Assert.assertTrue(r>0,"on instances on paginator page");
+
+ Assert.assertTrue(r > 0, "no instances on paginator page");
}
}
+ /**
+ * Tests preferences of portlet instances. CurrentUsersPortletInstance is used for this
test. It's property guestNumber is changed several times and it is asserted, that
+ * the change value is remembered.
+ */
+ //TODO refactor - using locators in code
+ //TODO change more values
@Test(enabled = true)
public void testPreferences() {
@@ -284,10 +542,17 @@
Assert.assertEquals(selenium.getText(TABLE_PREF_KEY + "/tbody/tr[" + r +
"]/td[4]"), "[viliam]");
selenium.click(SUBMIT_PREF_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
}
- // acquiring link names from paginator
+ /**
+ * Gets pages. acquiring link names from paginator
+ *
+ * @param paginator_location
+ * the paginator_location
+ *
+ * @return the pages
+ */
private String[] getPages(String paginator_location) {
String pagi = selenium.getText(paginator_location);
@@ -296,10 +561,17 @@
return pages;
}
- /*
- * function for traversing the portles in the portles table. when a string
- * in selected columns is not found, links form paginator are used to look
- * to the next page
+ /**
+ * Traverses portlets. function for traversing the portles in the portles
+ * table. when a string in selected columns is not found, links form
+ * paginator are used to look to the next page
+ *
+ * @param instance_name
+ * the instance_name
+ * @param row
+ * the row
+ *
+ * @return the int
*/
private int traversePortlets(String instance_name, int row) {