JBoss Portal SVN: r13477 - branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso.
by portal-commits@lists.jboss.org
Author: mposolda(a)redhat.com
Date: 2009-06-22 09:36:15 -0400 (Mon, 22 Jun 2009)
New Revision: 13477
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java
Removed:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/UserRolesHelperTestCase.java
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java
Log:
sso tests refactored.
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java 2009-06-22 13:24:53 UTC (rev 13476)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java 2009-06-22 13:36:15 UTC (rev 13477)
@@ -10,7 +10,7 @@
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
@Test(groups = { "sso_tests" }, enabled = true, description = "CAS selenium test case.")
-public class CASSeleniumTestCase extends UserRolesHelperTestCase {
+public class CASSeleniumTestCase extends SSOSeleniumTestCase {
/** prefix for locator properties */
public String casePfx = "sso.cas.";
@@ -128,7 +128,7 @@
public void loginAsAdminAndCreateNewRoleAndUser() {
loginToPortalAsAdmin();
createRole(PORTAL_CYRIL_ROLE, PORTAL_CYRIL_ROLE);
- createUser(PORTAL_CYRIL_USERNAME, PORTAL_CYRIL_PASSWORD, PORTAL_CYRIL_MAIL);
+ createUser(PORTAL_CYRIL_USERNAME, PORTAL_CYRIL_PASSWORD, PORTAL_CYRIL_MAIL, PORTAL_CYRIL_ROLE);
Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME));
logoutIfPossible();
Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL));
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java 2009-06-22 13:24:53 UTC (rev 13476)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java 2009-06-22 13:36:15 UTC (rev 13477)
@@ -1,8 +1,9 @@
package org.jboss.portal.test.selenium.sso;
-import java.text.MessageFormat;
+import static org.testng.Assert.assertEquals;
+import static org.testng.Assert.assertTrue;
-import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+import org.jboss.portal.test.selenium.cms.CMSFileTestCase;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -13,7 +14,7 @@
* @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
*/
@Test(groups = { "sso_tests" }, enabled = true, description = "JOSSO selenium test case.")
-public class JOSSOSeleniumTestCase extends UserRolesHelperTestCase {
+public class JOSSOSeleniumTestCase extends SSOSeleniumTestCase {
/** prefix for locator properties */
public String casePfx = "sso.josso.";
@@ -30,6 +31,7 @@
private final String ADR_PORTAL = getLoc(casePfx+"adr.portal","/portal");
private final String ADR_PORTAL_ADMIN = getLoc(casePfx+"adr.portal.admin","/portal/auth/portal/admin");
private final String ADR_PORTAL_DEFAULT = getLoc(casePfx+"adr.portal.default","/portal/auth/portal/default");
+ private final String ADR_PORTAL_SESSION_TEST = getLoc(casePfx+"adr.portal.test.session","/portal/auth/portal/default/Test/Session+test");
private final String LINK_LOGIN = getLoc(casePfx+"lnk.login", "link=Login");
private final String LINK_ADMIN = getLoc(casePfx+"lnk.admin", "link=Admin");
@@ -48,8 +50,18 @@
private final String JOSSO_INVALID_AUTH = getMess(casePfx + "josso.invalid.auth", "Invalid Authentication Information");
private final String PORTAL_LOGGED_IN_AS_MESSAGE = getMess(casePfx + "logged.in.mess", "Logged in as: ");
- private final String PORTAL_FORBIDDEN_MESS = getMess(casePfx + "forbidden.mess", "HTTP Status 403 -");
+ private final String PORTAL_FORBIDDEN_MESS = getMess(casePfx + "forbidden.mess", "HTTP Status 403 -");
+ private final String PORTAL_SESSION_TEST_NO_SESSION = getMess("samples.ses.no", "No session");
+ private final String PORTAL_SESSION_TEST_ID = getMess("samples.ses.id", "Session id");
+ public final String TBL_CMS_FILE = getLoc("cms.file.tbl.cms.file", "//div[@id='center']/div/div/div[3]/table");
+
+ private final long SESSION_TIMEOUT = 60000;
+ private final long SESSION_TIMEOUT_WAITING = SESSION_TIMEOUT + 30000; // It's session timeout and some additional time to wait for session timeout
+ private final String SES_SUB_PSCOPE = getLoc("samples.ses.sub.pscope", "portlet");
+ private final String SES_INP_VAL = getLoc("samples.ses.inp.val", "value");
+ private final String SES_INP_NAM = getLoc("samples.ses.inp.nam", "name");
+
@BeforeMethod(groups = { "log" })
private void logoutBeforeTest() {
logoutIfPossible();
@@ -130,7 +142,7 @@
public void loginAsAdminAndCreateNewRoleAndUser() {
loginToPortalAsAdmin();
createRole(PORTAL_JOSEPH_ROLE, PORTAL_JOSEPH_ROLE);
- createUser(PORTAL_JOSEPH_USERNAME, PORTAL_JOSEPH_PASSWORD, PORTAL_JOSEPH_MAIL);
+ createUser(PORTAL_JOSEPH_USERNAME, PORTAL_JOSEPH_PASSWORD, PORTAL_JOSEPH_MAIL, PORTAL_JOSEPH_ROLE);
Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME));
logout();
Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE));
@@ -171,6 +183,102 @@
}
/**
+ * This test loggs admin and then wait for 90 seconds. The session invalidates because portal is configured to Session timeout
+ * for only one minute.
+ * The user should be directly logged in even if session invalidates, because of JOSSO cookie (JOSSO_SESSIONID).
+ */
+ @Test(enabled = true)
+ public void loginAfterSessionTimeout() {
+ loginToPortalAsAdmin();
+ // Go to session test and put some attribute to portlet scope
+ openAndWait(ADR_PORTAL_SESSION_TEST);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_SESSION_TEST_NO_SESSION));
+ selenium.type(SES_INP_NAM, "scope1");
+ selenium.type(SES_INP_VAL, "scopeval1");
+ selenium.click(SES_SUB_PSCOPE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_SESSION_TEST_ID));
+
+ // waiting 90 seconds until session timeout occurs
+ waitFor(SESSION_TIMEOUT_WAITING);
+ // Session is invalidated but user is automatically logged in without need of coming to JOSSO console
+ openAndWait(ADR_PORTAL_SESSION_TEST);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_SESSION_TEST_NO_SESSION));
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME));
+ }
+
+ /**
+ * Simple file creation. File named "newFile" is created in the root directory of CMS module with main action selector.
+ * This test is used for testing CMS file creation while portal is configured for integration with JOSSO
+ *
+ */
+ @Test(enabled = true, description = "Simple file creation.")
+ public void testCreateFile() {
+ loginToPortalAsAdmin();
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select("//div[@id='center']/div/div/div[1]/div/select", "label=Create File");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+ selenium.type("filename", "newFile");
+ selenium.type("description", "newFile description");
+ selenium.type("title", "newFile title");
+ //elenium.select("language", "label=Czech");
+ selenium.click("save");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertEquals("newFile", selenium.getText("link=newFile"));
+ }
+
+ /**
+ * File creation and copying to default directory. File named "file2copy" is created in the root directory. Then the file is copied into the default directory.
+ * It's tested that creation and copying of file is good with JOSSO integration.
+ */
+ @Test(enabled = true, description = "File creation and copying to default directory.")
+ public void testCopyFile() {
+ loginToPortalAsAdmin();
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select("//div[@id='center']/div/div/div[1]/div/select", "label=Create File");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+ selenium.type("filename", "file2copy");
+ selenium.type("description", "file2copy description");
+ selenium.type("title", "file2copy title");
+ selenium.click("save");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertEquals("text/plain", selenium.getText("link=text/plain"));
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertEquals("file2copy", selenium.getText("link=file2copy"));
+
+ int row = findTableRow(TBL_CMS_FILE, "file2copy", 0) + 1;
+
+ selenium.select("//div[@id='center']/div/div/div[3]/table/tbody/tr[" + row + "]/td[2]/form/select", "label=Copy");
+ selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[" + row + "]/td[2]/form/select/option[3]");
+ selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[" + row + "]/td[2]/form/input");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=default");
+ selenium.click("submit");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=default");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isElementPresent("link=file2copy"));
+
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isElementPresent("link=file2copy"));
+ }
+
+ /**
* Loggs into portal as admin with usage of JOSSO.
*/
private void loginToPortalAsAdmin() {
Added: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java 2009-06-22 13:36:15 UTC (rev 13477)
@@ -0,0 +1,182 @@
+package org.jboss.portal.test.selenium.sso;
+
+import java.text.MessageFormat;
+
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+import org.testng.Assert;
+
+class SSOSeleniumTestCase extends JBossPortalSeleniumTestCase {
+
+ /** prefix for locator properties */
+ public String casePfx = "iden.man.";
+
+ private final String TBL_ROLELIST = getLoc(casePfx + "tbl.rolelist", "//table[contains(@id,'roles-form:userlist')]");
+
+ private final String LNK_T_ROLLIST_DEL = getLoc(casePfx + "lnk.t.rollist.del", "//a[contains(@id,''roles-form:userlist:{0}:delete-role-link'')]");
+
+ private final String SUB_CONF_CREATE_USER = getLoc(casePfx + "sub.conf.create.user", "//input[contains(@id,'confirm-form:admin')]");
+ private final String SUB_DELETE_ROLE = getLoc(casePfx + "sub.delete.role", "//input[contains(@id,'delete-role-form:confirm')]");
+ private final String SUB_ROLE_CREATE = getLoc(casePfx + "sub.role.create", "//input[contains(@id,'create-role-form:submit')]");
+ private final String INP_ROLEDISNAME = getLoc(casePfx + "inp.roledisname", "//input[contains(@id,'create-role-form:roledisplayname')]");
+ private final String INP_ROLENAME = getLoc(casePfx + "inp.rolename", "//input[contains(@id,'create-role-form:rolename')]");
+ private final String TBL_USERLIST = getLoc(casePfx + "tbl.userlist", "//table[contains(@id,'search-user-form1:userlist')]");
+ private final String LNK_ROLE_CREATE = getLoc(casePfx + "lnk.role.create", "//a[contains(@id, 'create-role-form:create-role-link')]");
+ private final String SUB_DEL_USER = getLoc(casePfx + "sub.del.user", "//input[contains(@id,'delete-user-form:submit')]");
+
+ private final String SUB_USER_ROLE = getLoc(casePfx + "sub.user.role", "//input[contains(@id,'register-role-form:submit')]");
+ private final String SUB_CREATE_USER = getLoc(casePfx + "sub.create.user", "//input[contains(@id,'register-form:submit')]");
+ private final String INP_PASSWORD_CHK = getLoc(casePfx + "inp.password.chk", "//input[contains(@id,'register-form:passwordCheck')]");
+ private final String INP_PASSWORD = getLoc(casePfx + "inp.password", "//input[contains(@id,'register-form:password')]");
+ private final String INP_USEREMAIL = getLoc(casePfx + "inp.useremail", "//input[contains(@id,'register-form:email')]");
+ private final String INP_USERNAME = getLoc(casePfx + "inp.username", "//input[contains(@id,'register-form:username')]");
+ private final String SUB_SEARCH_USER = getLoc(casePfx + "sub.search.user", "//input[contains(@id,'search-user-form:search') and @type='submit']");
+ private final String INP_SEARCH_USER = getLoc(casePfx + "inp.search.user", "//input[contains(@id,'search-user-form:searchString')]");
+ private final String LNK_SEARCH_USER = getLoc(casePfx + "lnk.search.user", "//a[contains(@id,'user-form:search-user-link')]");
+ private final String LNK_USERTAB = getLoc(casePfx + "lnk.usertab", "//a[contains(@id,'role-temp-form:manage-users')]");
+ private final String LNK_USERMAIN = getLoc(casePfx + "lnk.usermain", "//a[contains(@id,'user-temp-form1:user-adm-link')]");
+ private final String LNK_T_USRLIST_DEL = getLoc(casePfx + "lnk.t.usrlist.del", "//a[contains(@id,''search-user-form1:userlist:{0}:delete-user-link'')]");
+ private final String LNK_ROLETAB = getLoc(casePfx + "lnk.roletab", "//a[contains(@id,'user-temp-form:role-mgm-link')]");
+
+ private final String LNK_ROLEMAIN = getLoc(casePfx + "lnk.rolemain", "//a[contains(@id, 'role-temp-form1:role-admin-link')]");
+ private final String LNK_USERMANG_MAIN = getLoc(casePfx + "lnk.usermang.main", "//a[contains(@id,'user-temp-form1:assign-role-link')]");
+ private final String LNK_USERMANG_MAIN2 = getLoc(casePfx + "lnk.usermang.main2", "//a[contains(@id,'user-temp-form1:user-mgm-link')]");
+ private final String LNK_CREATE_USER = getLoc(casePfx + "lnk.create.user", "//a[contains(@id,':user-form:create-user-link')]");
+
+ //private final String CHK_ROLE = getLoc(casePfx + "chk.role", "//input[contains(@name,''assign-roles-form:roles'') and @value=''{0}'']");
+ private final String CHK_REGISTER_ROLE = getLoc(casePfx + "chk.reg.role", "//input[contains(@name,''register-role-form:roles'') and @value=''{0}'']");
+
+ private final long SEARCH_TIMEOUT = 10000;
+
+ protected void createRole(String roleName, String roleDisplayName) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Members");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
+
+ Assert.assertTrue(selenium.isElementPresent(LNK_ROLE_CREATE), "Button for role creating has wrong id or doesn't exist.");
+ //Assert.assertEquals(selenium.getText(LNK_ROLE_CREATE), "Create role", "Button for role creating has wrong label.");
+ selenium.click(LNK_ROLE_CREATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent("Role"), "Label for role name not present or incorrect.");
+ selenium.type(INP_ROLENAME, roleName);
+ Assert.assertTrue(selenium.isTextPresent("Display name"), "Label for display role name not present or incorrect.");
+ selenium.type(INP_ROLEDISNAME, roleDisplayName);
+ selenium.click(SUB_ROLE_CREATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(roleName), "Name of newly created role is missing.");
+ Assert.assertTrue(selenium.isTextPresent(roleDisplayName), "Display name of newly created role is missing.");
+ }
+
+ protected void deleteRole(String roleName) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Members");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
+
+ Assert.assertTrue(selenium.isTextPresent(roleName), "Role name is missing");
+
+ int r = findTableRow(TBL_ROLELIST, roleName, 0);
+ selenium.click(MessageFormat.format(LNK_T_ROLLIST_DEL, r - 1));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("Warning! You are about to delete the role '" + roleName + "'"),
+ "Confirmation text for role deletion missing missing.");
+ selenium.click(SUB_DELETE_ROLE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ }
+
+ protected void createUser(String userName, String userPass, String userMail, String roleToRegister) {
+ selenium.open("/portal/auth/portal/default");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Members");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(LNK_USERTAB);
+ clickIfVisible(LNK_USERMAIN);
+ selenium.click(LNK_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent("Username *"), "Label for username input is wrong or missing.");
+ selenium.type(INP_USERNAME, userName);
+ Assert.assertTrue(selenium.isTextPresent("E-Mail *"), "Label for e-mail input is wrong or missing.");
+ selenium.type(INP_USEREMAIL, userMail);
+ Assert.assertTrue(selenium.isTextPresent("Password *"), "Label for password input is wrong or missing.");
+ selenium.type(INP_PASSWORD, userPass);
+ Assert.assertTrue(selenium.isTextPresent("Confirm Password *"), "Label for password confirm input is wrong or missing.");
+ selenium.type(INP_PASSWORD_CHK, userPass);
+
+ selenium.click(SUB_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertFalse(selenium.isTextPresent("This username is already taken. tempUser"), "User already exists.");
+ Assert.assertTrue(selenium.isTextPresent(roleToRegister), "Role " + roleToRegister + " is not present.");
+ // register Cyril (or Joseph) role
+ String checkRole = MessageFormat.format(CHK_REGISTER_ROLE , roleToRegister);
+ selenium.click(checkRole);
+ // deregister User role
+ checkRole = MessageFormat.format(CHK_REGISTER_ROLE , "User");
+ selenium.click(checkRole);
+ clickAndWait(SUB_USER_ROLE);
+
+ Assert.assertTrue(selenium.isTextPresent("Confirmation"), "Confirmation screen is missing or corrupted.");
+ selenium.click(SUB_CONF_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("User created"), "User was not created (\"User created\" text missing).");
+
+ }
+
+ protected void deleteUser(String username, String email) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Members");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(LNK_USERTAB);
+ // user home page
+ clickIfVisible(LNK_USERMAIN);
+ clickIfVisible(LNK_USERMANG_MAIN);
+ clickIfVisible(LNK_USERMANG_MAIN2);
+
+ selenium.click(LNK_SEARCH_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INP_SEARCH_USER, username);
+ selenium.click(SUB_SEARCH_USER);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(SEARCH_TIMEOUT);
+ Assert.assertTrue(selenium.isTextPresent(username), "Username was not found.");
+ Assert.assertTrue(selenium.isTextPresent(email), "User e-mail adress was not found.");
+
+ selenium.click(butDelUsr_id(username));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_DEL_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("User deleted"), "user was not deleted (\"User deleted\" text missing).");
+ }
+
+ private String butDelUsr_id(String userName) {
+ String table = TBL_USERLIST;
+ int r = findTableRow(table, userName, 0);
+ return MessageFormat.format(LNK_T_USRLIST_DEL, r - 1);
+ }
+}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java 2009-06-22 13:24:53 UTC (rev 13476)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java 2009-06-22 13:36:15 UTC (rev 13477)
@@ -110,7 +110,7 @@
// Going to example app. User is still logged in even if not logged in the portal.
openAndWait(ADR_JMX_CONSOLE);
Assert.assertTrue(selenium.isElementPresent(JMX_IMAGE));
- Assert.assertEquals(JMX_AGENT_VIEW, selenium.getText(JMX_TITLE_ELEMENT));
+ Assert.assertTrue(selenium.getText(JMX_TITLE_ELEMENT).contains(JMX_AGENT_VIEW));
}
}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java 2009-06-22 13:24:53 UTC (rev 13476)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java 2009-06-22 13:36:15 UTC (rev 13477)
@@ -57,7 +57,7 @@
// TODO: this probably doesn't work in IE. So disable test while working with IE.
openAndWait("http://" + user + ":" + password + "@localhost:8080" + ADR_JMX_CONSOLE);
Assert.assertTrue(selenium.isElementPresent(JMX_IMAGE));
- Assert.assertEquals(JMX_AGENT_VIEW, selenium.getText(JMX_TITLE_ELEMENT));
+ Assert.assertTrue(selenium.getText(JMX_TITLE_ELEMENT).contains(JMX_AGENT_VIEW));
}
/**
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java 2009-06-22 13:24:53 UTC (rev 13476)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java 2009-06-22 13:36:15 UTC (rev 13477)
@@ -33,15 +33,14 @@
login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
openAndWait("http://localhost:8080" + ADR_JMX_CONSOLE);
- Assert.assertTrue(selenium.isElementPresent(JMX_IMAGE));
- Assert.assertEquals(JMX_AGENT_VIEW, selenium.getText(JMX_TITLE_ELEMENT));
+ Assert.assertTrue(selenium.isElementPresent(JMX_IMAGE));
+ Assert.assertTrue(selenium.getText(JMX_TITLE_ELEMENT).contains(JMX_AGENT_VIEW));
// logout from portal and login as user
logout();
login(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
openAndWait("http://localhost:8080" + ADR_JMX_CONSOLE);
// user is not authorized to see JMX console
- Assert.assertTrue(selenium.isTextPresent(PORTAL_FORBIDDEN_MESS));
- Assert.assertFalse(JMX_AGENT_VIEW.equals(selenium.getText(JMX_TITLE_ELEMENT)));
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_FORBIDDEN_MESS));
}
/**
Deleted: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/UserRolesHelperTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/UserRolesHelperTestCase.java 2009-06-22 13:24:53 UTC (rev 13476)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/UserRolesHelperTestCase.java 2009-06-22 13:36:15 UTC (rev 13477)
@@ -1,178 +0,0 @@
-package org.jboss.portal.test.selenium.sso;
-
-import java.text.MessageFormat;
-
-import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
-import org.testng.Assert;
-
-class UserRolesHelperTestCase extends JBossPortalSeleniumTestCase {
-
- /** prefix for locator properties */
- public String casePfx = "iden.man.";
-
- private final String TBL_ROLELIST = getLoc(casePfx + "tbl.rolelist", "//table[contains(@id,'roles-form:userlist')]");
-
- private final String LNK_T_ROLLIST_DEL = getLoc(casePfx + "lnk.t.rollist.del", "//a[contains(@id,''roles-form:userlist:{0}:delete-role-link'')]");
-
- private final String SUB_CONF_CREATE_USER = getLoc(casePfx + "sub.conf.create.user", "//input[contains(@id,'confirm-form:admin')]");
- private final String SUB_DELETE_ROLE = getLoc(casePfx + "sub.delete.role", "//input[contains(@id,'delete-role-form:confirm')]");
- private final String SUB_ROLE_CREATE = getLoc(casePfx + "sub.role.create", "//input[contains(@id,'create-role-form:submit')]");
- private final String INP_ROLEDISNAME = getLoc(casePfx + "inp.roledisname", "//input[contains(@id,'create-role-form:roledisplayname')]");
- private final String INP_ROLENAME = getLoc(casePfx + "inp.rolename", "//input[contains(@id,'create-role-form:rolename')]");
- private final String TBL_USERLIST = getLoc(casePfx + "tbl.userlist", "//table[contains(@id,'search-user-form1:userlist')]");
- private final String LNK_ROLE_CREATE = getLoc(casePfx + "lnk.role.create", "//a[contains(@id, 'create-role-form:create-role-link')]");
- private final String SUB_DEL_USER = getLoc(casePfx + "sub.del.user", "//input[contains(@id,'delete-user-form:submit')]");
-
- private final String SUB_USER_ROLE = getLoc(casePfx + "sub.user.role", "//input[contains(@id,'register-role-form:submit')]");
- private final String SUB_CREATE_USER = getLoc(casePfx + "sub.create.user", "//input[contains(@id,'register-form:submit')]");
- private final String INP_PASSWORD_CHK = getLoc(casePfx + "inp.password.chk", "//input[contains(@id,'register-form:passwordCheck')]");
- private final String INP_PASSWORD = getLoc(casePfx + "inp.password", "//input[contains(@id,'register-form:password')]");
- private final String INP_USEREMAIL = getLoc(casePfx + "inp.useremail", "//input[contains(@id,'register-form:email')]");
- private final String INP_USERNAME = getLoc(casePfx + "inp.username", "//input[contains(@id,'register-form:username')]");
- private final String SUB_SEARCH_USER = getLoc(casePfx + "sub.search.user", "//input[contains(@id,'search-user-form:search') and @type='submit']");
- private final String INP_SEARCH_USER = getLoc(casePfx + "inp.search.user", "//input[contains(@id,'search-user-form:searchString')]");
- private final String LNK_SEARCH_USER = getLoc(casePfx + "lnk.search.user", "//a[contains(@id,'user-form:search-user-link')]");
- private final String LNK_USERTAB = getLoc(casePfx + "lnk.usertab", "//a[contains(@id,'role-temp-form:manage-users')]");
- private final String LNK_USERMAIN = getLoc(casePfx + "lnk.usermain", "//a[contains(@id,'user-temp-form1:user-adm-link')]");
- private final String LNK_T_USRLIST_DEL = getLoc(casePfx + "lnk.t.usrlist.del", "//a[contains(@id,''search-user-form1:userlist:{0}:delete-user-link'')]");
- private final String LNK_ROLETAB = getLoc(casePfx + "lnk.roletab", "//a[contains(@id,'user-temp-form:role-mgm-link')]");
-
- private final String LNK_ROLEMAIN = getLoc(casePfx + "lnk.rolemain", "//a[contains(@id, 'role-temp-form1:role-admin-link')]");
- private final String LNK_USERMANG_MAIN = getLoc(casePfx + "lnk.usermang.main", "//a[contains(@id,'user-temp-form1:assign-role-link')]");
- private final String LNK_USERMANG_MAIN2 = getLoc(casePfx + "lnk.usermang.main2", "//a[contains(@id,'user-temp-form1:user-mgm-link')]");
- private final String LNK_CREATE_USER = getLoc(casePfx + "lnk.create.user", "//a[contains(@id,':user-form:create-user-link')]");
-
- private final String CHK_ROLE = getLoc(casePfx + "chk.role", "//input[contains(@name,''assign-roles-form:roles'') and @value=''{0}'']");
- private final long SEARCH_TIMEOUT = 10000;
-
- protected void createRole(String roleName, String roleDisplayName) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(LNK_ROLETAB);
- clickIfVisible(LNK_ROLEMAIN);
-
- Assert.assertTrue(selenium.isElementPresent(LNK_ROLE_CREATE), "Button for role creating has wrong id or doesn't exist.");
- Assert.assertEquals(selenium.getText(LNK_ROLE_CREATE), "Create role", "Button for role creating has wrong label.");
- selenium.click(LNK_ROLE_CREATE);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- Assert.assertTrue(selenium.isTextPresent("Role"), "Label for role name not present or incorrect.");
- selenium.type(INP_ROLENAME, roleName);
- Assert.assertTrue(selenium.isTextPresent("Display name"), "Label for display role name not present or incorrect.");
- selenium.type(INP_ROLEDISNAME, roleDisplayName);
- selenium.click(SUB_ROLE_CREATE);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- Assert.assertTrue(selenium.isTextPresent(roleName), "Name of newly created role is missing.");
- Assert.assertTrue(selenium.isTextPresent(roleDisplayName), "Display name of newly created role is missing.");
- }
-
- protected void deleteRole(String roleName) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(LNK_ROLETAB);
- clickIfVisible(LNK_ROLEMAIN);
-
- Assert.assertTrue(selenium.isTextPresent(roleName), "Role name is missing");
-
- int r = findTableRow(TBL_ROLELIST, roleName, 0);
- selenium.click(MessageFormat.format(LNK_T_ROLLIST_DEL, r - 1));
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Warning! You are about to delete the role '" + roleName + "'"),
- "Confirmation text for role deletion missing missing.");
- selenium.click(SUB_DELETE_ROLE);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- }
-
- protected void createUser(String userName, String userPass, String userMail) {
- selenium.open("/portal/auth/portal/default");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link=Members");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(LNK_USERTAB);
- clickIfVisible(LNK_USERMAIN);
- selenium.click(LNK_CREATE_USER);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- Assert.assertTrue(selenium.isTextPresent("Username *"), "Label for username input is wrong or missing.");
- selenium.type(INP_USERNAME, userName);
- Assert.assertTrue(selenium.isTextPresent("E-Mail *"), "Label for e-mail input is wrong or missing.");
- selenium.type(INP_USEREMAIL, userMail);
- Assert.assertTrue(selenium.isTextPresent("Password *"), "Label for password input is wrong or missing.");
- selenium.type(INP_PASSWORD, userPass);
- Assert.assertTrue(selenium.isTextPresent("Confirm Password *"), "Label for password confirm input is wrong or missing.");
- selenium.type(INP_PASSWORD_CHK, userPass);
-
- selenium.click(SUB_CREATE_USER);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- Assert.assertFalse(selenium.isTextPresent("This username is already taken. tempUser"), "User already exists.");
-
- // TODO: refactor this
- // Assert.assertTrue(selenium.isTextPresent("Joseph"), "Role Joseph is not present.");
- selenium.click("_jbpnsIdentityAdminPortletWindowsnpbj:j_id28:register-role-form:roles:2");
- selenium.click("_jbpnsIdentityAdminPortletWindowsnpbj:j_id28:register-role-form:roles:1");
- clickAndWait(SUB_USER_ROLE);
-
- Assert.assertTrue(selenium.isTextPresent("Confirmation"), "Confirmation screen is missing or corrupted.");
- selenium.click(SUB_CONF_CREATE_USER);
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("User created"), "User was not created (\"User created\" text missing).");
-
- }
-
- protected void deleteUser(String username, String email) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(LNK_USERTAB);
- // user home page
- clickIfVisible(LNK_USERMAIN);
- clickIfVisible(LNK_USERMANG_MAIN);
- clickIfVisible(LNK_USERMANG_MAIN2);
-
- selenium.click(LNK_SEARCH_USER);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.type(INP_SEARCH_USER, username);
- selenium.click(SUB_SEARCH_USER);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- waitFor(SEARCH_TIMEOUT);
- Assert.assertTrue(selenium.isTextPresent(username), "Username was not found.");
- Assert.assertTrue(selenium.isTextPresent(email), "User e-mail adress was not found.");
-
- selenium.click(butDelUsr_id(username));
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(SUB_DEL_USER);
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("User deleted"), "user was not deleted (\"User deleted\" text missing).");
- }
-
- private String butDelUsr_id(String userName) {
- String table = TBL_USERLIST;
- int r = findTableRow(table, userName, 0);
- return MessageFormat.format(LNK_T_USRLIST_DEL, r - 1);
- }
-}
14 years, 11 months
JBoss Portal SVN: r13476 - branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium.
by portal-commits@lists.jboss.org
Author: mposolda(a)redhat.com
Date: 2009-06-22 09:24:53 -0400 (Mon, 22 Jun 2009)
New Revision: 13476
Added:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalBookstoreSampleTestCase.java
Log:
PortalBookstoreSampleTestCase added to the ui testsuite.
Added: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalBookstoreSampleTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalBookstoreSampleTestCase.java (rev 0)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalBookstoreSampleTestCase.java 2009-06-22 13:24:53 UTC (rev 13476)
@@ -0,0 +1,385 @@
+package org.jboss.portal.test.selenium;
+
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * The Class PortalBookstoreSamplesTestCase is used for testing Bookstore sample application with usage of selenium.
+ * BookstoreSample application is used for demonstrating coordination features like events and public render parameters.
+ * So the main focus is maked to test the communication between portlets.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ *
+ */
+@Test(groups = { "test_samples" }, enabled = true)
+public class PortalBookstoreSampleTestCase extends JBossPortalSeleniumTestCase {
+
+ /** prefix for locator properties = samples.bookstore. */
+ public static String casePfx = "samples.bookstore.";
+
+ private final String ADR_BOOKSTORE_SAMPLES = getLoc(casePfx+"adr", "/portal/portal/default/Bookstore+sample");
+ private final String PORTLET_MODE_NORMAL = getMess(casePfx+"pmode.normal", "portlet-mode-normal");
+ private final String PORTLET_MODE_MINIMIZED = getMess(casePfx+"pmode.minimized", "portlet-mode-minimized");
+
+ private final String BOOK_1000_TITLE = getMess(casePfx+"book.1000.title", "Foundation Flash Cartoon Animation");
+ private final String BOOK_1000_AUTHOR = getMess(casePfx+"book.1000.author", "Tim Jones");
+ private final String BOOK_1000_IMAGE = getMess(casePfx+"book.1000.img", "animation.jpg");
+ private final String BOOK_1001_TITLE = getMess(casePfx+"book.1001.title", "Head First Design Patterns");
+ private final String BOOK_1001_AUTHOR = getMess(casePfx+"book.1001.author", "Elisabeth Freeman");
+ private final String BOOK_1001_IMAGE = getMess(casePfx+"book.1001.img", "patterns.jpg");
+ private final String BOOK_1004_TITLE = getMess(casePfx+"book.1004.title", "Java Servlet and JSP Cookbook");
+ private final String BOOK_1004_AUTHOR = getMess(casePfx+"book.1004.author", "Bruce Perry");
+ private final String BOOK_1004_IMAGE = getMess(casePfx+"book.1004.img", "servlets.jpg");
+ private final String BOOK_1005_TITLE = getMess(casePfx+"book.1005.title", "Mommywood");
+ private final String BOOK_1005_AUTHOR = getMess(casePfx+"book.1005.author", "Tori Spelling");
+ private final String BOOK_1005_IMAGE = getMess(casePfx+"book.1005.img", "mommywood.jpg");
+ private final String BOOK_1007_TITLE = getMess(casePfx+"book.1007.title", "The Picture of Dorian Gray");
+ private final String BOOK_1007_AUTHOR = getMess(casePfx+"book.1007.author", "Oscar Wilde");
+ private final String BOOK_1007_IMAGE = getMess(casePfx+"book.1007.img", "dorian.jpg");
+
+ // BookstorePortlet
+ private final String BOOKSTORE_PORTLET_START_SHOPPING_LINK = getLoc(casePfx+"bookstore.lnk.start", "link=Start Shopping");
+ private final String BOOKSTORE_PORTLET_BOOK_DETAIL_LINK = getLoc(casePfx+"bookstore.lnk.detail", "link=Java Servlet and JSP Cookbook");
+
+ // BookCatalogPortlet
+ private final String CATALOG_PORTLET_FIRST_ICON = getLoc(casePfx+"catalog.icon", "//div[@id='regionA']/div[2]/table/tbody/tr[1]/td[2]/div[2]/span[1]/a@class");
+
+ private final String CATALOG_PORTLET_TABLE_TR_PREFFIX = getLoc(casePfx+"catalog.tr.pref", "//tr[@id='BookCatalogPortlet_");
+ private final String CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX = getLoc(casePfx+"catalog.tr.suf.detail", "']/td[1]/a/strong");
+ private final String CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX = getLoc(casePfx+"catalog.tr.suf.add", "']/td[4]/p/strong/a");
+ private final String CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX = getLoc(casePfx+"catalog.tr.suf.count", "']/td[3]");
+
+ private final String CATALOG_PORTLET_TITLE = getMess(casePfx+"catalog.title", "Book Catalog Portlet");
+ private final String CATALOG_PORTLET_CHOOSE = getMess(casePfx+"catalog.choose", "Please choose from our selections:");
+
+ // BookDetailPortlet
+ private final String DETAIL_PORTLET_IMAGE_PREFIX = getLoc(casePfx+"detail.image.pref", "//img[@alt='");
+ private final String DETAIL_PORTLET_IMAGE_SUFFIX = getLoc(casePfx+"detail.image.suf", "']");
+ private final String DETAIL_PORTLET_BOOK_TITLE = getLoc(casePfx+"detail.bktitle", "bookDetailPortlet_title");
+ private final String DETAIL_PORTLET_BOOK_AUTHOR = getLoc(casePfx+"detail.bkauthor", "bookDetailPortlet_author");
+ private final String DETAIL_PORTLET_ADD_LINK = getLoc(casePfx+"detail.lnk.add", "BookDetailPortlet_AddBookLink");
+
+ // BookShowCartPortlet
+ private final String SHOWCART_PORTLET_CLEAR_CART_LINK = getLoc(casePfx+"showcart.lnk.clear", "link=Clear Cart");
+ private final String SHOWCART_PORTLET_HEADER = getLoc(casePfx+"showcart.header", "BookShowCartPortlet_header");
+ private final String SHOWCART_PORTLET_TABLE = getLoc(casePfx+"showcart.table", "BookShowCartPortlet_cardTable");
+ private final String SHOWCART_PORTLET_TABLE_TR_PREFIX = getLoc(casePfx+"showcart.table.tr.pref", "//tr[@id='BookShowCartPortlet_cardTable_");
+ private final String SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX = getLoc(casePfx+"showcart.table.tr.count.suf", "']/td[1]");
+ private final String SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX = getLoc(casePfx+"showcart.table.tr.title.suf", "']/td[2]/strong/a");
+ private final String SHOWCART_PORTLET_TABLE_TR_REMOVE_SUFFIX = getLoc(casePfx+"showcart.table.tr.remove.suf", "']/td[4]/strong/a");
+
+ private final String SHOWCART_PORTLET_EMPTY_CARD = getMess(casePfx+"showcart.header.card.empty", "Your cart is empty.");
+ private final String SHOWCART_PORTLET_CARD_ITEMS_PREFIX = getMess(casePfx+"showcart.header.card.pref", "Your shopping cart contains ");
+ private final String SHOWCART_PORTLET_CARD_ITEMS_SUFFIX = getMess(casePfx+"showcart.header.card.pref", " items.");
+
+ // BookCashierPortlet
+ private final String CASHIER_PORTLET_AMOUNT = getLoc(casePfx+"cashier.amount", "BookCashierPortlet_amount");
+ private final String CASHIER_PORTLET_INPUT_NAME = getLoc(casePfx+"cashier.inp.name", "cardname");
+ private final String CASHIER_PORTLET_INPUT_NUMBER = getLoc(casePfx+"cashier.inp.num", "cardnum");
+ private final String CASHIER_PORTLET_SUBMIT = getLoc(casePfx+"cashier.submit", "cashierSubmit");
+
+ // BookReceiptPortlet
+ private final String RECEIPT_PORTLET_HEADER = getLoc(casePfx+"receipt.header", "BookReceiptPortlet_header");
+ private final String RECEIPT_PORTLET_SUCCESS = getMess(casePfx+"receipt.success", "Thank you for purchasing your books from us ");
+ private final String RECEIPT_PORTLET_FAILURE = getMess(casePfx+"receipt.failure", "Your order could not be completed due to insufficient inventory.");
+ private final String RECEIPT_PORTLET_FAILURE_MESSAGE = getMess(casePfx+"receipt.failure.mess", "Not enough books with title: Foundation Flash Cartoon Animation in inventory.");
+
+ /**
+ * This runs before each test.
+ */
+ @BeforeMethod(groups = { "log" })
+ protected void beforeTest() {
+ selenium.open(ADR_BOOKSTORE_SAMPLES);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ // clear shopping cart if somethink is on it
+ if (selenium.isElementPresent(SHOWCART_PORTLET_CLEAR_CART_LINK)) {
+ clickAndWait(SHOWCART_PORTLET_CLEAR_CART_LINK);
+ }
+ }
+
+ /**
+ * This runs after each test.
+ */
+ @AfterMethod(groups = { "log" })
+ protected void logoutAfterTest() {
+ }
+
+ /**
+ * Test of ShowCatalogEvent. While clicking on "Start Shopping" link in Bookstore portlet, than the event should be thrown and
+ * BookCatalogPortlet should be put from minimized state to normal state.
+ */
+ @Test(enabled = true)
+ public void testBookstorePortletShowCatalog() {
+ Assert.assertTrue(selenium.isTextPresent(CATALOG_PORTLET_TITLE));
+ // Book Catalog portlet is minimized, so the "normalize portlet" icon is presented.
+ Assert.assertEquals(selenium.getAttribute(CATALOG_PORTLET_FIRST_ICON), PORTLET_MODE_NORMAL);
+ Assert.assertFalse(selenium.isTextPresent(CATALOG_PORTLET_CHOOSE));
+
+ // Click to "Start Shopping" and verify that portlet is shown in normal state and so "minimize portlet" icon is presented.
+ Assert.assertTrue(selenium.isElementPresent(BOOKSTORE_PORTLET_START_SHOPPING_LINK));
+ clickAndWait(BOOKSTORE_PORTLET_START_SHOPPING_LINK);
+ Assert.assertEquals(selenium.getAttribute(CATALOG_PORTLET_FIRST_ICON), PORTLET_MODE_MINIMIZED);
+ Assert.assertTrue(selenium.isTextPresent(CATALOG_PORTLET_CHOOSE));
+ }
+
+ /**
+ * Test of bookDetailId_Bookstore public render parameter. While clicking on book link at Bookstore portlet,
+ * the book detail should be shown in BookDetailPortlet.
+ */
+ @Test(enabled = true)
+ public void testBookstorePortletShowBookDetail() {
+ // No detail of any book is shown
+ Assert.assertFalse(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1004_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX));
+ // Click to the detail link in Bookstore portlet
+ Assert.assertTrue(selenium.isElementPresent(BOOKSTORE_PORTLET_BOOK_DETAIL_LINK));
+ clickAndWait(BOOKSTORE_PORTLET_BOOK_DETAIL_LINK);
+ // Assert that book is shown in BookDetail portlet.
+ Assert.assertEquals(BOOK_1004_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE));
+ Assert.assertEquals(BOOK_1004_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR));
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1004_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX));
+ }
+
+ /**
+ * Test of bookDetailId_BookCatalog public render parameter. While clicking on book detail link in BookCatalogPortlet
+ * the book detail should be shown in BookDetailPortlet.
+ */
+ @Test(enabled = true, dependsOnMethods={ "testBookstorePortletShowCatalog" })
+ public void testBookCatalogPortletShowBookDetail() {
+ // assert that book with id 1000 is shown in BookDetailPortlet while click to it in BookCatalogPortlet
+ Assert.assertTrue(selenium.isElementPresent(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX));
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX);
+ Assert.assertEquals(BOOK_1000_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE));
+ Assert.assertEquals(BOOK_1000_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR));
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1000_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX));
+ // assert that book with id 1001 is shown in BookDetailPortlet while click to it in BookCatalogPortlet
+ Assert.assertEquals(BOOK_1001_TITLE, selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX));
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX);
+ Assert.assertEquals(BOOK_1001_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE));
+ Assert.assertEquals(BOOK_1001_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR));
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1001_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX));
+ // assert that book with id 1007 is shown in BookDetailPortlet while click to it in BookCatalogPortlet
+ Assert.assertEquals(BOOK_1007_TITLE, selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1007" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX));
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1007" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX);
+ Assert.assertEquals(BOOK_1007_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE));
+ Assert.assertEquals(BOOK_1007_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR));
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1007_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX));
+ }
+
+ /**
+ * Test of AddBookEvent_Explicit sent from BookCatalogPortlet. While clicking on "Add to cart" link in BookCatalogPortlet
+ * the book should be added to BookShowCartPortlet.
+ */
+ @Test(enabled = true, dependsOnMethods={ "testBookstorePortletShowCatalog" })
+ public void testBookCatalogPortletAddBook() {
+ // Card is empty in BookShowCartPortlet
+ Assert.assertEquals(SHOWCART_PORTLET_EMPTY_CARD, selenium.getText(SHOWCART_PORTLET_HEADER));
+ Assert.assertFalse(selenium.isElementPresent(SHOWCART_PORTLET_TABLE));
+ // Book is added in BookCatalogPortlet and it should be shown in BookShowCartPortlet
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ Assert.assertEquals(SHOWCART_PORTLET_CARD_ITEMS_PREFIX + "1 item.", selenium.getText(SHOWCART_PORTLET_HEADER));
+ Assert.assertEquals("1", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1001" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals(BOOK_1001_TITLE, selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1001" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX));
+ Assert.assertEquals(4, countTableRows((SHOWCART_PORTLET_TABLE)));
+ // Add more books
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1005" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1007" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ // Test that books are added
+ Assert.assertEquals(7, countTableRows(SHOWCART_PORTLET_TABLE));
+ Assert.assertEquals(SHOWCART_PORTLET_CARD_ITEMS_PREFIX + "8" + SHOWCART_PORTLET_CARD_ITEMS_SUFFIX, selenium.getText(SHOWCART_PORTLET_HEADER));
+ Assert.assertEquals("2", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1000" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals("4", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1001" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals("1", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1005" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals("1", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1007" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals(BOOK_1000_TITLE, selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1000" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX));
+ Assert.assertEquals(BOOK_1005_TITLE, selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1005" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX));
+ Assert.assertEquals(BOOK_1007_TITLE, selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1007" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX));
+ }
+
+ /**
+ * Test of AddBookEvent_Explicit sent from BookDetailPortlet. While clicking on "Add to cart" link in BookDetailPortlet
+ * the book should be added to BookShowCartPortlet.
+ */
+ @Test(enabled = true, dependsOnMethods={ "testBookstorePortletShowCatalog" })
+ public void testBookDetailPortletAddBook() {
+ // Show book 1000 to BookDetailPortlet - add it two times
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX);
+ clickAndWait(DETAIL_PORTLET_ADD_LINK);
+ clickAndWait(DETAIL_PORTLET_ADD_LINK);
+ // Show book 1001 to BookDetailPortlet - add it two times
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX);
+ clickAndWait(DETAIL_PORTLET_ADD_LINK);
+ clickAndWait(DETAIL_PORTLET_ADD_LINK);
+ // Book 1004 from first portlet - one timme
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1004" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX);
+ clickAndWait(DETAIL_PORTLET_ADD_LINK);
+ // 1001 another time
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX);
+ clickAndWait(DETAIL_PORTLET_ADD_LINK);
+ // Test that books are added
+ Assert.assertEquals(6, countTableRows((SHOWCART_PORTLET_TABLE)));
+ Assert.assertEquals(SHOWCART_PORTLET_CARD_ITEMS_PREFIX + "6" + SHOWCART_PORTLET_CARD_ITEMS_SUFFIX, selenium.getText(SHOWCART_PORTLET_HEADER));
+ Assert.assertEquals("2", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1000" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals("3", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1001" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals("1", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1004" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ }
+
+ /**
+ * Test of bookDetailId_ShowCart public render parameter, which is sent from BookShowCartPortlet. While clicking to some book link in BookShowCartPortlet, the book should be shown
+ * in BookDetailPortlet
+ */
+ @Test(enabled = true, dependsOnMethods={ "testBookstorePortletShowCatalog" })
+ public void testBookShowCartPortletBookDetail() {
+ // Add some books from catalog to shopping cart
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1005" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+
+ // Click to detail links in BookShowCartPortlet and test that books are shown in BookDetailPortlet
+ clickAndWait(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1000" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX);
+ Assert.assertEquals(BOOK_1000_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE));
+ Assert.assertEquals(BOOK_1000_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR));
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1000_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX));
+
+ clickAndWait(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1001" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX);
+ Assert.assertEquals(BOOK_1001_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE));
+ Assert.assertEquals(BOOK_1001_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR));
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1001_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX));
+
+ clickAndWait(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1005" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX);
+ Assert.assertEquals(BOOK_1005_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE));
+ Assert.assertEquals(BOOK_1005_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR));
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1005_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX));
+ }
+
+ /**
+ * Test that totalAmount public render parameter is correctly sent and amount is correctly shown in BookCashierPortlet.
+ */
+ @Test(enabled = true, dependsOnMethods={ "testBookstorePortletShowCatalog" })
+ public void testBookShowCartPortletTotalAmount() {
+ // Add some books from catalog to shopping cart
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1005" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ // verify 1
+ Assert.assertTrue(valueEqualsCurrency(selenium.getText(CASHIER_PORTLET_AMOUNT), 149.93));
+
+ // Add books from details portlet
+ clickAndWait(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1000" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX);
+ clickAndWait(DETAIL_PORTLET_ADD_LINK);
+ clickAndWait(DETAIL_PORTLET_ADD_LINK);
+ // verify 2
+ Assert.assertTrue(valueEqualsCurrency(selenium.getText(CASHIER_PORTLET_AMOUNT), 229.91));
+
+ // Remove some books
+ clickAndWait(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1005" + SHOWCART_PORTLET_TABLE_TR_REMOVE_SUFFIX);
+ clickAndWait(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1000" + SHOWCART_PORTLET_TABLE_TR_REMOVE_SUFFIX);
+ clickAndWait(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1000" + SHOWCART_PORTLET_TABLE_TR_REMOVE_SUFFIX);
+ // verify 3
+ Assert.assertTrue(valueEqualsCurrency(selenium.getText(CASHIER_PORTLET_AMOUNT), 124.93));
+
+ // Clear card
+ clickAndWait(SHOWCART_PORTLET_CLEAR_CART_LINK);
+ // verify 4
+ Assert.assertTrue(valueEqualsCurrency(selenium.getText(CASHIER_PORTLET_AMOUNT), 0.00));
+ }
+
+ /**
+ * Test the SendReceiptEvent event and cardName public render parameters. The oreder of all books is submit in Cashier portlet and the successfull message
+ * is shown in BookReceiptPortlet.
+ */
+ @Test(enabled = true, dependsOnMethods={ "testBookstorePortletShowCatalog" })
+ public void testBookCashierPortletSubmitSuccessfull() {
+ // Add some books from catalog to shopping cart
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1004" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1004" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ Assert.assertEquals(SHOWCART_PORTLET_CARD_ITEMS_PREFIX + "5" + SHOWCART_PORTLET_CARD_ITEMS_SUFFIX, selenium.getText(SHOWCART_PORTLET_HEADER));
+ Assert.assertTrue(valueEqualsCurrency(selenium.getText(CASHIER_PORTLET_AMOUNT), 214.83));
+ Assert.assertEquals("3", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals("4", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals("9", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1004" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ // Fill the name and number in BookCashierPortlet and submit
+ selenium.type(CASHIER_PORTLET_INPUT_NAME, "Joseph Carry");
+ selenium.type(CASHIER_PORTLET_INPUT_NUMBER, "1111 2222 3333");
+ clickAndWait(CASHIER_PORTLET_SUBMIT);
+ // check BookShowCartPortlet and BookReceivePortlet
+ Assert.assertEquals(SHOWCART_PORTLET_EMPTY_CARD, selenium.getText(SHOWCART_PORTLET_HEADER));
+ Assert.assertEquals(RECEIPT_PORTLET_SUCCESS + "Joseph Carry.", selenium.getText(RECEIPT_PORTLET_HEADER));
+ Assert.assertEquals("1", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals("3", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals("7", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1004" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ // Test second successfull shopping
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ Assert.assertEquals(SHOWCART_PORTLET_CARD_ITEMS_PREFIX + "2" + SHOWCART_PORTLET_CARD_ITEMS_SUFFIX, selenium.getText(SHOWCART_PORTLET_HEADER));
+ selenium.type(CASHIER_PORTLET_INPUT_NAME, "Martin Carry");
+ selenium.type(CASHIER_PORTLET_INPUT_NUMBER, "1111 2222 3333");
+ clickAndWait(CASHIER_PORTLET_SUBMIT);
+ Assert.assertEquals(SHOWCART_PORTLET_EMPTY_CARD, selenium.getText(SHOWCART_PORTLET_HEADER));
+ Assert.assertEquals(RECEIPT_PORTLET_SUCCESS + "Martin Carry.", selenium.getText(RECEIPT_PORTLET_HEADER));
+ Assert.assertEquals("0", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals("2", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ }
+
+ /**
+ * Test the SendReceiptEvent event and exceptionMessage public render parameters. The oreder of all books is submit in Cashier portlet but the error message
+ * is shown in BookReceivePortlet.
+ */
+ @Test(enabled = true, dependsOnMethods={ "testBookCashierPortletSubmitSuccessfull" })
+ public void testBookCashierPortletSubmitFailure() {
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_ADD_SUFFIX);
+ Assert.assertEquals(SHOWCART_PORTLET_CARD_ITEMS_PREFIX + "2" + SHOWCART_PORTLET_CARD_ITEMS_SUFFIX, selenium.getText(SHOWCART_PORTLET_HEADER));
+ selenium.type(CASHIER_PORTLET_INPUT_NAME, "Martin Carry");
+ selenium.type(CASHIER_PORTLET_INPUT_NUMBER, "1111 2222 3333");
+ clickAndWait(CASHIER_PORTLET_SUBMIT);
+ // Check that order exception occured and order was not performed
+ Assert.assertEquals(RECEIPT_PORTLET_FAILURE, selenium.getText(RECEIPT_PORTLET_HEADER));
+ Assert.assertTrue(selenium.isTextPresent(RECEIPT_PORTLET_FAILURE_MESSAGE));
+ Assert.assertEquals(SHOWCART_PORTLET_CARD_ITEMS_PREFIX + "2" + SHOWCART_PORTLET_CARD_ITEMS_SUFFIX, selenium.getText(SHOWCART_PORTLET_HEADER));
+ // Remove the item and it should be fine after it
+ clickAndWait(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1000" + SHOWCART_PORTLET_TABLE_TR_REMOVE_SUFFIX);
+ Assert.assertEquals(SHOWCART_PORTLET_CARD_ITEMS_PREFIX + "1 item.", selenium.getText(SHOWCART_PORTLET_HEADER));
+ clickAndWait(CASHIER_PORTLET_SUBMIT);
+ // verify success
+ Assert.assertEquals(SHOWCART_PORTLET_EMPTY_CARD, selenium.getText(SHOWCART_PORTLET_HEADER));
+ Assert.assertEquals(RECEIPT_PORTLET_SUCCESS + "Martin Carry.", selenium.getText(RECEIPT_PORTLET_HEADER));
+ Assert.assertEquals("0", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ Assert.assertEquals("1", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX));
+ }
+
+ /**
+ * Test if given currency String equals to given value. For example:
+ * Params: ("$39.99", 39.99) - true
+ * Params: ("¤ 281,79", 281.79) - true
+ * Params: ("¤ 281,79", 18.15) - false
+ *
+ * @param currencyString
+ * @param value
+ * @return
+ */
+ private boolean valueEqualsCurrency(String currencyString, double value) {
+ String s = currencyString.replace(',', '.');
+ for (int i=0 ; i<s.length(); i++) {
+ if (("0".compareTo(currencyString) < -1) && ((s.compareTo("9") <= 1) || (s.charAt(0) == '9'))) {
+ double d = Double.parseDouble(s);
+ return d == value;
+ }
+ else {
+ s = s.substring(1);
+ }
+ }
+ return false;
+ }
+
+}
14 years, 11 months
JBoss Portal SVN: r13475 - in branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium: portal and 1 other directory.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-06-22 09:07:03 -0400 (Mon, 22 Jun 2009)
New Revision: 13475
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileUploadTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
Log:
[selenium] - some assert messages added
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java 2009-06-22 09:57:57 UTC (rev 13474)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java 2009-06-22 13:07:03 UTC (rev 13475)
@@ -98,7 +98,7 @@
Assert.assertEquals(tempDirName, selenium.getText("//div[@id='center']/div/div/ul/li[3]"));
selenium.click("link=Home");
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("link=" + tempDirName));
+ Assert.assertTrue(selenium.isElementPresent("link=" + tempDirName),"Created directory link not found.");
}
@@ -174,16 +174,16 @@
goToCms();
- Assert.assertTrue(selenium.isElementPresent("link=" + tempDirName));
+ Assert.assertTrue(selenium.isElementPresent("link=" + tempDirName),"temp directory link not found.");
selenium.select(takeAction(tempDirName) + "/select", "label=Delete");
selenium.click(takeAction(tempDirName) + "/select/option[4]");
selenium.click(takeAction(tempDirName) + "/input");
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /" + tempDirName));
- Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo these change!"));
- Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this resource?"));
+ Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /" + tempDirName),"confirmation message not present");
+ Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo these change!"),"confirmation message not present");
+ Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this resource?"),"confirmation message not present");
selenium.click(INP_DIR_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -192,16 +192,16 @@
selenium.waitForPageToLoad(PAGE_LOAD);
goToCms();
- Assert.assertTrue(selenium.isElementPresent("link=" + tempDirName));
+ Assert.assertTrue(selenium.isElementPresent("link=" + tempDirName),"temp directory link not found.");
selenium.select(takeAction(tempDirName) + "/select", "label=Delete");
selenium.click(takeAction(tempDirName) + "/select/option[4]");
selenium.click(takeAction(tempDirName) + "/input");
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /" + tempDirName));
- Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo these change!"));
- Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this resource?"));
+ Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /" + tempDirName),"confirmation message not present");
+ Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo these change!"),"confirmation message not present");
+ Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this resource?"),"confirmation message not present");
selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -227,9 +227,9 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent(INP_DIR_NAME));
- Assert.assertTrue(selenium.isElementPresent(INP_DIR_DESC));
- Assert.assertEquals("Confirm Directory Creation", selenium.getText("//div[@id='center']/div/h3"));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_NAME),"directory name input not found");
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_DESC),"directory description input not found");
+ Assert.assertEquals("Confirm Directory Creation", selenium.getText("//div[@id='center']/div/h3"),"confirmation message not found");
selenium.type(INP_DIR_NAME, copyDirName);
selenium.type(INP_DIR_DESC, "source folder for copy");
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileUploadTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileUploadTestCase.java 2009-06-22 09:57:57 UTC (rev 13474)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileUploadTestCase.java 2009-06-22 13:07:03 UTC (rev 13475)
@@ -123,7 +123,7 @@
* selenium.waitForPageToLoad(PAGE_LOAD);
*/
Assert.assertEquals(selenium.getText("//div[@id='center']/div/div/ul/li[3]"), "testFile.txt");
- Assert.assertTrue(selenium.isElementPresent("link=text/plain"));
+ Assert.assertTrue(selenium.isElementPresent("link=text/plain"),"file type string not found.");
Assert.assertTrue(selenium.isElementPresent("//div[@id='center']/div/div/table/tbody/tr[4]/td[3]"));
Assert.assertEquals(selenium.getText("//div[@id='center']/div/div/table/tbody/tr[4]/td[6]"), "file to upload");
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-06-22 09:57:57 UTC (rev 13474)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-06-22 13:07:03 UTC (rev 13475)
@@ -192,17 +192,17 @@
selenium.waitForPageToLoad(PAGE_LOAD);
debugScreenshot("pa" + ".jpg");
- Assert.assertTrue(selenium.isTextPresent(portalName));
+ Assert.assertTrue(selenium.isTextPresent(portalName),"portal name not found");
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
debugPrint(portalName + " : " + r);
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_MAIN, r)));
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_SECURITY, r)));
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_PROPERTIES, r)));
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_MAKEDEF, r)));
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_RENAME, r)));
- Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_THEME, r)));
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_MAIN, r)),"portal button main not found");
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_SECURITY, r)),"portal button security not found");
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_PROPERTIES, r)),"portal button properties not found");
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_MAKEDEF, r)),"portal button not make default found");
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_RENAME, r)),"portal button rename not found");
+ Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(POR_TL_THEME, r)),"portal button theme not found");
}
/**
@@ -239,7 +239,7 @@
clickIfVisible(LINK_PORTALS_ID);
final String portalToRename = "TestRenPortal";
- Assert.assertTrue(selenium.isTextPresent(portalToRename));
+ Assert.assertTrue(selenium.isTextPresent(portalToRename), "portal name not found");
final String portalRenamed = "AestPortal";
Assert.assertFalse(selenium.isTextPresent(portalRenamed), "Not renamed page already exist.");
@@ -252,8 +252,8 @@
selenium.click(SUBMIT_RENAME_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertFalse(selenium.isTextPresent(portalToRename));
- Assert.assertTrue(selenium.isTextPresent(portalRenamed));
+ Assert.assertFalse(selenium.isTextPresent(portalToRename), "portal name was found");
+ Assert.assertTrue(selenium.isTextPresent(portalRenamed), "portal name not found");
}
/**
@@ -293,15 +293,15 @@
selenium.click(INPUT_SUBMIT_CREATEPORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(portalToDelete));
+ Assert.assertTrue(selenium.isTextPresent(portalToDelete), "portal name not found");
int r = findTableRow(TABLE_PORTAL_ADMIN, portalToDelete, 0) - 1;
selenium.click(MessageFormat.format(POR_TL_DELETE, r));
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("WARNING! You are about to delete the " + portalToDelete + " portal from the context!"));
- Assert.assertTrue(selenium.isTextPresent("Delete portal"));
- Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this portal?"));
+ Assert.assertTrue(selenium.isTextPresent("WARNING! You are about to delete the " + portalToDelete + " portal from the context!"), "confirmation message is missing.");
+ Assert.assertTrue(selenium.isTextPresent("Delete portal"), "confirmation message is missing.");
+ Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this portal?"), "confirmation message is missing.");
selenium.click(SUBMIT_DELETE_PORTAL_CONF);
selenium.waitForPageToLoad(PAGE_LOAD);
// Assert.assertTrue(selenium.isTextPresent(
@@ -309,7 +309,7 @@
clickIfVisible("link=Admin");
clickIfVisible(TAB_PORTALOBJ_ID);
- Assert.assertFalse(selenium.isTextPresent(portalToDelete));
+ Assert.assertFalse(selenium.isTextPresent(portalToDelete), "deleted portal name was found");
}
@@ -356,7 +356,7 @@
selenium.click(INPUT_SUBMIT_CREATEPORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(portalName));
+ Assert.assertTrue(selenium.isTextPresent(portalName), "portal name not found");
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
@@ -473,7 +473,7 @@
selenium.click(INPUT_SUBMIT_CREATEPORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(portalName));
+ Assert.assertTrue(selenium.isTextPresent(portalName), "portal name not found");
r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
@@ -489,12 +489,12 @@
r = findTableRow(TBL_PP_PROPS, propName2, 0) - 1;
Assert.assertEquals(selenium.getValue(MessageFormat.format(INP_PP_PROP_VAL, r)), propVal2, "previously changed value other than expected");
- Assert.assertFalse(selenium.isChecked(CHK_PP_UNAVAIL_CHECK));
- Assert.assertFalse(selenium.isChecked(CHK_PP_ACCESS_CHECK));
- Assert.assertFalse(selenium.isChecked(CHK_PP_ERROR_CHECK));
- Assert.assertFalse(selenium.isChecked(CHK_PP_INTERNAL_CHECK));
- Assert.assertFalse(selenium.isChecked(CHK_PP_NF_CHECK));
- Assert.assertFalse(selenium.isChecked(CHK_PP_RES_CHECK));
+ Assert.assertFalse(selenium.isChecked(CHK_PP_UNAVAIL_CHECK),"CHK_PP_UNAVAIL_CHECK was not checked");
+ Assert.assertFalse(selenium.isChecked(CHK_PP_ACCESS_CHECK),"CHK_PP_ACCESS_CHECK was not checked");
+ Assert.assertFalse(selenium.isChecked(CHK_PP_ERROR_CHECK),"CHK_PP_ERROR_CHECK was not checked");
+ Assert.assertFalse(selenium.isChecked(CHK_PP_INTERNAL_CHECK),"CHK_PP_INTERNAL_CHECK was not checked");
+ Assert.assertFalse(selenium.isChecked(CHK_PP_NF_CHECK),"CHK_PP_NF_CHECK was not checked");
+ Assert.assertFalse(selenium.isChecked(CHK_PP_RES_CHECK),"CHK_PP_RES_CHECK was not checked");
Assert.assertEquals(selenium.getSelectedLabel(SEL_PP_ACCESS_SELECT), "Redirect to the specified resource");
Assert.assertEquals(selenium.getSelectedLabel(SEL_PP_UNAVAIL_SELECT), "Redirect to the specified resource");
Assert.assertEquals(selenium.getSelectedLabel(SEL_PP_ERROR_SELECT), "Display the default error message");
@@ -502,12 +502,12 @@
Assert.assertEquals(selenium.getSelectedLabel(SEL_PP_NF_SELECT), "Redirect to the specified resource");
Assert.assertEquals(selenium.getValue(INP_PP_RES_INPUT), "/WEB-INF/jsp/error/portalx.jsp");
- Assert.assertFalse(selenium.isChecked(CHK_PPA_ACCESS_CHECK));
- Assert.assertFalse(selenium.isChecked(CHK_PPA_CONTROL_CHECK));
- Assert.assertFalse(selenium.isChecked(CHK_PPA_ERROR_CHECK));
- Assert.assertFalse(selenium.isChecked(CHK_PPA_INTERNAL_CHECK));
- Assert.assertFalse(selenium.isChecked(CHK_PPA_NF_CHECK));
- Assert.assertFalse(selenium.isChecked(CHK_PPA_RES_CHECK));
+ Assert.assertFalse(selenium.isChecked(CHK_PPA_ACCESS_CHECK),"CHK_PPA_ACCESS_CHECK was not checked");
+ Assert.assertFalse(selenium.isChecked(CHK_PPA_CONTROL_CHECK),"CHK_PPA_CONTROL_CHECK was not checked");
+ Assert.assertFalse(selenium.isChecked(CHK_PPA_ERROR_CHECK),"CHK_PPA_ERROR_CHECK was not checked");
+ Assert.assertFalse(selenium.isChecked(CHK_PPA_INTERNAL_CHECK),"CHK_PPA_INTERNAL_CHECK was not checked");
+ Assert.assertFalse(selenium.isChecked(CHK_PPA_NF_CHECK),"CHK_PPA_NF_CHECK was not checked");
+ Assert.assertFalse(selenium.isChecked(CHK_PPA_RES_CHECK),"CHK_PPA_RES_CHECK was not checked");
Assert.assertEquals(selenium.getSelectedLabel(SEL_PPA_ACCESS_SELECT), "Redirect to the specified resource");
Assert.assertEquals(selenium.getSelectedLabel(SEL_PPA_CONTROL_SELECT), "Redirect to the specified resource");
Assert.assertEquals(selenium.getSelectedLabel(SEL_PPA_ERROR_SELECT), "Display the default error message");
@@ -548,12 +548,12 @@
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent(portalPage), "Portal page already present");
- Assert.assertTrue(selenium.isTextPresent("Create a page named:"));
+ Assert.assertTrue(selenium.isTextPresent("Create a page named:"), "create page string not found");
selenium.type(INPUT_PAGENAME, portalPage);
selenium.click(INPUT_SUBMIT_PAGECREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(portalPage));
+ Assert.assertTrue(selenium.isTextPresent(portalPage), "portal name not found");
}
/**
@@ -594,9 +594,9 @@
selenium.click(MessageFormat.format(PAG_TL_DELETE, r));
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Delete page"));
- Assert.assertTrue(selenium.isTextPresent("WARNING! You are about to delete the " + portalPage + " page from the " + portalName + " portal! "));
- Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this page?"));
+ Assert.assertTrue(selenium.isTextPresent("Delete page"),"confirmation message not found");
+ Assert.assertTrue(selenium.isTextPresent("WARNING! You are about to delete the " + portalPage + " page from the " + portalName + " portal! "),"confirmation message not found");
+ Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this page?"),"confirmation message not found");
}
@@ -645,10 +645,10 @@
selenium.click(SUB_LAYOUT_ADD_CENTER);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(windowName));
+ Assert.assertTrue(selenium.isTextPresent(windowName),"window name not found");
selenium.open("/portal/auth/portal/mimikry");
- Assert.assertTrue(selenium.isTextPresent("Current users"));
+ Assert.assertTrue(selenium.isTextPresent("Current users"),"current users string not found");
}
@@ -679,7 +679,7 @@
clickIfVisible(TAB_PORTALOBJ_ID);
clickIfVisible(LINK_PORTALS_ID);
clickIfVisible(LINK_PORTAL_HOME);
- Assert.assertTrue(selenium.isTextPresent("Create a portal named:"));
+ Assert.assertTrue(selenium.isTextPresent("Create a portal named:"),"create portal string not found");
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
clickAndWait(MessageFormat.format(POR_TL_MAIN, r));
@@ -749,7 +749,7 @@
clickIfVisible(TAB_PORTALOBJ_ID);
clickIfVisible(LINK_PORTALS_ID);
clickIfVisible(LINK_PORTAL_HOME);
- Assert.assertTrue(selenium.isTextPresent("Create a portal named:"));
+ Assert.assertTrue(selenium.isTextPresent("Create a portal named:"),"create portal string not found");
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
clickAndWait(MessageFormat.format(POR_TL_MAIN, r));
@@ -796,7 +796,7 @@
clickIfVisible(TAB_PORTALOBJ_ID);
clickIfVisible(LINK_PORTALS_ID);
clickIfVisible(LINK_PORTAL_HOME);
- Assert.assertTrue(selenium.isTextPresent("Create a portal named:"));
+ Assert.assertTrue(selenium.isTextPresent("Create a portal named:"), "create portal string not found");
r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
clickAndWait(MessageFormat.format(POR_TL_MAIN, r));
@@ -843,7 +843,7 @@
clickIfVisible(TAB_PORTALOBJ_ID);
clickIfVisible(LINK_PORTALS_ID);
clickIfVisible(LINK_PORTAL_HOME);
- Assert.assertTrue(selenium.isTextPresent("Create a portal named:"));
+ Assert.assertTrue(selenium.isTextPresent("Create a portal named:"),"create portal string not found");
r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
clickAndWait(MessageFormat.format(POR_TL_MAIN, r));
@@ -891,16 +891,16 @@
clickIfVisible(TAB_PORTALOBJ_ID);
clickIfVisible(LINK_PORTALS_ID);
clickIfVisible(LINK_PORTAL_HOME);
- Assert.assertTrue(selenium.isTextPresent("Create a portal named:"));
+ Assert.assertTrue(selenium.isTextPresent("Create a portal named:"),"create portal string not found");
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
clickAndWait(MessageFormat.format(POR_TL_MAIN, r));
r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
clickAndWait(MessageFormat.format(PAG_TL_THEME, r));
- Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_LAY));
- Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_THE));
- Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_REN));
+ Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_LAY),"PAG_THE_LAY wrong label is selected");
+ Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_THE),"PAG_THE_THE wrong label is selected");
+ Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_REN),"PAG_THE_REN wrong label is selected");
selenium.select(PAG_THE_LAY, "label=3columns");
selenium.select(PAG_THE_THE, "label=maple");
@@ -916,9 +916,9 @@
r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
clickAndWait(MessageFormat.format(PAG_TL_THEME, r));
- Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_LAY));
- Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_THE));
- Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_REN));
+ Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_LAY),"PAG_THE_LAY wrong label is selected");
+ Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_THE),"PAG_THE_THE wrong label is selected");
+ Assert.assertEquals("default", selenium.getSelectedLabel(PAG_THE_REN),"PAG_THE_REN wrong label is selected");
selenium.select(PAG_THE_LAY, "label=3columns");
selenium.select(PAG_THE_THE, "label=maple");
selenium.select(PAG_THE_REN, "label=emptyRenderer");
14 years, 11 months
JBoss Portal SVN: r13474 - in branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium: cms and 1 other directory.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-06-22 05:57:57 -0400 (Mon, 22 Jun 2009)
New Revision: 13474
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/assert.properties
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
Log:
[selnium] - some assert message fixes
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/assert.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/assert.properties 2009-06-19 15:14:33 UTC (rev 13473)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/assert.properties 2009-06-22 09:57:57 UTC (rev 13474)
@@ -9,6 +9,10 @@
iden.man.chk.role=Create new role
cms.sec.denied=You are not allowed to access the resource
+cms.dir.msg.inv.desc=A value below was invalid
+cms.file.msg.val.invalid.filename=A value below was invalid
+cms.file.msg.val.invalid.title=A value below was invalid
+cms.file.msg.val.invalid.desc=A value below was invalid
samples.ajax.p3.l3=$256.00
samples.ajax.p3.l2=SANTA CRUZ ALLSTAR
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-06-19 15:14:33 UTC (rev 13473)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-06-22 09:57:57 UTC (rev 13474)
@@ -19,9 +19,9 @@
/** prefix for locator properties = cms.file. */
private final String casePfx = "cms.file.";
- private final String MSG_VAL_INVALID_FILENAME = getMess("msg.val.invalid.filename","A value below is invalid");
- private final String MSG_VAL_INVALID_DESC = getMess("msg.val.invalid.desc","A value below is invalid");
- private final String MSG_VAL_INVALID_TITLE = getMess("msg.val.invalid.title","A value below is invalid");
+ private final String MSG_VAL_INVALID_FILENAME = getMess(casePfx +"msg.val.invalid.filename","A value belw is invalid");
+ private final String MSG_VAL_INVALID_DESC = getMess(casePfx +"msg.val.invalid.desc","A value below is invalid");
+ private final String MSG_VAL_INVALID_TITLE = getMess(casePfx +"msg.val.invalid.title","A value below is invalid");
private final String SEL_ACTION = getLoc(casePfx + "sel.action","//div[@id='center']/div/div/div[1]/div/select");
private final String INP_FC_SAVE = getLoc(casePfx + "inp.fc.save","save");
private final String INP_FC_LANGUAGE = getLoc(casePfx + "inp.fc.language","language");
@@ -204,7 +204,7 @@
selenium.select(INP_FC_LANGUAGE, "label=Czech");
selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+ System.out.println("!"+MSG_VAL_INVALID_FILENAME);
Assert.assertTrue(selenium.isTextPresent(MSG_VAL_INVALID_FILENAME), "Input validation for filename is missing.");
selenium.type(INP_FC_FILENAME, "newFile");
@@ -436,19 +436,24 @@
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.select("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/select", "label=Delete");
- selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/select/option[4]");
- selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/input");
+
+ int r = findTableRow(TBL_CMS_FILE, "newFile", 0) + 1;
+
+ selenium.select("//div[@id='center']/div/div/div[3]/table/tbody/tr["+r+"]/td[2]/form/select", "label=Delete");
+ selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr["+r+"]/td[2]/form/select/option[4]");
+ selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr["+r+"]/td[2]/form/input");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /newFile"));
Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo these change!"));
Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this resource?"));
selenium.click("cancel");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/select", "label=Delete");
- selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/select/option[4]");
- selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/input");
+
+ r = findTableRow(TBL_CMS_FILE, "newFile", 0) + 1;
+
+ selenium.select("//div[@id='center']/div/div/div[3]/table/tbody/tr["+r+"]/td[2]/form/select", "label=Delete");
+ selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr["+r+"]/td[2]/form/select/option[4]");
+ selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr["+r+"]/td[2]/form/input");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /newFile"));
Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo these change!"));
@@ -499,9 +504,11 @@
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/select", "label=Delete");
- selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/select/option[4]");
- selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr[3]/td[2]/form/input");
+ int r = findTableRow(TBL_CMS_FILE, name, 0) + 1;
+
+ selenium.select("//div[@id='center']/div/div/div[3]/table/tbody/tr["+r+"]/td[2]/form/select", "label=Delete");
+ selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr["+r+"]/td[2]/form/select/option[4]");
+ selenium.click("//div[@id='center']/div/div/div[3]/table/tbody/tr["+r+"]/td[2]/form/input");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /" + name));
Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo these change!"));
14 years, 11 months
JBoss Portal SVN: r13472 - branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-06-18 08:30:44 -0400 (Thu, 18 Jun 2009)
New Revision: 13472
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/locator.properties
Log:
[JBPORTAL-2392] - user creation portlet validation test
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-06-18 11:33:53 UTC (rev 13471)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortletUserCreationTestCase.java 2009-06-18 12:30:44 UTC (rev 13472)
@@ -15,62 +15,48 @@
/** 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 = getLoc(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 = getLoc(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 = getLoc(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 = getLoc(casePfx+"submit.create.user.cancel","//input[contains(@id,'register-form:cancel')]");
-
- /** The INPU t_ userpasswdconf. */
- private final String INPUT_USERPASSWDCONF = getLoc(casePfx+"input.userpasswdconf","//input[contains(@id,'register-form:passwordCheckv");
-
- /** The INPU t_ userpasswd. */
- private final String INPUT_USERPASSWD = getLoc(casePfx+"input.userpasswd","//input[contains(@id,'register-form:password')]");
-
- /** The INPU t_ usermail. */
- private final String INPUT_USERMAIL = getLoc(casePfx+"input.usermail","//input[contains(@id,'register-form:email')]");
-
- /** The INPU t_ username. */
- private final String INPUT_USERNAME = getLoc(casePfx+"input.username","//input[contains(@id,'register-form:username')]");
-
- /** The LIN k_ creat e_ user. */
- private final String LINK_CREATE_USER = getLoc(casePfx+"link.create.user","//a[contains(@id,'create-account-form:register')]");
-
- /** The TA b_ welcome. */
- private final String TAB_WELCOME = getLoc(casePfx+"tab.welcome","//a[contains(@id,'register-temp-form:start-link')]");
+
+ private final String SUB_CREATE_CONF = getLoc(casePfx+"submit.create.conf","//input[contains(@id,'confirm-form:user')]");
+ private final String SUB_CREATE_CONF_EDIT = getLoc(casePfx+"submit.create.conf.edit","//input[contains(@id,'//input[contains(@id,'confirm-form:revise')]");
+ private final String SUB_CREATE_USER = getLoc(casePfx+"submit.create.user","//input[contains(@id,'register-form:submit')]");
+ private final String SUB_CREATE_USER_CANCEL = getLoc(casePfx+"submit.create.user.cancel","//input[contains(@id,'register-form:cancel')]");
+ private final String INP_USERPASSWDCONF = getLoc(casePfx+"input.userpasswdconf","//input[contains(@id,'register-form:passwordCheck");
+ private final String INP_CAPTCHA= getLoc(casePfx+"input.captcha","//input[contains(@id,'register-form:validateCaptcha')]");
+ private final String INP_USERPASSWD = getLoc(casePfx+"input.userpasswd","//input[contains(@id,'register-form:password')]");
+ private final String INP_USERMAIL = getLoc(casePfx+"input.usermail","//input[contains(@id,'register-form:email')]");
+ private final String INP_USERNAME = getLoc(casePfx+"input.username","//input[contains(@id,'register-form:username')]");
+ private final String LNK_CREATE_USER = getLoc(casePfx+"link.create.user","//a[contains(@id,'create-account-form:register')]");
+ private final String TAB_WELCOME = getLoc(casePfx+"tab.welcome","//a[contains(@id,'register-temp-form:start-link')]");
+ private final String MSG_NAME_VALID = getMess(casePfx+"msg.name.valid","is an invalid username");
+ private final String MSG_MAIL_VALID = getMess(casePfx+"msg.mail.valid","Invalid E-Mail address.");
+ private final String MSG_PASS_VALID = getMess(casePfx+"msg.pass.valid","*");
+ private final String MSG_PASS2_VALID = getMess(casePfx+"msg.pass2.valid","*");
+ private final String MSG_CAPTCHA_VALID = getMess(casePfx+"msg.captcha.valid","Captcha incorrect");
-
/**
* User creation test.
*/
- @Test(enabled = true, description = "Simple user creation.")
+ @Test(enabled = false, description = "Simple user creation.")
public void userCreationTest() {
selenium.open("/portal");
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(TAB_WELCOME);
- Assert.assertTrue((selenium.isElementPresent(LINK_CREATE_USER)));
- selenium.click(LINK_CREATE_USER);
+ Assert.assertTrue((selenium.isElementPresent(LNK_CREATE_USER)));
+ selenium.click(LNK_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue((selenium.isTextPresent("Username *")));
Assert.assertTrue((selenium.isTextPresent("E-Mail *")));
Assert.assertTrue((selenium.isTextPresent("Password *")));
Assert.assertTrue((selenium.isTextPresent("Confirm Password *")));
- selenium.type(INPUT_USERNAME, "portletUser");
- selenium.type(INPUT_USERMAIL, "portletUser(a)redhat.com");
- selenium.type(INPUT_USERPASSWD, "portletUserPassword");
- selenium.type(INPUT_USERPASSWDCONF, "portletUserPassword");
- selenium.click(SUBMIT_CREATE_USER);
+ selenium.type(INP_USERNAME, "portletUser");
+ selenium.type(INP_USERMAIL, "portletUser(a)redhat.com");
+ selenium.type(INP_USERPASSWD, "portletUserPassword");
+ selenium.type(INP_USERPASSWDCONF, "portletUserPassword");
+ selenium.click(SUB_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue((selenium.isTextPresent("portletUser")));
Assert.assertTrue((selenium.isTextPresent("portletUser(a)redhat.com")));
- selenium.click(SUBMIT_CREATE_CONF);
+ selenium.click(SUB_CREATE_CONF);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue((selenium.isTextPresent("Your account has been successfully created. You may want to login now.")));
}
@@ -78,55 +64,55 @@
/**
* User creation long test.
*/
- @Test(enabled = true, description = "User creation using most of the active elements on page.")
+ @Test(enabled = false, description = "User creation using most of the active elements on page.")
public void userCreationLongTest() {
//canceling of creation
selenium.open("/portal");
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(TAB_WELCOME);
- Assert.assertTrue((selenium.isElementPresent(LINK_CREATE_USER)));
- selenium.click(LINK_CREATE_USER);
+ Assert.assertTrue((selenium.isElementPresent(LNK_CREATE_USER)));
+ selenium.click(LNK_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue((selenium.isTextPresent("Username *")));
Assert.assertTrue((selenium.isTextPresent("E-Mail *")));
Assert.assertTrue((selenium.isTextPresent("Password *")));
Assert.assertTrue((selenium.isTextPresent("Confirm Password *")));
- selenium.type(INPUT_USERNAME, "portletLongUser");
- selenium.type(INPUT_USERMAIL, "portletLongUser(a)redhat.com");
- selenium.type(INPUT_USERPASSWD, "portletLongUserPassword");
- selenium.type(INPUT_USERPASSWDCONF, "portletLongUserPassword");
+ selenium.type(INP_USERNAME, "portletLongUser");
+ selenium.type(INP_USERMAIL, "portletLongUser(a)redhat.com");
+ selenium.type(INP_USERPASSWD, "portletLongUserPassword");
+ selenium.type(INP_USERPASSWDCONF, "portletLongUserPassword");
- selenium.click(SUBMIT_CREATE_USER_CANCEL);
+ selenium.click(SUB_CREATE_USER_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
// editing of creation
selenium.open("/portal");
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(TAB_WELCOME);
- Assert.assertTrue((selenium.isElementPresent(LINK_CREATE_USER)));
- selenium.click(LINK_CREATE_USER);
+ Assert.assertTrue((selenium.isElementPresent(LNK_CREATE_USER)));
+ selenium.click(LNK_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_USERNAME, "portlextLongUser");
- selenium.type(INPUT_USERMAIL, "portxletLongUser(a)redhat.com");
- selenium.type(INPUT_USERPASSWD, "porxtletLongUserPassword");
- selenium.type(INPUT_USERPASSWDCONF, "porxtletLongUserPassword");
- selenium.click(SUBMIT_CREATE_USER);
+ selenium.type(INP_USERNAME, "portlextLongUser");
+ selenium.type(INP_USERMAIL, "portxletLongUser(a)redhat.com");
+ selenium.type(INP_USERPASSWD, "porxtletLongUserPassword");
+ selenium.type(INP_USERPASSWDCONF, "porxtletLongUserPassword");
+ selenium.click(SUB_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(SUBMIT_CREATE_CONF_EDIT);
+ selenium.click(SUB_CREATE_CONF_EDIT);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_USERNAME, "portletLong2User");
- selenium.type(INPUT_USERMAIL, "portletLong2User(a)redhat.com");
- selenium.type(INPUT_USERPASSWD, "portletLong2UserPassword");
- selenium.type(INPUT_USERPASSWDCONF, "portletLong2UserPassword");
- selenium.click(SUBMIT_CREATE_USER);
+ selenium.type(INP_USERNAME, "portletLong2User");
+ selenium.type(INP_USERMAIL, "portletLong2User(a)redhat.com");
+ selenium.type(INP_USERPASSWD, "portletLong2UserPassword");
+ selenium.type(INP_USERPASSWDCONF, "portletLong2UserPassword");
+ selenium.click(SUB_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue((selenium.isTextPresent("portletLong2User")));
Assert.assertTrue((selenium.isTextPresent("portletLong2User(a)redhat.com")));
- selenium.click(SUBMIT_CREATE_CONF);
+ selenium.click(SUB_CREATE_CONF);
selenium.waitForPageToLoad(PAGE_LOAD);
// verification
@@ -136,28 +122,28 @@
/**
* User creation cancel edit test.
*/
- @Test(enabled = true, description = "Canceling of editing during the user creation.")
+ @Test(enabled = false, description = "Canceling of editing during the user creation.")
public void userCreationCancelEditTest() {
selenium.open("/portal");
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(TAB_WELCOME);
- Assert.assertTrue((selenium.isElementPresent(LINK_CREATE_USER)));
- selenium.click(LINK_CREATE_USER);
+ Assert.assertTrue((selenium.isElementPresent(LNK_CREATE_USER)));
+ selenium.click(LNK_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_USERNAME, "portletCLongUser");
- selenium.type(INPUT_USERMAIL, "portletCLongUser(a)redhat.com");
- selenium.type(INPUT_USERPASSWD, "portletCLongUserPassword");
- selenium.type(INPUT_USERPASSWDCONF, "portletCLongUserPassword");
- selenium.click(SUBMIT_CREATE_USER);
+ selenium.type(INP_USERNAME, "portletCLongUser");
+ selenium.type(INP_USERMAIL, "portletCLongUser(a)redhat.com");
+ selenium.type(INP_USERPASSWD, "portletCLongUserPassword");
+ selenium.type(INP_USERPASSWDCONF, "portletCLongUserPassword");
+ selenium.click(SUB_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click(SUBMIT_CREATE_CONF_EDIT);
+ selenium.click(SUB_CREATE_CONF_EDIT);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_USERNAME, "portletCLong2User");
- selenium.type(INPUT_USERMAIL, "portletCLong2User(a)redhat.com");
- selenium.type(INPUT_USERPASSWD, "portletCLong2UserPassword");
- selenium.type(INPUT_USERPASSWDCONF, "portletCLong2UserPassword");
- selenium.click(SUBMIT_CREATE_USER_CANCEL);
+ selenium.type(INP_USERNAME, "portletCLong2User");
+ selenium.type(INP_USERMAIL, "portletCLong2User(a)redhat.com");
+ selenium.type(INP_USERPASSWD, "portletCLong2UserPassword");
+ selenium.type(INP_USERPASSWDCONF, "portletCLong2UserPassword");
+ selenium.click(SUB_CREATE_USER_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("You can create an account."));
@@ -166,18 +152,18 @@
/**
* Existing user creation test.
*/
- @Test(enabled = true, description = "Creation of already existing user.")
+ @Test(enabled = false, description = "Creation of already existing user.")
public void existingUserCreationTest() {
selenium.open("/portal");
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(TAB_WELCOME);
- selenium.click(LINK_CREATE_USER);
+ selenium.click(LNK_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_USERNAME, "user");
- selenium.type(INPUT_USERMAIL, "user(a)portal.com");
- selenium.type(INPUT_USERPASSWD, "userpassword");
- selenium.type(INPUT_USERPASSWDCONF, "userpassword");
- selenium.click(SUBMIT_CREATE_USER);
+ selenium.type(INP_USERNAME, "user");
+ selenium.type(INP_USERMAIL, "user(a)portal.com");
+ selenium.type(INP_USERPASSWD, "userpassword");
+ selenium.type(INP_USERPASSWDCONF, "userpassword");
+ selenium.click(SUB_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("This username is already taken. user"));
}
@@ -190,13 +176,13 @@
selenium.open("/portal");
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(TAB_WELCOME);
- selenium.click(LINK_CREATE_USER);
+ selenium.click(LNK_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_USERNAME, "invalidMail");
- selenium.type(INPUT_USERMAIL, "invalidMail@");
- selenium.type(INPUT_USERPASSWD, "invalidMailp");
- selenium.type(INPUT_USERPASSWDCONF, "invalidMailp");
- selenium.click(SUBMIT_CREATE_USER);
+ selenium.type(INP_USERNAME, "invalidMail");
+ selenium.type(INP_USERMAIL, "invalidMail@");
+ selenium.type(INP_USERPASSWD, "invalidMailp");
+ selenium.type(INP_USERPASSWDCONF, "invalidMailp");
+ selenium.click(SUB_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Invalid E-Mail address."));
@@ -205,37 +191,105 @@
/**
* Password not match.
*/
- @Test(enabled = true, description = "Not matching password confirmation.")
+ @Test(enabled = false, description = "Not matching password confirmation.")
public void passwordNotMatch() {
selenium.open("/portal");
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(TAB_WELCOME);
- selenium.click(LINK_CREATE_USER);
+ selenium.click(LNK_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_USERNAME, "wrongPass");
- selenium.type(INPUT_USERMAIL, "wrongPass(a)redhat.com");
- selenium.type(INPUT_USERPASSWD, "wrongPass1");
- selenium.type(INPUT_USERPASSWDCONF, "wrongPass2");
- selenium.click(SUBMIT_CREATE_USER);
+ selenium.type(INP_USERNAME, "wrongPass");
+ selenium.type(INP_USERMAIL, "wrongPass(a)redhat.com");
+ selenium.type(INP_USERPASSWD, "wrongPass1");
+ selenium.type(INP_USERPASSWDCONF, "wrongPass2");
+ selenium.click(SUB_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("The passwords doesn't match."));
}
+
+ /**
+ * Tests input validation for all public inputs.
+ */
+ @Test(enabled = true, description = "Using short password.")
+ public void testXSSInputValidation() {
+ String userName = "portlextLongUser";
+ String userMail = "portxletLongUser(a)redhat.com";
+ String userPass = "porxtletLongUserPassword";
+ String captcha = "imCaptcha";
+
+ selenium.open("/portal");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ clickIfVisible(TAB_WELCOME);
+ Assert.assertTrue((selenium.isElementPresent(LNK_CREATE_USER)));
+ selenium.click(LNK_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(INP_USERNAME, XSS_STR1);
+ selenium.type(INP_USERMAIL, userMail);
+ selenium.type(INP_USERPASSWD, userPass);
+ selenium.type(INP_USERPASSWDCONF, userPass);
+ selenium.type(INP_CAPTCHA, captcha);
+ selenium.click(SUB_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_NAME_VALID),"validation error message missing or other than expected.");
+
+ selenium.type(INP_USERNAME, userName);
+ selenium.type(INP_USERMAIL, XSS_STR1);
+ selenium.type(INP_USERPASSWD, userPass);
+ selenium.type(INP_USERPASSWDCONF, userPass);
+ selenium.type(INP_CAPTCHA, captcha);
+ selenium.click(SUB_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_MAIL_VALID),"validation error message missing or other than expected.");
+
+ selenium.type(INP_USERNAME, userName);
+ selenium.type(INP_USERMAIL, userMail);
+ selenium.type(INP_USERPASSWD, XSS_STR1);
+ selenium.type(INP_USERPASSWDCONF, userPass);
+ selenium.type(INP_CAPTCHA, captcha);
+ selenium.click(SUB_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_PASS_VALID),"validation error message missing or other than expected.");
+
+ selenium.type(INP_USERNAME, userName);
+ selenium.type(INP_USERMAIL, userMail);
+ selenium.type(INP_USERPASSWD, userPass);
+ selenium.type(INP_USERPASSWDCONF, XSS_STR1);
+ selenium.type(INP_CAPTCHA, captcha);
+ selenium.click(SUB_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_PASS2_VALID),"validation error message missing or other than expected.");
+
+ selenium.type(INP_USERNAME, userName);
+ selenium.type(INP_USERMAIL, userMail);
+ selenium.type(INP_USERPASSWD, userPass);
+ selenium.type(INP_USERPASSWDCONF, userPass);
+ selenium.type(INP_CAPTCHA, XSS_STR1);
+ selenium.click(SUB_CREATE_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_CAPTCHA_VALID),"validation error message missing or other than expected.");
+ }
+
/**
* Short pass.
*/
- @Test(enabled = true, description = "Using short password.")
+ @Test(enabled = false, description = "Using short password.")
public void shortPass() {
selenium.open("/portal");
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(TAB_WELCOME);
- selenium.click(LINK_CREATE_USER);
+ selenium.click(LNK_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_USERNAME, "wrongPass");
- selenium.type(INPUT_USERMAIL, "wrongPass(a)redhat.com");
- selenium.type(INPUT_USERPASSWD, "w1");
- selenium.type(INPUT_USERPASSWDCONF, "w1");
- selenium.click(SUBMIT_CREATE_USER);
+ selenium.type(INP_USERNAME, "wrongPass");
+ selenium.type(INP_USERMAIL, "wrongPass(a)redhat.com");
+ selenium.type(INP_USERPASSWD, "w1");
+ selenium.type(INP_USERPASSWDCONF, "w1");
+ selenium.click(SUB_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("password: Validation Error: Value is less than allowable minimum of '6'"));
}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/locator.properties
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/locator.properties 2009-06-18 11:33:53 UTC (rev 13471)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/locator.properties 2009-06-18 12:30:44 UTC (rev 13472)
@@ -108,7 +108,7 @@
user.crea.port.submit.create.conf.edit=//input[contains(@id,'//input[contains(@id,'confirm-form:revise')]
user.crea.port.submit.create.user=//input[contains(@id,'register-form:submit')]
user.crea.port.submit.create.user.cancel=//input[contains(@id,'register-form:cancel')]
-user.crea.port.input.userpasswdconf=//input[contains(@id,'register-form:passwordCheckv
+user.crea.port.input.userpasswdconf=//input[contains(@id,'register-form:passwordCheck')]
user.crea.port.input.userpasswd=//input[contains(@id,'register-form:password')]
user.crea.port.input.usermail=//input[contains(@id,'register-form:email')]
user.crea.port.input.username=//input[contains(@id,'register-form:username')]
14 years, 11 months
JBoss Portal SVN: r13471 - in branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium: cms and 1 other directories.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-06-18 07:33:53 -0400 (Thu, 18 Jun 2009)
New Revision: 13471
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.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:
[JBPORTAL-2392] - dozen of selenium input validation tests
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-06-17 21:29:16 UTC (rev 13470)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-06-18 11:33:53 UTC (rev 13471)
@@ -1,8 +1,6 @@
package org.jboss.portal.test.selenium;
import org.testng.Assert;
-import org.testng.annotations.AfterClass;
-import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -17,6 +15,11 @@
/** prefix for locator properties = dash. */
public String casePfx = "dash.";
+
+ private final String MSG_WINDOW_NAME_VALID = getMess(casePfx+"msg.window.name.valid","is an invalid window name");
+ private final String MSG_PAGE_RENAME_VALID = getMess(casePfx+"msg.page.rename.valid","is an invalid portal object name");
+ private final String MSG_PAGE_NAME_VALID = getMess(casePfx+"msg.page.name.valid","is an invalid page name");
+
private final String DIV_PORTET_EDITOR_TITLE = getLoc(casePfx + "div.portlet.editor.title", "portlet-editor-title");
private final String HAND_R1 = getLoc(casePfx + "hand.r1", "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div[2]/div/div");
private final String HAND_L1 = getLoc(casePfx + "hand.l1", "//html/body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div");
@@ -33,7 +36,7 @@
private final String INP_PAGE_RENAME = getLoc(casePfx + "inp.page.rename", "//input[contains(@id,'renameForm:newName')]");
private final String INP_WINDOW_NAME = getLoc(casePfx + "inp.window.name", "//input[contains(@id,'windowForm:windowName')]");
private final String LINK_WEATHER_PORTLET = getLoc(casePfx + "link.weather.portlet", "link=*WeatherPortlet*");
- private final String LINK_PORTL3 = getLoc(casePfx + "link.portl2", "link=*WSRP admin portlet*");
+ private final String LINK_PORTL3 = getLoc(casePfx + "link.portl3", "link=*WSRP admin portlet*");
private final String LINK_PORTL2 = getLoc(casePfx + "link.portl2", "link=*Who's online portlet*");
private final String LINK_PORTL1 = getLoc(casePfx + "link.portl1", "link=*Welcome portlet*");
private final String OPT_PORTL2 = getLoc(casePfx + "opt.portl2", "IdentityUserPortletWindow");
@@ -420,6 +423,12 @@
Assert.assertTrue(selenium.isTextPresent("Gadgets powered by Google"));
}
+ /**
+ * Testing input validation for page creation. Test navigates to configure
+ * dashboard interface and tries to create a new page on the dashboard with
+ * the XSS string. The XSS string is inputed into the create page input and
+ * after submitting it is asserted that the error message is present.
+ */
@Test(enabled = true)
public void testXssCreatePage() {
selenium.click(LNK_DASHBOARD);
@@ -432,9 +441,17 @@
selenium.type(INP_PAGENAME, XSS_STR1);
clickAndWait(SUB_CREATEPAGE);
- Assert.assertTrue(selenium.isTextPresent("is an invalid page name"),"Message \""+"is an invalid page name"+"\" not found.");
+ Assert.assertTrue(selenium.isTextPresent(MSG_PAGE_NAME_VALID),"Message \""+MSG_PAGE_NAME_VALID+"\" not found.");
}
+ /**
+ * Testing input validation for page renaming. Test navigates to configure
+ * dashboard interface and tries to rename a page on the dashboard with the
+ * XSS string. Firstly new page named "DashXSSToRenamePage" is created. Then
+ * it is tried to be renamed to XSS string by typing it into rename input.
+ * After submitting it is asserted that the validation error message is
+ * present on the screen
+ */
@Test(enabled = true)
public void testXssRenamePage() {
selenium.click(LNK_DASHBOARD);
@@ -467,9 +484,18 @@
selenium.click(SUB_PAGE_RENAME);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid portal object name"),"Message: \""+"is an invalid portal object name"+"\" not found");
+ Assert.assertTrue(selenium.isTextPresent(MSG_PAGE_RENAME_VALID),"Message: \""+MSG_PAGE_RENAME_VALID+"\" not found");
}
+ /**
+ * Testing input validation for window creation. Test navigates to configure
+ * dashboard interface and select previously selected "DashTestPage" page.
+ * Then it clicks on the portlet link defined in property file as
+ * (prefix+)"link.portl3". XSS string is inputted into the window name input
+ * and after adding the portlet to the center region of layout (clicking on
+ * the particular submit) it is asserted that the validation error message
+ * is present on the screen.
+ */
@Test(enabled = true, dependsOnMethods = {"testCreatePage"})
public void testXssWindowName() {
selenium.click(LNK_DASHBOARD);
@@ -486,7 +512,7 @@
selenium.click(SUB_ADDCENTER);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid window name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_WINDOW_NAME_VALID));
}
// http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-06-17 21:29:16 UTC (rev 13470)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-06-18 11:33:53 UTC (rev 13471)
@@ -16,13 +16,16 @@
@Test(groups = { "admin_ui" }, enabled = true)
public class IdentityAdminTestCase extends JBossPortalSeleniumTestCase {
- private static final String LNK_MEMBERS = "link=Members";
-
- private static final String LNK_ADMIN = "link=Admin";
-
/** prefix for locator properties */
public String casePfx = "iden.man.";
+ private final String MSG_ROLE_DISPNAME_VALID = getMess(casePfx+"msg.role.dispname.valid","is an invalid role display name");
+ private final String MSG_ROLE_NAME_VALID = getMess(casePfx+"msg.role.name.valid","is an invalid role name");
+ private final String MSG_EDIT_USER_VALID = getMess(casePfx+"msg.edit.user.valid","is an invalid value");
+
+ private final String LNK_MEMBERS = getLoc(casePfx+"lnk.members","link=Members");
+ private final String LNK_ADMIN = getLoc(casePfx+"lnk.admin","link=Admin");
+
private final String INP_USER_SEARCH_PREV = getLoc(casePfx + "inp.user.search.prev", "//input[contains(@id,'search-user-form1:prev-page')]");
private final String INP_USER_SEARCH_NEXT = getLoc(casePfx + "inp.user.search.next", "//input[contains(@id,'search-user-form1:next-page')]");
@@ -547,7 +550,7 @@
selenium.type(INP_ROLEDISNAME, "diddi");
clickAndWait(SUB_ROLE_CREATE);
- Assert.assertTrue(selenium.isTextPresent("is an invalid role name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_ROLE_NAME_VALID));
openAndWait(ADR_PORTAL);
clickIfVisible(LNK_ADMIN);
@@ -562,7 +565,7 @@
clickAndWait(SUB_ROLE_CREATE);
- Assert.assertTrue(selenium.isTextPresent("is an invalid role display name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_ROLE_DISPNAME_VALID));
}
@@ -604,7 +607,7 @@
selenium.click(SUB_EDIT_ROLE_SUBMIT);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid role display name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_ROLE_DISPNAME_VALID));
deleteRole(roleName);
}
@@ -628,46 +631,46 @@
// firstname
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:givenname')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:givenname')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// lastname
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:familyname')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:familyname')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// location
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:location')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:location')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// skype
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:skype')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:skype')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// icq
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:icq')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:icq')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// aim
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:aim')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:aim')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// msn
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:msnm')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:msnm')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// yahoo
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:yim')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:yim')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// xmmp
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:xmmp')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:xmmp')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// homepage
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:homepage')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:homepage')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// occup
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:occupation')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:occupation')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// hobby
goToEdit(userName, userMail);
- testInput("//input[contains(@id,'profile-form:interests')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//input[contains(@id,'profile-form:interests')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// sign
goToEdit(userName, userMail);
- testInput("//textarea[contains(@id,'profile-form:signature')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//textarea[contains(@id,'profile-form:signature')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
// extra
goToEdit(userName, userMail);
- testInput("//textarea[contains(@id,'profile-form:extra')]", XSS_STR1, SUB_EDIT_PROF, "is an invalid value");
+ testInput("//textarea[contains(@id,'profile-form:extra')]", XSS_STR1, SUB_EDIT_PROF, MSG_EDIT_USER_VALID);
deleteUser(userName, userMail);
}
@@ -732,7 +735,7 @@
private void testInput(String inpLoc, String inpStr, String subLoc, String mes) {
selenium.type(inpLoc, inpStr);
clickAndWait(subLoc);
- Assert.assertTrue(selenium.isTextPresent(mes));
+ Assert.assertTrue(selenium.isTextPresent(mes),"input validation error message is missing or other than expected.");
}
/**
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-06-17 21:29:16 UTC (rev 13470)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-06-18 11:33:53 UTC (rev 13471)
@@ -13,9 +13,11 @@
@Test(groups = { "login" }, enabled = true)
public class UserLoginTestCase extends JBossPortalSeleniumTestCase {
+
/** prefix for locator properties = user.login. */
public final String casePfx = "user.login.";
+ private final String MSG_LOGIN_WRONGPASS = getMess(casePfx+"msg,login.wrongpass","The user doesn't exist or the password is incorrect");
private final String ADR_PORTAL = getLoc(casePfx + "adr.portal", "/portal");
private final String FRM_MAIN = getLoc(casePfx + "frm.main", "relative=up");
private final String SUB_CANCEL = getLoc(casePfx + "sub.portal", "cancel");
@@ -238,8 +240,8 @@
*
* Try to login with user/us2er and check that you are not logged in.
*/
- @Test(enabled = true, description = "xss attack")
- public void testXssAttack() {
+ @Test(enabled = true, description = "xss login")
+ public void testXssLogin() {
final String loginName = "user";
final String loginPass = "us2er";
@@ -257,7 +259,7 @@
selenium.fireEvent(INP_PASSWORD, "keydown");
selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("The user doesn't exist or the password is incorrect"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_LOGIN_WRONGPASS));
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -273,9 +275,8 @@
selenium.fireEvent(INP_PASSWORD, "keydown");
selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("The user doesn't exist or the password is incorrect"));
-
- Assert.assertTrue(selenium.isTextPresent("The user doesn't exist or the password is incorrect "), "\"Logged in as\" message missing.");
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_LOGIN_WRONGPASS), "\"Logged in as\" message missing.");
}
}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-06-17 21:29:16 UTC (rev 13470)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-06-18 11:33:53 UTC (rev 13471)
@@ -18,6 +18,18 @@
/** prefix for locator properties */
public static String casePfx = "test.wsrp.";
+
+ private final String MSG_PROD_SAVED = getMess(casePfx+"msg.prod.saved","Producer configuration successfully saved!");
+ private final String MSG_PROP_REGPOL_VALID = getMess(casePfx+"msg.prod.regpol.valid","is an invalid class nam");
+ private final String MSG_PROP_REGPROP_VALID = getMess(casePfx+"msg.prod.regprop.valid","is an invalid class nam");
+ private final String MSG_PROD_NAME_VALID =getMess(casePfx+"msg.prod.name.valid","error");
+ private final String MSG_PROD_LAB_VALID = getMess(casePfx+"msg.prod.lab.valid","error");
+ private final String MSG_PROD_HINT_VALID =getMess(casePfx+"msg.prod.hint.valid","error");
+
+ private final String MSG_CONS_REGVAL_VALID = getMess(casePfx+"msg.cons.regval.valid","An unexpected error occured");
+ private final String MSG_CONS_EXP_VALID = getMess(casePfx+"msg.cons.exp.valid","must be a number between");
+ private final String MSG_CONS_ADD_VALID = getMess(casePfx+"msg.cons.add.valid","Require a well-formed URL");
+ private final String MSG_CONS_NAME_VALID = getMess(casePfx+"msg.cons.name.valid","is an invalid Consumer name");
private final String INP_CONSUMER_NAME = getLoc(casePfx + "inp.consumer.name", "//input[contains(@id,'edit-cons-form:id')]");
private final String INP_PRODID = getLoc(casePfx + "inp.prodid", "//input[contains(@id,'edit-cons-form:id')]");
@@ -92,12 +104,7 @@
// selenium extension
@Test(enabled = true, description = "Creating a standard BEA consumer.")
public void testCreateBeaConsumer() {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
selenium.type(INPUT_CREATECONS, "BEA");
@@ -130,12 +137,7 @@
@Test(enabled = true, dependsOnMethods = { "testCreateBeaConsumer", "testBeaConsumerDeregister" }, description = "Standard BEA consumer registering.")
public void testBeaConsumerRegister() {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAreg", 0) - 1;
@@ -162,12 +164,7 @@
public void testBeaConsumerDeregister() {
createConsumer("BEAreg", "100", "http://wsrp.bea.com:7001/producer/producer?WSDL");
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
@@ -190,13 +187,7 @@
*/
@Test(enabled = true, dependsOnMethods = { "testCreateBeaConsumer", "testBeaConsumerDeactivate" }, description = "Standard BEA consumer activating.")
public void testBeaConsumerActivate() {
- selenium.open("/portal/");
-
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAact", 0) - 1;
@@ -222,12 +213,7 @@
createConsumer("BEAact", "100", "http://wsrp.bea.com:7001/producer/producer?WSDL");
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
@@ -262,12 +248,7 @@
public void testBeaConsumerDelete() {
createConsumer("BEAdel", "100", "http://wsrp.bea.com:7001/producer/producer?WSDL");
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
@@ -310,12 +291,7 @@
// TODO registration policy properties tests missing
@Test(enabled = true, description = "Basic configuring of WSRP producer.")
public void testConfigureProducer() {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_PRODCONF);
Assert.assertTrue(selenium.isTextPresent("Producer configuration"));
@@ -328,7 +304,7 @@
selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Producer configuration successfully saved!"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROD_SAVED));
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(ID_LINK_PRODCONF);
@@ -351,12 +327,7 @@
final String name = "renameMe";
final String nameNew = "renameNewMe";
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
@@ -391,19 +362,25 @@
Assert.assertTrue(r > 0, "Renamed consumer not found in table");
}
- /*
- *
+ /**
+ * Tests input validation while managing WSRP consumers. Firstly, the
+ * testcase navigates to WSRP consumers page. It types XSS string into
+ * "Create a consumer named:" input and clicks "Create consumer". The error
+ * message on the screen is asserted. Then it types a valid name
+ * ("XssBeaConsumer") into the input and clicks on create consumer. On newly
+ * opened page there are three new inputs: producer id, cache expiration and
+ * endpoint configuration. Into each of that inputs the XSS string is
+ * inputed in three steps and after clicking "Refresh and save" in each
+ * step, the presence of validation error message is asserted. Then the
+ * consumer is created by filling in valid data and XSS is typed into newly
+ * opened input "Registration information:". After clicking update
+ * properties, the validation error message is asserted again.
*/
@Test(enabled = true)
public void testXssConsumerManage() {
String beaName = "XssBeaConsumer";
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
@@ -412,7 +389,7 @@
selenium.click(SUBMIT_CREATECONS);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid Consumer name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_CONS_NAME_VALID),"validation error message missing or other than expected.");
selenium.type(INPUT_CREATECONS, beaName);
@@ -424,23 +401,22 @@
selenium.click(SUBMIT_REFRESHSAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Require a well-formed URL"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_CONS_ADD_VALID),"validation error message missing or other than expected.");
selenium.type(INPUT_CACHEEXP, XSS_STR1);
selenium.type(INPUT_CONSWSDL, "http://wsrp.bea.com:7001/producer/producer?WSDL");
selenium.click(SUBMIT_REFRESHSAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("must be a number between"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_CONS_EXP_VALID),"validation error message missing or other than expected.");
- selenium.setSpeed("5000");
selenium.type(INP_PRODID, XSS_STR1);
selenium.type(INPUT_CACHEEXP, "600");
selenium.type(INPUT_CONSWSDL, "http://wsrp.bea.com:7001/producer/producer?WSDL");
selenium.click(SUBMIT_REFRESHSAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid Consumer name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_CONS_NAME_VALID),"validation error message missing or other than expected.");
selenium.type(INP_PRODID, beaName);
selenium.type(INPUT_CACHEEXP, "600");
@@ -452,11 +428,29 @@
selenium.click(SUB_CONS_REGVAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("An unexpected error occured"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_CONS_REGVAL_VALID),"validation error message missing or other than expected.");
}
- /*
- *
+ private void goToWSRP() {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=WSRP");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+
+ /**
+ * Tests the input validation properties of WSRP producers part of JBP. The
+ * test is navigated into producers part of WSRP interface. The XSS string
+ * is typed in registration policy input and after clicking save, is it
+ * asserted, that the validation error message is present. The XSS string is
+ * typed in "Registration property validator class name" input and after
+ * clicking save, is it asserted, that the validation error message is
+ * present. Valid inputs are saved to three inputs of
+ * "registration properties" and they are saved. Then in three steps each of
+ * this input is filled with the XSS string and after clicking save it is
+ * asserted, that the validation error message is present.
*/
@Test(enabled = true)
public void testXssProducerManage() {
@@ -465,21 +459,15 @@
selenium.type("//input[contains(@id,'producer-form:registrationPolicy')]", XSS_STR1);
selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid class nam"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_REGPOL_VALID),"validation error message missing or other than expected.");
goToProducers();
selenium.type("//input[contains(@id,'producer-form:validator')]", XSS_STR1);
selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid class nam"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_REGPROP_VALID),"validation error message missing or other than expected.");
- // properties
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_PRODCONF);
Assert.assertTrue(selenium.isTextPresent("Producer configuration"));
@@ -492,34 +480,43 @@
selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Producer configuration successfully saved!"));
- clickIfVisible(ID_LINK_CONSCONF);
- clickIfVisible(ID_LINK_PRODCONF);
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROD_SAVED),"validation error message missing or other than expected.");
+
+ selenium.type(INPUT_PROPNAME, XSS_STR1);
+ selenium.type(INPUT_PROPLABEL, "testProp label");
+ selenium.type(INPUT_PROPHINT, "tetsPropHint");
- Assert.assertEquals("testProp", selenium.getValue(INPUT_PROPNAME));
- Assert.assertEquals("testProp label", selenium.getValue(INPUT_PROPLABEL));
- Assert.assertEquals("tetsPropHint", selenium.getValue(INPUT_PROPHINT));
- }
+ selenium.click(SUB_PROD_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROD_NAME_VALID),"validation error message missing or other than expected.");
+
+ selenium.type(INPUT_PROPNAME, "testProp");
+ selenium.type(INPUT_PROPLABEL, XSS_STR1);
+ selenium.type(INPUT_PROPHINT, "tetsPropHint");
- private void goToProducers() {
- selenium.open("/portal/");
+ selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROD_LAB_VALID),"validation error message missing or other than expected.");
+
+ selenium.type(INPUT_PROPNAME, "testProp");
+ selenium.type(INPUT_PROPLABEL, "testProp label");
+ selenium.type(INPUT_PROPHINT, XSS_STR1);
+
+ selenium.click(SUB_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROD_HINT_VALID),"validation error message missing or other than expected.");
+
+ }
+ private void goToProducers() {
+ goToWSRP();
+
clickIfVisible(ID_LINK_PRODCONF);
Assert.assertTrue(selenium.isTextPresent("Producer configuration"));
}
private void createConsumer(String name, String timeout, String address) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=WSRP");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
selenium.type(INPUT_CREATECONS, name);
selenium.click(SUBMIT_CREATECONS);
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java 2009-06-17 21:29:16 UTC (rev 13470)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java 2009-06-18 11:33:53 UTC (rev 13471)
@@ -17,9 +17,17 @@
/** prefix for locator properties = cms.dir.*/
public final String casePfx = "cms.dir.";
+
+ private final String MSG_INV_DESC = getMess(casePfx+"msg.inv.desc","A value below is invalid");
+ private final String MSG_INV_NAME = getMess(casePfx+"msg.inv.name","Folder Name is invalid");
+ private final String LAB_ACT_CREATE_FOLDER = getLoc(casePfx+"","Create Folder");
+ private final String INP_DIR_CANCEL = getLoc(casePfx+"","cancel");
+ private final String INP_DIR_SUB = getLoc(casePfx+"","submit");
+ private final String INP_DIR_DESC = getLoc(casePfx+"","newcollectiondescription");
+ private final String INP_DIR_NAME = getLoc(casePfx+"","newcollectionname");
private final String SEL_CMS_ACTION = getLoc(casePfx + "sel.cms.action", "//div[@id='center']/div/div/div[1]/div/select");
private final String ADR_CMS_INTERFACE = getLoc(casePfx + "adr.cms.interface", "/portal/auth/portal/admin/CMS");
-
+
private final String defaultDirName = "default";
private final String tempDirName = "tempDir";
private final String copyDirName = "copySrc";
@@ -51,43 +59,37 @@
// canceling of creating
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
selenium.open(ADR_CMS_INTERFACE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent(tempDirName), "Test folder is already present.");
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("newcollectionname", tempDirName);
- selenium.type("newcollectiondescription", "test folder");
- selenium.click("cancel");
+ selenium.type(INP_DIR_NAME, tempDirName);
+ selenium.type(INP_DIR_DESC, "test folder");
+ selenium.click(INP_DIR_CANCEL);
// really creating
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
selenium.open(ADR_CMS_INTERFACE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent(tempDirName), "Test folder is already present.");
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("newcollectionname", tempDirName);
- selenium.type("newcollectiondescription", "test folder");
- selenium.click("submit");
+ selenium.type(INP_DIR_NAME, tempDirName);
+ selenium.type(INP_DIR_DESC, "test folder");
+ selenium.click(INP_DIR_SUB);
// assuring that the directory is created
@@ -101,6 +103,64 @@
}
/**
+ * Testing input validation for inputs in directory creation. Test navigates
+ * to create new directory interface. Xss string is filled into directory
+ * name and valid string is filled into directory description input. After
+ * submit it is asserted, that error message about invalid name is present.
+ * Valid string is filled into directory name and XSS string is filled into
+ * directory description input. After submit it is asserted, that error
+ * message about invalid description is present.
+ */
+ @Test(enabled = true, description = "Xss directory creation.")
+ public void testXssCreateDirectory() {
+
+ // XSS name
+
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ goToCms();
+
+ selenium.open(ADR_CMS_INTERFACE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertFalse(selenium.isTextPresent(tempDirName), "Test folder is already present.");
+
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+
+ selenium.type(INP_DIR_NAME, XSS_STR1);
+ selenium.type(INP_DIR_DESC, "test folder");
+ selenium.click(INP_DIR_SUB);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_INV_NAME), "Input validation for name is missing.");
+ // XSS description
+
+ selenium.click(INP_DIR_CANCEL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+ selenium.type(INP_DIR_NAME, tempDirName);
+ selenium.type(INP_DIR_DESC, XSS_STR1);
+ selenium.click(INP_DIR_SUB);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_INV_DESC), "Input validation for description is missing.");
+ }
+
+ private void goToCms() {
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+
+
+ /**
* Deletes a directory.
*
* With action selector an action to delete a directory is chosen. The directory had to be deleted was created with {@link CMSDirectoryTestCase#testCreateDirectory()}.
@@ -112,10 +172,7 @@
// firstly cancel the delete process
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
Assert.assertTrue(selenium.isElementPresent("link=" + tempDirName));
selenium.select(takeAction(tempDirName) + "/select", "label=Delete");
@@ -127,16 +184,13 @@
Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /" + tempDirName));
Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo these change!"));
Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this resource?"));
- selenium.click("cancel");
+ selenium.click(INP_DIR_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
// really deleting
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
Assert.assertTrue(selenium.isElementPresent("link=" + tempDirName));
selenium.select(takeAction(tempDirName) + "/select", "label=Delete");
@@ -148,16 +202,13 @@
Assert.assertTrue(selenium.isTextPresent("Confirm Deletion of /" + tempDirName));
Assert.assertTrue(selenium.isTextPresent("WARNING! You will not be able to undo these change!"));
Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this resource?"));
- selenium.click("submit");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
// assuring that the deletition was processed
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
Assert.assertFalse(selenium.isElementPresent("link=" + tempDirName));
}
@@ -170,22 +221,19 @@
*/
@Test(enabled = true, dependsOnMethods = "testCreateDirectory", description = "Copying of directory.")
public void testCopyDirectory() {
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("newcollectionname"));
- Assert.assertTrue(selenium.isElementPresent("newcollectiondescription"));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_NAME));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_DESC));
Assert.assertEquals("Confirm Directory Creation", selenium.getText("//div[@id='center']/div/h3"));
- selenium.type("newcollectionname", copyDirName);
- selenium.type("newcollectiondescription", "source folder for copy");
- selenium.click("submit");
+ selenium.type(INP_DIR_NAME, copyDirName);
+ selenium.type(INP_DIR_DESC, "source folder for copy");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals(copyDirName, selenium.getText("//div[@id='center']/div/div/ul/li[3]"));
@@ -198,7 +246,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=" + defaultDirName);
- selenium.click("submit");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals("copySrc", selenium.getText("//div[@id='center']/div/div/ul/li[5]"));
Assert.assertTrue(selenium.isElementPresent("link=" + defaultDirName));
@@ -221,22 +269,19 @@
public void testCopyCancelDirectory() {
String copyCancelDirName = "L" + "copyLDirName" + "Cancel";
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("newcollectionname"));
- Assert.assertTrue(selenium.isElementPresent("newcollectiondescription"));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_NAME));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_DESC));
Assert.assertEquals("Confirm Directory Creation", selenium.getText("//div[@id='center']/div/h3"));
- selenium.type("newcollectionname", copyCancelDirName);
- selenium.type("newcollectiondescription", "source folder for copy");
- selenium.click("submit");
+ selenium.type(INP_DIR_NAME, copyCancelDirName);
+ selenium.type(INP_DIR_DESC, "source folder for copy");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Home");
@@ -247,7 +292,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=" + defaultDirName);
- selenium.click("cancel");
+ selenium.click(INP_DIR_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isElementPresent("link=" + copyCancelDirName));
@@ -266,23 +311,19 @@
*/
@Test(enabled = true, dependsOnMethods = "testCreateDirectory", description = "Moving a directory.")
public void testMoveDirectory() {
- // selenium.setSpeed("3000");
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("newcollectionname"));
- Assert.assertTrue(selenium.isElementPresent("newcollectiondescription"));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_NAME));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_DESC));
Assert.assertEquals("Confirm Directory Creation", selenium.getText("//div[@id='center']/div/h3"));
- selenium.type("newcollectionname", moveDirName);
- selenium.type("newcollectiondescription", "source folder for move");
- selenium.click("submit");
+ selenium.type(INP_DIR_NAME, moveDirName);
+ selenium.type(INP_DIR_DESC, "source folder for move");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals(moveDirName, selenium.getText("//div[@id='center']/div/div/ul/li[3]"));
@@ -297,7 +338,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=" + defaultDirName);
- selenium.click("submit");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals(moveDirName, selenium.getText("//div[@id='center']/div/div/ul/li[5]"));
@@ -321,22 +362,19 @@
public void testMoveCancelDirectory() {
String moveCancelDirName = "X" + "moveXDirName" + "Cancel";
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=CMS");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ goToCms();
- selenium.select(SEL_CMS_ACTION, "label=Create Folder");
+ selenium.select(SEL_CMS_ACTION, "label="+LAB_ACT_CREATE_FOLDER);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- Assert.assertTrue(selenium.isElementPresent("newcollectionname"));
- Assert.assertTrue(selenium.isElementPresent("newcollectiondescription"));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_NAME));
+ Assert.assertTrue(selenium.isElementPresent(INP_DIR_DESC));
Assert.assertEquals("Confirm Directory Creation", selenium.getText("//div[@id='center']/div/h3"));
- selenium.type("newcollectionname", moveCancelDirName);
- selenium.type("newcollectiondescription", "source folder for move");
- selenium.click("submit");
+ selenium.type(INP_DIR_NAME, moveCancelDirName);
+ selenium.type(INP_DIR_DESC, "source folder for move");
+ selenium.click(INP_DIR_SUB);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Home");
@@ -347,7 +385,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=" + defaultDirName);
- selenium.click("cancel");
+ selenium.click(INP_DIR_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-06-17 21:29:16 UTC (rev 13470)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-06-18 11:33:53 UTC (rev 13471)
@@ -19,6 +19,16 @@
/** prefix for locator properties = cms.file. */
private final String casePfx = "cms.file.";
+ private final String MSG_VAL_INVALID_FILENAME = getMess("msg.val.invalid.filename","A value below is invalid");
+ private final String MSG_VAL_INVALID_DESC = getMess("msg.val.invalid.desc","A value below is invalid");
+ private final String MSG_VAL_INVALID_TITLE = getMess("msg.val.invalid.title","A value below is invalid");
+ private final String SEL_ACTION = getLoc(casePfx + "sel.action","//div[@id='center']/div/div/div[1]/div/select");
+ private final String INP_FC_SAVE = getLoc(casePfx + "inp.fc.save","save");
+ private final String INP_FC_LANGUAGE = getLoc(casePfx + "inp.fc.language","language");
+ private final String INP_FC_TITLE = getLoc(casePfx + "inp.fc.title","title");
+ private final String INP_FC_DESC = getLoc(casePfx + "inp.fc.desc","description");
+ private final String INP_FC_FILENAME = getLoc(casePfx + "inp.fc.filename","filename");
+
private final String TBL_CMS_FILEVER = getLoc(casePfx + "tbl.cms.filever", "//div[@id='center']/div/div/table");
public final String TBL_CMS_FILE = getLoc(casePfx + "tbl.cms.file", "//div[@id='center']/div/div/div[3]/table");
public final String TBL_FILE_PENDING = getLoc(casePfx + "tbl.file.pending", "//div[@id='center']/div/div/table[2]");
@@ -53,7 +63,6 @@
Assert.assertTrue(selenium.isElementPresent("link=private"));
Assert.assertTrue(selenium.isElementPresent("link=index.html"));
Assert.assertTrue(selenium.isElementPresent("link=project.html"));
- // Assert.assertTrue(selenium.isElementPresent("link=support.html"));
selenium.click("link=index.html");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isElementPresent("link=text/html"));
@@ -136,14 +145,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select", "label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", "newFile");
- selenium.type("description", "newFile description");
- selenium.type("title", "newFile title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, "newFile");
+ selenium.type(INP_FC_DESC, "newFile description");
+ selenium.type(INP_FC_TITLE, "newFile title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
/*
* Assert.assertTrue(selenium.isElementPresent(TBL_FILE_PENDING));
@@ -169,9 +178,58 @@
}
/**
- * Editing of a file. File name "file2edit" is created and then edited. Nothing is changed, but the file is saved again. It is asserted, that the version
- * got incremented.
+ * Tests input validation in file creation interface. Test navigates to file
+ * creation interface. It inputs XSS string into filename input and valid
+ * string to others inputs. After clicking saved it is asserted that error
+ * message about non valid name is present. Then it inputs XSS string into
+ * file description input and valid string to others inputs. After clicking
+ * saved it is asserted that error message about non valid description is
+ * present. Then it inputs XSS string into file title input and valid string
+ * to others inputs. After clicking saved it is asserted that error message
+ * about non valid title is present.
*/
+ @Test(enabled = true, description = "Simple file creation input validation.")
+ public void testXssCreateFile() {
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_ACTION, "label=Create File");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+
+ selenium.type(INP_FC_FILENAME, XSS_STR1);
+ selenium.type(INP_FC_DESC, "newFile description");
+ selenium.type(INP_FC_TITLE, "newFile title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_VAL_INVALID_FILENAME), "Input validation for filename is missing.");
+
+ selenium.type(INP_FC_FILENAME, "newFile");
+ selenium.type(INP_FC_DESC, XSS_STR1);
+ selenium.type(INP_FC_TITLE, "newFile title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_VAL_INVALID_DESC), "Input validation for file description is missing.");
+
+ selenium.type(INP_FC_FILENAME, "newFile");
+ selenium.type(INP_FC_DESC, "newFile description");
+ selenium.type(INP_FC_TITLE, XSS_STR1);
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_VAL_INVALID_TITLE), "Input validation for file title is missing.");
+
+ }
+
+ /**
+ * Editing of a file. File name "file2edit" is created and then edited.
+ * Nothing is changed, but the file is saved again. It is asserted, that the
+ * version got incremented.
+ */
@Test(enabled = true, description = "Editing of a file.")
public void testEditFile() {
@@ -179,14 +237,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select", "label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", "file2edit");
- selenium.type("description", "file2edit description");
- selenium.type("title", "file2edit title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, "file2edit");
+ selenium.type(INP_FC_DESC, "file2edit description");
+ selenium.type(INP_FC_TITLE, "file2edit title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
int row = findTableRow(TBL_CMS_FILEVER, "1.0", 2) + 1;
@@ -199,7 +257,7 @@
selenium.click("link=text/plain");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("save");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("1.1"));
Assert.assertTrue(selenium.isElementPresent("//div[@id='center']/div/div/table/tbody/tr[5]/td[3]/img"));
@@ -211,8 +269,10 @@
}
/**
- * Creation of an existing file. The file named "existingFile" is created. Then the system tries to create the same file again.
- * It is asserted that instead of creating a new instance of such a file, only its version is updated.
+ * Creation of an existing file. The file named "existingFile" is created.
+ * Then the system tries to create the same file again. It is asserted that
+ * instead of creating a new instance of such a file, only its version is
+ * updated.
*/
@Test(enabled = true, dependsOnMethods = "testDeleteFile", description = "Creation of an existing file.")
public void testCreateExistingFile() {
@@ -224,14 +284,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select", "label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", "existingFile");
- selenium.type("description", "existingFile description");
- selenium.type("title", "existingFile title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, "existingFile");
+ selenium.type(INP_FC_DESC, "existingFile description");
+ selenium.type(INP_FC_TITLE, "existingFile title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals("Czech", selenium.getText("link=Czech"));
Assert.assertEquals("text/plain", selenium.getText("link=text/plain"));
@@ -246,8 +306,10 @@
}
/**
- * File creation and moving to default directory. File named "fileToMove" is created in the root directory. Then the file is moved into the default directory.
- * At the end it is asserted, that file is appearing in the "default" directory, but it's not existing in the root directory.
+ * File creation and moving to default directory. File named "fileToMove" is
+ * created in the root directory. Then the file is moved into the default
+ * directory. At the end it is asserted, that file is appearing in the
+ * "default" directory, but it's not existing in the root directory.
*/
@Test(enabled = true, description = "File creation and moving to default directory.")
public void testMoveFile() {
@@ -255,14 +317,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select", "label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", "fileToMove");
- selenium.type("description", "fileToMove description");
- selenium.type("title", "fileToMove title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, "fileToMove");
+ selenium.type(INP_FC_DESC, "fileToMove description");
+ selenium.type(INP_FC_TITLE, "fileToMove title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals("Czech", selenium.getText("link=Czech"));
Assert.assertEquals("text/plain", selenium.getText("link=text/plain"));
@@ -294,8 +356,10 @@
}
/**
- * File creation and copying to default directory. File named "file2copy" is created in the root directory. Then the file is copied into the default directory.
- * At the end it is asserted, that file is appearing in the both of "default" and the root directory.
+ * File creation and copying to default directory. File named "file2copy" is
+ * created in the root directory. Then the file is copied into the default
+ * directory. At the end it is asserted, that file is appearing in the both
+ * of "default" and the root directory.
*/
@Test(enabled = true, description = "File creation and copying to default directory.")
public void testCopyFile() {
@@ -303,14 +367,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select", "label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", "file2copy");
- selenium.type("description", "file2copy description");
- selenium.type("title", "file2copy title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, "file2copy");
+ selenium.type(INP_FC_DESC, "file2copy description");
+ selenium.type(INP_FC_TITLE, "file2copy title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
int row = findTableRow(TBL_CMS_FILEVER, "1.0", 2) + 1;
@@ -406,14 +470,14 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select("//div[@id='center']/div/div/div[1]/div/select", "label=Create File");
+ selenium.select(SEL_ACTION, "label=Create File");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type("filename", name);
- selenium.type("description", name + " description");
- selenium.type("title", "existingFile title");
- selenium.select("language", "label=Czech");
- selenium.click("save");
+ selenium.type(INP_FC_FILENAME, name);
+ selenium.type(INP_FC_DESC, name + " description");
+ selenium.type(INP_FC_TITLE, "existingFile title");
+ selenium.select(INP_FC_LANGUAGE, "label=Czech");
+ selenium.click(INP_FC_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals("Czech", selenium.getText("link=Czech"));
Assert.assertEquals("text/plain", selenium.getText("link=text/plain"));
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-06-17 21:29:16 UTC (rev 13470)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-06-18 11:33:53 UTC (rev 13471)
@@ -18,9 +18,15 @@
// TODO - adding of simple portlet - more portlet types
@Test(groups = { "admin_portal" }, enabled = true, description = "Partal administrating.")
public class AdminPortalTestCase extends JBossPortalSeleniumTestCase {
-
/** prefix for locator properties = portal.admin. */
public final String casePfx = "portal.admin.";
+
+ private final String MSG_PORTAL_ERR_VALID = getMess(casePfx+"msg.portal.err.valid","is an invalid property path");
+ private final String MSG_PAGE_ERR_VALID = getMess(casePfx+"msg.page.err.valid","is an invalid property path");
+ private final String MSG_PROP_VAL_VALID = getMess(casePfx+"msg.prop.val.valid","is an invalid property value");
+ private final String MSG_PROP_NAME_VALID = getMess(casePfx+"msg.prop.name.valid","is an invalid property name");
+ private final String MSG_WINDOW_NAME_VALID = getMess(casePfx+"msg.window.name.valid","is an invalid window name");
+ private final String MSG_PAGE_NAME_VALID = getMess(casePfx+"msg.page.name.valid","is an invalid page name");
private final String SUB_SEC_SUBMIT = getLoc(casePfx + "sub.sec.submit", "//input[contains(@id,'common-edit-security-form:update')]");
private final String SUB_SEC_CANCEL = getLoc(casePfx + "sub.sec.cancel", "//input[contains(@id,'common-edit-security-form:cancel')]");
@@ -617,13 +623,7 @@
createPortal(portalName);
createPage(portalName, pageName);
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
clickIfVisible(LINK_PORTAL_HOME);
@@ -956,14 +956,7 @@
createPortal(portalName);
createPage(portalName, pageName);
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- // add
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
clickIfVisible(LINK_PORTAL_HOME);
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
@@ -1070,15 +1063,16 @@
}
+ /**
+ * Test input validation for portal create input. Tests navigates to portal
+ * admin interface. The XSS is typed into the create portal input and after
+ * submitting it is asserted that validation error message is present on the
+ * screen.
+ */
@Test(enabled = true)
public void testXssPortalCreate() {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
+
clickIfVisible(LINK_PORTALS_ID);
selenium.type(INPUT_PORTALNAME, XSS_STR1);
@@ -1088,18 +1082,30 @@
Assert.assertTrue(selenium.isTextPresent("is an invalid portal name"));
}
+
+ private void goToPortalAdmin() {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ }
+
+ /**
+ * Test input validation for page create input. Tests navigates to portal
+ * admin interface, creates a portal name "XssPortal" and clicks on it. The
+ * XSS is typed into the create page input and after submitting it is
+ * asserted that validation error message is present on the screen.
+ */
@Test(enabled = true)
public void testXssPageCreate() {
final String portalName = "XssPortal";
createPortal(portalName);
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
@@ -1111,9 +1117,17 @@
selenium.click(INPUT_SUBMIT_PAGECREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid page name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PAGE_NAME_VALID));
}
+ /**
+ * Test input validation for window create input. Tests navigates to portal
+ * admin interface, creates a portal name "XssPortal" and clicks on it. On
+ * the actual page new page named "XssPage" is created and it is clicked on
+ * it. The "who's online" portlet link is clicked and the XSS is typed into
+ * the create window input. After submitting (adding to center) it is
+ * asserted that validation error message is present on the screen.
+ */
@Test(enabled = true)
public void testXssWindowCreate() {
final String portalName = "XssPortal";
@@ -1122,13 +1136,7 @@
createPortal(portalName);
createPage(portalName, pageName);
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
clickIfVisible(LINK_PORTAL_HOME);
@@ -1150,17 +1158,31 @@
selenium.click(SUB_LAYOUT_ADD_CENTER);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid window name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_WINDOW_NAME_VALID));
}
+ /**
+ * Test input validation for many inputs in properties interface of specific
+ * portal. New portal named "XssPropertiesPortal" is created and the test
+ * navigates to its properties page. Firstly the XSS string is written into
+ * the custom property input (creating new property), after clicking on
+ * related submit button, it is asserted, that validation error message is
+ * present on the screen. Then a property with valid name "XssValuesProp" is
+ * created, and the XSS string is typed into its value input. After clicking
+ * on related submit button, it is asserted, that validation error message
+ * is present on the screen. At last the the first redirection input is
+ * filled with XSS string and after clicking on related submit button, it is
+ * asserted, that validation error message is present on the screen. The
+ * same is done for the second redirection input.
+ */
@Test(enabled = true)
public void testXssPortalProperties() {
final String portalName = "XssPropertiesPortal";
createPortal(portalName);
- // then property it
+ // then click on its properties button
selenium.click("link=Admin");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -1178,8 +1200,20 @@
selenium.click(SUB_PP_PROPADD);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_NAME_VALID));
+ selenium.type(INP_PP_PROPNAME, "XssValuesProp");
+ selenium.click(SUB_PP_PROPADD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ r = findTableRow(TBL_PP_PROPS, "XssValuesProp", 0) - 1;
+
+ selenium.type(MessageFormat.format(INP_PP_PROP_VAL, r), XSS_STR1);
+ selenium.click(SUB_PP_PROPVAL_UPDATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_VAL_VALID));
+
// redirection
check(CHK_PP_RES_CHECK, false);
@@ -1187,25 +1221,19 @@
selenium.type(INP_PP_RES_INPUT, XSS_STR1);
selenium.click(SUB_PP_ERROR_FORM_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property path"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PORTAL_ERR_VALID));
check(CHK_PPA_RES_CHECK, false);
waitFor(AJAX_LOAD);
selenium.type(INP_PPA_RES_SELECT, XSS_STR1);
selenium.click(SUB_PPA_FORM_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property path"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PAGE_ERR_VALID));
}
private void createPortal(String name) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
selenium.type(INPUT_PORTALNAME, name);
@@ -1214,12 +1242,7 @@
}
private void createPage(String portalName, String pageName) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(TAB_PORTALOBJ_ID);
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java 2009-06-17 21:29:16 UTC (rev 13470)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java 2009-06-18 11:33:53 UTC (rev 13471)
@@ -15,10 +15,15 @@
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
public class DashboardsTestCase extends JBossPortalSeleniumTestCase {
-
+
/** prefix for locator properties = portal.dash. */
public final String casePfx = "portal.dash.";
+ private final String MSG_PROP_UPDATE_VALID = getMess(casePfx+"msg.prop.update.valid","is an invalid property value");
+ private final String MSG_PROP_ADD_VALID = getMess(casePfx+"msg.prop.add.valid","is an invalid property name");
+ private final String MSG_PORTAL_ERR_VALID = getMess(casePfx+"msg.portal.err.valid","is an invalid property path");
+ private final String MSG_PAGE_ERR_VALID = getMess(casePfx+"msg.page.err.valid","is an invalid property path");
+
private final String T_DH_SUB_UPDATE = getLoc(casePfx + "t.dh.sub.update", "//form[contains(@id,'common-edit-theme-form')]/input[@type='submit']");
private final String T_DH_SEL_RENDERSET = getLoc(casePfx + "t.dh.sel.renderset", "//select[contains(@id,'common-edit-theme-form:renderSet')]");
private final String T_DH_SEL_THEME = getLoc(casePfx + "t.dh.sel.theme", "//select[contains(@id,'common-edit-theme-form:theme')]");
@@ -76,14 +81,21 @@
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(propName));
}
-
+
+ /**
+ * Testing the input for adding a property for validation. Test navigates to
+ * portal admin dashboard configuration interface. It types the XSS to
+ * property name input. After clicking on relevant submit button it is
+ * asserted that relevant message about non valid input is present on the
+ * screen.
+ */
@Test(enabled = true)
public void testXssPropAdd() {
selenium.type(INPUT_PROP_NAME, XSS_STR1);
selenium.click(SUBMIT_ADD_PROP);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_ADD_VALID));
}
/**
@@ -109,14 +121,19 @@
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals(selenium.getValue(MessageFormat.format(T_PROPS_INPUT_VALUE, r - 1)), value, "Updated value not found.");
- Assert.assertTrue(selenium.isTextPresent("is an invalid property value"));
}
-
+
+ /**
+ * Tests input validation for property value input. Test navigates to
+ * dashboards configuration in portal admin. It creates a new property named
+ * "XssStrProp". Then it tries to add new value to it - XSS string. After
+ * pressing the relevant update button, it is asserted, that the input
+ * validation message is present.
+ */
@Test(enabled = true)
public void testXssPropUpdate() {
final String propName = "XssStrProp";
-
Assert.assertFalse(selenium.isTextPresent(propName));
selenium.type(INPUT_PROP_NAME, propName);
selenium.click(SUBMIT_ADD_PROP);
@@ -129,7 +146,7 @@
selenium.click(SUBMIT_UPDATE_VALUE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_UPDATE_VALID));
}
/**
@@ -144,14 +161,12 @@
Assert.assertFalse(selenium.isTextPresent(propName));
selenium.type(INPUT_PROP_NAME, propName);
selenium.click(SUBMIT_ADD_PROP);
- System.out.println("WATCH OUT!");
- selenium.setSpeed("6000");
+
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(propName));
int r = findTableRow(TABLE_PROPS, propName, 0);
-
- System.out.println(MessageFormat.format(T_PROPS_LINK_DEL, r - 1));
+
selenium.click(MessageFormat.format(T_PROPS_LINK_DEL, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -169,24 +184,39 @@
// TODO - no assertions done
@Test(enabled = true)
public void testPortalError() {
- selenium.select(T_PO_SEL_ACCESS, "label=Redirect to the specified resource");
+ selenium.select(T_PO_SEL_ACCESS, "label="+"Redirect to the specified resource");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PO_SEL_UNAVAIL, "label=Redirect to the specified resource");
+ selenium.select(T_PO_SEL_UNAVAIL, "label="+"Redirect to the specified resource");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PO_SEL_PNF, "label=Redirect to the specified resource");
+ selenium.select(T_PO_SEL_PNF, "label="+"Redirect to the specified resource");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.type(T_PO_INP_PAGEADD, "/WEB-INF/jsp/error/portalX.jsp");
selenium.click(T_PO_SUB_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
+
+ logoutIfPossible();
+ login("admin", "admin");
+ goToDash();
+
+ Assert.assertEquals(selenium.getSelectedLabel(T_PO_SEL_ACCESS),"Redirect to the specified resource");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PO_SEL_UNAVAIL),"Redirect to the specified resource");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PO_SEL_PNF),"Redirect to the specified resource");
+ Assert.assertEquals(selenium.getValue(T_PO_INP_PAGEADD),"/WEB-INF/jsp/error/portalX.jsp");
}
+ /**
+ * Testing input validation for portal error redirection. The input for error
+ * redirection for portals is filled with XSS string and after pressing the
+ * relevant submit button, the presence of correct validation error message
+ * is asserted.
+ */
@Test(enabled = true)
public void testXssPortalError() {
selenium.type(T_PO_INP_PAGEADD, XSS_STR1);
selenium.click(T_PO_SUB_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property path"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PORTAL_ERR_VALID));
}
/**
@@ -197,42 +227,77 @@
// TODO - no assertions done
@Test(enabled = true)
public void testPageError() {
- selenium.select(T_PA_SEL_ACCESS, "label=Display the default error message");
+ selenium.select(T_PA_SEL_ACCESS, "label="+"Display the default error message");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PA_SEL_CONTROL, "label=Redirect to the specified resource");
+ selenium.select(T_PA_SEL_CONTROL, "label="+"Redirect to the specified resource");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PA_SEL_ERROR, "label=Remove the resource from page");
+ selenium.select(T_PA_SEL_ERROR, "label="+"Remove the resource from page");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PA_SEL_INTERN, "label=Display the default error message");
+ selenium.select(T_PA_SEL_INTERN, "label="+"Display the default error message");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(T_PA_SEL_PNF, "label=Redirect to the specified resource");
+ selenium.select(T_PA_SEL_PNF, "label="+"Redirect to the specified resource");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.type(T_PA_INP_PAGEADD, "/WEB-INF/jsp/error/pageY.jsp");
selenium.click(T_PA_SUB_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
+
+ logoutIfPossible();
+ login("admin", "admin");
+ goToDash();
+
+ Assert.assertEquals(selenium.getSelectedLabel(T_PA_SEL_ACCESS),"Display the default error message");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PA_SEL_CONTROL),"Redirect to the specified resource");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PA_SEL_ERROR),"Remove the resource from page");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PA_SEL_INTERN),"Display the default error message");
+ Assert.assertEquals(selenium.getSelectedLabel(T_PA_SEL_PNF),"Redirect to the specified resource");
+ Assert.assertEquals(selenium.getValue(T_PA_INP_PAGEADD),"/WEB-INF/jsp/error/pageY.jsp");
}
+ /**
+ * Testing input validation for page error redirection. The input for error
+ * redirection for pages is filled with XSS string and after pressing the
+ * relevant submit button, the presence of correct validation error message
+ * is asserted.
+ */
@Test(enabled = true)
public void testXssPageError() {
selenium.type(T_PA_INP_PAGEADD, XSS_STR1);
selenium.click(T_PA_SUB_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid property path"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PAGE_ERR_VALID));
}
/**
* Testing of dashboard theme. The layout, theme and renderset are changed,
* but no assertion is done.
*/
- // TODO - no assertions done
@Test(enabled = true)
public void testDashboardTheme() {
-
safeSelect(T_DH_SEL_LAYOUT, "1column");
- safeSelect(T_DH_SEL_RENDERSET, "default");
- safeSelect(T_DH_SEL_THEME, "nphalanx");
+ safeSelect(T_DH_SEL_THEME, "maple");
+ safeSelect(T_DH_SEL_RENDERSET, "default");
clickAndWait(T_DH_SUB_UPDATE);
+
+ logoutIfPossible();
+ login("admin","admin");
+ goToDash();
+
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_LAYOUT),"1column");
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_THEME),"maple");
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_RENDERSET),"default");
+
+
+ //TODO reconcile if restoring the default properties is needed
+ /*
+ logoutIfPossible();
+ login("admin","admin");
+ goToDash();
+
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_LAYOUT),"1column");
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_RENDERSET),"default");
+ Assert.assertEquals(selenium.getSelectedLabel(T_DH_SEL_THEME),"maple");
+ */
}
Modified: branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java 2009-06-17 21:29:16 UTC (rev 13470)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java 2009-06-18 11:33:53 UTC (rev 13471)
@@ -311,6 +311,7 @@
goToProperties();
// add original drag and drop
+ selenium.setSpeed("5000");
selectIfNotSelected(SEL_PREDEF_PROP, "Drag and drop");
selenium.click(SUB_POR_PROPERTY);
selenium.waitForPageToLoad(PAGE_LOAD);
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-06-17 21:29:16 UTC (rev 13470)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java 2009-06-18 11:33:53 UTC (rev 13471)
@@ -13,9 +13,11 @@
*/
public class PortletDefinitionsTestCase extends JBossPortalSeleniumTestCase{
+
/** prefix for locator properties = portal.port.def.*/
public final String casePfx = "portal.port.def.";
+ private final String MSG_INS_NAME_VALID = getMess(casePfx+"msg.ins.name.valid","is an invalid instance name");
private final String T_LINK_PREF = getLoc(casePfx+"t.link.pref","//a[contains(@id,''def-list:portlet-pref-{0}'')]");
private final String SUBMIT_CREATE_INST = getLoc(casePfx+"submit.create.inst","//input[contains(@name,'add_instance_form:j_id19')]");
private final String INPUT_INSTANCE_NAME = getLoc(casePfx+"input.instance.name","//input[contains(@id,'add_instance_form:instanceId')]");
@@ -105,7 +107,7 @@
selenium.type(INPUT_INSTANCE_NAME, XSS_STR1);
selenium.click(SUBMIT_CREATE_INST);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid instance name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_INS_NAME_VALID));
}
/**
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-06-17 21:29:16 UTC (rev 13470)
+++ branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java 2009-06-18 11:33:53 UTC (rev 13471)
@@ -21,6 +21,9 @@
/** prefix for locator properties = portal.port.ins. */
public final String casePfx = "portal.port.ins.";
+ private final String MSG_PI_PROP_APPEND_VALID = getMess(casePfx+"msg.pi.prop.append.valid","is an invalid instance name");
+ private final String MSG_PI_PROP_UPDATE_VALID = getMess(casePfx+"msg.pi.prop.update.valid","is an invalid instance name");
+ private final String MSG_INV_DIS_NAME = getMess(casePfx+"","is an invalid display name");
private final String TAB_PORTLET_INSTANCES = getLoc(casePfx + "tab.portlet.instances", "//table[contains(@id,'instancesTable2')]");
private final String UL_PAGINATOR = getLoc(casePfx + "ul.paginator", "//ul[@class='pagination property-container']");
private final String SUBMIT_SECURITY_UPDATE = getLoc(casePfx + "submit.security.update", "//input[contains(@id,'common-edit-security-form:update')]");
@@ -91,7 +94,14 @@
clickAndWait(SUBMIT_MODIFY_NAME);
Assert.assertTrue(findTableRow(TABLE_DISPNAMES, name, 1) >= 0);
}
-
+
+ /**
+ * Test input validation for portlet instance name. Test navigates into
+ * portlet instance of counter portlet. It selects "english" as a language
+ * for the name to be added and types XSS string to the name input. After
+ * pressing the relevant submit button it is asserted that relevant error
+ * message about non valid input is present.
+ */
@Test(enabled = true)
public void testXssAddName() {
int r = traversePortlets(NAME_COUNTPORT, 0);
@@ -99,11 +109,10 @@
safeSelect(SELECT_LANGUAGE, "English");
-
selenium.type(INPUT_NAME, XSS_STR1);
clickAndWait(SUBMIT_MODIFY_NAME);
- Assert.assertTrue(selenium.isTextPresent("is an invalid display name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_INV_DIS_NAME));
}
/**
@@ -558,22 +567,30 @@
selenium.waitForPageToLoad(PAGE_LOAD);
}
-
+
+ /**
+ * Testing input validation for portlet instance properties. It navigates to
+ * preferences interface for CurrentUsersPortletInstance portlet instance.
+ * Then it clicks on "guestNumber" property and two new inputs appears on
+ * the screen. XSS string is typed into the "Edit existing values" and after
+ * pressing the relevant submit button, it is asserted, that the validation
+ * error message is present. XSS string is typed into the "Append a value "
+ * and after pressing the relevant submit button, it is asserted, that the
+ * validation error message is present.
+ */
@Test(enabled = true)
public void testXssPreferences() {
int r = traversePortlets(NAME_COUNTPORT, 0);
clickAndWait(MessageFormat.format(LNK_PREF_BUTTON, r));
- // selenium.click(LINK_CURUSER_PREFERENCES);
-
+
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(SUBMIT_PREF_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
r = traversePortlets(NAME_COUNTPORT, 0);
clickAndWait(MessageFormat.format(LNK_PREF_BUTTON, r));
-
- selenium.waitForPageToLoad(PAGE_LOAD);
+
Assert.assertTrue(findTableRow(TABLE_PREF_KEY, "guestNumber", 0) >= 0);
selenium.click(LINK_PREF_GUESTNUM);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -585,12 +602,12 @@
selenium.type(INPUT_PREF_APPEND, XSS_STR1);
selenium.click(INPUT_PREF_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid instance name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PI_PROP_APPEND_VALID), "validation message wrong or missing.");
selenium.type(INPUT_PREF_NEWVAL, XSS_STR1);
selenium.click(SUBMIT_PREF_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("is an invalid instance name"));
+ Assert.assertTrue(selenium.isTextPresent(MSG_PI_PROP_UPDATE_VALID), "validation message wrong or missing.");
}
/**
14 years, 11 months
JBoss Portal SVN: r13470 - in branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal: wsrp and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-06-17 17:29:16 -0400 (Wed, 17 Jun 2009)
New Revision: 13470
Modified:
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java
branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
Log:
- JBPORTAL-2425:
+ WSRPPortletURL.create is now able to handle extra characters in an uninterpreted way to allow for concatenation
+ Adapted toString methods.
- Fixed a bug in WSRPResourceURL.dealWithSpecificParams that wasn't properly removing consumed parameters.
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java 2009-06-17 21:24:28 UTC (rev 13469)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/test/wsrp/other/WSRPPortletURLTestCase.java 2009-06-17 21:29:16 UTC (rev 13470)
@@ -132,6 +132,21 @@
checkInvalidURL(stillInvalid, "Should have detected missing end token", WSRPRewritingConstants.END_WSRP_REWRITE);
}
+ public void testExtraRelaxedValidation()
+ {
+ String valid = "wsrp_rewrite?wsrp-urlType=resource&wsrp-url=http%3A%2F%2Flocalhost%3A8080%2Fhelloworld&wsrp-requiresRewrite=true/wsrp_rewrite/helloworld.jar";
+ WSRPPortletURL url = WSRPPortletURL.create(valid);
+ assertEquals("http://localhost:8080/helloworld/helloworld.jar", url.toString());
+
+ String invalid = "wsrp_rewrite?wsrp-urlType=resource&wsrp-url=http%3A%2F%2Flocalhost%3A8080%2Fhelloworld&wsrp-requiresRewrite=true/wsrp_rewrite&foo=bar/helloworld.jar";
+ checkInvalidURL(invalid, "Should have detected improper position of end token", WSRPRewritingConstants.END_WSRP_REWRITE);
+
+ WSRPPortletURL.setStrict(false);
+ String validInRelaxedMode = "wsrp_rewrite?wsrp-urlType=resource&wsrp-url=http%3A%2F%2Flocalhost%3A8080%2Fhelloworld&wsrp-requiresRewrite=true/wsrp_rewrite&foo=bar/helloworld.jar";
+ url = WSRPPortletURL.create(validInRelaxedMode);
+ assertEquals("http://localhost:8080/helloworld&foo=bar/helloworld.jar", url.toString());
+ }
+
public void testExtraParameters()
{
String validInRelaxedMode = "wsrp_rewrite?wsrp-urlType=render&foo=bar/wsrp_rewrite";
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java 2009-06-17 21:24:28 UTC (rev 13469)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPPortletURL.java 2009-06-17 21:29:16 UTC (rev 13470)
@@ -65,9 +65,11 @@
private WindowState windowState;
/** Are we using strict rewriting parameters validation mode? */
- private static boolean strict = true;
+ protected static boolean strict = true;
/** Holds extra parameters if we are in relaxed validation mode */
private Map<String, String> extraParams;
+ /** Holds extra data after URL in relaxed mode */
+ protected String extra;
/** Remember position of extra parameters wrt end token */
private boolean extraParamsAfterEndToken = false;
@@ -115,6 +117,7 @@
{
WSRPPortletURL other = (WSRPPortletURL)portletURL;
url.setParams(other.extraParams, other.toString());
+ url.setExtra(other.extra);
}
return url;
@@ -131,6 +134,7 @@
String originalURL = encodedURL;
boolean extraAfterEnd = false;
+ String extra = null;
// URL needs to start wsrp_rewrite? and end with /wsrp_rewrite in strict validation mode
if (!encodedURL.startsWith(WSRPRewritingConstants.BEGIN_WSRP_REWRITE))
@@ -139,25 +143,44 @@
}
if (!encodedURL.endsWith(WSRPRewritingConstants.END_WSRP_REWRITE))
{
- if (strict)
+ // first remove prefix only (as suffix is not at the end of the string)
+ encodedURL = encodedURL.substring(WSRPRewritingConstants.WSRP_REWRITE_PREFIX_LENGTH);
+
+ // end token should be marked by the first / in the URL and extract it
+ int endTokenIndex = encodedURL.indexOf('/');
+ if (endTokenIndex < 0)
{
- throw new IllegalArgumentException(encodedURL + " does not end with " + WSRPRewritingConstants.END_WSRP_REWRITE);
+ throw new IllegalArgumentException(originalURL + " does not contain " + WSRPRewritingConstants.END_WSRP_REWRITE);
}
+
+ encodedURL = encodedURL.substring(0, endTokenIndex)
+ + encodedURL.substring(endTokenIndex + WSRPRewritingConstants.WSRP_REWRITE_SUFFIX_LENGTH);
+
+ /*
+ we need to deal with the case when a WSRP URL is concatenated to a context path using something similar to:
+ renderResponse.encodeURL(renderRequest.getContextPath()) in which case, there should be a slash still present.
+ How to process further depends on whether we're in strict mode or not...
+ */
+ int concatenationIndex = encodedURL.indexOf('/');
+
+ if (strict && concatenationIndex != endTokenIndex)
+ {
+ // in strict mode, the only character available after the end token is the concatenating slash
+ throw new IllegalArgumentException(encodedURL + " does not end with "
+ + WSRPRewritingConstants.END_WSRP_REWRITE + " or does not appear to be a valid concatenation of URLs.");
+ }
else
{
- // first remove prefix only (as suffix is not at the end of the string)
- encodedURL = encodedURL.substring(WSRPRewritingConstants.WSRP_REWRITE_PREFIX_LENGTH);
-
- // find end token and extract it
- int endTokenIndex = encodedURL.indexOf('/');
- if (endTokenIndex < 0)
+ // deal with extra characters: this should only happen when the URL is concatenated to form a longer one
+ // hence, it should be possible to have param-value pairs followed by a slash '/' then characters.
+ // Anything after the slash will be kept as is, uninterpreted.
+ if (concatenationIndex != -1)
{
- throw new IllegalArgumentException(originalURL + " does not contain " + WSRPRewritingConstants.END_WSRP_REWRITE);
+ String tmp = encodedURL;
+ encodedURL = encodedURL.substring(0, concatenationIndex);
+ extra = tmp.substring(concatenationIndex);
}
- encodedURL = encodedURL.substring(0, endTokenIndex)
- + encodedURL.substring(endTokenIndex + WSRPRewritingConstants.WSRP_REWRITE_SUFFIX_LENGTH);
-
// remember that we should position the extra params after the end token
extraAfterEnd = true;
}
@@ -228,6 +251,7 @@
url.setParams(params, originalURL);
url.setExtraParamsAfterEndToken(extraAfterEnd);
+ url.setExtra(extra);
return url;
}
@@ -378,16 +402,17 @@
if (extraParams != null && !extraParams.isEmpty())
{
StringBuffer extras = new StringBuffer();
- for (Map.Entry<String, String> entry : extraParams.entrySet())
- {
- createURLParameter(extras, entry.getKey(), entry.getValue());
- }
+ appendExtraParams(extras);
// if we had extra params, we need to figure out where thwy should be positioned wrt end token
if (extraParamsAfterEndToken)
{
sb.append(WSRPRewritingConstants.END_WSRP_REWRITE);
sb.append(extras);
+ if (extra != null)
+ {
+ sb.append(extra);
+ }
}
else
{
@@ -403,6 +428,17 @@
return sb.toString();
}
+ protected void appendExtraParams(StringBuffer buffer)
+ {
+ if (extraParams != null)
+ {
+ for (Map.Entry<String, String> entry : extraParams.entrySet())
+ {
+ createURLParameter(buffer, entry.getKey(), entry.getValue());
+ }
+ }
+ }
+
protected abstract void appendEnd(StringBuffer sb);
protected final void createURLParameter(StringBuffer sb, String name, String value)
@@ -522,4 +558,9 @@
{
this.extraParamsAfterEndToken = extraParamsAfterEndToken;
}
+
+ public void setExtra(String extra)
+ {
+ this.extra = extra;
+ }
}
Modified: branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java
===================================================================
--- branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2009-06-17 21:24:28 UTC (rev 13469)
+++ branches/JBoss_Portal_Branch_2_7/wsrp/src/main/org/jboss/portal/wsrp/WSRPResourceURL.java 2009-06-17 21:29:16 UTC (rev 13470)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2006, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -104,11 +104,12 @@
if (paramValue != null)
{
requiresRewrite = Boolean.valueOf(paramValue);
+ params.remove(WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE);
}
else
{
throw new IllegalArgumentException("The parsed parameters don't contain a value for the required "
- + WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE + " parameter in " + originalURL);
+ + WSRPRewritingConstants.RESOURCE_REQUIRES_REWRITE + " parameter in " + originalURL);
}
paramValue = getRawParameterValueFor(params, WSRPRewritingConstants.RESOURCE_URL);
@@ -135,10 +136,11 @@
catch (MimeTypeParseException e)
{
log.debug("Couldn't determine (based on extension) MIME type of file: " + file
- + "\nRetrieving the associated resource will probably fail.");
+ + "\nRetrieving the associated resource will probably fail.");
}
isSupported(mediaType);
+ params.remove(WSRPRewritingConstants.RESOURCE_URL);
}
catch (MalformedURLException e)
{
@@ -148,7 +150,7 @@
else
{
throw new IllegalArgumentException("The parsed parameters don't contain a value for the required "
- + WSRPRewritingConstants.RESOURCE_URL + " parameter in " + originalURL);
+ + WSRPRewritingConstants.RESOURCE_URL + " parameter in " + originalURL);
}
}
@@ -161,7 +163,7 @@
if (!type.isAllowedSubType(mediaType))
{
log.debug("MIME type '" + mediaType
- + "' is not currently supported. Retrieving the associated resource will probably fail.");
+ + "' is not currently supported. Retrieving the associated resource will probably fail.");
return;
}
}
@@ -171,6 +173,16 @@
public String toString()
{
- return resourceURL.toExternalForm();
+ StringBuffer result = new StringBuffer(resourceURL.toExternalForm());
+
+ appendExtraParams(result);
+
+ // append extra characters if we have some
+ if (extra != null)
+ {
+ result.append(extra);
+ }
+
+ return result.toString();
}
}
14 years, 11 months
JBoss Portal SVN: r13469 - in modules/common/trunk/common/src: test/java/org/jboss/portal/test/common/util and 1 other directory.
by portal-commits@lists.jboss.org
Author: chris.laprun(a)jboss.com
Date: 2009-06-17 17:24:28 -0400 (Wed, 17 Jun 2009)
New Revision: 13469
Modified:
modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java
Log:
- Added VALID_ASCII_CLASS_NAME to detect ASCII class names in validation.
Modified: modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java
===================================================================
--- modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2009-06-17 21:22:49 UTC (rev 13468)
+++ modules/common/trunk/common/src/main/java/org/jboss/portal/common/util/ParameterValidation.java 2009-06-17 21:24:28 UTC (rev 13469)
@@ -37,6 +37,7 @@
{
public final static Pattern CSS_DISTANCE = Pattern.compile("\\d+\\W*(em|ex|px|in|cm|mm|pt|pc|%)?");
public final static Pattern XSS_CHECK = Pattern.compile("([^<>\\(\\)=\\\\](?<!%5C))*", Pattern.CASE_INSENSITIVE);
+ public final static Pattern VALID_ASCII_CLASS_NAME = Pattern.compile("([a-z][a-z0-9_]*\\.)*[A-Z][A-Za-z0-9_$]*");
/**
* Implements a behavior to be executed in case a value fails to be validated. Uses the Chain of responsibility
Modified: modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java
===================================================================
--- modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java 2009-06-17 21:22:49 UTC (rev 13468)
+++ modules/common/trunk/common/src/test/java/org/jboss/portal/test/common/util/ParameterValidationTestCase.java 2009-06-17 21:24:28 UTC (rev 13469)
@@ -121,6 +121,17 @@
}
+ public void testSanitizeFromPatternClassNameCheck()
+ {
+ assertNull(ParameterValidation.sanitizeFromPattern("foo", ParameterValidation.VALID_ASCII_CLASS_NAME, null));
+ assertNull(ParameterValidation.sanitizeFromPattern("com.example.foo", ParameterValidation.VALID_ASCII_CLASS_NAME, null));
+ assertNull(ParameterValidation.sanitizeFromPattern("com.example.foo.1Foo", ParameterValidation.VALID_ASCII_CLASS_NAME, null));
+ assertEquals("Foo", ParameterValidation.sanitizeFromPattern("Foo", ParameterValidation.VALID_ASCII_CLASS_NAME, null));
+ assertEquals("com.example.Foo", ParameterValidation.sanitizeFromPattern("com.example.Foo", ParameterValidation.VALID_ASCII_CLASS_NAME, null));
+ assertEquals("com.example.Foo$_1", ParameterValidation.sanitizeFromPattern("com.example.Foo$_1", ParameterValidation.VALID_ASCII_CLASS_NAME, null));
+ assertEquals("com2.example.Foo$_1", ParameterValidation.sanitizeFromPattern("com2.example.Foo$_1", ParameterValidation.VALID_ASCII_CLASS_NAME, null));
+ }
+
public void testSanitizeFromValuesNullValue()
{
String defaultValue = "default";
14 years, 11 months