JBoss Portal SVN: r13538 - in branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium: sso and 1 other directory.
by portal-commits@lists.jboss.org
Author: mposolda(a)redhat.com
Date: 2009-07-10 10:53:03 -0400 (Fri, 10 Jul 2009)
New Revision: 13538
Modified:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
Log:
Refactor SSO and Ldap tests to remove compilation failures.
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-07-10 14:53:03 UTC (rev 13538)
@@ -30,7 +30,7 @@
private final String INP_USER_SEARCH_NEXT = getLoc(casePfx + "inp.user.search.next", "//input[contains(@id,'search-user-form1:next-page')]");
private final String SEL_SEARCHUSER_LIMIT = getLoc(casePfx + "sel.searchuser.limit", "//select[contains(@id,'search-user-form:limit')]");
- private final String SUB_EDIT_PROF = getLoc(casePfx + "sub.edit.prof", "//input[contains(@id,'profile-form:submit')]");
+ final String SUB_EDIT_PROF = getLoc(casePfx + "sub.edit.prof", "//input[contains(@id,'profile-form:submit')]");
private final String SUB_PAGIN_LEFT = getLoc(casePfx + "sub.pagin.left", INP_USER_SEARCH_PREV);
private final String SUB_PAGIN_RIGHT = getLoc(casePfx + "sub.pagin.right", INP_USER_SEARCH_NEXT);
@@ -89,7 +89,7 @@
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}'']");
+ final String CHK_ROLE = getLoc(casePfx + "chk.role", "//input[contains(@name,''assign-roles-form:roles'') and @value=''{0}'']");
private final String MSG_CREATE_ROLE = getMess(casePfx + "chk.role", "Create role");
@@ -102,7 +102,7 @@
return MessageFormat.format(LNK_T_USRLIST_DEL, r - 1);
}
- private String butUsrRol_id(String userName) {
+ String butUsrRol_id(String userName) {
String table = TBL_USERLIST;
int r = findTableRow(table, userName, 0);
return MessageFormat.format(LNK_T_USRLIST_ROLES, r - 1);
@@ -723,7 +723,7 @@
Assert.assertTrue(selenium.isTextPresent("is an invalid"));
}
- private void goToEdit(String userName, String userMail) {
+ void goToEdit(String userName, String userMail) {
searchUser(userName, userMail);
int r = findTableRow(TBL_USERLIST, userName, 0);
@@ -957,7 +957,7 @@
}
- private void deleteUser(String username, String email) {
+ void deleteUser(String username, String email) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_ADMIN);
@@ -998,7 +998,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
}
- private void createRole(String roleName, String roleDisplayName) {
+ void createRole(String roleName, String roleDisplayName) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_ADMIN);
@@ -1025,7 +1025,7 @@
Assert.assertTrue(selenium.isTextPresent(roleDisplayName), "Display name of newly created role is missing.");
}
- private void deleteRole(String roleName) {
+ void deleteRole(String roleName) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_ADMIN);
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java 2009-07-10 14:53:03 UTC (rev 13538)
@@ -24,9 +24,7 @@
private final String PORTAL_CYRIL_MAIL = "cyril(a)redhat.com";
private final String PORTAL_CYRIL_ROLE = "Cyril";
- // TODO: uncomment and remove getProp part
-
- /*private final String ADR_PORTAL = getLoc(casePfx+"adr.portal","/portal");
+ 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");
@@ -49,33 +47,8 @@
private final String CAS_LOGOUT_SUCCESSFULL = getMess(casePfx + "cas.logout.succ", "Logout successful");
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 ADR_PORTAL = getProp(casePfx+"adr.portal","/portal");
- private final String ADR_PORTAL_ADMIN = getProp(casePfx+"adr.portal.admin","/portal/auth/portal/admin");
- private final String ADR_PORTAL_DEFAULT = getProp(casePfx+"adr.portal.default","/portal/auth/portal/default");
-
- private final String LINK_LOGIN = getProp(casePfx+"lnk.login", "link=Login");
- private final String LINK_ADMIN = getProp(casePfx+"lnk.admin", "link=Admin");
- private final String LINK_WEATHER = getProp(casePfx+"lnk.weather", "link=Weather");
- private final String LINK_COPY_DASHBOARD = getProp(casePfx+"lnk.cp.dashboard", "link=Copy to my dashboard");
- private final String LINK_CONFIGURE_DASHBOARD = getProp(casePfx+"lnk.conf.dashboard", "link=Configure dashboard");
- private final String LINK_DASHBOARD = getProp(casePfx+"lnk.dashboard", "link=Dashboard");
- private final String LINK_LOGOUT = getProp(casePfx+"lnk.logout", "link=Logout");
- private final String FORBIDDEN_ELEMENT = getProp(casePfx+"forbidden.element", "//h1");
-
- private final String CAS_INPUT_USERNAME = getProp(casePfx + "cas.input.username", "username");
- private final String CAS_INPUT_PASSWORD = getProp(casePfx + "cas.input.password", "password");
- private final String CAS_SUBMIT_LOGIN = getProp(casePfx + "cas.submit.login", "//input[@value='LOGIN']");
- private final String CAS_IMAGE = getProp(casePfx + "cas.image", "//img[@alt='Central Authentication Service']");
-
- private final String CAS_INVALID_AUTH = getProp(casePfx + "cas.invalid.auth", "The credentials you provided cannot be determined to be authentic.");
- private final String CAS_LOGIN_MESSAGE = getProp(casePfx + "cas.login.mess", "Enter your JA-SIG NetID and Password.");
- private final String CAS_LOGOUT_SUCCESSFULL = getProp(casePfx + "cas.logout.succ", "Logout successful");
-
- private final String PORTAL_LOGGED_IN_AS_MESSAGE = getProp(casePfx + "logged.in.mess", "Logged in as: ");
- private final String PORTAL_FORBIDDEN_MESS = getProp(casePfx + "forbidden.mess", "HTTP Status 403 -");
-
@BeforeMethod(groups = { "log" })
private void logoutBeforeTest() {
logoutIfPossible();
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java 2009-07-10 14:53:03 UTC (rev 13538)
@@ -24,9 +24,7 @@
private final String PORTAL_JOSEPH_MAIL = "joseph(a)redhat.com";
private final String PORTAL_JOSEPH_ROLE = "Joseph";
- // TODO: uncomment and remove getProp part
-
- /*private final String ADR_PORTAL = getLoc(casePfx+"adr.portal","/portal");
+ 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");
@@ -59,42 +57,7 @@
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");
- */
- private final String ADR_PORTAL = getProp(casePfx+"adr.portal","/portal");
- private final String ADR_PORTAL_ADMIN = getProp(casePfx+"adr.portal.admin","/portal/auth/portal/admin");
- private final String ADR_PORTAL_DEFAULT = getProp(casePfx+"adr.portal.default","/portal/auth/portal/default");
- private final String ADR_PORTAL_SESSION_TEST = getProp(casePfx+"adr.portal.test.session","/portal/auth/portal/default/Test/Session+test");
-
- private final String LINK_LOGIN = getProp(casePfx+"lnk.login", "link=Login");
- private final String LINK_ADMIN = getProp(casePfx+"lnk.admin", "link=Admin");
- private final String LINK_WEATHER = getProp(casePfx+"lnk.weather", "link=Weather");
- private final String LINK_COPY_DASHBOARD = getProp(casePfx+"lnk.cp.dashboard", "link=Copy to my dashboard");
- private final String LINK_CONFIGURE_DASHBOARD = getProp(casePfx+"lnk.conf.dashboard", "link=Configure dashboard");
- private final String LINK_DASHBOARD = getProp(casePfx+"lnk.dashboard", "link=Dashboard");
- private final String LINK_LOGOUT = getProp(casePfx+"lnk.logout", "link=Logout");
- private final String FORBIDDEN_ELEMENT = getProp(casePfx+"forbidden.element", "//h1");
-
- private final String JOSSO_INPUT_USERNAME = getProp(casePfx + "josso.input.username", "josso_username");
- private final String JOSSO_INPUT_PASSWORD = getProp(casePfx + "josso.input.password", "josso_password");
- private final String JOSSO_SUBMIT_LOGIN = getProp(casePfx + "josso.submit.login", "//input[@value='Login']");
- private final String JOSSO_IMAGE = getProp(casePfx + "josso.image", "//img[@alt='Java Open Single SignOn']");
-
- private final String JOSSO_INVALID_AUTH = getProp(casePfx + "josso.invalid.auth", "Invalid Authentication Information");
-
- private final String PORTAL_LOGGED_IN_AS_MESSAGE = getProp(casePfx + "logged.in.mess", "Logged in as: ");
- private final String PORTAL_FORBIDDEN_MESS = getProp(casePfx + "forbidden.mess", "HTTP Status 403 -");
- private final String PORTAL_SESSION_TEST_NO_SESSION = getProp("samples.ses.no", "No session");
- private final String PORTAL_SESSION_TEST_ID = getProp("samples.ses.id", "Session id");
-
- public final String TBL_CMS_FILE = getProp("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 = getProp("samples.ses.sub.pscope", "portlet");
- private final String SES_INP_VAL = getProp("samples.ses.inp.val", "value");
- private final String SES_INP_NAM = getProp("samples.ses.inp.nam", "name");
-
@BeforeMethod(groups = { "log" })
private void logoutBeforeTest() {
logoutIfPossible();
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java 2009-07-10 14:53:03 UTC (rev 13538)
@@ -16,10 +16,8 @@
/** prefix for locator properties */
public String casePfx = "iden.man.";
-
- // TODO: uncomment and remove getProp part
- /*private final String TBL_ROLELIST = getLoc(casePfx + "tbl.rolelist", "//table[contains(@id,'roles-form:userlist')]");
+ 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'')]");
@@ -52,43 +50,8 @@
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 String CHK_REGISTER_ROLE = getLoc(casePfx + "chk.reg.role", "//input[contains(@name,''register-role-form:roles'') and @value=''{0}'']");
- private final String TBL_ROLELIST = getProp(casePfx + "tbl.rolelist", "//table[contains(@id,'roles-form:userlist')]");
-
- private final String LNK_T_ROLLIST_DEL = getProp(casePfx + "lnk.t.rollist.del", "//a[contains(@id,''roles-form:userlist:{0}:delete-role-link'')]");
-
- private final String SUB_CONF_CREATE_USER = getProp(casePfx + "sub.conf.create.user", "//input[contains(@id,'confirm-form:admin')]");
- private final String SUB_DELETE_ROLE = getProp(casePfx + "sub.delete.role", "//input[contains(@id,'delete-role-form:confirm')]");
- private final String SUB_ROLE_CREATE = getProp(casePfx + "sub.role.create", "//input[contains(@id,'create-role-form:submit')]");
- private final String INP_ROLEDISNAME = getProp(casePfx + "inp.roledisname", "//input[contains(@id,'create-role-form:roledisplayname')]");
- private final String INP_ROLENAME = getProp(casePfx + "inp.rolename", "//input[contains(@id,'create-role-form:rolename')]");
- private final String TBL_USERLIST = getProp(casePfx + "tbl.userlist", "//table[contains(@id,'search-user-form1:userlist')]");
- private final String LNK_ROLE_CREATE = getProp(casePfx + "lnk.role.create", "//a[contains(@id, 'create-role-form:create-role-link')]");
- private final String SUB_DEL_USER = getProp(casePfx + "sub.del.user", "//input[contains(@id,'delete-user-form:submit')]");
-
- private final String SUB_USER_ROLE = getProp(casePfx + "sub.user.role", "//input[contains(@id,'register-role-form:submit')]");
- private final String SUB_CREATE_USER = getProp(casePfx + "sub.create.user", "//input[contains(@id,'register-form:submit')]");
- private final String INP_PASSWORD_CHK = getProp(casePfx + "inp.password.chk", "//input[contains(@id,'register-form:passwordCheck')]");
- private final String INP_PASSWORD = getProp(casePfx + "inp.password", "//input[contains(@id,'register-form:password')]");
- private final String INP_USEREMAIL = getProp(casePfx + "inp.useremail", "//input[contains(@id,'register-form:email')]");
- private final String INP_USERNAME = getProp(casePfx + "inp.username", "//input[contains(@id,'register-form:username')]");
- private final String SUB_SEARCH_USER = getProp(casePfx + "sub.search.user", "//input[contains(@id,'search-user-form:search') and @type='submit']");
- private final String INP_SEARCH_USER = getProp(casePfx + "inp.search.user", "//input[contains(@id,'search-user-form:searchString')]");
- private final String LNK_SEARCH_USER = getProp(casePfx + "lnk.search.user", "//a[contains(@id,'user-form:search-user-link')]");
- private final String LNK_USERTAB = getProp(casePfx + "lnk.usertab", "//a[contains(@id,'role-temp-form:manage-users')]");
- private final String LNK_USERMAIN = getProp(casePfx + "lnk.usermain", "//a[contains(@id,'user-temp-form1:user-adm-link')]");
- private final String LNK_T_USRLIST_DEL = getProp(casePfx + "lnk.t.usrlist.del", "//a[contains(@id,''search-user-form1:userlist:{0}:delete-user-link'')]");
- private final String LNK_ROLETAB = getProp(casePfx + "lnk.roletab", "//a[contains(@id,'user-temp-form:role-mgm-link')]");
-
- private final String LNK_ROLEMAIN = getProp(casePfx + "lnk.rolemain", "//a[contains(@id, 'role-temp-form1:role-admin-link')]");
- private final String LNK_USERMANG_MAIN = getProp(casePfx + "lnk.usermang.main", "//a[contains(@id,'user-temp-form1:assign-role-link')]");
- private final String LNK_USERMANG_MAIN2 = getProp(casePfx + "lnk.usermang.main2", "//a[contains(@id,'user-temp-form1:user-mgm-link')]");
- private final String LNK_CREATE_USER = getProp(casePfx + "lnk.create.user", "//a[contains(@id,':user-form:create-user-link')]");
-
- //private final String CHK_ROLE = getProp(casePfx + "chk.role", "//input[contains(@name,''assign-roles-form:roles'') and @value=''{0}'']");
- private final String CHK_REGISTER_ROLE = getProp(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) {
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java 2009-07-10 14:53:03 UTC (rev 13538)
@@ -15,9 +15,6 @@
/** prefix for locator properties */
public String casePfx = "sso.tomcatvalve.";
- // TODO: uncomment and remove getProp part
-
- /*
protected final String ADR_PORTAL = getLoc(casePfx+"adr.portal","/portal");
protected final String ADR_EXAMPLE = getLoc(casePfx+"adr.example","/TomcatSSOValveExampleApp");
protected final String ADR_JMX_CONSOLE = getLoc(casePfx+"adr.jmx","/jmx-console/");
@@ -43,34 +40,7 @@
protected final String LOGGED_IN_AS_MESSAGE = getMess(casePfx+"logged.in.mess", "Logged in as: ");
protected final String JMX_AGENT_VIEW = getMess(casePfx+"jmx.agnview", "JMX Agent View");
protected final String PORTAL_FORBIDDEN_MESS = getMess(casePfx + "forbidden.mess", "HTTP Status 403 -");
- */
- protected final String ADR_PORTAL = getProp(casePfx+"adr.portal","/portal");
- protected final String ADR_EXAMPLE = getProp(casePfx+"adr.example","/TomcatSSOValveExampleApp");
- protected final String ADR_JMX_CONSOLE = getProp(casePfx+"adr.jmx","/jmx-console/");
- protected final String EXAMPLE_TITLE_ELEMENT = getProp(casePfx+"ex.title","//h1");
- protected final String EXAMPLE_INP_USERNAME = getProp(casePfx+"ex.inp.username","j_username");
- protected final String EXAMPLE_INP_PASSWORD = getProp(casePfx+"ex.inp.password","j_password");
- protected final String EXAMPLE_LOGIN = getProp(casePfx+"ex.login","//input[@value='Login']");
- protected final String EXAMPLE_LOGOUT = getProp(casePfx+"ex.logout","//input[@value='Logout']");
- protected final String EXAMPLE_LOGGED_USER_OUTPUT = getProp(casePfx+"ex.logged.user.label","//tr[1]/td[2]/b");
- protected final String EXAMPLE_AUTHORIZED_ROLE_OUTPUT = getProp(casePfx+"ex.logged.role.auth.label","//tr[4]/td[2]/b");
- protected final String JMX_TITLE_ELEMENT = getProp(casePfx+"jmx.title.element", "//h1");
- protected final String JMX_IMAGE = getProp(casePfx+"jmx.image", "//img[@alt='JBoss']");
-
- protected final String LNK_LOGIN = getProp(casePfx+"lnk.login","link=Login");
- protected final String LNK_LOGOUT = getProp(casePfx+"lnk.logout","link=Logout");
- protected final String LNK_DEFAULT = getProp(casePfx+"lnk.default","link=default");
- protected final String LNK_ADMIN = getProp(casePfx+"lnk.admin","link=Admin");
- protected final String LNK_WSRP = getProp(casePfx+"lnk.wsrp","link=WSRP");
- protected final String LNK_DASHBOARD = getProp(casePfx+"lnk.default.dashboard","link=Dashboard");
-
- protected final String EXAMPLE_LOGIN_FORM = getProp(casePfx+"example.login.form", "Login form");
- protected final String EXAMPLE_TITLE_OUTPUT = getProp(casePfx+"example.title.output", "Tomcat SSO valve example servlet");
- protected final String LOGGED_IN_AS_MESSAGE = getProp(casePfx+"logged.in.mess", "Logged in as: ");
- protected final String JMX_AGENT_VIEW = getProp(casePfx+"jmx.agnview", "JMX Agent View");
- protected final String PORTAL_FORBIDDEN_MESS = getProp(casePfx + "forbidden.mess", "HTTP Status 403 -");
-
protected final String EXAMPLE_ADMIN_USERNAME = "admin";
protected final String EXAMPLE_ADMIN_PASSWORD = "password";
protected final String EXAMPLE_ADMIN2_USERNAME = "admin2";
16 years, 10 months
JBoss Portal SVN: r13537 - in branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests: apps and 3 other directories.
by portal-commits@lists.jboss.org
Author: vrockai
Date: 2009-07-10 10:25:44 -0400 (Fri, 10 Jul 2009)
New Revision: 13537
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/apps/portal-bookstore-samples.war
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalBookstoreSampleTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/assert.properties
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowUploadTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalWizardTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-cms-wf.xml
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-cms.xml
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-noxss.xml
Modified:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/build.xml
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesFullTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/EndToEndBeaPortlet.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalAjaxSamplesTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalSamplesTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortletUserCreationTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSExportFolderTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileUploadTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/locator.properties
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PageCoordinationTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java
Log:
[selenium] - tests from 2.7 migration
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/apps/portal-bookstore-samples.war
===================================================================
(Binary files differ)
Property changes on: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/apps/portal-bookstore-samples.war
___________________________________________________________________
Name: svn:mime-type
+ application/octet-stream
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/build.xml
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/build.xml 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/build.xml 2009-07-10 14:25:44 UTC (rev 13537)
@@ -1,227 +1,366 @@
-
<project name="Tests" default="compile" basedir="." xmlns:server="http://jboss.org/ns/test/ant/server">
- <property environment="env" />
+ <property environment="env" />
- <property name="workspace" location="${basedir}" />
- <property name="java.home" location="${env.JAVA_HOME}" />
+ <property name="workspace" location="${basedir}" />
+ <property name="java.home" location="${env.JAVA_HOME}" />
+
+<!--
+ <property name="suitename" location="testng-files" />
+ <property name="testname" location="testng-files" />
+ <property name="testng.dir" location="testng-files" />
+-->
+
+ <property name="testng.output.dir" location="test-output" />
+ <property name="testng.debug.dir" location="debug" />
- <property name="suitename" location="testng-files" />
- <property name="testname" location="testng-files" />
+ <property name="dir.testfiles" location="test_files" />
+ <property name="dir.javadoc" location="javadoc" />
+ <property name="test.build.dir" location="output/classes" />
+ <property name="test.src.dir" location="src" />
+ <property name="lib.dir" location="lib" />
+ <property name="hudson.lib.dir" location="/qa/tools/opt/" />
+ <property name="jboss-test.jar" location="${hudson.lib.dir}/jboss-test.jar" />
+ <available file="${jboss-test.jar}" property="jboss-test.jar.present" />
+ <property name="junit.report.dir" location="test-report" />
- <property name="testng.dir" location="testng-files" />
- <property name="testng.output.dir" location="test-output" />
- <property name="testng.debug.dir" location="debug" />
- <property name="test.build.dir" location="output/classes" />
- <property name="test.src.dir" location="src" />
- <property name="lib.dir" location="lib" />
- <property name="hudson.lib.dir" location="/qa/tools/opt/" />
- <property name="jboss-test.jar" location="${hudson.lib.dir}/jboss-test.jar" />
- <available file="${jboss-test.jar}" property="jboss-test.jar.present" />
- <property name="junit.report.dir" location="test-report" />
+ <property name="selsrv.dir" location="selenium-rc-server" />
+ <property name="node0" value="localhost" />
+ <property name="jboss.test.home" value="${env.JBOSS_TEST_HOME}" />
+ <property name="jboss.home" value="${env.JBOSS_HOME}" />
+ <property name="jboss.test.jar" value="lib/jboss-test.jar" />
+ <property name="jboss.portal.dir" value="${env.JBOSS_UNZIPED_DIR}" />
+ <property name="portal_archive" value="${env.JBOSS_ARCHIVE}" />
+ <property name="portal.instance" value="default" />
- <property name="selsrv.dir" location="selenium-rc-server" />
- <property name="node0" value="localhost" />
- <property name="jboss.test.home" value="${env.JBOSS_TEST_HOME}" />
- <property name="jboss.home" value="${env.JBOSS_HOME}" />
- <property name="jboss.test.jar" value="lib/jboss-test.jar" />
- <property name="jboss.portal.dir" value="${env.JBOSS_UNZIPED_DIR}" />
- <property name="portal_archive" value="${env.JBOSS_ARCHIVE}" />
- <property name="portal.instance" value="default" />
+ <property name="test.suite" value="testng.xml" />
+ <property name="test.cms.suite" value="testng-cms.xml" />
+ <property name="usecase.suite" value="end2end.xml" />
- <property name="test.suite" value="testng.xml" />
- <property name="usecase.suite" value="end2end.xml" />
+ <!-- Default properties for single-test-without-dependencies -->
+ <property name="suite.test.name" value="Ant test" />
+
+ <path id="jboss.test.classpath">
+ <pathelement path="${jboss.test.jar}" />
+ </path>
- <path id="jboss.test.classpath">
- <pathelement path="${jboss.test.jar}" />
- </path>
+ <path id="libraries.cp">
+ <fileset dir="${lib.dir}">
+ <include name="*.jar" />
+ </fileset>
+ </path>
- <path id="libraries.cp">
- <fileset dir="${lib.dir}">
- <include name="*.jar" />
- </fileset>
+ <path id="test.cp">
+ <pathelement location="${test.build.dir}" />
+ <path refid="libraries.cp" />
+ </path>
- </path>
+ <taskdef name="testng" classpathref="libraries.cp" classname="org.testng.TestNGAntTask" />
+ <taskdef name="config" classname="org.jboss.ant.taskdefs.server.ConfigManagerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
+ <classpath id="server.taskdef.classpath">
+ <path refid="jboss.test.classpath" />
+ </classpath>
+ </taskdef>
+ <taskdef name="start" classname="org.jboss.ant.taskdefs.server.StartServerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
+ <classpath refid="server.taskdef.classpath" />
+ </taskdef>
+ <taskdef name="stop" classname="org.jboss.ant.taskdefs.server.StopServerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
+ <classpath refid="server.taskdef.classpath" />
+ </taskdef>
- <path id="test.cp">
- <pathelement location="${test.build.dir}" />
- <path refid="libraries.cp" />
- </path>
+ <target name="init">
+ <echo message="Browser : ${browser}" />
+ <echo message="Screenshot : ${screenshot}" />
+ <echo message="Workspace : ${workspace}" />
+ <echo message="Deleting testng report directory" />
+ <delete dir="${testng.output.dir}" />
+ <delete dir="${testng.debug.dir}" />
+ <!--delete dir="${dir.javadoc}" /-->
+ </target>
- <taskdef name="testng" classpathref="libraries.cp" classname="org.testng.TestNGAntTask" />
- <taskdef name="config" classname="org.jboss.ant.taskdefs.server.ConfigManagerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
- <classpath id="server.taskdef.classpath">
- <path refid="jboss.test.classpath" />
- </classpath>
- </taskdef>
- <taskdef name="start" classname="org.jboss.ant.taskdefs.server.StartServerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
- <classpath refid="server.taskdef.classpath" />
- </taskdef>
- <taskdef name="stop" classname="org.jboss.ant.taskdefs.server.StopServerTask" uri="http://jboss.org/ns/test/ant/server" loaderref="server.loader">
- <classpath refid="server.taskdef.classpath" />
- </taskdef>
+ <target name="compile" depends="">
+ <echo message="Compiling testsuite" />
+ <mkdir dir="${test.build.dir}" />
+ <javac srcdir="${test.src.dir}" destdir="${test.build.dir}" classpathref="libraries.cp" debug="on" />
+ <copy file="${test.src.dir}/org/jboss/portal/test/selenium/locator.properties" todir="${test.build.dir}/org/jboss/portal/test/selenium/" />
+ <copy file="${test.src.dir}/org/jboss/portal/test/selenium/assert.properties" todir="${test.build.dir}/org/jboss/portal/test/selenium/" />
+ </target>
+
+ <target name="jar-task" depends="compile">
+ <jar destfile="${lib.dir}/createFile.jar" basedir="${test.build.dir}" includes="**/ant/**" />
+ <taskdef name="createfile" classname="org.jboss.portal.test.ant.FileCreate" classpath="${lib.dir}/createFile.jar"/>
+ </target>
- <target name="init">
- <echo message="Browser : ${browser}" />
- <echo message="Screenshot : ${screenshot}" />
- <echo message="Deleting testng report directory" />
- <delete dir="${testng.output.dir}" />
- <delete dir="${testng.debug.dir}" />
- </target>
+ <target name="create-test-files" depends="jar-task">
+
+ <mkdir dir="${dir.testfiles}/tmp"/>
+ <createfile filename="${dir.testfiles}/tmp/bigfile" size="20971520"/>
+ <zip destfile="${dir.testfiles}/big_archive.zip" basedir="${dir.testfiles}/tmp/" includes="bigfile" />
+
+ <mkdir dir="${dir.testfiles}/tmp/many_files"/>
+ <createfile filename="${dir.testfiles}/tmp/many_files/file" count="101" size="1024" suffix=".txt"/>
+ <zip destfile="${dir.testfiles}/many_files.zip" basedir="${dir.testfiles}/tmp/" includes="many_files/**" />
+ </target>
+ <target name="javadoc" depends="">
+ <delete dir="${dir.javadoc}" />
+ <mkdir dir="${dir.javadoc}" />
+ <javadoc packagenames="org.jboss.portal.test.selenium.*" classpathref="libraries.cp" access="public" destdir="${dir.javadoc}" author="true" version="true" use="true">
+ <fileset dir="${test.src.dir}" defaultexcludes="yes">
+ <include name="**/*.java" />
+ </fileset>
+ </javadoc>
+ </target>
- <target name="compile" depends="">
- <echo message="Compiling testsuite" />
- <mkdir dir="${test.build.dir}" />
- <javac srcdir="${test.src.dir}" destdir="${test.build.dir}" classpathref="libraries.cp" debug="on" />
- <copy file="${test.src.dir}/org/jboss/portal/test/selenium/locator.properties" todir="${test.build.dir}/org/jboss/portal/test/selenium/"/>
- </target>
+ <target name="run-src">
+ <echo message="Starting Selenium Remote Control" />
+ <java jar="${selsrv.dir}/selenium-server.jar" fork="true" spawn="true">
+ <arg value="-multiWindow" />
+ <arg value="-timeout" />
+ <arg value="320000" />
+ <arg value="-port" />
+ <arg value="44444" />
+ <arg value="-log" />
+ <arg value="selenium.log" />
+ <arg value="-debug" />
+ <arg value="-userExtensions" />
+ <arg value="${selsrv.dir}/user-extensions.js" />
+ </java>
+ <sleep seconds="20" />
+ </target>
+
+ <target name="run-src-with-ssl">
+ <echo message="Starting Selenium Remote Control with usage of HTTPS" />
+ <java jar="${selsrv.dir}/selenium-server.jar" fork="true" spawn="true">
+ <arg value="-trustAllSSLCertificates" />
+ <arg value="-multiWindow" />
+ <arg value="-port" />
+ <arg value="44444" />
+ <arg value="-log" />
+ <arg value="selenium.log" />
+ <arg value="-debug" />
+ <arg value="-userExtensions" />
+ <arg value="${selsrv.dir}/user-extensions.js" />
+ </java>
+ <sleep seconds="20" />
+ </target>
- <target name="run-src">
- <echo message="Starting Selenium Remote Control" />
- <java jar="${selsrv.dir}/selenium-server.jar" fork="true" spawn="true">
- <arg value="-multiWindow" />
- <arg value="-port" />
- <arg value="44444" />
- <arg value="-log" />
- <arg value="selenium.log" />
- <arg value="-debug" />
- <arg value="-userExtensions" />
- <arg value="${selsrv.dir}/user-extensions.js" />
- </java>
- <sleep seconds="20" />
- </target>
+ <target name="stop-src">
+ <get taskname="selenium-shutdown" src="http://localhost:44444/selenium-server/driver/?cmd=shutDown" dest="result.txt" ignoreerrors="true" />
+ <echo taskname="selenium-shutdown" message="DGF Errors during shutdown are expected" />
+ </target>
- <target name="stop-src">
- <get taskname="selenium-shutdown" src="http://localhost:44444/selenium-server/driver/?cmd=shutDown" dest="result.txt" ignoreerrors="true" />
- <echo taskname="selenium-shutdown" message="DGF Errors during shutdown are expected" />
- </target>
-
- <target name="copyApps">
- <echo message="Copying userInterceptor portlet into the ${portal.instance} server" />
- <copy file="apps/userDetail-portlet.war" tofile="${jboss.home}/server/${portal.instance}/deploy/userDetail-portlet.war" />
+ <target name="copyApps">
+ <echo message="Copying userInterceptor portlet into the ${portal.instance} server" />
+ <copy file="apps/userDetail-portlet.war" tofile="${jboss.home}/server/${portal.instance}/deploy/userDetail-portlet.war" />
<echo message="Copying httpHeader portlet into the ${portal.instance} server" />
<copy file="apps/httpHeader-portlet.war" tofile="${jboss.home}/server/${portal.instance}/deploy/httpHeader-portlet.war" />
- </target>
+ <echo message="Copying portal-bookstore-samples into the ${portal.instance} server" />
+ <copy file="apps/portal-bookstore-samples.war" tofile="${jboss.home}/server/${portal.instance}/deploy/portal-bookstore-samples.war" />
+ </target>
- <target name="clean">
- <echo message="Going to delete directory ${test.build.dir}" />
- <delete dir="${test.build.dir}" />
- </target>
+ <target name="clean">
+ <echo message="Going to delete directory ${test.build.dir}" />
+ <delete dir="${dir.testfiles}/tmp"/>
+ <delete dir="${test.build.dir}" />
+ </target>
- <server:config javaHome="${java.home}" jbossHome="${jboss.home}">
- <server name="${portal.instance}" host="${node0}">
+ <server:config javaHome="${java.home}" jbossHome="${jboss.home}">
+ <server name="${portal.instance}" host="${node0}">
<!-- jvmarg value="${jpda.cmdline}" / -->
- <jvmarg value="-Xmx512m" />
- <jvmarg value="-XX:MaxPermSize=128m" />
- <sysproperty key="java.endorsed.dirs" value="${jboss.home}/lib/endorsed" />
- </server>
- </server:config>
+ <jvmarg value="-Xmx512m" />
+ <jvmarg value="-XX:MaxPermSize=128m" />
+ <sysproperty key="java.endorsed.dirs" value="${jboss.home}/lib/endorsed" />
+ </server>
+ </server:config>
+ <target name="cleanup">
+ <echo message="Cleaning up..." />
+ <antcall target="stop-src" />
+ </target>
- <target name="cleanup">
- <echo message="Cleaning up..." />
- <antcall target="stop-src" />
+ <target name="selenium-groups" depends="init, compile, run-src, copyApps, create-test-files">
+ <echo message="Runing TestNG groups: ${testng.groups}" />
- </target>
+ <mkdir dir="test-output" />
+ <mkdir dir="debug" />
+ <testng classpathref="test.cp" groups="" sourcedir="${test.src.dir}" listeners="org.jboss.portal.test.selenium.JBossSeleniumTestListener" outputdir="${testng.output.dir}" suitename="SeleniumSuite">
- <target name="run-and-build" depends="init, compile, run-src">
- <echo message="Starting portal instance : ${portal.instance}" />
- <server:start name="${portal.instance}" />
+ <classfileset dir="${test.build.dir}" includes="**/*.class" />
- <echo message="Runing TestNG" />
- <mkdir dir="test-output" />
- <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="test-output" listeners="org.testng.reporters.JUnitXMLReporter" suitename="SeleniumSuite">
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="debug" value="${debug}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="userCount" value="${userCount}" />
+ <sysproperty key="html-src" value="${html-src}" />
+ <sysproperty key="output-dir" value="${testng.output.dir}" />
- <xmlfileset dir="." includes="${testng.suite}" />
- <sysproperty key="browser" value="${browser}" />
- <sysproperty key="screenshot" value="${screenshot}" />
- <sysproperty key="workspace" value="${workspace}" />
- <sysproperty key="userCount" value="${userCount}" />
- <sysproperty key="html-src" value="${html-src}" />
- <sysproperty key="output-dir" value="${testng.output.dir}" />
- <jvmarg value="-ea" />
+ <jvmarg value="-ea" />
- </testng>
- <echo message="Stoping portal instance : ${portal.instance}" />
- <server:stop name="${portal.instance}" />
- <antcall target="cleanup" />
- </target>
+ </testng>
+ <antcall target="cleanup" />
+ </target>
- <target name="single-test" depends="init, compile, run-src, copyApps">
- <echo message="Runing TestNG" />
+ <target name="selenium-suite" depends="init, compile, run-src, copyApps, create-test-files">
+ <echo message="Runing TestNG" />
- <mkdir dir="test-output" />
- <mkdir dir="debug" />
- <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" listeners="org.jboss.portal.test.selenium.JBossSeleniumTestListener" suitename="SeleniumSingleTest" verbose="2">
+ <mkdir dir="test-output" />
+ <mkdir dir="debug" />
+ <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" suitename="SeleniumSuite">
- <classfileset dir="${test.build.dir}" includes="${testname}" />
- <sysproperty key="browser" value="${browser}" />
- <sysproperty key="screenshot" value="${screenshot}" />
- <sysproperty key="debug" value="${debug}" />
- <sysproperty key="workspace" value="${workspace}" />
- <sysproperty key="userCount" value="${userCount}" />
- <sysproperty key="html-src" value="${html-src}" />
- <sysproperty key="output-dir" value="${testng.output.dir}" />
- <jvmarg value="-ea" />
- </testng>
- <antcall target="cleanup" />
+ <xmlfileset dir="." includes="${user.suite}" />
- </target>
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="debug" value="${debug}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="userCount" value="${userCount}" />
+ <sysproperty key="html-src" value="${html-src}" />
+ <sysproperty key="output-dir" value="${testng.output.dir}" />
- <target name="selenium-test" depends="init, compile, run-src, copyApps">
- <echo message="Runing TestNG" />
+ <jvmarg value="-ea" />
- <mkdir dir="test-output" />
- <mkdir dir="debug" />
- <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" suitename="SeleniumSuite">
+ </testng>
+ <antcall target="cleanup" />
+ </target>
- <xmlfileset dir="." includes="${test.suite}" />
+ <target name="run-and-build" depends="init, compile, copyApps, create-test-files">
+ <echo message="Starting portal instance : ${portal.instance}" />
+ <server:start name="${portal.instance}" />
- <sysproperty key="browser" value="${browser}" />
- <sysproperty key="screenshot" value="${screenshot}" />
- <sysproperty key="debug" value="${debug}" />
- <sysproperty key="workspace" value="${workspace}" />
- <sysproperty key="userCount" value="${userCount}" />
- <sysproperty key="html-src" value="${html-src}" />
- <sysproperty key="output-dir" value="${testng.output.dir}" />
-
+ <echo message="Runing TestNG" />
+ <mkdir dir="test-output" />
+ <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" suitename="SeleniumSuite">
- <jvmarg value="-ea" />
+ <xmlfileset dir="." includes="${test.suite}" />
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="debug" value="${debug}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="html-src" value="${html-src}" />
+ <sysproperty key="output-dir" value="${testng.output.dir}" />
- </testng>
- <antcall target="cleanup" />
- </target>
+ <jvmarg value="-ea" />
- <target name="selenium-usecase" depends="init, compile, run-src, copyApps">
- <echo message="Runing TestNG" />
+ </testng>
+ <echo message="Stoping portal instance : ${portal.instance}" />
+ <server:stop name="${portal.instance}" />
+ <antcall target="cleanup" />
+ </target>
- <mkdir dir="test-output" />
- <mkdir dir="debug" />
-
- <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" suitename="SeleniumSuite">
+ <target name="single-test" depends="init, compile, run-src, copyApps, create-test-files">
+ <echo message="Runing TestNG" />
- <xmlfileset dir="." includes="${usecase.suite}" />
+ <mkdir dir="test-output" />
+ <mkdir dir="debug" />
+ <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" listeners="org.jboss.portal.test.selenium.JBossSeleniumTestListener" suitename="SeleniumSingleTest" verbose="2">
- <sysproperty key="browser" value="${browser}" />
- <sysproperty key="screenshot" value="${screenshot}" />
- <sysproperty key="debug" value="${debug}" />
- <sysproperty key="workspace" value="${workspace}" />
- <sysproperty key="userCount" value="${userCount}" />
- <sysproperty key="html-src" value="${html-src}" />
- <sysproperty key="output-dir" value="${testng.output.dir}" />
- <jvmarg value="-ea" />
+ <classfileset dir="${test.build.dir}" includes="${testname}" />
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="debug" value="${debug}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="userCount" value="${userCount}" />
+ <sysproperty key="html-src" value="${html-src}" />
+ <sysproperty key="output-dir" value="${testng.output.dir}" />
+ <jvmarg value="-ea" />
+ </testng>
+
+ <antcall target="cleanup" />
- </testng>
- <antcall target="cleanup" />
- </target>
+ </target>
- <target name="archive" >
- <!--<touch file="touchme.txt"/>-->
- <echo file="touchme.txt" message="pipik2"/>
- <genkey alias="apache-group" storepass="secret" dname="CN=Ant Group, OU=Jakarta Division, O=Apache.org, C=US"/>
- <echo message=""/>
- </target>
+ <target name="single-test-without-dependencies" depends="run-src">
+ <echo message="Runing TestNG" />
+ <!--<mkdir dir="test-output" />
+ <mkdir dir="debug" />-->
+ <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" listeners="org.jboss.portal.test.selenium.JBossSeleniumTestListener" suitename="SeleniumSingleTest" testname="${suite.test.name}" verbose="2" >
+
+ <classfileset dir="${test.build.dir}" includes="${testname}" />
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="debug" value="${debug}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="userCount" value="${userCount}" />
+ <sysproperty key="html-src" value="${html-src}" />
+ <sysproperty key="output-dir" value="${testng.output.dir}" />
+ <jvmarg value="-ea" />
+ </testng>
+
+ <antcall target="cleanup" />
+
+ </target>
+
+ <target name="selenium-test" depends="init, compile, run-src, copyApps, create-test-files">
+ <echo message="Runing TestNG" />
+
+ <mkdir dir="test-output" />
+ <mkdir dir="debug" />
+ <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" suitename="SeleniumSuite">
+
+ <xmlfileset dir="." includes="${test.suite}" />
+
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="debug" value="${debug}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="userCount" value="${userCount}" />
+ <sysproperty key="html-src" value="${html-src}" />
+ <sysproperty key="output-dir" value="${testng.output.dir}" />
+
+ <jvmarg value="-ea" />
+
+ </testng>
+ <antcall target="cleanup" />
+ </target>
+
+ <target name="selenium-cms-test" depends="init, compile, run-src, copyApps, create-test-files">
+ <echo message="Runing TestNG" />
+
+ <mkdir dir="test-output" />
+ <mkdir dir="debug" />
+ <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" suitename="SeleniumSuite">
+
+ <xmlfileset dir="." includes="${test.cms.suite}" />
+
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="debug" value="${debug}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="userCount" value="${userCount}" />
+ <sysproperty key="html-src" value="${html-src}" />
+ <sysproperty key="output-dir" value="${testng.output.dir}" />
+
+ <jvmarg value="-ea" />
+
+ </testng>
+ <antcall target="cleanup" />
+ </target>
+
+ <target name="selenium-usecase" depends="init, compile, run-src, copyApps, create-test-files">
+ <echo message="Runing TestNG" />
+
+ <mkdir dir="test-output" />
+ <mkdir dir="debug" />
+
+ <testng classpathref="test.cp" sourcedir="${test.src.dir}" outputdir="${testng.output.dir}" suitename="SeleniumSuite">
+
+ <xmlfileset dir="." includes="${usecase.suite}" />
+
+ <sysproperty key="browser" value="${browser}" />
+ <sysproperty key="screenshot" value="${screenshot}" />
+ <sysproperty key="debug" value="${debug}" />
+ <sysproperty key="workspace" value="${workspace}" />
+ <sysproperty key="userCount" value="${userCount}" />
+ <sysproperty key="html-src" value="${html-src}" />
+ <sysproperty key="output-dir" value="${testng.output.dir}" />
+ <jvmarg value="-ea" />
+
+ </testng>
+ <antcall target="cleanup" />
+ </target>
+
</project>
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesFullTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesFullTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesFullTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -7,8 +7,6 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
-
@Test(groups = { "coordination_samples" }, enabled = true)
public class CoordinationSamplesFullTestCase extends JBossPortalSeleniumTestCase {
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/CoordinationSamplesTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -7,8 +7,14 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import com.sun.corba.se.impl.protocol.giopmsgheaders.Message;
-
+/**
+ * The Class Coordination Samples TestCase is responsible for testing of
+ * coordination features of JBoss Portal using it's coordination samples page.
+ * In default state the page is available on address <a
+ * href="http://localhost:8080/portal/portal/default/Coordination+Samples"
+ * >/portal/portal/default/Coordination+Samples</a>.
+ */
+//TODO - refactor to use property file
@Test(groups = { "coordination_samples" }, enabled = true)
public class CoordinationSamplesTestCase extends JBossPortalSeleniumTestCase {
@@ -75,16 +81,52 @@
private final String EVT_R_C3 = "Backpack";
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
selenium.open("/portal/portal/default/default");
selenium.waitForPageToLoad(PAGE_LOAD);
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ protected void logoutAfterTest() {
}
+ /**
+ * Default coordination test is responsible for testing default coordination
+ * on the coordination samples page. It has to work with the default page <a
+ * href="http://localhost:8080/portal/portal/default/Coordination+Samples">/
+ * portal/portal/default/Coordination+Samples</a>. <br/> It starts with
+ * opening <a href=
+ * "http://localhost:8080/portal/portal/default/Coordination+Samples?zip=78759"
+ * >http://localhost:8080/portal/portal/default/Coordination+Samples?zip=
+ * 78759</a> and checking that both variables on page have values asserted
+ * like this: <br/>
+ * <table>
+ * <tr>
+ * <td>Weather for (my_zipcode)</td>
+ * <td>78759</td>
+ * </tr>
+ * <tr>
+ * <td>Map for (your_zipcode)</td>
+ * <td>78759</td>
+ * </tr>
+ * </table>
+ * Then it fills up the <em>Page Parameter Portlet</em> with values:
+ * <table>
+ * <tr>
+ * <td>Page parameter name</td>
+ * <td>xyz</td>
+ * </tr>
+ * <tr>
+ * <td>Page parameter value</td>
+ * <td>123</td>
+ * </tr>
+ * </table>
+ *
+ * clicks on submit button and assert the url is in format <a href=
+ * "http://localhost:8080//portal/portal/default/Coordination+Samples?xyz=123"
+ * >/portal/portal/default/Coordination+Samples?xyz=123</a>
+ */
@Test(enabled = true)
public void defaultCoordinationTest() {
selenium.open("/portal/portal/default/Coordination+Samples");
@@ -103,6 +145,37 @@
Assert.assertTrue(selenium.getLocation().endsWith("/portal/portal/default/Coordination+Samples?xyz=123"));
}
+ /**
+ * Events explicit test.
+ *
+ * <h3>For the page:
+ * http://host:8080/portal/portal/default/Coordination+Samples
+ * /Events+-+Explicit</h3>
+ * <p>
+ * This is demonstration of explicit event wiring.
+ * </p>
+ * <ul>
+ * <li>Click on "Add to Cart" on the Catalog Portlet on the left half for
+ * Snowboard.</li>
+ * </ul>
+ * <p>
+ * Assert that two Cart Portlets on the left half<strong> have Snowboard in
+ * them.</strong>
+ * </p>
+ * <p style="padding-left: 30px;"> Assert that two Cart Porlets on the right
+ * <strong>have "Cart is empty"</strong></p>
+ * <ul>
+ * <li>Click on "Add to Cart" on the Catalog Portlet on the right half for
+ * Tent.</li>
+ * </ul>
+ * <p>
+ * Assert that two Cart Portlets on the left half <strong>have no
+ * "Tent"</strong> in them
+ * </p>
+ * <p style="padding-left: 30px;"> Assert that two Cart Porlets on the
+ * <strong>right have "Tent"</strong> in them.</p><p
+ * style="min-height: 8pt; height: 8pt; padding: 0px;"> </p>
+ */
@Test(enabled = true)
public void eventsExplicitTest() {
selenium.click("link=Events - Explicit");
@@ -161,6 +234,39 @@
Assert.assertTrue(findTableRow(EVT_R3_TAB, EVT_R_C3, 0) > 0);
}
+ /**
+ * Events fallback test.
+ *
+ * <h3>For the page:
+ * http://host:8080/portal/portal/default/Coordination+Samples
+ * /Events+-+Fallback</h3>
+ * <p>
+ * This is demonstration of mix of both explicit and implicit. (Is there a
+ * better way to describe this?)
+ * </p>
+ * <ul>
+ * <li>Click on "Add to Cart" on the Catalog Portlet on the left half for
+ * Snowboard.</li>
+ * </ul>
+ * <p>
+ * Assert that two Cart Portlets on the left half<strong> have Snowboard in
+ * them.</strong>
+ * </p>
+ * <p style="padding-left: 30px;"> Assert that two Cart Porlets on the right
+ * <strong>have "Cart is empty"</strong></p>
+ * <ul>
+ * <li>Click on "Add to Cart" on the Catalog Portlet on the right half for
+ * Tent.</li>
+ * </ul>
+ * <p>
+ * Assert that two Cart Portlets on the left half <strong>have
+ * "Tent"</strong> in them
+ * </p>
+ * <p style="padding-left: 30px;"> Assert that two Cart Porlets on the
+ * <strong>right have "Tent"</strong> in them.</p><p
+ * style="min-height: 8pt; height: 8pt; padding: 0px;"> </p><p
+ * style="min-height: 8pt; height: 8pt; padding: 0px;"> </p>
+ */
@Test(enabled = true)
public void eventsFallbackTest() {
selenium.click("link=Events - Fallback");
@@ -219,6 +325,39 @@
Assert.assertTrue(findTableRow(EVT_R3_TAB, EVT_R_C3, 0) > 0);
}
+ /**
+ * Events implicit test.
+ *
+ * <h3>For the page:
+ * http://host:8080/portal/portal/default/Coordination+Samples
+ * /Events+-+Implicit</h3>
+ * <p>
+ * This is implicit wiring which is the default wiring. Events are
+ * propagated based on their Qname regarless of which portlet generated the
+ * event.
+ * </p>
+ * <ul>
+ * <li>Click on "Add to Cart" on the Catalog Portlet on the left half for
+ * Snowboard.</li>
+ * </ul>
+ * <p>
+ * Assert that two Cart Portlets on the left half<strong> have Snowboard in
+ * them.</strong>
+ * </p>
+ * <p style="padding-left: 30px;"> Assert that two Cart Porlets on the right
+ * <strong>have Snowboard in them.</strong></p>
+ * <ul>
+ * <li>Click on "Add to Cart" on the Catalog Portlet on the right half for
+ * Tent.</li>
+ * </ul>
+ * <p>
+ * Assert that two Cart Portlets on the left half <strong>have
+ * "Tent"</strong> in them
+ * </p>
+ * <p style="padding-left: 30px;"> Assert that two Cart Porlets on the
+ * <strong>right have "Tent"</strong> in them.</p><p
+ * style="min-height: 8pt; height: 8pt; padding: 0px;"> </p>
+ */
@Test(enabled = true)
public void eventsImplicitTest() {
selenium.click("link=Events - Implicit");
@@ -301,6 +440,35 @@
Assert.assertTrue(findTableRow(EVT_R3_TAB, EVT_R_C3, 0) > 0);
}
+ /**
+ * Parameter alias test.
+ *
+ * <h3>For the page:
+ * http://host:8080/portal/portal/default/Coordination+Samples
+ * /Parameters+-+Alias</h3><p
+ * style="min-height: 8pt; height: 8pt; padding: 0px;"> </p>
+ * <ul>
+ * <li><span>Hit the URL </span><a class="jive-link-external-small" href="http://host:8080/portal/portal/default/Coordination+Samples/Parameters+-+..."
+ * >http://host:8080/portal/portal/default/Coordination+Samples/Parameters+-
+ * +Alias?binding1=Viliam</a><span>. Assert that </span><strong>"Viliam" is
+ * present</strong> in all PublicParametersPortletWindow for foo* parameters
+ * </li>
+ * <li><span>Hit the URL </span><a class="jive-link-external-small" href="http://host:8080/portal/portal/default/Coordination+Samples/Parameters+-+..."
+ * >http://host:8080/portal/portal/default/Coordination+Samples/Parameters+-
+ * +Alias?binding2=Prabhat</a><span>. Assert that </span><strong>"Prabhat"
+ * is present </strong>in all PublicParametersPortletWindow for juu*
+ * parameters and <strong>Viliam is not present</strong> in all
+ * PublicParametersPortletWindow for foo* parameters</li>
+ * <li>Add "footest" for foo1 in PublicParametersPortletWindow1 and hit
+ * update. Assert that "footest" is present in all
+ * PublicParametersPortletWindow</li>
+ * <li>Click on Remove link from PublicParametersPortletWindow4 for foo2.
+ * Assert that "footest" is removed from all PublicParametersPortletWindow.</li>
+ * <li>In Page Parameters Portlet, add any parameter and value (xyz, 123)
+ * and verify that URL is changed (appended with ?xyz=123) once you hit
+ * update.</li>
+ * </ul>
+ */
@Test(enabled = true)
public void parameterAliasTest() {
selenium.click("link=Parameters - Alias");
@@ -423,6 +591,30 @@
}
+ /**
+ * Parameter explicit test.
+ *
+ * <h3>For the page:
+ * http://host:8080/portal/portal/default/Coordination+Samples
+ * /Parameters+-+Explicit</h3>
+ * <ul>
+ * <li><span>Hit the URL </span><a class="jive-link-external-small" href="http://host:8080/portal/portal/default/Coordination+Samples/Parameters+-+..."
+ * >http://host:8080/portal/portal/default/Coordination+Samples/Parameters+-
+ * +Explicit?binding1=Viliam</a><span>. Assert that </span><strong>"Viliam"
+ * is present in Windows 1,2 and 3 but not in 4.</strong></li>
+ * <li>Click on Remove link from Window 3 and assert that "Viliam" is not
+ * present in any of windows.</li>
+ * <li><span>Hit the URL </span><a class="jive-link-external-small" href="http://host:8080/portal/portal/default/Coordination+Samples/Parameters+-+..."
+ * >http://host:8080/portal/portal/default/Coordination+Samples/Parameters+-
+ * +Explicit?binding2=Nepal</a><span>. Assert that "Nepal" is present in
+ * Window1 for bar1, daa1 for Window2, bar2 for Window3, daa2 for
+ * Window4.</span><br/></li>
+ * <li>In Page Parameters Portlet, add any parameter and value (xyz, 123)
+ * and verify that URL is changed (appended with ?xyz=123) once you hit
+ * update.</li>
+ * </ul>
+ * <p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p>
+ */
@Test(enabled = true)
public void parameterExplicitTest() {
selenium.click("link=Parameters - Explicit+Alias");
@@ -469,9 +661,9 @@
Assert.assertEquals(selenium.getValue(PAR_R2_FOO2), "");
Assert.assertEquals(selenium.getValue(PAR_R2_DAA2), "");
Assert.assertEquals(selenium.getValue(PAR_R2_BAR2), "");
-
+
clickAndWait(PAR_R1_FOO1_R);
-
+
Assert.assertEquals(selenium.getValue(PAR_L1_DAA1), "");
Assert.assertEquals(selenium.getValue(PAR_L1_BAR1), "");
Assert.assertEquals(selenium.getValue(PAR_L1_JUU1), "");
@@ -521,6 +713,33 @@
Assert.assertTrue(selenium.getLocation().endsWith("Parameters+-+Explicit?xyz=123"));
}
+ /**
+ * Parameter explicit alias test.
+ *
+ * <h3>For the page:
+ * http://host:8080/portal/portal/default/Coordination+Samples
+ * /Parameters+-+Explicit%2BAlias</h3>
+ * <ul>
+ * <li><span>Hit the URL </span><a class="jive-link-external-small" href="http://host:8080/portal/portal/portal/default/Coordination+Samples/Parame..."
+ * >http://host:8080/portal/portal/portal/default/Coordination+Samples/
+ * Parameters+-+Explicit%2BAlias?binding1=prabhat</a><span>. Assert that
+ * </span><strong>"Prabhat" is present in Windows 1 for foo1 and in Windows2
+ * for bar1.<br/></strong></li>
+ * <li>Click on Remove link from Window 2 and assert that "Prabhat" is not
+ * present in any of windows.</li>
+ * <li><span>Hit the URL </span><a class="jive-link-external-small" href="http://host:8080/portal/portal/portal/default/Coordination+Samples/Parame..."
+ * >http://host:8080/portal/portal/portal/default/Coordination+Samples/
+ * Parameters+-+Explicit%2BAlias?binding2=Thomas</a><span>. Assert that
+ * "Thomas" is present in Window2, Window3 and Window4 but not in Window1.
+ * Since foo parameter in Window is part of binding1 and it's explicit
+ * binding, using binding2 does not have impact on foo parameter for
+ * window1.</span><br/></li>
+ * <li>In Page Parameters Portlet, add any parameter and value (xyz, 123)
+ * and verify that URL is changed (appended with ?xyz=123) once you hit
+ * update.</li>
+ * </ul>
+ * <p style="min-height: 8pt; height: 8pt; padding: 0px;"> </p>
+ */
@Test(enabled = true)
public void parameterExplicitAliasTest() {
selenium.click("link=Parameters - Explicit+Alias");
@@ -567,9 +786,9 @@
Assert.assertEquals(selenium.getValue(PAR_R2_FOO2), "");
Assert.assertEquals(selenium.getValue(PAR_R2_DAA2), "");
Assert.assertEquals(selenium.getValue(PAR_R2_BAR2), "");
-
+
clickAndWait(PAR_R1_BAR1_R);
-
+
Assert.assertEquals(selenium.getValue(PAR_L1_DAA1), "");
Assert.assertEquals(selenium.getValue(PAR_L1_BAR1), "");
Assert.assertEquals(selenium.getValue(PAR_L1_JUU1), "");
@@ -619,6 +838,21 @@
Assert.assertTrue(selenium.getLocation().endsWith("/portal/portal/default/Coordination+Samples/Parameters+-+Explicit%2BAlias?xyz=123"));
}
+ /**
+ * Parameter implicit test.
+ *
+ * <h3>For the page:
+ * http://host:8080/portal/portal/default/Coordination+Samples
+ * /Parameters+-+Implicit</h3>
+ * <ul>
+ * <li>Add "footest" for foo1 in PublicParametersPortletWindow1 and hit
+ * update. Assert that "footest" is present in all
+ * PublicParametersPortletWindow</li>
+ * <li>Click on Remove link from PublicParametersPortletWindow4 for foo2.
+ * Assert that "footest" is removed from all PublicParametersPortletWindow</li>
+ * <li>Need clarification for the rest.</li>
+ * </ul>
+ */
@Test(enabled = true)
public void parameterImplicitTest() {
selenium.click("link=Parameters - Implicit");
@@ -647,9 +881,9 @@
Assert.assertEquals(selenium.getValue(PAR_R2_FOO2), "footest");
Assert.assertEquals(selenium.getValue(PAR_R2_DAA2), "");
Assert.assertEquals(selenium.getValue(PAR_R2_BAR2), "");
-
+
clickAndWait(PAR_L1_FOO1_R);
-
+
Assert.assertEquals(selenium.getValue(PAR_L1_DAA1), "");
Assert.assertEquals(selenium.getValue(PAR_L1_BAR1), "");
Assert.assertEquals(selenium.getValue(PAR_L1_JUU1), "");
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/DashboardTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -1,72 +1,161 @@
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;
/**
+ * DashboardTestCase is responsible for testing configure dashboard functions.
+ * Each test is running with user "admin" logged in.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
-@Test(groups = { "cms_dashboard" }, enabled = true, description = "Dashboard issues test case.")
+@Test(groups = { "dashboard" }, enabled = true, description = "Dashboard issues test case.")
public class DashboardTestCase extends JBossPortalSeleniumTestCase {
- private static final String POWERED_BY_JBOSS_PORTAL = "Powered by JBoss Enterprise Portal Platform";
-
+ /** prefix for locator properties = dash. */
public String casePfx = "dash.";
- private final String LNK_POR_WEA_EDIT = getProp(casePfx + "lnk.por.wea.edit", "//body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div/div/div[2]/span/a");
- private final String SUB_LAYOUT_UPDATE = getProp(casePfx + "sub.layout.update", "//input[contains(@name,'dashboardLayoutForm:j_id12')]");
- private final String SUB_PAGE_RENAME = getProp(casePfx + "sub.page.rename", "//form[contains(@id,'renameForm')]/input[@type='submit']");
- private final String INP_PAGE_RENAME = getProp(casePfx + "inp.page.rename", "//input[contains(@id,'renameForm:newName')]");
- private final String LINK_WEATHER_PORTLET = getProp(casePfx + "link.weather.portlet", "link=*WeatherPortlet*");
- private final String LINK_PORTL2 = getProp(casePfx + "link.portl2", "link=*Who's online portlet*");
- private final String LINK_PORTL1 = getProp(casePfx + "link.portl1", "link=*Welcome portlet*");
- private final String OPT_PORTL1 = getProp(casePfx + "opt.portl1", "JSPPortletWindow");
- private final String SEL_CONTENT_TYPE = getProp(casePfx + "sel.content.type", "//select[contains(@id,'contentTypesForm:instanceId')]");
- private final String SUB_DEL_FROM_CENTER_REGION = getProp(casePfx + "sub.del.from.center.region", "//input[contains(@id,'layoutForm:l_center')]");
- private final String SUB_DOWN_CENTER_REGION = getProp(casePfx + "sub.down.center.region", "//input[contains(@id,'layoutForm:d_center')]");
- private final String SUB_UP_CENTER_REGION = getProp(casePfx + "sub.up.center.region", "//input[contains(@id,'layoutForm:u_center')]");
- private final String SEL_CENTER_REGION = getProp(casePfx + "sel.center.region", "//select[contains(@id,'layoutForm:selectMany_center')]");
- private final String SUB_ADDCENTER = getProp(casePfx + "sub.addcenter", "//input[contains(@id,'layoutForm:a_center')]");
- private final String SUB_ADDLEFT = getProp(casePfx + "sub.addleft", "//input[contains(@id,'layoutForm:a_left')]");
- private final String LNK_CONFIGURE_DASHBOARD = getProp(casePfx + "lnk.configure.dashboard", "link=Configure dashboard");
- private final String LNK_DASHBOARD = getProp(casePfx + "lnk.dashboard", "link=Dashboard");
- private final String SEL_PAGE = getProp(casePfx + "sel.page", "//select[contains(@id,'pageNameSelector')]");
- private final String INP_PAGENAME = getProp(casePfx + "inp.pagename", "//input[contains(@id,':pageName')]");
- private final String SUB_CREATEPAGE = getProp(casePfx + "sub.createpage", "//form[contains(@id,'j_id3')]/input[@type='submit']");
- private final String SEL_LAYOUT = getProp(casePfx + "sel.layout", "//select[contains(@id,'dashboardLayoutForm:layoutSelector')]");
- private final String SEL_THEME = getProp(casePfx + "sel.theme", "//select[contains(@id,'dashboardThemeForm:themeSelector')]");
- private final String SUB_THEMESEL = getProp(casePfx + "sub.themesel", "//form[contains(@id,'dashboardThemeForm')]/input[@type='submit']");
+ private final String MSG_NO_PORTLET = getMess(casePfx
+ + "msg.no.portlet", "You must select a content type!");
+ 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");
+ private final String SPAN_R1 = getLoc(
+ casePfx + "span.r1",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/div/table/tbody/tr/td[2]/div/div/span");
+ private final String DIV_REG_A = getLoc(casePfx + "div.reg.a",
+ "//div[@id='regionA']");
+ private final String DIV_REG_B = getLoc(casePfx + "div.reg.b",
+ "//div[@id='regionB']");
+ private final String SPAN_L2 = getLoc(
+ casePfx + "span.l2",
+ "//html/body/div[2]/div/div/div[2]/div/div/div/div[2]/div/div/table/tbody/tr/td[2]/div/div/span");
+ private final String IMG_R1_JBOSS = getLoc(casePfx+"img.r1.jboss","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/div/div/div/img");
+ private final String IMG_R1_JBOSS_HANDLE = getLoc(casePfx+"img.r1.jboss","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/div");
+ private final String SPAN_L1 = getLoc(
+ casePfx + "span.l1",
+ "//html/body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div/div/span");
+ private final String MSG_POWER = getMess(casePfx + "msg.power",
+ "Powered by JBoss");
+ private final String LNK_POR_WEA_EDIT = getLoc(
+ casePfx + "lnk.por.wea.edit",
+ "//body/div[2]/div/div/div[2]/div/div/div/div/div/div/table/tbody/tr/td[2]/div/div/div[2]/span/a");
+ private final String SUB_LAYOUT_UPDATE = getLoc(casePfx
+ + "sub.layout.update",
+ "//input[contains(@name,'dashboardLayoutForm:j_id12')]");
+ private final String SUB_PAGE_RENAME = getLoc(casePfx + "sub.page.rename",
+ "//form[contains(@id,'renameForm')]/input[@type='submit']");
+ 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.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");
+ private final String OPT_PORTL1 = getLoc(casePfx + "opt.portl1",
+ "JSPPortletWindow");
+ private final String SEL_CONTENT_TYPE = getLoc(
+ casePfx + "sel.content.type",
+ "//select[contains(@id,'contentTypesForm:instanceId')]");
+ private final String SUB_DEL_FROM_CENTER_REGION = getLoc(casePfx
+ + "sub.del.from.center.region",
+ "//input[contains(@id,'layoutForm:l_center')]");
+ private final String SUB_DOWN_CENTER_REGION = getLoc(casePfx
+ + "sub.down.center.region",
+ "//input[contains(@id,'layoutForm:d_center')]");
+ private final String SUB_UP_CENTER_REGION = getLoc(casePfx
+ + "sub.up.center.region",
+ "//input[contains(@id,'layoutForm:u_center')]");
+ private final String SEL_CENTER_REGION = getLoc(casePfx
+ + "sel.center.region",
+ "//select[contains(@id,'layoutForm:selectMany_center')]");
+ private final String SUB_ADDCENTER = getLoc(casePfx + "sub.addcenter",
+ "//input[contains(@id,'layoutForm:a_center')]");
+ private final String SUB_ADDLEFT = getLoc(casePfx + "sub.addleft",
+ "//input[contains(@id,'layoutForm:a_left')]");
+ private final String LNK_CONFIGURE_DASHBOARD = getLoc(casePfx
+ + "lnk.configure.dashboard", "link=Configure dashboard");
+ private final String LNK_DASHBOARD = getLoc(casePfx + "lnk.dashboard",
+ "link=Dashboard");
+ private final String SEL_PAGE = getLoc(casePfx + "sel.page",
+ "//select[contains(@id,'pageNameSelector')]");
+ private final String INP_PAGENAME = getLoc(casePfx + "inp.pagename",
+ "//input[contains(@id,':pageName')]");
+ private final String SUB_CREATEPAGE = getLoc(casePfx + "sub.createpage",
+ "//form[contains(@id,'j_id3')]/input[@type='submit']");
+ private final String SEL_LAYOUT = getLoc(casePfx + "sel.layout",
+ "//select[contains(@id,'dashboardLayoutForm:layoutSelector')]");
+ private final String SEL_THEME = getLoc(casePfx + "sel.theme",
+ "//select[contains(@id,'dashboardThemeForm:themeSelector')]");
+ private final String SUB_THEMESEL = getLoc(casePfx + "sub.themesel",
+ "//form[contains(@id,'dashboardThemeForm')]/input[@type='submit']");
+
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
}
- @AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ /*
+ * @AfterMethod(groups = {"log"}) protected void logoutAfterTest() {
+ * System.out.println("vilko"); }
+ */
+ /**
+ * Simple drag and drop test processed on "user" dashboard. The greetings
+ * portlet is moved from left to right column and the cms portlet is moved
+ * from the right to left corner. The names of Greetings and User profile
+ * portlets are then used for final assertion. The Greetings portlet message
+ * must be at the top right corner and the "user profile" message should be
+ * in the top left corner.
+ */
+ @Test(enabled = true)
+ public void testDragAndDrop() {
+ logout();
+ login("user", "user");
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- }
+ Assert.assertEquals(selenium.getText(SPAN_L1), "Greetings !");
+ Assert.assertEquals(selenium.getText(SPAN_L2), "User profile");
- private void wait(int t) {
- try {
- Thread.sleep(t);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ selenium.dragAndDropToObject(HAND_L1, DIV_REG_B);
+ selenium.dragAndDropToObject(HAND_R1, DIV_REG_A);
+
+ Assert.assertEquals(selenium.getText(SPAN_L1), "User profile");
+ Assert.assertEquals(selenium.getText(SPAN_R1), "Greetings !");
}
- @Test(enabled = true)
+ /**
+ * Creates a page. In Dashboard configuration a new page named
+ * "DashTestPage" is created. The existence of the link (page) is then
+ * asserted on dashboard.s
+ */
+ @Test()
public void testCreatePage() {
selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- wait(15000);
-
selenium.click(LNK_CONFIGURE_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -77,19 +166,26 @@
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
Assert.assertTrue(selenium.isElementPresent("link=" + pageName));
selenium.click("link=" + pageName);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(POWERED_BY_JBOSS_PORTAL));
+ Assert.assertTrue(selenium.isTextPresent(MSG_POWER));
}
+ /**
+ * Renaming of a page on dashboard. firstly a page named "DashToRenamePage"
+ * is created the same way as in {@link DashboardTestCase#testCreatePage()}.
+ * The page is then renamed to "DashRenamedPage". The existence of the link
+ * named by renamed page on the dashboard is then used as a final assertion.
+ */
@Test(enabled = true, dependsOnMethods = { "testCreatePage" })
public void testRenamePage() {
// firstly create page
selenium.click(LNK_DASHBOARD);
- wait(15000);
+ waitFor(AJAX_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -102,10 +198,11 @@
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
Assert.assertTrue(selenium.isElementPresent("link=" + pageName));
selenium.click("link=" + pageName);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(POWERED_BY_JBOSS_PORTAL));
+ Assert.assertTrue(selenium.isTextPresent(MSG_POWER));
// then rename it
selenium.click(LNK_CONFIGURE_DASHBOARD);
@@ -117,19 +214,32 @@
selenium.click(SUB_PAGE_RENAME);
selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_DASHBOARD);
+ waitFor(AJAX_LOAD);
+ Assert.assertTrue(selenium.isElementPresent("Link=" + pageNameNew));
+
}
+ /**
+ * Updating a theme on a page. On a page created in
+ * {@link DashboardTestCase#testCreatePage()} a theme is changed to
+ * "renaissance". It is asserted that it was not selected before and at the
+ * end it is asserted, that the renaissance value is selected.
+ */
@Test(enabled = true, dependsOnMethods = { "testCreatePage" })
public void testUpdateTheme() {
- // selenium.setSpeed("10000");
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
// selenium.waitForPageToLoad(PAGE_LOAD);
- wait(15000);
+ waitFor(AJAX_LOAD);
selectIfNotSelected(SEL_PAGE, "DashTestPage");
- wait(15000);
+
+ Assert.assertFalse(selenium.getSelectedLabel(SEL_THEME).equals(
+ "renaissance"),
+ "Previously selected theme other then expected.");
+
selenium.select(SEL_THEME, "label=renaissance");
selenium.click(SUB_THEMESEL);
@@ -142,20 +252,31 @@
selectIfNotSelected(SEL_PAGE, "DashTestPage");
- Assert.assertEquals(selenium.getSelectedLabel(SEL_THEME), "renaissance", "Previously selected theme other then expected.");
+ Assert
+ .assertEquals(selenium.getSelectedLabel(SEL_THEME),
+ "renaissance",
+ "Previously selected theme other then expected.");
}
+ /**
+ * Updating a layout on a page. On a page created in
+ * {@link DashboardTestCase#testCreatePage()} a theme is changed to
+ * "generic". It is asserted that it was not selected before and at the end
+ * it is asserted, that the renaissance value is selected.
+ */
@Test(enabled = true, dependsOnMethods = { "testCreatePage" })
public void testUpdateLayout() {
- // selenium.setSpeed("10000");
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
// selenium.waitForPageToLoad(PAGE_LOAD);
- wait(15000);
+ waitFor(AJAX_LOAD);
selenium.windowMaximize();
selectIfNotSelected(SEL_PAGE, "DashTestPage");
- wait(15000);
+
+ Assert.assertFalse(selenium.getSelectedLabel(SEL_LAYOUT).equals(
+ "generic"), "Previously selected layout other then expected.");
+
selenium.select(SEL_LAYOUT, "label=generic");
selenium.click(SUB_LAYOUT_UPDATE);
@@ -168,23 +289,27 @@
selectIfNotSelected(SEL_PAGE, "DashTestPage");
- Assert.assertEquals(selenium.getSelectedLabel(SEL_LAYOUT), "generic", "Previously selected layout other then expected.");
+ Assert.assertEquals(selenium.getSelectedLabel(SEL_LAYOUT), "generic",
+ "Previously selected layout other then expected.");
}
+ /**
+ * Adding a portlet to dashboard. Adding a "Who's online portlet" to
+ * dashboard (center). At the end some strings specific for the portlet are
+ * asserted to appear on a dashboard.
+ */
@Test(enabled = true, dependsOnMethods = { "testCreatePage" })
public void testAddPortlet() {
- // selenium.setSpeed("10000");
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
// selenium.waitForPageToLoad(PAGE_LOAD);
- wait(15000);
+ waitFor(AJAX_LOAD);
selectIfNotSelected(SEL_PAGE, "DashTestPage");
- wait(15000);
selenium.click(LINK_PORTL2);
selenium.waitForPageToLoad(PAGE_LOAD);
- waitForElement("portlet-editor-title");
+ waitForElement(DIV_PORTET_EDITOR_TITLE);
selenium.click(SUB_ADDCENTER);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -193,13 +318,25 @@
selenium.click("link=DashTestPage");
selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+
Assert.assertTrue(selenium.isTextPresent("Current users"));
Assert.assertTrue(selenium.isTextPresent("Among them: * logged-in"));
Assert.assertTrue(selenium.isTextPresent("[admin]"));
- // selenium.setSpeed("0");
}
- @Test(enabled = true, dependsOnMethods = { "testCreatePage", "testAddPortlet" })
+ /**
+ * Moving with portlets on a dashboard. Firstly a page called "DashMovePage"
+ * is created the same way as in {@link DashboardTestCase#testCreatePage()}.
+ * Then two portlets ("Welcome portlet", "Who's online portlet" in that
+ * order) are added to the page the same way as in
+ * {@link DashboardTestCase#testAddPortlet()}. Their positions are swapped
+ * at the end and the ordering of strings on a dashboard page is used for
+ * assertion.
+ *
+ */
+ @Test(enabled = true, dependsOnMethods = { "testCreatePage",
+ "testAddPortlet" })
public void testMovePortlet() {
final String pageName = "DashMovePage";
@@ -207,7 +344,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
// selenium.waitForPageToLoad(PAGE_LOAD);
- wait(15000);
+ waitFor(AJAX_LOAD);
selenium.type(INP_PAGENAME, pageName);
selenium.click(SUB_CREATEPAGE);
@@ -219,14 +356,12 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selectIfNotSelected(SEL_PAGE, pageName);
- wait(15000);
selenium.click(LINK_PORTL1);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(SUB_ADDCENTER);
selenium.waitForPageToLoad(PAGE_LOAD);
selectIfNotSelected(SEL_PAGE, pageName);
- wait(15000);
selenium.click(LINK_PORTL2);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(SUB_ADDCENTER);
@@ -240,9 +375,33 @@
Assert.assertFalse(assertTextOrder("Current;Greetings"));
Assert.assertTrue(assertTextOrder("Greetings;Current"));
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ selectIfNotSelected(SEL_PAGE, pageName);
+
+ selenium.addSelection(SEL_CENTER_REGION, OPT_PORTL2);
+ selenium.click(SUB_UP_CENTER_REGION);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(assertTextOrder("Current;Greetings"));
+ Assert.assertFalse(assertTextOrder("Greetings;Current"));
+
}
- @Test(enabled = true, dependsOnMethods = { "testCreatePage", "testMovePortlet" })
+ /**
+ * Reordering of portlets. After the portlets are moved in
+ * {@link DashboardTestCase#testMovePortlet()}, they are swaped to the
+ * previous position (reordered again) with this test. The ordering of
+ * strings on a dashboard page is used for assertion.
+ */
+ @Test(enabled = true, dependsOnMethods = { "testCreatePage",
+ "testMovePortlet" })
public void testReorder() {
final String pageName = "DashMovePage";
@@ -250,11 +409,11 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
// selenium.waitForPageToLoad(PAGE_LOAD);
- wait(15000);
+ waitFor(AJAX_LOAD);
selectIfNotSelected(SEL_PAGE, pageName);
- wait(15000);
+
selenium.addSelection(SEL_CENTER_REGION, OPT_PORTL1);
- selenium.click(SUB_DOWN_CENTER_REGION);
+ selenium.click(SUB_UP_CENTER_REGION);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_DASHBOARD);
@@ -262,10 +421,16 @@
selenium.click("link=" + pageName);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertFalse(assertTextOrder("Greetings;Current"));
- Assert.assertTrue(assertTextOrder("Current;Greetings"));
+ Assert.assertFalse(assertTextOrder("Current;Greetings"));
+ Assert.assertTrue(assertTextOrder("Greetings;Current"));
}
+ /**
+ * Deleting of a portlet. Portlet added in
+ * {@link DashboardTestCase#testAddPortlet()} is used in this test. The
+ * portlet is deleted and it is asserted that string specific for this
+ * portlet are not appearing on the dashboard anymore.
+ */
@Test(enabled = true, dependsOnMethods = { "testAddPortlet" })
public void testDeletePortlet() {
@@ -273,11 +438,12 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
// selenium.waitForPageToLoad(PAGE_LOAD);
- wait(15000);
+ waitFor(AJAX_LOAD);
selectIfNotSelected(SEL_PAGE, "DashTestPage");
- wait(15000);
- selenium.addSelection(SEL_CENTER_REGION, "label=CurrentUsersPortletWindow");
+
+ selenium.addSelection(SEL_CENTER_REGION,
+ "label=CurrentUsersPortletWindow");
selenium.click(SUB_DEL_FROM_CENTER_REGION);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -291,15 +457,20 @@
Assert.assertFalse(selenium.isTextPresent("[admin]"));
}
+ /**
+ * Adding of google portlet. Same as
+ * {@link DashboardTestCase#testAddPortlet()} but added portlet is of type
+ * "widget/google" (content type selector). "Band Culinaria" google portlet
+ * is used in this test.
+ */
@Test(enabled = false, dependsOnMethods = { "testCreatePage" })
public void testAddGooglePortlet() {
selenium.click(LNK_DASHBOARD);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
// selenium.waitForPageToLoad(PAGE_LOAD);
- wait(15000);
+ waitFor(AJAX_LOAD);
selectIfNotSelected(SEL_PAGE, "DashTestPage");
- wait(15000);
selenium.select(SEL_CONTENT_TYPE, "label=widget/google");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Band Culinaria");
@@ -315,9 +486,148 @@
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, groups = {"XSS"})
+ public void testXssCreatePage() {
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INP_PAGENAME, XSS_STR1);
+ clickAndWait(SUB_CREATEPAGE);
+
+ 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, groups = {"XSS"})
+ public void testXssRenamePage() {
+ selenium.click(LNK_DASHBOARD);
+ waitFor(AJAX_LOAD);
+
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ final String pageName = "DashXSSToRenamePage";
+
+ selenium.type(INP_PAGENAME, pageName);
+
+ clickAndWait(SUB_CREATEPAGE);
+
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ Assert.assertTrue(selenium.isElementPresent("link=" + pageName));
+ selenium.click("link=" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_POWER));
+
+ // then rename it
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selectIfNotSelected(SEL_PAGE, pageName);
+
+ selenium.type(INP_PAGE_RENAME, XSS_STR1);
+ selenium.click(SUB_PAGE_RENAME);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ 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" }, groups = {"XSS"})
+ public void testXssWindowName() {
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ waitFor(AJAX_LOAD);
+
+ selectIfNotSelected(SEL_PAGE, "DashTestPage");
+ selenium.click(LINK_PORTL3);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ waitForElement(DIV_PORTET_EDITOR_TITLE);
+ selenium.type(INP_WINDOW_NAME, XSS_STR1);
+ selenium.click(SUB_ADDCENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_WINDOW_NAME_VALID));
+ }
+
+ /**
+ * Test window name input when no portlet is selected. Types XSS string into
+ * window name and without selecting any portlet it clicks on relevant
+ * submit button. Final assert is made - XSS string should not be the value
+ * of window name input.
+ *
+ * @jira(JBPORTAL-2418)
+ */
+ @Test(enabled = true, dependsOnMethods = { "testCreatePage" }, groups = {"XSS"})
+ public void testXssNonPortletWindowName() {
+ selenium.click(LNK_DASHBOARD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click(LNK_CONFIGURE_DASHBOARD);
+ waitFor(AJAX_LOAD);
+
+ selectIfNotSelected(SEL_PAGE, "DashTestPage");
+ selenium.type(INP_WINDOW_NAME, XSS_STR1);
+ selenium.click(SUB_ADDCENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertFalse(selenium.getValue(INP_WINDOW_NAME).equals(XSS_STR1),
+ "XSS string found on the page in window name input.");
+ Assert.assertTrue(selenium.isTextPresent(MSG_NO_PORTLET),"Message about no portlet selected missing or other then expected");
+ }
+
// http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023
// https://jira.jboss.org/jira/browse/JBPORTAL-2177
- @Test(enabled = false)
+ /**
+ * Dashboard rename page loses portlet state settings bug testing. From
+ * forum reference <a
+ * href="http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023"
+ * >http://www.jboss.com/index.html?module=bb&op=viewtopic&t=143023</a>.
+ * Jira for this issue already created in <a
+ * href="https://jira.jboss.org/jira/browse/JBPORTAL-2177"
+ * >https://jira.jboss.org/jira/browse/JBPORTAL-2177</a>.
+ *
+ * <pre>
+ * - in Configure Dashboard, create a new dashboard page; I called mine test1
+ * - in the left region, add the Weather portlet
+ * - return to the Dashboard, select the new tab/page (test1), you see Miami weather (the default)
+ * - EDIT the weather portlet and enter a local zipcode, press OK, you see local weather, so far so good
+ * - return to Configure Dashboard, rename the page (test1a)
+ * - return to the Dashboard, select the newly renamed tab
+ * - now you no longer see the local weather because renaming the page has lost the portlet window-specific settings
+ * </pre>
+ */
+ @Test(enabled = true)
public void testBugResetPortletSetting() {
final String pageName = "page1";
final String pageNameNew = "page1a";
@@ -329,7 +639,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
// selenium.waitForPageToLoad(PAGE_LOAD);
- wait(15000);
+ waitFor(AJAX_LOAD);
selenium.type(INP_PAGENAME, pageName);
selenium.click(SUB_CREATEPAGE);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -340,7 +650,7 @@
selenium.click("link=" + pageName);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(POWERED_BY_JBOSS_PORTAL));
+ Assert.assertTrue(selenium.isTextPresent(MSG_POWER));
// add weather portlet
selenium.open("/portal/");
@@ -351,7 +661,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selectIfNotSelected(SEL_PAGE, pageName);
- wait(15000);
+
selenium.click(LINK_WEATHER_PORTLET);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(SUB_ADDLEFT);
@@ -378,10 +688,10 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CONFIGURE_DASHBOARD);
// selenium.waitForPageToLoad(PAGE_LOAD);
- wait(15000);
+ waitFor(AJAX_LOAD);
selectIfNotSelected(SEL_PAGE, pageName);
- wait(15000);
+
selenium.type(INP_PAGE_RENAME, pageNameNew);
selenium.click(SUB_PAGE_RENAME);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -394,7 +704,9 @@
selenium.click("link=" + pageNameNew);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Alexandria"), "Previously selected portlet settings were changed after renaming of portal page.");
+ Assert
+ .assertTrue(
+ selenium.isTextPresent("Alexandria"),
+ "Previously selected portlet settings were changed after renaming of portal page.");
}
-
}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/EndToEndBeaPortlet.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/EndToEndBeaPortlet.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/EndToEndBeaPortlet.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -2,141 +2,112 @@
import java.text.MessageFormat;
+import org.jboss.portal.test.selenium.portal.AdminPortalTestCase;
+import org.jboss.portal.test.selenium.portal.PortletDefinitionsTestCase;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
/**
+ * EndToEndBeaPortlet is reposnsible for end-to-end testing of adding a BEA
+ * portlet into a portal page.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
-@Test(groups = {"end2end"}, enabled = true, description = "Creating of new portal with content.")
+@Test(groups = { "end2end" }, enabled = true, description = "Creating of new portal with content.")
public class EndToEndBeaPortlet extends JBossPortalSeleniumTestCase {
- private static final String SUB_VIEW_PORTLETS = "//input[contains(@id,'definition-form:view-portlets')]";
- private static final String SEL_CONS_TYPE = "//select[contains(@id,'definition-form:menu')]";
-
+ /** prefix for locator properties = e2e.wsrp. */
public static String casePfx = "e2e.wsrp.";
-
- private final String INP_CONSUMER_NAME = getProp(casePfx+"inp.consumer.name","//input[contains(@id,'edit-cons-form:id')]");
- private final String SUBMIT_REFRESH_CANCEL = getProp(casePfx+"submit.refresh.cancel","//a[contains(@id,'edit-cons-form:list-cons-link')]");
- private final String SUBMIT_PROD_SAVE = getProp(casePfx+"submit.prod.save","//input[contains(@id,'producer-form:save-producer')]");
- private final String SUBMIT_CONSDEL_CONF = getProp(casePfx+"submit.consdel.conf","//a[contains(@id,'confirm-delete-form:destroy-link')]");
-
- private final String SUBMIT_CONS_REGVAL = getProp(casePfx+"submit.cons.regval","//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
- private final String SUBMIT_REFRESHFINAL = getProp(casePfx+"submit.refreshfinal","//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
-
- private final String INPUT_CONS_REGVALUE = getProp(casePfx+"input.cons.regvalue","//input[contains(@id,'edit-cons-form:existingProps:0:prop-value-input')]");
- private final String SUBMIT_REFRESHSAVE = getProp(casePfx+"submit.refreshsave","//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
- private final String INPUT_CONSWSDL = getProp(casePfx+"input.conswsdl","//input[contains(@id,'edit-cons-form:wsdl')]");
- private final String INPUT_CACHEEXP = getProp(casePfx+"input.cacheexp","//input[contains(@id,'edit-cons-form:cache')]");
- private final String SUBMIT_ADDPROP_INIT = getProp(casePfx+"submit.addprop.init","//a[contains(@id,'producer-form:add-reg-prop')]");
- private final String SUBMIT_ADDPROP = getProp(casePfx+"submit.addprop","//a[contains(@id,'producer-form:add-reg-prop')]");
- private final String INPUT_PROPHINT = getProp(casePfx+"input.prophint","//input[contains(@id,'producer-form:reg-properties:0:hint')]");
- private final String INPUT_PROPLABEL = getProp(casePfx+"input.proplabel","//input[contains(@id,'producer-form:reg-properties:0:label')]");
- private final String INPUT_PROPNAME = getProp(casePfx+"input.propname","//input[contains(@id,'producer-form:reg-properties:0:name')]");
- private final String SUBMIT_CREATECONS = getProp(casePfx+"submit.createcons","//input[contains(@id,'createConsumer:createConsumerButton')]");
- private final String INPUT_CREATECONS = getProp(casePfx+"input.createcons","//input[contains(@id,'createConsumer:consumerName')]");
- private final String ID_LINK_PRODCONF = getProp(casePfx+"id.link.prodconf","//a[contains(@id,'cons-temp-form:producer-link')]");
- private final String ID_LINK_CONSCONF = getProp(casePfx+"id.link.consconf","//a[contains(@id,'producer-temp-form:consumersTab')]");
- private final String LINK_CONSUMER_HOME =getProp(casePfx+"link.consumer.home","//a[contains(@id,'cons-temp-form1:list-cons-link')]");
-
- private final String LINK_T_CONS_CON=getProp(casePfx+"link.t.cons.con","//a[contains(@id,''consumer-list-form:consumersList:{0}:configure'')]");
- private final String LINK_T_CONS_REF=getProp(casePfx+"link.t.cons.ref","//a[contains(@id,''consumer-list-form:consumersList:{0}:refresh'')]");
- private final String LINK_T_CONS_ACT=getProp(casePfx+"link.t.cons.act","//a[contains(@id,''consumer-list-form:consumersList:{0}:activate'')]");
- private final String LINK_T_CONS_DEA=getProp(casePfx+"link.t.cons.dea","//a[contains(@id,''consumer-list-form:consumersList:{0}:activate'')]");
- private final String LINK_T_CONS_REG=getProp(casePfx+"link.t.cons.reg","//a[contains(@id,''consumer-list-form:consumersList:{0}:register'')]");
- private final String LINK_T_CONS_DER=getProp(casePfx+"link.t.cons.der","//a[contains(@id,''consumer-list-form:consumersList:{0}:register'')]");
- private final String LINK_T_CONS_DEL=getProp(casePfx+"link.t.cons.del","//a[contains(@id,''consumer-list-form:consumersList:{0}:delete'')]");
-
- ///
-
- public final String SEL_PORTLET_TYPE = getProp(casePfx+"sel.portlet.type","//select[contains(@id,'windowForm:instanceId')]");
- private final String SUB_LAYOUT_ADD_CENTER = getProp(casePfx+"sub.layout.add.center","//input[contains(@id,'layoutForm:a_center')]");
- private final String INP_WINDOW_NAME = getProp(casePfx+"inp.window.name","//input[contains(@id,'windowForm:windowName')]");
- private final String SUB_RENAME_PORTAL = getProp(casePfx+"sub.rename.portal","//input[contains(@id,'renameForm:rename')]");
- private final String INP_RENAME_PORTAL = getProp(casePfx+"inp.rename.portal","//input[contains(@id,'renameForm:newName')]");
- private final String SUB_DELETE_PORTAL_CONF = getProp(casePfx+"sub.delete.portal.conf","//input[contains(@id,'delete-view:confirm-form:delete')]");
- private final String INP_SUBMIT_PAGECREATE = getProp(casePfx+"inp.submit.pagecreate","//input[contains(@id,'create-page-form:create-page')]");
- private final String INP_PAGENAME = getProp(casePfx+"inp.pagename","//input[contains(@id,'create-page-form:pageName')]");
- private final String INP_PORTALNAME = getProp(casePfx+"inp.portalname","//input[contains(@id,'create-portal-form:name')]");
- private final String INP_SUBMIT_CREATEPORTAL = getProp(casePfx+"inp.submit.createportal","//input[contains(@id,'create-portal-form:create-portal')]");
- private final String TAB_PORTALOBJ_ID = getProp(casePfx+"tab.portalobj.id","Link=Admin");
- private final String LNK_PORTALS_ID = getProp(casePfx+"lnk.portals.id","link=*Portal Objects*");
- private final String LNK_PORTAL_HOME = getProp(casePfx+"lnk.portal.home","//a[contains(@id,'obj-temp-form:object-link-0')]");
- private final String TBL_PORTAL_ADMIN = getProp(casePfx+"tbl.portal.admin","//table[contains(@id,'obj-nav-form:portal-datatable')]");
- private final String POR_TL_MAIN = getProp(casePfx+"por.tl.main","//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]");
- private final String POR_TL_SECURITY = getProp(casePfx+"por.tl.security","//a[contains(@id,''obj-nav-form:portal-datatable:{0}:security-link'')]");
- private final String POR_TL_PROPERTIES = getProp(casePfx+"por.tl.properties","//a[contains(@id,''obj-nav-form:portal-datatable:{0}:prop-link'')]");
- private final String POR_TL_THEME = getProp(casePfx+"por.tl.theme","//a[contains(@id,''obj-nav-form:portal-datatable:{0}:theme-link'')]");
- private final String POR_TL_RENAME = getProp(casePfx+"por.tl.rename","//a[contains(@id,''obj-nav-form:portal-datatable:{0}:rename'')]");
- private final String POR_TL_DELETE = getProp(casePfx+"por.tl.delete","//a[contains(@id,''obj-nav-form:portal-datatable:{0}:delete'')]");
- private final String POR_TL_MAKEDEF = getProp(casePfx+"por.tl.makedef","//a[contains(@id,''obj-nav-form:portal-datatable:{0}:default-link'')]");
- private final String TBL_PORTALPAGE_ADMIN = getProp(casePfx+"tbl.portalpage.admin","//table[contains(@id,'obj-nav-form:pages-datatable')]");
- private final String PAG_TL_MAIN = getProp(casePfx+"pag.tl.main","//a[contains(@id,''obj-nav-form:pages-datatable:{0}:object-link'')]");
- private final String PAG_TL_LAYOUT = getProp(casePfx+"pag.tl.layout","//a[contains(@id,''obj-nav-form:pages-datatable:{0}:edit-page-layout'')]");
- private final String PAG_TL_SECURITY = getProp(casePfx+"pag.tl.security","//a[contains(@id,''obj-nav-form:pages-datatable:{0}:security-link'')]");
- private final String PAG_TL_PROPERTIES = getProp(casePfx+"pag.tl.properties","//a[contains(@id,''obj-nav-form:pages-datatable:{0}:prop-link'')]");
- private final String PAG_TL_THEME = getProp(casePfx+"pag.tl.theme","//a[contains(@id,''obj-nav-form:pages-datatable:{0}:theme-link'')]");
- private final String PAG_TL_RENAME = getProp(casePfx+"pag.tl.rename","//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-link'')]");
- private final String PAG_TL_DISPLAY = getProp(casePfx+"pag.tl.display","//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-display'')]");
- private final String PAG_TL_DELETE = getProp(casePfx+"pag.tl.delete","//a[contains(@id,''obj-nav-form:pages-datatable:{0}:delete-link'')]");
- private final String PAG_TL_MAKEDEF = getProp(casePfx+"pag.tl.makedef","//a[contains(@id,''obj-nav-form:pages-datatable:{0}:default-link'')]");
-
- /// def
-
- private static final String T_LINK_PREF = "//a[contains(@id,''def-list:portlet-pref-{0}'')]";
- private static final String SUBMIT_CREATE_INST = "//input[contains(@name,'add_instance_form:j_id19')]";
- private static final String INPUT_INSTANCE_NAME = "//input[contains(@id,'add_instance_form:instanceId')]";
- private static final String T_LINK_CREATE = "//a[contains(@id,''def-list:create-instance-{0}'')]";
- private static final String SUBMIT_PROVIDER_VIEW = "//input[contains(@id,'definition-form:view-portlets')]";
- private static final String SELECT_PROVIDER = "//select[contains(@id,'definition-form:menu')]";
- private static final String TABLE_PORTLET = "//form[contains(@id,'def-list')]/table";
- private static final String LINK_NAME_ADMIN_PORT = "//a[contains(@id,'common-show-portlet-detail-form:field1:select')]";
- private static final String LINK_ADMIN_PORT = "//a[contains(@id,'def-list:portlet-def-0')]";
- private static final String LINK_ADMIN = "link=Admin";
- private static final String LINK_TAB_PD = "//a[contains(@id,'admin-subtab-form:portlet-def-link')]";
- private static final String LINK_PD_MAIN = "//a[contains(@id,'man-form:def-link')]";
+ private final String LNK_BEA_PREV = getLoc(casePfx + "lnk.bea.next", "link=Goto previous page");
+ private final String LNK_BEA_NEXT = getLoc(casePfx + "lnk.bea.prev", "link=Click here to goto next page");
+ private final String SUB_VIEW_PORTLETS = "//input[contains(@id,'definition-form:view-portlets')]";
+ private final String SEL_CONS_TYPE = "//select[contains(@id,'definition-form:menu')]";
+ private final String ADR_HOME = getLoc(casePfx + "adr.home", "portal/auth/portal/default");
+ private final String SUBMIT_CONS_REGVAL = getLoc(casePfx + "submit.cons.regval", "//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
+ private final String SUBMIT_REFRESHFINAL = getLoc(casePfx + "submit.refreshfinal", "//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
+ private final String INPUT_CONS_REGVALUE = getLoc(casePfx + "input.cons.regvalue",
+ "//input[contains(@id,'edit-cons-form:existingProps:0:prop-value-input')]");
+ private final String SUBMIT_REFRESHSAVE = getLoc(casePfx + "submit.refreshsave", "//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
+ private final String INPUT_CONSWSDL = getLoc(casePfx + "input.conswsdl", "//input[contains(@id,'edit-cons-form:wsdl')]");
+ private final String INPUT_CACHEEXP = getLoc(casePfx + "input.cacheexp", "//input[contains(@id,'edit-cons-form:cache')]");
+ private final String SUBMIT_CREATECONS = getLoc(casePfx + "submit.createcons", "//input[contains(@id,'createConsumer:createConsumerButton')]");
+ private final String INPUT_CREATECONS = getLoc(casePfx + "input.createcons", "//input[contains(@id,'createConsumer:consumerName')]");
+ private final String ID_LINK_CONSCONF = getLoc(casePfx + "id.link.consconf", "//a[contains(@id,'producer-temp-form:consumersTab')]");
+ private final String SEL_PORTLET_TYPE = getLoc(casePfx + "sel.portlet.type", "//select[contains(@id,'windowForm:instanceId')]");
+ private final String SUB_LAYOUT_ADD_CENTER = getLoc(casePfx + "sub.layout.add.center", "//input[contains(@id,'layoutForm:a_center')]");
+ private final String TAB_PORTALOBJ_ID = getLoc(casePfx + "tab.portalobj.id", "Link=Admin");
+ private final String LNK_PORTALS_ID = getLoc(casePfx + "lnk.portals.id", "link=*Portal Objects*");
+ private final String LNK_PORTAL_HOME = getLoc(casePfx + "lnk.portal.home", "//a[contains(@id,'obj-temp-form:object-link-0')]");
+ private final String TBL_PORTAL_ADMIN = getLoc(casePfx + "tbl.portal.admin", "//table[contains(@id,'obj-nav-form:portal-datatable')]");
+ private final String POR_TL_MAIN = getLoc(casePfx + "por.tl.main", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]");
+ private final String TBL_PORTALPAGE_ADMIN = getLoc(casePfx + "tbl.portalpage.admin", "//table[contains(@id,'obj-nav-form:pages-datatable')]");
+ private final String PAG_TL_LAYOUT = getLoc(casePfx + "pag.tl.layout", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:edit-page-layout'')]");
+ private final String SUB_CREATE_INS = getLoc(casePfx + "sub.create.ins", "//input[contains(@name,'add_instance_form:j_id19')]");
+ private final String INP_INS_NAME = getLoc(casePfx + "inp.ins.name", "//input[contains(@id,'add_instance_form:instanceId')]");
+ private final String T_LNK_CREATE = getLoc(casePfx + "t.lnk.create", "//a[contains(@id,''def-list:create-instance-{0}'')]");
+ private final String TAB_PORTLET = getLoc(casePfx + "tab.portlet", "//form[contains(@id,'def-list')]/table");
+ private final String LNK_ADMIN = getLoc(casePfx + "lnk.admin", "link=Admin");
+ private final String LNK_TAB_PD = getLoc(casePfx + "lnk.tab.pd", "//a[contains(@id,'admin-subtab-form:portlet-def-link')]");
+ private final String LNK_PD_MAIN = getLoc(casePfx + "lnk.pd.main", "//a[contains(@id,'man-form:def-link')]");
- public static String WSRP_CONSUMER_TABLE = "//table[contains(@id,':consumer-list-form:consumersList')]";
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
- //logout();
+ protected void logoutAfterTest() {
}
-
- private String PORTLET = "";
-
+
+ /**
+ * Testing the end-to-end adding of bea portlet. Simple WSRP consumer with
+ * name "BeaE2E" is created similar way as in
+ * {@link WSRPTestCase#testCreateBeaConsumer()}. Then the portlet instance
+ * is created with definition name "BEA: Hellow World", instance name
+ * "1BeaPor" and of type "BeaE2E" similar way as in
+ * {@link PortletDefinitionsTestCase#testCreateInstance()}. The instance is
+ * then added to page "default" to portal "default" similar way as in
+ * {@link AdminPortalTestCase#testCreateWindow()}. The final assertion is
+ * made in the "default" page of "default" portal. The appearance of string
+ * specific for bea portlet is asserted. The link
+ * "Click here to goto next page." in Bea portlet is then clicked, the text
+ * "Welcome back!" is asserted. At the end the link "Goto previous page." is
+ * clicked and the previous text is asserted.
+ */
@Test(enabled = true, description = "Creating a standard BEA portlet.")
- public void testEnd2EndBeaPortlet(){
-
+ public void testEnd2EndBeaPortlet() {
+
String consName = "BeaE2E";
String portalName = "default";
String pageName = "default";
- String defName= "BEA: Hello World";
- String insName = "1BeaPor";
-
+ String defName = "BEA: Hello World";
+ String insName = "1BeaPor";
+
createConsumer(consName);
createInstance(defName, consName, insName);
addPortlet(portalName, pageName, insName, "portlet");
-
- selenium.open("/portal/");
+
+ selenium.open(ADR_HOME);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
Assert.assertTrue(selenium.isTextPresent("1BeaPorWindow"));
Assert.assertTrue(selenium.isTextPresent("Welcome to WebLogic Portal WSRP Demo."));
-
+
+ selenium.click(LNK_BEA_NEXT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent("Welcome back!"));
+ selenium.click(LNK_BEA_PREV);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
}
-
- private void createConsumer(String consumerName){
- selenium.open("/portal/");
+
+ private void createConsumer(String consumerName) {
+ selenium.open(ADR_HOME);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Admin");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -145,96 +116,83 @@
clickIfVisible(ID_LINK_CONSCONF);
selenium.type(INPUT_CREATECONS, consumerName);
-
+
selenium.click(SUBMIT_CREATECONS);
selenium.waitForPageToLoad(PAGE_LOAD);
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("Refresh failed (probably because the registration information was not valid)."));
+ //Assert.assertTrue(selenium.isTextPresent("Refresh failed (probably because the registration information was not valid)."));
Assert.assertTrue(selenium.isTextPresent("Missing value"));
selenium.type(INPUT_CONS_REGVALUE, "public");
selenium.click(SUBMIT_CONS_REGVAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Refresh was successful."));
+ Assert.assertTrue(selenium.isTextPresent("configuration (active)"));
selenium.click(SUBMIT_REFRESHFINAL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(consumerName));
}
-
- private void createInstance(String defName, String type, String insName){
- selenium.open("/portal/");
+
+ private void createInstance(String defName, String type, String insName) {
+ selenium.open(ADR_HOME);
selenium.waitForPageToLoad(PAGE_LOAD);
-
- clickIfVisible(LINK_ADMIN);
- clickIfVisible(LINK_ADMIN);
- clickIfVisible(LINK_TAB_PD);
- clickIfVisible(LINK_PD_MAIN);
-
- selenium.select(SEL_CONS_TYPE, "label="+type);
+
+ clickIfVisible(LNK_ADMIN);
+ clickIfVisible(LNK_ADMIN);
+ clickIfVisible(LNK_TAB_PD);
+ clickIfVisible(LNK_PD_MAIN);
+
+ selenium.select(SEL_CONS_TYPE, "label=" + type);
selenium.click(SUB_VIEW_PORTLETS);
selenium.waitForPageToLoad(PAGE_LOAD);
-
- int r = findTableRow(TABLE_PORTLET, defName, 0);
-
- selenium.click(MessageFormat.format(T_LINK_CREATE,r-1));
- selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_INSTANCE_NAME, insName);
- selenium.click(SUBMIT_CREATE_INST);
+ int r = findTableRow(TAB_PORTLET, defName, 0);
+
+ selenium.click(MessageFormat.format(T_LNK_CREATE, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent(insName + " portlet details"));
+
+ selenium.type(INP_INS_NAME, insName);
+ selenium.click(SUB_CREATE_INS);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(insName + " portlet details"));
}
-
+
private void addPortlet(String portalName, String pageName, String portletName, String type) {
- selenium.open("/portal/");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.open(ADR_HOME);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
- clickIfVisible(TAB_PORTALOBJ_ID);
- clickIfVisible(LNK_PORTALS_ID);
- clickIfVisible(LNK_PORTAL_HOME);
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LNK_PORTALS_ID);
+ clickIfVisible(LNK_PORTAL_HOME);
- int r = findTableRow(TBL_PORTAL_ADMIN, portalName, 0) - 1;
- selenium.click(MessageFormat.format(POR_TL_MAIN, r));
- selenium.waitForPageToLoad(PAGE_LOAD);
+ int r = findTableRow(TBL_PORTAL_ADMIN, portalName, 0) - 1;
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
- r = findTableRow(TBL_PORTALPAGE_ADMIN, pageName, 0) - 1;
+ r = findTableRow(TBL_PORTALPAGE_ADMIN, pageName, 0) - 1;
- // click on the page layout
- selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
+ // click on the page layout
+ selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
+ waitFor(AJAX_LOAD);
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- //hack
- selenium.select(SEL_PORTLET_TYPE, "label=" + "cms");
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- selenium.select(SEL_PORTLET_TYPE, "label=" + type);
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
-
- selenium.click("link=*"+portletName+"*");
- selenium.waitForPageToLoad(PAGE_LOAD);
+ // hack
+ selenium.select(SEL_PORTLET_TYPE, "label=" + "cms");
+ waitFor(AJAX_LOAD);
- selenium.click(SUB_LAYOUT_ADD_CENTER);
- selenium.waitForPageToLoad(PAGE_LOAD);
-
- }
+ selenium.select(SEL_PORTLET_TYPE, "label=" + type);
+ waitFor(AJAX_LOAD);
+
+ selenium.click("link=*" + portletName + "*");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click(SUB_LAYOUT_ADD_CENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ }
}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -8,80 +8,92 @@
import org.testng.annotations.Test;
/**
+ * IdentityAdminTestCase is responsible for
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
@Test(groups = { "admin_ui" }, enabled = true)
public class IdentityAdminTestCase extends JBossPortalSeleniumTestCase {
-
+ /** prefix for locator properties */
public String casePfx = "iden.man.";
- private final String INP_USER_SEARCH_PREV = getProp(casePfx + "inp.user.search.prev", "//input[contains(@id,'search-user-form1:prev-page')]");
- private final String INP_USER_SEARCH_NEXT = getProp(casePfx + "inp.user.search.next", "//input[contains(@id,'search-user-form1:next-page')]");
+ 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')]");
- private final String SEL_SEARCHUSER_LIMIT = getProp(casePfx + "sel.searchuser.limit", "//select[contains(@id,'search-user-form:limit')]");
- final String SUB_EDIT_PROF = getProp(casePfx + "sub.edit.prof", "//input[contains(@id,'profile-form:submit')]");
+ private final String SEL_SEARCHUSER_LIMIT = getLoc(casePfx + "sel.searchuser.limit", "//select[contains(@id,'search-user-form:limit')]");
+ private final String SUB_EDIT_PROF = getLoc(casePfx + "sub.edit.prof", "//input[contains(@id,'profile-form:submit')]");
- private final String SUB_PAGIN_LEFT = getProp(casePfx + "sub.pagin.left", INP_USER_SEARCH_PREV);
- private final String SUB_PAGIN_RIGHT = getProp(casePfx + "sub.pagin.right", INP_USER_SEARCH_NEXT);
+ private final String SUB_PAGIN_LEFT = getLoc(casePfx + "sub.pagin.left", INP_USER_SEARCH_PREV);
+ private final String SUB_PAGIN_RIGHT = getLoc(casePfx + "sub.pagin.right", INP_USER_SEARCH_NEXT);
- private final String SUB_EDIT_USER_EMAIL_CANCEL = getProp(casePfx + "sub.edit.user.email.cancel", "//input[contains(@id,'profile-form:cancel')]");
- private final String INP_EDIT_USER_EMAIL = getProp(casePfx + "inp.edit.user.email", "//input[contains(@id,'profile-form:email')]");
- private final String SUB_ROLE_SEARCH_USER = getProp(casePfx + "sub.role.search.user", "//input[contains(@id,'search-user-form:search') and @type='submit']");
- private final String INP_ROLE_SEARCH_USER = getProp(casePfx + "inp.role.search.user", "//input[contains(@id,'search-user-form:searchString')]");
- private final String SUB_EDIT_ROLE_SUBMIT = getProp(casePfx + "sub.edit.role.submit", "//input[contains(@id,'edit-role-link:submit')]");
- private final String SUB_EDIT_ROLE_CANCEL = getProp(casePfx + "sub.edit.role.cancel", "//input[contains(@id,'edit-role-link:cancel')]");
- private final String INP_EDIT_ROLE_NAME = getProp(casePfx + "inp.edit.role.name", "//input[contains(@id,'edit-role-link:display-name')]");
- private final String SUB_PASS_CHANGE_SUBMIT = getProp(casePfx + "sub.pass.change.submit", "//input[contains(@name,'change-pwd-form:j_id31')]");
- private final String SUB_PASS_CHANGE_CANCEL = getProp(casePfx + "sub.pass.change.cancel", "//input[contains(@id,'change-pwd-form:cancel')]");
- private final String INP_PASS_CHANGE_P2 = getProp(casePfx + "inp.pass.change.p2", "//input[contains(@id,':change-pwd-form:passwordCheck')]");
- private final String INP_PASS_CHANGE_P1 = getProp(casePfx + "inp.pass.change.p1", "//input[contains(@id,':change-pwd-form:password')]");
- private final String LNK_CHANGE_PASS = getProp(casePfx + "lnk.change.pass", "//a[contains(@id,':profile-form:change-pwd-adm-link')]");
- public final String TBL_USERLIST = getProp(casePfx + "tbl.userlist", "//table[contains(@id,'search-user-form1:userlist')]");
- public final String LNK_T_USRLIST_DEL = getProp(casePfx + "lnk.t.usrlist.del", "//a[contains(@id,''search-user-form1:userlist:{0}:delete-user-link'')]");
- public final String LNK_T_USRLIST_ROLES = getProp(casePfx + "lnk.t.usrlist.roles", "//a[contains(@id,''search-user-form1:userlist:{0}:assign-role-link'')]");
- public final String LNK_T_USRLIST_DIS = getProp(casePfx + "lnk.t.usrlist.dis", "//a[contains(@id,''search-user-form1:userlist:{0}:enable-user-link'')]");
- public final String LNK_T_USRLIST_EDIT = getProp(casePfx + "lnk.t.usrlist.edit", "//a[contains(@id,''search-user-form1:userlist:{0}:rename-link'')]");
+ private final String SUB_EDIT_USER_EMAIL_CANCEL = getLoc(casePfx + "sub.edit.user.email.cancel", "//input[contains(@id,'profile-form:cancel')]");
+ private final String INP_EDIT_USER_EMAIL = getLoc(casePfx + "inp.edit.user.email", "//input[contains(@id,'profile-form:email')]");
+ private final String SUB_ROLE_SEARCH_USER = getLoc(casePfx + "sub.role.search.user", "//input[contains(@id,'search-user-form:search') and @type='submit']");
+ private final String INP_ROLE_SEARCH_USER = getLoc(casePfx + "inp.role.search.user", "//input[contains(@id,'search-user-form:searchString')]");
+ private final String SUB_EDIT_ROLE_SUBMIT = getLoc(casePfx + "sub.edit.role.submit", "//input[contains(@id,'edit-role-link:submit')]");
+ private final String SUB_EDIT_ROLE_CANCEL = getLoc(casePfx + "sub.edit.role.cancel", "//input[contains(@id,'edit-role-link:cancel')]");
+ private final String INP_EDIT_ROLE_NAME = getLoc(casePfx + "inp.edit.role.name", "//input[contains(@id,'edit-role-link:display-name')]");
+ private final String SUB_PASS_CHANGE_SUBMIT = getLoc(casePfx + "sub.pass.change.submit", "//input[contains(@name,'change-pwd-form:j_id31')]");
+ private final String SUB_PASS_CHANGE_CANCEL = getLoc(casePfx + "sub.pass.change.cancel", "//input[contains(@id,'change-pwd-form:cancel')]");
+ private final String INP_PASS_CHANGE_P2 = getLoc(casePfx + "inp.pass.change.p2", "//input[contains(@id,':change-pwd-form:passwordCheck')]");
+ private final String INP_PASS_CHANGE_P1 = getLoc(casePfx + "inp.pass.change.p1", "//input[contains(@id,':change-pwd-form:password')]");
+ private final String LNK_CHANGE_PASS = getLoc(casePfx + "lnk.change.pass", "//a[contains(@id,':profile-form:change-pwd-adm-link')]");
+ private final String TBL_USERLIST = getLoc(casePfx + "tbl.userlist", "//table[contains(@id,'search-user-form1:userlist')]");
+ 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_T_USRLIST_ROLES = getLoc(casePfx + "lnk.t.usrlist.roles", "//a[contains(@id,''search-user-form1:userlist:{0}:assign-role-link'')]");
+ private final String LNK_T_USRLIST_DIS = getLoc(casePfx + "lnk.t.usrlist.dis", "//a[contains(@id,''search-user-form1:userlist:{0}:enable-user-link'')]");
+ private final String LNK_T_USRLIST_EDIT = getLoc(casePfx + "lnk.t.usrlist.edit", "//a[contains(@id,''search-user-form1:userlist:{0}:rename-link'')]");
+ private final String TBL_ROLELIST = getLoc(casePfx + "tbl.rolelist", "//table[contains(@id,'roles-form:userlist')]");
- public final String TBL_ROLELIST = getProp(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 LNK_T_ROLLIST_MEMBERS = getLoc(casePfx + "lnk.t.rollist.members", "//a[contains(@id,''roles-form:userlist:{0}:view-role-link'')]");
+ private final String LNK_T_ROLLIST_EDIT = getLoc(casePfx + "lnk.t.rollist.edit", "//a[contains(@id,''roles-form:userlist:{0}:edit-role-link'')]");
- public final String LNK_T_ROLLIST_DEL = getProp(casePfx + "lnk.t.rollist.del", "//a[contains(@id,''roles-form:userlist:{0}:delete-role-link'')]");
- public final String LNK_T_ROLLIST_MEMBERS = getProp(casePfx + "lnk.t.rollist.members", "//a[contains(@id,''roles-form:userlist:{0}:view-role-link'')]");
- public final String LNK_T_ROLLIST_EDIT = getProp(casePfx + "lnk.t.rollist.edit", "//a[contains(@id,''roles-form:userlist:{0}:edit-role-link'')]");
+ private final String TBL_ROLEMEMBERS = getLoc(casePfx + "tbl.rolemembers", "//table[contains(@id,'role-members-form:role-data-table')]");
- public final String TBL_ROLEMEMBERS = getProp(casePfx + "tbl.rolemembers", "//table[contains(@id,'role-members-form:role-data-table')]");
+ 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')]");
- public final String SUB_CONF_CREATE_USER = getProp(casePfx + "sub.conf.create.user", "//input[contains(@id,'confirm-form:admin')]");
- public final String SUB_DELETE_ROLE = getProp(casePfx + "sub.delete.role", "//input[contains(@id,'delete-role-form:confirm')]");
- public final String SUB_ROLE_CREATE = getProp(casePfx + "sub.role.create", "//input[contains(@id,'create-role-form:submit')]");
- public final String INP_ROLEDISNAME = getProp(casePfx + "inp.roledisname", "//input[contains(@id,'create-role-form:roledisplayname')]");
- public final String INP_ROLENAME = getProp(casePfx + "inp.rolename", "//input[contains(@id,'create-role-form:rolename')]");
+ 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_ASSIGN_ROLE = getLoc(casePfx + "sub.assign.role", "//input[contains(@id,'assign-roles-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')]");
- public final String LNK_ROLE_CREATE = getProp(casePfx + "lnk.role.create", "//a[contains(@id, 'create-role-form:create-role-link')]");
- public final String SUB_DEL_USER = getProp(casePfx + "sub.del.user", "//input[contains(@id,'delete-user-form:submit')]");
- public final String SUB_ASSIGN_ROLE = getProp(casePfx + "sub.assign.role", "//input[contains(@id,'assign-roles-form:submit')]");
- public final String SUB_USER_ROLE = getProp(casePfx + "sub.user.role", "//input[contains(@id,'register-role-form:submit')]");
- public final String SUB_CREATE_USER = getProp(casePfx + "sub.create.user", "//input[contains(@id,'register-form:submit')]");
- public final String INP_PASSWORD_CHK = getProp(casePfx + "inp.password.chk", "//input[contains(@id,'register-form:passwordCheck')]");
- public final String INP_PASSWORD = getProp(casePfx + "inp.password", "//input[contains(@id,'register-form:password')]");
- public final String INP_USEREMAIL = getProp(casePfx + "inp.useremail", "//input[contains(@id,'register-form:email')]");
- public final String INP_USERNAME = getProp(casePfx + "inp.username", "//input[contains(@id,'register-form:username')]");
- public final String SUB_SEARCH_USER = getProp(casePfx + "sub.search.user", "//input[contains(@id,'search-user-form:search') and @type='submit']");
- public final String INP_SEARCH_USER = getProp(casePfx + "inp.search.user", "//input[contains(@id,'search-user-form:searchString')]");
- public final String LNK_SEARCH_USER = getProp(casePfx + "lnk.search.user", "//a[contains(@id,'user-form:search-user-link')]");
- public final String LNK_USERTAB = getProp(casePfx + "lnk.usertab", "//a[contains(@id,'role-temp-form:manage-users')]");
- public final String LNK_USERMAIN = getProp(casePfx + "lnk.usermain", "//a[contains(@id,'user-temp-form1:user-adm-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-adm-link')]");
+ private final String LNK_ROLEMAIN2 = getLoc(casePfx + "lnk.rolemain2", "//a[contains(@id, 'role-admin-link')]");
- public final String LNK_ROLETAB = getProp(casePfx + "lnk.roletab", "//a[contains(@id,'user-temp-form:role-mgm-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')]");
- public final String LNK_ROLEMAIN = getProp(casePfx + "lnk.rolemain", "//a[contains(@id, 'role-temp-form1:role-admin-link')]");
- public final String LNK_USERMANG_MAIN = getProp(casePfx + "lnk.usermang.main", "//a[contains(@id,'user-temp-form1:assign-role-link')]");
- public final String LNK_USERMANG_MAIN2 = getProp(casePfx + "lnk.usermang.main2", "//a[contains(@id,'user-temp-form1:user-mgm-link')]");
- public final String LNK_CREATE_USER = getProp(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}'']");
- public final String CHK_ROLE = getProp(casePfx + "chk.role", "//input[contains(@name,''assign-roles-form:roles'') and @value=''{0}'']");
+ private final String MSG_CREATE_ROLE = getMess(casePfx + "chk.role", "Create role");
+ /** The timeout used to wait after clicking submit button in user search. */
public final long SEARCH_TIMEOUT = 10000;
private String butDelUsr_id(String userName) {
@@ -90,20 +102,20 @@
return MessageFormat.format(LNK_T_USRLIST_DEL, r - 1);
}
- String butUsrRol_id(String userName) {
+ private String butUsrRol_id(String userName) {
String table = TBL_USERLIST;
int r = findTableRow(table, userName, 0);
return MessageFormat.format(LNK_T_USRLIST_ROLES, r - 1);
}
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ private void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ private void logoutAfterTest() {
}
@@ -118,6 +130,12 @@
* }
*/
+ /**
+ * Test create user is responsible for user creation. It creates a user
+ * named "tempUser" with password "TempPassword" and e-mail
+ * "tempUser(a)redhat.com". Then it tries to look up the user with search
+ * function. At the end, it deletes the temp user.
+ */
@Test(enabled = true, description = "Creation of new user.")
public void testCreateUser() {
createUser("tempUser", "tempPassword", "tempUser(a)redhat.com");
@@ -125,6 +143,13 @@
deleteUser("tempUser", "tempUser(a)redhat.com");
}
+ /**
+ * Test create existing user is respnosible for testing already created user
+ * creation. It creates a user named "tempUser" with password "TempPassword"
+ * and e-mail "tempUser(a)redhat.com". Then it tries to look up the user with
+ * search function. After success it tries to create the same user again and
+ * asserts that it is not possible. At the end, it deletes the temp user.
+ */
@Test(enabled = true, dependsOnMethods = { "testCreateUser" }, description = "Creation of already existing user.")
public void testCreateExistingUser() {
createUser("tempUser", "tempPassword", "tempUser(a)redhat.com");
@@ -133,6 +158,11 @@
deleteUser("tempUser", "tempUser(a)redhat.com");
}
+ /**
+ * Test create role is responsible for user creation. It creates a role
+ * named "tempRole" with display name "tempRoleDisplay". At the end, it
+ * deletes the temp user.
+ */
@Test(enabled = true, description = "Creation of new role.")
public void testCreateRole() {
String role = "tempRole";
@@ -140,12 +170,27 @@
deleteRole(role);
}
+ /**
+ * Test delete user is responsible for deleting a user. At first it creates
+ * user "deleteMe" with password "deleterPass" and e-mail
+ * "disableMe(a)redhat.com" At the end it deletes the user.
+ */
@Test(enabled = true, description = "Creating and deteling a user.")
public void testDeleteUser() {
createUser("deleteMe", "deleterPass", "disableMe(a)redhat.com");
deleteUser("deleteMe", "disableMe(a)redhat.com");
}
+ /**
+ * Test disable user is responsible for disabling a user. At first it
+ * creates user "disableMe" with password "disablePass" and e-mail
+ * "disableMe(a)redhat.com" After that, it logs out and try to login as
+ * disableMe/disablePass. After success it logs out again, and login as
+ * admin. It disables the disableMe user and tries to login as
+ * disableMe/disablePass again asserting that login is not possible (
+ * message about disabled account has to appear ).
+ *
+ */
@Test(enabled = true, description = "Creating and disabling a user.")
public void testDisableUser() {
final String userName = "disableMe";
@@ -167,21 +212,18 @@
logout();
// trying to log in with disabled account
- selenium.open(ADDR_PORTAL);
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LINK_LOGIN);
selenium.selectFrame(FRAME_LOGIN_CONTENT);
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ waitFor(AJAX_LOAD);
selenium.type(INPUT_USERNAME, userName);
selenium.type(INPUT_PASSWORD, userPass);
+ selenium.fireEvent(INPUT_PASSWORD, "keydown");
+
selenium.click(SUBMIT_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Your account is disabled"), "Message telling that account is disabled is other then expected or missing.");
@@ -194,6 +236,15 @@
deleteUser(userName, userMail);
}
+ /**
+ * Test enable user is responsible for enabling a user. At first it creates
+ * user "enableMe" with password "enableMe" and e-mail "enableMe(a)redhat.com"
+ * Then it disables the user, asserts the user is really disabled and at the
+ * end it enables the user. Only the appereance (or non-appereance ) of the
+ * "Enable" button for the user is used for assertions.
+ */
+ // TODO better checking of the user status should be reconsidered (logging
+ // in)
@Test(enabled = true, dependsOnMethods = { "testDisableUser" }, description = "Enabling disabled user.")
public void testEnableUser() {
final String userName = "enableMe";
@@ -220,10 +271,18 @@
searchUser(userName, userMail);
r = findTableRow(TBL_USERLIST, "Enable", 5);
Assert.assertTrue(r < 0, "No user should be disabled.");
-
+
deleteUser(userName, userMail);
}
+ /**
+ * Test edit user is responsible for user editing. At first it creates user
+ * "editMe" with password "editPass" and e-mail "editMe(a)redhat.com". Then it
+ * searches for the user and click on edit link. The e-mail of user is
+ * changed to "editMe2(a)redhat.com". The user is searched again and assert
+ * for his e-mail is made at the end. The user is deleted at the end of this
+ * test.
+ */
@Test(enabled = true, description = "Editing a user.")
public void testEditUser() {
final String userName = "editMe";
@@ -251,26 +310,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.type(INP_EDIT_USER_EMAIL, "editMe2(a)redhat.com");
- /*
- * selenium.select("profile-form:timezone",
- * "label=(GMT -12:00 hours) Eniwetok, Kwajalein");
- * selenium.select("profile-form:theme", "label=portal.industrial");
- * selenium.select("profile-form:locale", "label=Albanian");
- * selenium.type("profile-form:givenname", "Edit");
- * selenium.type("profile-form:lastname", "Meme");
- * selenium.type("profile-form:location", "Editoland");
- * selenium.type("profile-form:skype", "editor");
- * selenium.type("profile-form:icq", "112113114");
- * selenium.type("profile-form:aim", "83838495");
- * selenium.type("profile-form:msnm", "u8u8i9o0");
- * selenium.type("profile-form:yim", "99384875");
- * selenium.type("profile-form:xmmp", "10309128");
- * selenium.type("profile-form:homepage", "http://www.edit.com");
- * selenium.type("profile-form:occupation", "editor");
- * selenium.type("profile-form:interests", "editing");
- * selenium.type("profile-form:signature", "----\n\ni like to edit");
- * selenium.type("profile-form:extra", "me edit good");
- */
+
selenium.click(SUB_EDIT_PROF);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("editMe2(a)redhat.com"), "Edited e-mail adress not visible.");
@@ -279,6 +319,14 @@
}
+ /**
+ * Test edit user change password is responsible for testing the change of
+ * password for a user. At first it creates user "changePass" with password
+ * "changePassPass" and e-mail "changePass(a)redhat.com". Then the password
+ * change orm is filled, but canceled. The next step is submitting the
+ * password change to new value "changePass2". At the end the test tries to
+ * login with the new password and then it deletes the "changePass" user.
+ */
@Test(enabled = true, description = "Editing a user - changing of password.")
public void testEditUserChangePassword() {
final String userName = "changePass";
@@ -338,6 +386,15 @@
deleteUser(userName, userMail);
}
+ /**
+ * Test role members is responsible for role assignment. At first it creates
+ * user "newRoleMember" with password "newRoleMember" and e-mail
+ * "newRoleMem(a)redhatqa.com". Then it creates role with name "membersRole"
+ * and display name "membersRoleDisplay". At next step it assignes the role
+ * to the user. It click for the "members" button for the "membersRole" and
+ * tries to find "newRoleMember". At the end it deletes the "newRoleMember"
+ * user and "membersRole" role.
+ */
@Test(enabled = true, description = "Managing members of role.")
public void testRoleMembers() {
final String roleName = "membersRole";
@@ -353,6 +410,7 @@
clickUntilMembers();
clickIfVisible(LNK_ROLETAB);
clickIfVisible(LNK_ROLEMAIN);
+ clickIfVisible(LNK_ROLEMAIN2);
int r = findTableRow(TBL_ROLELIST, roleName, 0);
selenium.click(MessageFormat.format(LNK_T_ROLLIST_MEMBERS, r - 1));
@@ -377,6 +435,12 @@
deleteUser(userName, userMail);
}
+ /**
+ * Test role edit is responsible for testing of role editing. At first it
+ * creates role with name "editRole" and display name "editRoleDisplay". At
+ * the end it change the display name to "editedRoleDisplay" and delete the
+ * role.
+ */
@Test(enabled = true, description = "Creation of new role.")
public void testRoleEdit() {
final String roleName = "editRole";
@@ -429,22 +493,258 @@
deleteRole(roleName);
}
- @Test(enabled = false)
- public void testManyUsers() {
- for (int i = 0; i < 25; i++) {
- createUser("user0" + i + "", "useruser", "user0" + i + "" + "@portal.com");
- }
+ /**
+ * Xss testing of user creating dialog. XSS string is passed to user name
+ * input, the form is submitted and text indicating incorrect username input
+ * is asserted. The page is realoaded and XSS string is passed to user
+ * e-mail input, the form is submitted and text indicating incorrect user
+ * e-mail input is asserted.
+ */
+ @Test(enabled = true, groups = {"XSS"})
+ public void testXssUserCreate() {
+ openAndWait(ADR_PORTAL);
+ clickAndWait(LNK_ADMIN);
+ clickAndWait(LNK_MEMBERS);
+ clickAndWait(LNK_CREATE_USER);
+
+ selenium.type(INP_USERNAME, XSS_STR1);
+ clickAndWait(SUB_CREATE_USER);
+
+ Assert.assertTrue(selenium.isTextPresent("is an invalid username"));
+
+ openAndWait(ADR_PORTAL);
+
+ clickIfVisible(LNK_ADMIN);
+ clickIfVisible(LNK_MEMBERS);
+ clickIfVisible(LNK_CREATE_USER);
+
+ selenium.type(INP_USERNAME, "user");
+ selenium.type(INP_USEREMAIL, XSS_STR1);
+
+ clickAndWait(SUB_CREATE_USER);
+
+ Assert.assertTrue(selenium.isTextPresent("Invalid E-Mail address."));
+
}
-
- void goToEdit(String userName, String userMail) {
+
+ /**
+ * When creating a role, firstly the XSS string is put into role name input
+ * and "diddi" is put into role display name. After pressing the create
+ * button it is asserted, that an error message about invalid role name was
+ * printed. In the second approach, the role name is "rolee" and XSS string
+ * is used as a role display name. After pressing the create button it is
+ * asserted, that an error message about invalid role display name was
+ * printed.
+ */
+ @Test(enabled = true, groups = {"XSS"})
+ public void testXssRoleCreate() {
+ openAndWait(ADR_PORTAL);
+ clickIfVisible(LNK_ADMIN);
+ clickIfVisible(LNK_ADMIN);
+ clickIfVisible(LNK_MEMBERS);
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
+ clickIfVisible(LNK_ROLE_CREATE);
+
+ selenium.type(INP_ROLENAME, XSS_STR1);
+ selenium.type(INP_ROLEDISNAME, "diddi");
+ clickAndWait(SUB_ROLE_CREATE);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_ROLE_NAME_VALID));
+
+ openAndWait(ADR_PORTAL);
+ clickIfVisible(LNK_ADMIN);
+ clickIfVisible(LNK_ADMIN);
+ clickIfVisible(LNK_MEMBERS);
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
+ clickIfVisible(LNK_ROLE_CREATE);
+
+ selenium.type(INP_ROLENAME, "rolee");
+ selenium.type(INP_ROLEDISNAME, XSS_STR1);
+
+ clickAndWait(SUB_ROLE_CREATE);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_ROLE_DISPNAME_VALID));
+
+ }
+
+ /**
+ * After creating a role (editRole/editRoleDisplay), the role is about to be
+ * edited. The role display name is changed to to XSS string and submit
+ * button is pressed. It is asserted that the error message about invalid
+ * role display name was printed.
+ */
+ @Test(enabled = true, groups = {"XSS"})
+ public void testXssRoleEdit() {
+ // EDIT ROLE
+
+ final String roleName = "editRole";
+ final String roleDisplayName = "editRoleDisplay";
+
+ openAndWait(ADR_PORTAL);
+ clickIfVisible(LNK_ADMIN);
+ clickIfVisible(LNK_ADMIN);
+ clickIfVisible(LNK_MEMBERS);
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
+ clickIfVisible(LNK_ROLE_CREATE);
+
+ createRole(roleName, roleDisplayName);
+
+ openAndWait(ADR_PORTAL);
+ clickIfVisible(LNK_ADMIN);
+ clickIfVisible(LNK_ADMIN);
+ clickIfVisible(LNK_MEMBERS);
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
+
+ int r = findTableRow(TBL_ROLELIST, roleName, 0);
+ selenium.click(MessageFormat.format(LNK_T_ROLLIST_EDIT, r - 1));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INP_EDIT_ROLE_NAME, XSS_STR1);
+ selenium.click(SUB_EDIT_ROLE_SUBMIT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_ROLE_DISPNAME_VALID));
+
+ deleteRole(roleName);
+ }
+
+ /**
+ * User (editXssMe, editXssPass, editXssMe(a)redhat.com) is created. The user
+ * is then edited. The Xss string is written to each input on the edit user
+ * screen and the submit button is pressed. Other field are left blank. It
+ * is asserted, that the error message about invalid input for each input is
+ * written on the screen after pressing the submit button.
+ */
+ @Test(enabled = true, dependsOnMethods = { "testEditUser" }, groups = {"XSS"})
+ public void testXssEditUser() {
+ final String userName = "editXssMe";
+ final String userPass = "editXssPass";
+ final String userMail = "editXssMe(a)redhat.com";
+ createUser(userName, userPass, userMail);
+ goToEdit(userName, userMail);
+
+ testInput(INP_EDIT_USER_EMAIL, XSS_STR1, SUB_EDIT_PROF, "Invalid E-Mail address.");
+
+ // firstname
+ goToEdit(userName, userMail);
+ 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, MSG_EDIT_USER_VALID);
+ // location
+ goToEdit(userName, userMail);
+ 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, MSG_EDIT_USER_VALID);
+ // icq
+ goToEdit(userName, userMail);
+ 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, MSG_EDIT_USER_VALID);
+ // msn
+ goToEdit(userName, userMail);
+ 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, MSG_EDIT_USER_VALID);
+ // xmmp
+ goToEdit(userName, userMail);
+ 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, MSG_EDIT_USER_VALID);
+ // occup
+ goToEdit(userName, userMail);
+ 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, MSG_EDIT_USER_VALID);
+ // sign
+ goToEdit(userName, userMail);
+ 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, MSG_EDIT_USER_VALID);
+
+ deleteUser(userName, userMail);
+ }
+
+ /**
+ * Into the search user input a XSS string is written and search button is
+ * pressed. The presence of input validation error is asserted.
+ */
+ @Test(enabled = false, dependsOnMethods = { "testing input validation for user search input" }, groups = {"XSS"})
+ public void testXssSearchUser() {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_ADMIN);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_MEMBERS);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(LNK_USERTAB);
+ clickIfVisible(LNK_USERMAIN);
+ clickIfVisible(LNK_USERMANG_MAIN);
+
+ selenium.click(LNK_SEARCH_USER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INP_SEARCH_USER, XSS_STR1);
+ selenium.click(SUB_SEARCH_USER);
+
+ waitFor(SEARCH_TIMEOUT);
+
+ Assert.assertTrue(selenium.isTextPresent("is an invalid"));
+ }
+
+ /**
+ * Into the search role members input a XSS string is written and search
+ * button is pressed. The presence of input validation error is asserted.
+ */
+ @Test(enabled = false, dependsOnMethods = { "testing input validation for role members search input" }, groups = {"XSS"})
+ public void testXssSearchRoleMembers() {
+
+ clickUntilMembers();
+ clickIfVisible(LNK_ROLETAB);
+ clickIfVisible(LNK_ROLEMAIN);
+ clickIfVisible(LNK_ROLEMAIN2);
+
+ // search for the real member of current role
+ selenium.type(INP_ROLE_SEARCH_USER, XSS_STR1);
+ selenium.click(SUB_ROLE_SEARCH_USER);
+ waitFor(10000);
+
+ Assert.assertTrue(selenium.isTextPresent("is an invalid"));
+ }
+
+ private void goToEdit(String userName, String userMail) {
searchUser(userName, userMail);
int r = findTableRow(TBL_USERLIST, userName, 0);
selenium.click(MessageFormat.format(LNK_T_USRLIST_EDIT, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
- }
+ }
+ private void testInput(String inpLoc, String inpStr, String subLoc, String mes) {
+ selenium.type(inpLoc, inpStr);
+ clickAndWait(subLoc);
+ Assert.assertTrue(selenium.isTextPresent(mes),"input validation error message is missing or other than expected.");
+ }
+
+ /**
+ * Test search user count is responsible for the search functions for
+ * users.. The test creates 95 users named man0us - man94us. Then it tests
+ * the paginator of the search functions. It sets count of results to 10,50
+ * and 100, traverse through paginator and check, whether the amount of
+ * returned results is correct.
+ */
@Test(enabled = true, description = "Altering the number of rows in user search")
public void testSearchUserCount() {
@@ -465,12 +765,12 @@
selenium.click(INP_USER_SEARCH_PREV);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals(countTableRows(TBL_USERLIST) - 1, 50, "Wrong number of row in user table #2.");
-
+
searchSimple("man", "100");
selenium.waitForPageToLoad(PAGE_LOAD);
- //selenium.setSpeed("60000");
+ // selenium.setSpeed("60000");
Assert.assertEquals(countTableRows(TBL_USERLIST) - 1, 95, "Wrong number of row in user table #4.");
- //selenium.setSpeed("0");
+ // selenium.setSpeed("0");
/*
* for(int i=0; i< 95; i++){ deleteUser("man"+i+"us",
* "man"+i+"us"+"@redhatqa.com"); }
@@ -478,6 +778,13 @@
}
+ /**
+ * User (tempUser, tempPassword, tempUser(a)redhat.com) and role (tempRole,
+ * tempRoleDisplay) are created. The role is assigned to the user and it is
+ * asserted by the checked button in user roles. The role is then deassigned
+ * and it is asserted the same way as before. At the end of the test both
+ * the user and the role are deleted.
+ */
@Test(enabled = true, dependsOnMethods = { "testCreateUser", "testCreateRole" }, description = "Assigning of the role to the user.")
public void testAssignRole2User() {
String user = "tempUser";
@@ -544,16 +851,17 @@
selenium.open("/portal/auth/portal/default");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
+ selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
+ selenium.click(LNK_MEMBERS);
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(LNK_USERTAB);
clickIfVisible(LNK_USERMAIN);
selenium.click(LNK_CREATE_USER);
- selenium.waitForPageToLoad(PAGE_LOAD);
+ waitFor(AJAX_LOAD);
+ // selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Username *"), "Label for username input is wrong or missing.");
selenium.type(INP_USERNAME, userName);
@@ -567,7 +875,7 @@
selenium.click(SUB_CREATE_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertFalse(selenium.isTextPresent("This username is already taken. tempUser"), "User already exists.");
+ Assert.assertFalse(selenium.isTextPresent("This username is already taken."), "User already exists.");
selenium.click(SUB_USER_ROLE);
@@ -583,9 +891,9 @@
selenium.open("/portal/auth/portal/default");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
+ selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
+ selenium.click(LNK_MEMBERS);
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(LNK_USERMAIN);
@@ -606,15 +914,15 @@
void searchUser(String userName, String userMail) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
+ selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
+ selenium.click(LNK_MEMBERS);
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(LNK_USERTAB);
clickIfVisible(LNK_USERMAIN);
clickIfVisible(LNK_USERMANG_MAIN);
-
+ clickIfVisible("//a[contains(@id,'user-temp-form1:user-managment-link')]");
selenium.click(LNK_SEARCH_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -649,12 +957,12 @@
}
- void deleteUser(String username, String email) {
+ private void deleteUser(String username, String email) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
+ selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
+ selenium.click(LNK_MEMBERS);
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(LNK_USERTAB);
@@ -662,6 +970,7 @@
clickIfVisible(LNK_USERMAIN);
clickIfVisible(LNK_USERMANG_MAIN);
clickIfVisible(LNK_USERMANG_MAIN2);
+ clickIfVisible("//a[contains(@id,'user-temp-form1:user-managment-link')]");
selenium.click(LNK_SEARCH_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -683,25 +992,25 @@
private void clickUntilMembers() {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
+ selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
+ selenium.click(LNK_MEMBERS);
selenium.waitForPageToLoad(PAGE_LOAD);
}
- void createRole(String roleName, String roleDisplayName) {
+ private void createRole(String roleName, String roleDisplayName) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
+ selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
+ selenium.click(LNK_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.");
+ Assert.assertEquals(selenium.getText(LNK_ROLE_CREATE), MSG_CREATE_ROLE, "Button for role creating has wrong label.");
selenium.click(LNK_ROLE_CREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -716,17 +1025,19 @@
Assert.assertTrue(selenium.isTextPresent(roleDisplayName), "Display name of newly created role is missing.");
}
- void deleteRole(String roleName) {
+ private void deleteRole(String roleName) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
+ selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
+ selenium.click(LNK_MEMBERS);
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(LNK_ROLETAB);
clickIfVisible(LNK_ROLEMAIN);
+ clickIfVisible(LNK_ROLEMAIN2);
+
Assert.assertTrue(selenium.isTextPresent(roleName), "Role name is missing");
int r = findTableRow(TBL_ROLELIST, roleName, 0);
@@ -744,9 +1055,9 @@
private void searchSimple(String name, String count) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Admin");
+ selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Members");
+ selenium.click(LNK_MEMBERS);
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(LNK_USERTAB);
@@ -757,10 +1068,10 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.select(SEL_SEARCHUSER_LIMIT, "label=" + count);
- //waitFor(SEARCH_TIMEOUT);
+ // waitFor(SEARCH_TIMEOUT);
selenium.type(INP_SEARCH_USER, name);
selenium.click(SUB_SEARCH_USER);
-
+
waitFor(SEARCH_TIMEOUT);
}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -7,11 +7,18 @@
import org.testng.Assert;
import org.testng.annotations.AfterClass;
import org.testng.annotations.BeforeClass;
+import org.testng.annotations.Test;
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
/**
+ * JBossPortalSeleniumTestCase is the main class used in JBoss Portal selenium
+ * testing. Each testcase class has to extend this class. The
+ * JBossPortalSeleniumTestCase contains many basic methods for simple
+ * orientation in JBoss Portal like login/logout or finding elements in table.
+ * It also encapsulates selenium javascript extensions used in the tests.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
public class JBossPortalSeleniumTestCase {
@@ -21,36 +28,53 @@
static {
try {
- props = getProperties();
+ propsLoc = getProperties("org/jboss/portal/test/selenium/locator.properties");
} catch (Exception e) {
- // TODO: handle exception
+ e.printStackTrace();
}
+
+ try {
+ propsMes = getProperties("org/jboss/portal/test/selenium/assert.properties");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
- public final String LINK_LOGOUT = getProp(casePfx + "link.logout", "link=Logout");
- public final String SUBMIT_LOGIN = getProp(casePfx + "submit.login", "login");
- public final String ADDR_PORTAL = getProp(casePfx + "addr.portal", "/portal/");
- public final String FRAME_LOGIN_CONTENT = getProp(casePfx + "frame.login.content", "login-content");
- public final String LINK_LOGIN = getProp(casePfx + "link.login", "link=Login");
- public final String INPUT_PASSWORD = getProp(casePfx + "input.password", "j_password");
- public final String INPUT_USERNAME = getProp(casePfx + "input.username", "j_username");
+ protected final String LINK_LOGOUT = getLoc(casePfx + "lnk.logout", "link=Logout");
+ protected final String SUBMIT_LOGIN = getLoc(casePfx + "sub.login", "login");
+ protected final String ADR_PORTAL = getLoc(casePfx + "adr.portal", "/portal/");
+ protected final String FRAME_LOGIN_CONTENT = getLoc(casePfx + "frame.login.content", "login-content");
+ protected final String LINK_LOGIN = getLoc(casePfx + "lnk.login", "link=Login");
+ protected final String INPUT_PASSWORD = getLoc(casePfx + "inp.password", "j_password");
+ protected final String INPUT_USERNAME = getLoc(casePfx + "inp.username", "j_username");
+
+ /** String used as an XSS input in xss test methods */
+ protected final String XSS_STR1 = getMess("portal.xxs.1", "/Dave</option><script>alert(document.cookie);</script>");
- protected static Properties props;
+ protected static Properties propsLoc;
+ protected static Properties propsMes;
protected Selenium selenium;
- // Generic timeout in miliseconds
- protected static final String PAGE_LOAD = "2400000";
- protected static final long AJAX_LOAD = 3000;
+ /**
+ * Generic timeout in miliseconds used in every selenium function
+ * waitForPageToLoad()}
+ */
+ public static String PAGE_LOAD = "240000";
+ /** Generic timeout in miliseconds used for AJAX timeouts } */
+ public static long AJAX_LOAD = 6000;
// protected static final String PAGE_LOAD = "60000";
// protected static final long AJAX_LOAD = 2000;
- // Element timeout in seconds
- protected static final int ELEM_TIMEOUT = 220;
+ /** Element timeout in seconds used in waitForElement functions */
+ public static int ELEM_TIMEOUT = 220;
- @BeforeClass
- public void setupChromeForLogin() throws Exception {
-
+ @BeforeClass()
+ protected void setupChromeForLogin() throws Exception {
+ PAGE_LOAD = getMess("selenium.timeout.page", PAGE_LOAD);
+ AJAX_LOAD = Integer.valueOf(getMess("selenium.timeout.ajax", String.valueOf(AJAX_LOAD)));
+ ELEM_TIMEOUT = Integer.valueOf(getMess("selenium.timeout.elem", String.valueOf(ELEM_TIMEOUT+"")));
+
String browser = System.getProperty("browser");
selenium = new DefaultSelenium("127.0.0.1", 44444, browser, "http://localhost:8080/portal/");
@@ -59,45 +83,79 @@
selenium.start();
selenium.setTimeout(PAGE_LOAD);
selenium.setSpeed("0");
+ selenium.setTimeout(PAGE_LOAD);
}
- @AfterClass
- public void tearDownInstaller() throws Exception {
+ @AfterClass()
+ protected void tearDownInstaller() throws Exception {
selenium.stop();
}
- private static Properties getProperties() throws IOException {
+ private static Properties getProperties(String resource) throws IOException {
ClassLoader cl = ClassLoader.getSystemClassLoader();
- InputStream is = cl.getResourceAsStream("org/jboss/portal/test/selenium/locator.properties");
+ InputStream is = cl.getResourceAsStream(resource);
Properties props = new Properties();
props.load(is);
if (props == null) {
- is = JBossPortalSeleniumTestCase.class.getResourceAsStream("org/jboss/portal/test/selenium/locator.properties");
+ is = JBossPortalSeleniumTestCase.class.getResourceAsStream(resource);
props.load(is);
}
- if (props == null) {
- // System.out.println("still null");
- }
return props;
}
- protected String getProp(String prop, String subst) {
+ private String getProperty(Properties properties, String property, String subst) {
if (subst == null || "".equals(subst)) {
subst = "Locator not set";
}
- if (props == null) {
- // System.out.println("props null");
+ if (properties == null) {
return subst;
- } else {
- // System.out.println("! props null");
- return props.getProperty(prop) != null ? props.getProperty(prop) : subst;
+ } else {
+ return properties.getProperty(property) != null ? properties.getProperty(property) : subst;
}
}
+
+ /**
+ * Gets the property. Property file is named assert.properties and it's
+ * located in the org.jboss.portal.test.selenium package. It contains
+ * messages used in asserts in selenium tests.
+ *
+ * @param prop
+ * the name of the property
+ * @param subst
+ * the value which is returned in the case the property isn't set
+ *
+ * @return the prop
+ */
+ public String getMess(String prop, String subst) {
+ return getProperty(propsMes, prop, subst);
+ }
+
+ /**
+ * Gets the property. Property file is named locator.properties and it's
+ * located in the org.jboss.portal.test.selenium package. It contains
+ * locator properties for all locators used in selenium tests.
+ *
+ * @param prop
+ * the name of the property
+ * @param subst
+ * the value which is returned in the case the property isn't set
+ *
+ * @return the prop
+ */
+ public String getLoc(String prop, String subst) {
+ return getProperty(propsLoc, prop, subst);
+ }
- protected void clickIfVisible(String id) {
+ /**
+ * Click on an element only in case element is present on the screen.
+ *
+ * @param id
+ * element locator
+ */
+ public void clickIfVisible(String id) {
if (selenium.isElementPresent(id)) {
selenium.click(id);
@@ -106,16 +164,48 @@
}
}
- protected int findTableRow(String tableLocation, String searchName, int searchCol) {
+ /**
+ * Finding the correct row in a table due to input string and columns. The
+ * function uses selenium javascript extension findTableRow. It tries to
+ * look up the input string in the chosen column in selected table. After
+ * the first occurrence of input string, it returns the number of row where
+ * it was found.
+ *
+ * @param tableLocation
+ * the table locator
+ * @param searchName
+ * the string which the function searches for
+ * @param searchCol
+ * the column in which the function searches for
+ *
+ * @return the number of row with the first occurrence of searchName string.
+ */
+ public int findTableRow(String tableLocation, String searchName, int searchCol) {
return Integer.valueOf(selenium.getEval("selenium.findTableRow(\"" + tableLocation + "\",'" + searchName + "'," + searchCol + ")"));
}
- protected int countTableRows(String tableLocation) {
+ /**
+ * Counts table rows for selected table.
+ *
+ * @param tableLocation
+ * the table locator
+ *
+ * @return the number of rows of the table
+ */
+ public int countTableRows(String tableLocation) {
return Integer.valueOf(selenium.getEval("selenium.countTableRows(\"" + tableLocation + "\")"));
}
// TODO refactor
- protected void safeSelect(String locator, String value) {
+ /**
+ * Selects a value only if the value is present in the select. If the value is not present, selection fails.
+ *
+ * @param locator
+ * the locator of the select tag
+ * @param value
+ * the value which should be selected
+ */
+ public void safeSelect(String locator, String value) {
waitForElement(locator);
for (int second = 0;; second++) {
@@ -143,39 +233,82 @@
selenium.select(locator, "label=" + value);
}
- protected void clickAndWait(String locator) {
+ /**
+ * Click and wait. Substitution for two selenium commands click and waitForPageToLoad.
+ *
+ * @param locator the locator of the element to be clicked on
+ */
+ public void clickAndWait(String locator) {
waitForElement(locator);
selenium.click(locator);
selenium.waitForPageToLoad(PAGE_LOAD);
}
- protected void openAndWait(String locator) {
+ /**
+ * Open and wait. Substitution for two selenium commands open and waitForPageToLoad.
+ *
+ * @param locator the address to be opened
+ */
+ public void openAndWait(String locator) {
selenium.open(locator);
selenium.waitForPageToLoad(PAGE_LOAD);
}
- protected void selectIfNotSelected(String selector, String label) {
+ /**
+ * Select if not selected. If the value is already selected, the method does nothing.
+ *
+ * @param selector the selector locator
+ * @param label the label to be selected
+ */
+ public void selectIfNotSelected(String selector, String label) {
waitForElement(selector);
if (!selenium.getSelectedLabel(selector).equals(label)) {
selenium.select(selector, "label=" + label);
selenium.waitForPageToLoad(PAGE_LOAD);
}
}
+
+ public void check(String locator, boolean d) {
+ waitForElement(locator);
+ if (selenium.isChecked(locator) != d) {
+ selenium.click(locator);
+ }
+ }
- protected boolean assertTextOrder(String text) {
+ /**
+ * Asserts the text order on the page. The messages which order is to be determined are inputed in a comma separated way. i.e. "string1;string2;string3". The method
+ * asserts that they appear on the page in the same order as typed in the input string. It returns true if the order is the same or false otherwise.
+ *
+ * @param text input text in comma separated format which order is to be asserted
+ *
+ * @return true if the order is the same or false otherwise
+ */
+ public boolean assertTextOrder(String text) {
return Boolean.valueOf(selenium.getEval("selenium.assertTextOrder(\"" + text + "\")"));
}
- protected void waitFor(long time) {
+ /**
+ * Waits for specified time in ms. Used mostly in AJAX based tests.
+ *
+ * @param time
+ * the time (in ms) to be waited for.
+ */
+ public void waitFor(long time) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
- // TODO Auto-generated catch block
e.printStackTrace();
}
}
- protected void waitForElement(String locator) {
+ /**
+ * Waits for element to appear on the screen. Used mostly in AJAX based
+ * tests.
+ *
+ * @param locator
+ * the locator of the element to be waited for
+ */
+ public void waitForElement(String locator) {
for (int second = 0;; second++) {
if (second >= ELEM_TIMEOUT) {
Assert.fail("Element " + locator + " not found.");
@@ -190,7 +323,21 @@
}
}
- protected void waitForElement(String locatorElem, String locatorLink, long timeToWait, long n) {
+ /**
+ * Waits for element to appear on the screen. Used mostly in AJAX based
+ * tests.
+ *
+ * @param locatorElem
+ * the element locator
+ * @param locatorLink
+ * the link locator - not used
+ * @param timeToWait
+ * the time (in ms) to wait until timeout is reached
+ * @param n
+ * the n
+ */
+ // TODO refactor - locatorLink is not used
+ public void waitForElement(String locatorElem, String locatorLink, long timeToWait, long n) {
for (int i = 0;; i++) {
if (i >= n) {
Assert.fail("Element " + locatorElem + " not found.");
@@ -205,6 +352,12 @@
}
}
+ /**
+ * Waits for text to appear on the screen. Used mostly in AJAX based tests.
+ *
+ * @param text
+ * the text to be waited for
+ */
public void waitForText(String text) {
for (int second = 0;; second++) {
if (second >= ELEM_TIMEOUT) {
@@ -220,8 +373,16 @@
}
}
- protected void login(String username, String password) {
- selenium.open(ADDR_PORTAL);
+ /**
+ * Login into JBoss portal.
+ *
+ * @param username
+ * the username
+ * @param password
+ * the password
+ */
+ public void login(String username, String password) {
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LINK_LOGIN);
@@ -233,14 +394,18 @@
selenium.type(INPUT_USERNAME, username);
selenium.type(INPUT_PASSWORD, password);
+ selenium.fireEvent(INPUT_PASSWORD, "keydown");
Assert.assertTrue(selenium.isElementPresent(SUBMIT_LOGIN));
selenium.click(SUBMIT_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Logged in as: " + username), "Not logged in, login message missing.");
}
- protected void logout() {
- selenium.open(ADDR_PORTAL);
+ /**
+ * Logs out from JBoss portal application.
+ */
+ public void logout() {
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isElementPresent(LINK_LOGOUT));
selenium.click(LINK_LOGOUT);
@@ -249,8 +414,12 @@
Assert.assertTrue(selenium.isElementPresent("Link=Login"), "Login link not present.");
}
- protected void logoutIfPossible() {
- selenium.open(ADDR_PORTAL);
+ /**
+ * Logs out from portal application if a user is logged in.
+ */
+ // TODO refactoring needed - use function logout()
+ public void logoutIfPossible() {
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
if (selenium.isElementPresent(LINK_LOGOUT)) {
selenium.click(LINK_LOGOUT);
@@ -260,16 +429,30 @@
}
}
- protected void debugPrint(String debugText) {
+ /**
+ * Prints a message into the system output for debugging purposes. The
+ * message is printed only in the case, if the value true of parameter
+ * <i>debug</i> was passed to jvm with -Ddebug="true" switch.
+ *
+ * @param debugText
+ * the debug text
+ */
+ public void debugPrint(String debugText) {
if (JBossSeleniumTestListener.debug)
System.out.println("[Selenium debug] : " + debugText);
}
- protected void debugScreenshot(String filename) {
- if (JBossSeleniumTestListener.debug){
- selenium.windowMaximize();
+ /**
+ * Captures screenshot for debugging purposes. Saves a screenshot into debug
+ * directory. The screenshot is saved only in the case, if the value true of
+ * parameter <i>debug</i> was passed to jvm with -Ddebug="true" switch.
+ *
+ * @param filename
+ * the filename of the debug screenshot
+ */
+ public void debugScreenshot(String filename) {
+ if (JBossSeleniumTestListener.debug)
selenium.captureScreenshot(debugDir + "/" + filename);
- }
}
}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossSeleniumTestListener.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -11,6 +11,40 @@
import com.thoughtworks.selenium.Selenium;
import com.thoughtworks.selenium.SeleniumException;
+/**
+ * The listener interface for receiving JBossSeleniumTest events.
+ * The class that is interested in processing a JBossSeleniumTest
+ * event implements this interface, and the object created
+ * with that class is registered with a component using the
+ * component's <code>addJBossSeleniumTestListener<code> method. When
+ * the JBossSeleniumTest event occurs, that object's appropriate
+ * method is invoked. <br/>
+ * JBossSeleniumTestListener is responsible for decoding most of the parameters which are passed to selenium tests.
+ * <table>
+ * <thead>
+ * <tr>
+ * <th>parameter name</th>
+ * <th>valid values</th>
+ * <th>default value</th>
+ * <th>description</th>
+ * </tr>
+ * </thead>
+ * <tr>
+ * <td>screenshot</td>
+ * <td>true/false</td>
+ * <td>false</td>
+ * <td>If true, screenshots are taken after the test failure. They are saved into directory specified by the "output" parameter.</td>
+ * </tr><tr>
+ * <td>html-src</td><td>true/false</td><td>false</td><td>If true, html sources are taken after the test failure. They are saved into directory specified by the "output" parameter.</td>
+ * </tr><tr>
+ * <td>debug</td><td>true/false</td><td>false</td><td>If true, debug screenshots are taken and debug messages are turned on. Debug screenshot are saved into debug directory.</td>
+ * </tr><tr>
+ * <td>output-dir</td><td><path-to-dir></td><td>""</td><td>Path to the directory where html sources and screenshots are saved.</td>
+ * </tr>
+ * </table>
+ *
+ * @see JBossSeleniumTestEvent
+ */
public class JBossSeleniumTestListener extends TestListenerAdapter {
protected static Selenium selenium;
@@ -42,6 +76,9 @@
}
}
+ /* (non-Javadoc)
+ * @see org.testng.TestListenerAdapter#onTestFailure(org.testng.ITestResult)
+ */
@Override
public void onTestFailure(ITestResult tr) {
@@ -59,6 +96,7 @@
if (screenshot) {
try {
selenium.windowMaximize();
+ waitFor(5000);
selenium.captureScreenshot(name + ".jpg");
} catch (SeleniumException e2) {
e2.printStackTrace();
@@ -66,5 +104,19 @@
}
count++;
}
+
+ /**
+ * Waits for specified time in ms. Used mostly in AJAX based tests.
+ *
+ * @param time
+ * the time (in ms) to be waited for.
+ */
+ public void waitFor(long time) {
+ try {
+ Thread.sleep(time);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ }
}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalAjaxSamplesTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalAjaxSamplesTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalAjaxSamplesTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -5,147 +5,222 @@
import org.testng.annotations.Test;
import static org.testng.Assert.*;
-
+/**
+ * The Class PortalAjaxSamplesTestCase is used for testing of ajax line of
+ * portlets from portal-basic-samples.sar.
+ */
@Test(groups = { "test_samples" }, enabled = true)
public class PortalAjaxSamplesTestCase extends JBossPortalSeleniumTestCase {
- public static long AJAX_TIMEOUT = 12500;
-
+ /** The AJAX_ timeout. */
+ public static long AJAX_TIMEOUT = 10000;
+
+ /** prefix for locator properties = samples.ajax. */
public static String casePfx = "samples.ajax.";
-
- private final String SES_LNK_INVALIDATE = getProp(casePfx+"ses.lnk.invalidate","link=invalidate");
- private final String RES_DIV_RTEXT = getProp(casePfx+"res.div.rtext","repeat-text");
- private final String RES_DIV_PTEXT = getProp(casePfx+"res.div.ptext","product-text");
- private final String RES_LNK_P3 = getProp(casePfx+"res.lnk.p3","link=Product3");
- private final String RES_LNK_P2 = getProp(casePfx+"res.lnk.p2","link=Product2");
- private final String RES_LNK_P1 = getProp(casePfx+"res.lnk.p1","link=Product1");
- private final String RES_INP = getProp(casePfx+"res.inp","repeat");
- private final String RES_LNK = getProp(casePfx+"res.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[17]/a");
- private final String WIN_DIV_CON = getProp(casePfx+"win.div.con","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div");
- private final String WIN_LNK = getProp(casePfx+"win.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[16]/a");
- private final String SES_TAB_PSCOPE = getProp(casePfx+"ses.tab.pscope","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/table");
- private final String SES_TAB_ASCOPE = getProp(casePfx+"ses.tab.ascope","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/table[2]");
- private final String SES_SUB_ASCOPE = getProp(casePfx+"ses.sub.ascope","application");
- private final String SES_SUB_PSCOPE = getProp(casePfx+"ses.sub.pscope","portlet");
- private final String SES_INP_VAL = getProp(casePfx+"ses.inp.val","value");
- private final String SES_INP_NAM = getProp(casePfx+"ses.inp.nam","name");
- private final String SES_LNK = getProp(casePfx+"ses.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[14]/a");
- private final String PUB_1_LNK_FOO_REM = getProp(casePfx+"pub.1.lnk.foo.rem","//html/body/div[2]/div/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr/td[2]/a");
- private final String PUB_3_LNK_BAR_REM = getProp(casePfx+"pub.3.lnk.bar.rem","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr[2]/td[2]/a");
- private final String PUB_3_LNK_JUU_REM = getProp(casePfx+"pub.3.lnk.juu.rem","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr/td[2]/a");
- private final String PUB_SUB_2 = getProp(casePfx+"pub.sub.2","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr[3]/td/input");
- private final String PUB_SUB_1 = getProp(casePfx+"pub.sub.1","//input[@value='Update']");
- private final String PUB_DIV_3_BAR = getProp(casePfx+"pub.div.3.bar","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr[2]/td[2]/input");
- private final String PUB_DIV_3_JUU = getProp(casePfx+"pub.div.3.juu","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr/td[2]/input");
- private final String PUB_DIV_2_JUU = getProp(casePfx+"pub.div.2.juu","juu");
- private final String PUB_DIV_2_FOO = getProp(casePfx+"pub.div.2.foo","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr/td[2]/input");
- private final String PUB_DIV_1_BAR = getProp(casePfx+"pub.div.1.bar","bar");
- private final String PUB_DIV_1_FOO = getProp(casePfx+"pub.div.1.foo","foo");
- private final String PUB_LNK = getProp(casePfx+"pub.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[12]/a");
- private final String PEVT_DIV_P3_MAX = getProp(casePfx+"pevt.div.p3.max","//html/body/div[2]/div/div/div[2]/div[2]/div/div[3]/div/div/table/tbody/tr/td[2]/div/div[2]/span/a");
- private final String PEVT_DIV_P2_MAX = getProp(casePfx+"pevt.div.p2.max","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr/td[2]/div/div[2]/span/a");
- private final String PEVT_DIV_L3_MAX = getProp(casePfx+"pevt.div.l3.max","//html/body/div[2]/div/div/div[2]/div/div/div[3]/div/div/table/tbody/tr/td[2]/div/div[2]/span/a");
- private final String PEVT_DIV_L2_MAX = getProp(casePfx+"pevt.div.l2.max","//html/body/div[2]/div/div/div[2]/div/div/div[2]/div/div/table/tbody/tr/td[2]/div/div[2]/span/a");
- private final String PEVT_DIV_P3 = getProp(casePfx+"pevt.div.p3","//html/body/div[2]/div/div/div[2]/div[2]/div/div[3]/div/div/table/tbody/tr[2]/td[2]/div/div");
- private final String PEVT_DIV_P2 = getProp(casePfx+"pevt.div.p2","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div");
- private final String PEVT_DIV_P1 = getProp(casePfx+"pevt.div.p1","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div");
- private final String PEVT_DIV_L3 = getProp(casePfx+"pevt.div.l3","//html/body/div[2]/div/div/div[2]/div/div/div[3]/div/div/table/tbody/tr[2]/td[2]/div/div");
- private final String PEVT_DIV_L2 = getProp(casePfx+"pevt.div.l2","//html/body/div[2]/div/div/div[2]/div/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div");
- private final String PEVT_DIV_L1 = getProp(casePfx+"pevt.div.l1","//html/body/div[2]/div/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[2]/div/div");
- private final String PEVT_LNK = getProp(casePfx+"pevt.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[11]/a");
- private final String MOD_DIV_CON = getProp(casePfx+"mod.div.con","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div");
- private final String MOD_LNK = getProp(casePfx+"mod.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[10]/a");
- private final String MPOR_DIV_CON = getProp(casePfx+"mpor.div.con","content-container");
- private final String MPOR_LNK = getProp(casePfx+"mpor.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[9]/a");
- private final String MINS_DIV_CON = getProp(casePfx+"mins.div.con","content-container");
- private final String MINS_LNK = getProp(casePfx+"mins.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[8]/a");
- private final String JS_LNK_SUBMIT = getProp(casePfx+"js.lnk.submit","link=submit");
- private final String JS_OPT_3 = getProp(casePfx+"js.opt.3","//form[@id='jbpnsFormAutoSubmitPortletWindowsnpbj_the_form']/select/option[3]");
- private final String JS_OPT_2 = getProp(casePfx+"js.opt.2","//form[@id='jbpnsFormAutoSubmitPortletWindowsnpbj_the_form']/select/option[2]");
- private final String JS_OPT_1 = getProp(casePfx+"js.opt.1","//form[@id='jbpnsFormAutoSubmitPortletWindowsnpbj_the_form']/select/option[1]");
- private final String JS_LAB_C = getProp(casePfx+"js.lab.c","label=C");
- private final String JS_LAB_B = getProp(casePfx+"js.lab.b","label=B");
- private final String JS_LAB_A = getProp(casePfx+"js.lab.a","label=A");
- private final String JS_SEL_LETTER = getProp(casePfx+"js.sel.letter","//select[@onclick=\"document.getElementById('jbpnsFormAutoSubmitPortletWindowsnpbj_the_form').submit()\"]");
- private final String JS_LNK = getProp(casePfx+"js.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[7]/a");
- private final String HEAD_INP_CONTENT = getProp(casePfx+"head.inp.content","Introducing-HeaderContentInput");
- private final String HEAD_DIV_CONTENT = getProp(casePfx+"head.div.content","Introducing-HeaderContent");
- private final String HEAD_LNK = getProp(casePfx+"head.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[6]/a");
- private final String EXC_LNK_PORTLET = getProp(casePfx+"exc.lnk.portlet","link=render PortletException");
- private final String EXC_LNK = getProp(casePfx+"exc.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[5]/a");
- private final String EVT_SUB_COLOR = getProp(casePfx+"evt.sub.color","//input[@type='submit']");
- private final String EVT_DIV_BLACK = getProp(casePfx+"evt.div.black","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[contains(@style,'black')]");
- private final String EVT_DIV_RED = getProp(casePfx+"evt.div.red","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[contains(@style,'red')]");
- private final String EVT_DIV_BLUE = getProp(casePfx+"evt.div.blue","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[contains(@style,'blue')]");
- private final String EVT_SEL_LAB_BLACK = getProp(casePfx+"evt.sel.lab.black","label=black");
- private final String EVT_SEL_LAB_RED = getProp(casePfx+"evt.sel.lab.red","label=red");
- private final String EVT_SEL_LAB_BLUE = getProp(casePfx+"evt.sel.lab.blue","label=blue");
- private final String EVT_SEL_COL = getProp(casePfx+"evt.sel.col","color");
- private final String EVT_LNK = getProp(casePfx+"evt.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[4]/a");
- private final String ENC_LNK = getProp(casePfx+"enc.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[3]/a");
- private final String ENC_INP_REN = getProp(casePfx+"enc.inp.ren","text");
- private final String ENC_SUB_ACT = getProp(casePfx+"enc.sub.act","//input[@value='Submit to action phase']");
- private final String ENC_INP_ACT = getProp(casePfx+"enc.inp.act","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/div/form[2]/input");
- private final String ENC_TEXTAREA2 = getProp(casePfx+"enc.textarea2","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/div[5]/textarea");
- private final String ENC_TEXTAREA1 = getProp(casePfx+"enc.textarea1","//textarea[@name='text']");
- private final String CHAR_ALL_SUB_CHECK = getProp(casePfx+"char.all.sub.check","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/div[8]/form/input[3]");
- private final String CHAR_INP_TEXT_SUB_CHECK = getProp(casePfx+"char.inp.text.sub.check","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/div[6]/form/input[4]");
- private final String CHAR_LNK_TEXTAREA_CHECK = getProp(casePfx+"char.lnk.textarea.check","//input[@value='check']");
- private final String CHAR_INP_TEXT = getProp(casePfx+"char.inp.text","//input[@name='text']");
- private final String CHAR_TEXTAREA = getProp(casePfx+"char.textarea","text");
- private final String CHAR_SUB_CHANGE = getProp(casePfx+"char.sub.change","//input[@value='change']");
- private final String CHAR_INP_TO = getProp(casePfx+"char.inp.to","to");
- private final String CHAR_INP_FROM = getProp(casePfx+"char.inp.from","from");
- private final String CHAR_LNK = getProp(casePfx+"char.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[2]/a");
- private final String CACHE_LNK = getProp(casePfx+"cache.lnk","//ul[@id='tabsHeader']/li[4]/ul/li[1]/a");
- private final String CACHE_LNK_2REN = getProp(casePfx+"cache.lnk.2ren","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[5]/a");
- private final String CACHE_LNK_2ACT = getProp(casePfx+"cache.lnk.2act","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[4]/a");
- private final String CACHE_LNK_1REN = getProp(casePfx+"cache.lnk.1ren","link=render");
- private final String CACHE_LNK_1ACT = getProp(casePfx+"cache.lnk.1act","link=action");
- private final String CACHE_DIV_2_RENDER = getProp(casePfx+"cache.div.2.render","//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[2]/div");
- private final String CACHE_DIV_1_RENDER = getProp(casePfx+"cache.div.1.render","//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/div[2]/div");
+ private final String MSG_P3_L3 = getMess(casePfx + "p3.l3", "$256.00");
+ private final String MSG_P3_L2 = getMess(casePfx + "p3.l2", "SANTA CRUZ ALLSTAR");
+ private final String MSG_P3_L1 = getMess(casePfx + "p3.l1", "Product ID: 3");
-
-
+ private final String MSG_P2_L3 = getMess(casePfx + "p2.l3", "$319.99");
+ private final String MSG_P2_L2 = getMess(casePfx + "p2.l2", "FORUM DESTROYER LTD");
+ private final String MSG_P2_L1 = getMess(casePfx + "p2.l1", "Product ID: 2");
+
+ private final String MSG_P1_L3 = getMess(casePfx + "p1.l3", "Sale Price: $314.96");
+ private final String MSG_P1_L2 = getMess(casePfx + "p1.l2", "B BY BURTON ALPHA");
+ private final String MSG_P1_L1 = getMess(casePfx + "p1.l1", "Product ID: 1");
+
+ private final String SES_LNK_INVALIDATE = getLoc(casePfx + "ses.lnk.invalidate", "link=invalidate");
+ private final String RES_DIV_RTEXT = getLoc(casePfx + "res.div.rtext", "repeat-text");
+ private final String RES_DIV_PTEXT = getLoc(casePfx + "res.div.ptext", "product-text");
+ private final String RES_LNK_P3 = getLoc(casePfx + "res.lnk.p3", "link=Product3");
+ private final String RES_LNK_P2 = getLoc(casePfx + "res.lnk.p2", "link=Product2");
+ private final String RES_LNK_P1 = getLoc(casePfx + "res.lnk.p1", "link=Product1");
+ private final String RES_INP = getLoc(casePfx + "res.inp", "repeat");
+ private final String RES_LNK = getLoc(casePfx + "res.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[17]/a");
+ private final String WIN_DIV_CON = getLoc(casePfx + "win.div.con",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div");
+ private final String WIN_LNK = getLoc(casePfx + "win.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[16]/a");
+ private final String SES_TAB_PSCOPE = getLoc(casePfx + "ses.tab.pscope",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/table");
+ private final String SES_TAB_ASCOPE = getLoc(casePfx + "ses.tab.ascope",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/table[2]");
+ private final String SES_SUB_ASCOPE = getLoc(casePfx + "ses.sub.ascope", "application");
+ private final String SES_SUB_PSCOPE = getLoc(casePfx + "ses.sub.pscope", "portlet");
+ private final String SES_INP_VAL = getLoc(casePfx + "ses.inp.val", "value");
+ private final String SES_INP_NAM = getLoc(casePfx + "ses.inp.nam", "name");
+ private final String SES_LNK = getLoc(casePfx + "ses.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[14]/a");
+ private final String PUB_1_LNK_FOO_REM = getLoc(casePfx + "pub.1.lnk.foo.rem",
+ "//html/body/div[2]/div/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr/td[2]/a");
+ private final String PUB_3_LNK_BAR_REM = getLoc(casePfx + "pub.3.lnk.bar.rem",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr[2]/td[2]/a");
+ private final String PUB_3_LNK_JUU_REM = getLoc(casePfx + "pub.3.lnk.juu.rem",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr/td[2]/a");
+ private final String PUB_SUB_2 = getLoc(casePfx + "pub.sub.2",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr[3]/td/input");
+ private final String PUB_SUB_1 = getLoc(casePfx + "pub.sub.1", "//input[@value='Update']");
+ private final String PUB_DIV_3_BAR = getLoc(casePfx + "pub.div.3.bar",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr[2]/td[2]/input");
+ private final String PUB_DIV_3_JUU = getLoc(casePfx + "pub.div.3.juu",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr/td[2]/input");
+ private final String PUB_DIV_2_JUU = getLoc(casePfx + "pub.div.2.juu", "juu");
+ private final String PUB_DIV_2_FOO = getLoc(casePfx + "pub.div.2.foo",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr/td[2]/input");
+ private final String PUB_DIV_1_BAR = getLoc(casePfx + "pub.div.1.bar", "bar");
+ private final String PUB_DIV_1_FOO = getLoc(casePfx + "pub.div.1.foo", "foo");
+ private final String PUB_LNK = getLoc(casePfx + "pub.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[12]/a");
+ private final String PEVT_DIV_P3_MAX = getLoc(casePfx + "pevt.div.p3.max",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[3]/div/div/table/tbody/tr/td[2]/div/div[2]/span/a");
+ private final String PEVT_DIV_P2_MAX = getLoc(casePfx + "pevt.div.p2.max",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr/td[2]/div/div[2]/span/a");
+ private final String PEVT_DIV_L3_MAX = getLoc(casePfx + "pevt.div.l3.max",
+ "//html/body/div[2]/div/div/div[2]/div/div/div[3]/div/div/table/tbody/tr/td[2]/div/div[2]/span/a");
+ private final String PEVT_DIV_L2_MAX = getLoc(casePfx + "pevt.div.l2.max",
+ "//html/body/div[2]/div/div/div[2]/div/div/div[2]/div/div/table/tbody/tr/td[2]/div/div[2]/span/a");
+ private final String PEVT_DIV_P3 = getLoc(casePfx + "pevt.div.p3",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[3]/div/div/table/tbody/tr[2]/td[2]/div/div");
+ private final String PEVT_DIV_P2 = getLoc(casePfx + "pevt.div.p2",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div");
+ private final String PEVT_DIV_P1 = getLoc(casePfx + "pevt.div.p1",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div");
+ private final String PEVT_DIV_L3 = getLoc(casePfx + "pevt.div.l3",
+ "//html/body/div[2]/div/div/div[2]/div/div/div[3]/div/div/table/tbody/tr[2]/td[2]/div/div");
+ private final String PEVT_DIV_L2 = getLoc(casePfx + "pevt.div.l2",
+ "//html/body/div[2]/div/div/div[2]/div/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div");
+ private final String PEVT_DIV_L1 = getLoc(casePfx + "pevt.div.l1", "//html/body/div[2]/div/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[2]/div/div");
+ private final String PEVT_LNK = getLoc(casePfx + "pevt.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[11]/a");
+ private final String MOD_DIV_CON = getLoc(casePfx + "mod.div.con",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div");
+ private final String MOD_LNK = getLoc(casePfx + "mod.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[10]/a");
+ private final String MPOR_DIV_CON = getLoc(casePfx + "mpor.div.con", "content-container");
+ private final String MPOR_LNK = getLoc(casePfx + "mpor.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[9]/a");
+ private final String MINS_DIV_CON = getLoc(casePfx + "mins.div.con", "content-container");
+ private final String MINS_LNK = getLoc(casePfx + "mins.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[8]/a");
+ private final String JS_LNK_SUBMIT = getLoc(casePfx + "js.lnk.submit", "link=submit");
+ private final String JS_OPT_3 = getLoc(casePfx + "js.opt.3", "//form[@id='jbpnsFormAutoSubmitPortletWindowsnpbj_the_form']/select/option[3]");
+ private final String JS_OPT_2 = getLoc(casePfx + "js.opt.2", "//form[@id='jbpnsFormAutoSubmitPortletWindowsnpbj_the_form']/select/option[2]");
+ private final String JS_OPT_1 = getLoc(casePfx + "js.opt.1", "//form[@id='jbpnsFormAutoSubmitPortletWindowsnpbj_the_form']/select/option[1]");
+ private final String JS_LAB_C = getLoc(casePfx + "js.lab.c", "label=C");
+ private final String JS_LAB_B = getLoc(casePfx + "js.lab.b", "label=B");
+ private final String JS_LAB_A = getLoc(casePfx + "js.lab.a", "label=A");
+ private final String JS_SEL_LETTER = getLoc(casePfx + "js.sel.letter",
+ "//select[@onclick=\"document.getElementById('jbpnsFormAutoSubmitPortletWindowsnpbj_the_form').submit()\"]");
+ private final String JS_LNK = getLoc(casePfx + "js.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[7]/a");
+ private final String HEAD_INP_CONTENT = getLoc(casePfx + "head.inp.content", "Introducing-HeaderContentInput");
+ private final String HEAD_DIV_CONTENT = getLoc(casePfx + "head.div.content", "Introducing-HeaderContent");
+ private final String HEAD_LNK = getLoc(casePfx + "head.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[6]/a");
+ private final String EXC_LNK_PORTLET = getLoc(casePfx + "exc.lnk.portlet", "link=render PortletException");
+ private final String EXC_LNK = getLoc(casePfx + "exc.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[5]/a");
+ private final String EVT_SUB_COLOR = getLoc(casePfx + "evt.sub.color", "//input[@type='submit']");
+ private final String EVT_DIV_BLACK = getLoc(casePfx + "evt.div.black",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[contains(@style,'black')]");
+ private final String EVT_DIV_RED = getLoc(casePfx + "evt.div.red",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[contains(@style,'red')]");
+ private final String EVT_DIV_BLUE = getLoc(casePfx + "evt.div.blue",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[contains(@style,'blue')]");
+ private final String EVT_SEL_LAB_BLACK = getLoc(casePfx + "evt.sel.lab.black", "label=black");
+ private final String EVT_SEL_LAB_RED = getLoc(casePfx + "evt.sel.lab.red", "label=red");
+ private final String EVT_SEL_LAB_BLUE = getLoc(casePfx + "evt.sel.lab.blue", "label=blue");
+ private final String EVT_SEL_COL = getLoc(casePfx + "evt.sel.col", "color");
+ private final String EVT_LNK = getLoc(casePfx + "evt.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[4]/a");
+ private final String ENC_LNK = getLoc(casePfx + "enc.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[3]/a");
+ private final String ENC_INP_REN = getLoc(casePfx + "enc.inp.ren", "text");
+ private final String ENC_SUB_ACT = getLoc(casePfx + "enc.sub.act", "//input[@value='Submit to action phase']");
+ private final String ENC_INP_ACT = getLoc(casePfx + "enc.inp.act",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/div/form[2]/input");
+ private final String ENC_TEXTAREA2 = getLoc(casePfx + "enc.textarea2",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/div[5]/textarea");
+ private final String ENC_TEXTAREA1 = getLoc(casePfx + "enc.textarea1", "//textarea[@name='text']");
+ private final String CHAR_ALL_SUB_CHECK = getLoc(casePfx + "char.all.sub.check",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/div[8]/form/input[3]");
+ private final String CHAR_INP_TEXT_SUB_CHECK = getLoc(casePfx + "char.inp.text.sub.check",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/div[6]/form/input[4]");
+ private final String CHAR_LNK_TEXTAREA_CHECK = getLoc(casePfx + "char.lnk.textarea.check", "//input[@value='check']");
+ private final String CHAR_INP_TEXT = getLoc(casePfx + "char.inp.text", "//input[@name='text']");
+ private final String CHAR_TEXTAREA = getLoc(casePfx + "char.textarea", "text");
+ private final String CHAR_SUB_CHANGE = getLoc(casePfx + "char.sub.change", "//input[@value='change']");
+ private final String CHAR_INP_TO = getLoc(casePfx + "char.inp.to", "to");
+ private final String CHAR_INP_FROM = getLoc(casePfx + "char.inp.from", "from");
+ private final String CHAR_LNK = getLoc(casePfx + "char.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[2]/a");
+ private final String CACHE_LNK = getLoc(casePfx + "cache.lnk", "//ul[@id='tabsHeader']/li[4]/ul/li[1]/a");
+ private final String CACHE_LNK_2REN = getLoc(casePfx + "cache.lnk.2ren",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[5]/a");
+ private final String CACHE_LNK_2ACT = getLoc(casePfx + "cache.lnk.2act",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[4]/a");
+ private final String CACHE_LNK_1REN = getLoc(casePfx + "cache.lnk.1ren", "link=render");
+ private final String CACHE_LNK_1ACT = getLoc(casePfx + "cache.lnk.1act", "link=action");
+ private final String CACHE_DIV_2_RENDER = getLoc(casePfx + "cache.div.2.render",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[2]/div");
+ private final String CACHE_DIV_1_RENDER = getLoc(casePfx + "cache.div.1.render",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/div[2]/div");
+
+ private final String URL_LNK = getLoc(casePfx + "url.lnk", "");
+ private final String URL_INP_NAME1 = getLoc(casePfx + "url.inp.name1", "");
+ private final String URL_INP_VALUE1 = getLoc(casePfx + "url.inp.value1", "");
+ private final String URL_SUB1 = getLoc(casePfx + "url.sub1", "");
+ private final String URL_DIV1 = getLoc(casePfx + "url.div1", "");
+ private final String URL_LNK1_R = getLoc(casePfx + "url.lnk1.red", "");
+ private final String URL_LNK1_B = getLoc(casePfx + "url.lnk1.blue", "");
+ private final String URL_LNK1_W = getLoc(casePfx + "url.lnk1.white", "");
+ private final String URL_INP_NAME2 = getLoc(casePfx + "url.inp.name2", "");
+ private final String URL_INP_VALUE2 = getLoc(casePfx + "url.inp.value2", "");
+ private final String URL_SUB2 = getLoc(casePfx + "url.sub2", "");
+ private final String URL_DIV2 = getLoc(casePfx + "url.div2", "");
+ private final String URL_LNK2_R = getLoc(casePfx + "url.lnk2.red", "");
+ private final String URL_LNK2_B = getLoc(casePfx + "url.lnk2.blue", "");
+ private final String URL_LNK2_W = getLoc(casePfx + "url.lnk2.white", "");
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
selenium.open("/portal/portal/default/default");
waitFor(AJAX_TIMEOUT);
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ protected void logoutAfterTest() {
}
+
+ /**
+ * Cache test. Test clicks on action and render links in both portlets and
+ * assert the change of render call count values accordingly.
+ */
@Test(enabled = true)
public void cacheTest() {
selenium.click(CACHE_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
assertEquals("0", selenium.getText(CACHE_DIV_1_RENDER));
assertEquals("0", selenium.getText(CACHE_DIV_2_RENDER));
-
+
selenium.click(CACHE_LNK_1ACT);
waitFor(AJAX_TIMEOUT);
assertEquals("1", selenium.getText(CACHE_DIV_1_RENDER));
assertEquals("0", selenium.getText(CACHE_DIV_2_RENDER));
-
+
selenium.click(CACHE_LNK_1REN);
waitFor(AJAX_TIMEOUT);
assertEquals("1", selenium.getText(CACHE_DIV_1_RENDER));
assertEquals("0", selenium.getText(CACHE_DIV_2_RENDER));
-
+
selenium.click(CACHE_LNK_2ACT);
waitFor(AJAX_TIMEOUT);
assertEquals("1", selenium.getText(CACHE_DIV_1_RENDER));
assertEquals("1", selenium.getText(CACHE_DIV_2_RENDER));
-
+
selenium.click(CACHE_LNK_2REN);
waitFor(AJAX_TIMEOUT);
assertEquals("1", selenium.getText(CACHE_DIV_1_RENDER));
- assertEquals("2", selenium.getText(CACHE_DIV_2_RENDER));
+ assertEquals("2", selenium.getText(CACHE_DIV_2_RENDER));
}
-
+
+ /**
+ * Charset test.
+ * <ul>
+ * <li>set the testing range and check</li>
+ * <li>change the testing range and check</li>
+ * <li>change text in textarea to incorrect and check</li>
+ * <li>change text in textarea to correct and check</li>
+ * </ul>
+ */
@Test(enabled = true)
public void charsetTest() {
selenium.click(CHAR_LNK);
@@ -173,9 +248,13 @@
selenium.type(CHAR_INP_TEXT, "789:;<=>?@f");
selenium.click(CHAR_ALL_SUB_CHECK);
waitFor(AJAX_TIMEOUT);
- assertTrue(selenium.isTextPresent("Test result: The input matched the expected result"));
+ assertTrue(selenium.isTextPresent("Test result: The input matched the expected result"));
}
-
+
+ /**
+ * Encoding test. Test fills in inputs for "text to pass" and submit them to
+ * render and action phase. The text in textareas is asserted accordingly.
+ */
@Test(enabled = true)
public void encodingTest() {
selenium.click(ENC_LNK);
@@ -191,9 +270,13 @@
selenium.click("//input[@value='Submit to render phase']");
waitFor(AJAX_TIMEOUT);
assertEquals("", selenium.getValue(ENC_TEXTAREA1));
- assertEquals("action", selenium.getValue(ENC_TEXTAREA2));
+ assertEquals("action", selenium.getValue(ENC_TEXTAREA2));
}
-
+
+ /**
+ * Event test. The tests changes the colors for text and asserts that color
+ * was really changed.
+ */
@Test(enabled = true)
public void eventTest() {
selenium.click(EVT_LNK);
@@ -211,25 +294,37 @@
waitFor(AJAX_LOAD);
assertTrue(selenium.isElementPresent(EVT_DIV_BLACK));
}
-
+
+ /**
+ * Exception test. After accessing the portlet, the string
+ * "javax.portlet.PortletException" is asserted to appear on the screen.
+ */
@Test(enabled = true)
public void exceptionTest() {
selenium.click(EXC_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(EXC_LNK_PORTLET);
waitFor(AJAX_TIMEOUT);
- assertTrue(selenium.isTextPresent("javax.portlet.PortletException"));
+ assertTrue(selenium.isTextPresent("javax.portlet.PortletException"));
}
-
+
+ /**
+ * File system content test. After accessing the portlet, the string
+ * "Bar content" is asserted to appear on the screen.
+ */
@Test(enabled = true)
public void headerTest() {
selenium.click(HEAD_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
- assertTrue(selenium.isElementPresent(HEAD_DIV_CONTENT));
+ assertTrue(selenium.isElementPresent(HEAD_DIV_CONTENT));
selenium.click(HEAD_INP_CONTENT);
assertEquals("hello from the injected java script!", selenium.getAlert());
}
-
+
+ /**
+ * Javascript test. Selects some values from the list and after refresh
+ * asserts that nothing was selected.
+ */
@Test(enabled = true)
public void javascriptTest() {
selenium.click(JS_LNK);
@@ -238,100 +333,122 @@
waitFor(AJAX_TIMEOUT);
selenium.click(JS_OPT_1);
waitFor(AJAX_TIMEOUT);
-
+
assertFalse(selenium.isSomethingSelected(JS_SEL_LETTER));
-
+
selenium.addSelection(JS_SEL_LETTER, JS_LAB_B);
waitFor(AJAX_TIMEOUT);
selenium.click(JS_OPT_2);
waitFor(AJAX_TIMEOUT);
-
+
assertFalse(selenium.isSomethingSelected(JS_SEL_LETTER));
-
+
selenium.addSelection(JS_SEL_LETTER, JS_LAB_C);
waitFor(AJAX_TIMEOUT);
selenium.click(JS_OPT_3);
waitFor(AJAX_TIMEOUT);
-
+
assertFalse(selenium.isSomethingSelected(JS_SEL_LETTER));
-
+
selenium.click(JS_LNK_SUBMIT);
waitFor(AJAX_TIMEOUT);
-
+
assertFalse(selenium.isSomethingSelected(JS_SEL_LETTER));
}
-
+
+ /**
+ * Missing instance test. The page is opened and it is asserted, that no
+ * portlet is on the screen.
+ */
@Test(enabled = true)
public void missingInstanceTest() {
selenium.click(MINS_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
- assertEquals("", selenium.getText(MINS_DIV_CON));
+ assertEquals("", selenium.getText(MINS_DIV_CON));
}
-
+
+ /**
+ * Missing portlet test. The page is opened and it is asserted, that no
+ * portlet is on the screen.
+ */
@Test(enabled = true)
public void missingPortletTest() {
selenium.click(MPOR_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
- assertEquals("", selenium.getText(MPOR_DIV_CON));
+ assertEquals("", selenium.getText(MPOR_DIV_CON));
}
-
+
+ /**
+ * Mode test. The page is opened and it is asserted, that only a text "view"
+ * is present in portlet content.
+ */
@Test(enabled = true)
public void modeTest() {
selenium.click(MOD_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
assertEquals("View", selenium.getText(MOD_DIV_CON));
}
-
+
+ /**
+ * Page event test. The test clicks on "normal" button for each portlet on
+ * the screen and asserts, that every other portlet in the column is
+ * minimalised.
+ */
@Test(enabled = true)
public void pageEventTest() {
final String portletText = "This is a simple showcase of Portal Node Event Listener. For this portal page it ensures that in every column, only one portlet window is in NORMAL state. Try to change the window state of other portlets and see what happens. To learn more, read InterPortlet Communication (IPC) chapter in JBoss Portal Reference Guide.";
final String emptyText = "";
-
+
selenium.click(PEVT_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
// Left column
-
+
assertEquals(portletText, selenium.getText(PEVT_DIV_L1));
assertEquals(emptyText, selenium.getText(PEVT_DIV_L2));
assertEquals(emptyText, selenium.getText(PEVT_DIV_L3));
-
+
selenium.click(PEVT_DIV_L2_MAX);
waitFor(AJAX_TIMEOUT);
-
+
assertEquals(emptyText, selenium.getText(PEVT_DIV_L1));
assertEquals(portletText, selenium.getText(PEVT_DIV_L2));
assertEquals(emptyText, selenium.getText(PEVT_DIV_L3));
-
+
selenium.click(PEVT_DIV_L3_MAX);
waitFor(AJAX_TIMEOUT);
-
+
assertEquals(emptyText, selenium.getText(PEVT_DIV_L1));
assertEquals(emptyText, selenium.getText(PEVT_DIV_L2));
assertEquals(portletText, selenium.getText(PEVT_DIV_L3));
-
+
// Right column
-
+
assertEquals(portletText, selenium.getText(PEVT_DIV_P1));
assertEquals(emptyText, selenium.getText(PEVT_DIV_P2));
assertEquals(emptyText, selenium.getText(PEVT_DIV_P3));
-
+
selenium.click(PEVT_DIV_P2_MAX);
waitFor(AJAX_TIMEOUT);
-
+
assertEquals(emptyText, selenium.getText(PEVT_DIV_P1));
assertEquals(portletText, selenium.getText(PEVT_DIV_P2));
assertEquals(emptyText, selenium.getText(PEVT_DIV_P3));
-
+
selenium.click(PEVT_DIV_P3_MAX);
waitFor(AJAX_TIMEOUT);
-
+
assertEquals(emptyText, selenium.getText(PEVT_DIV_P1));
assertEquals(emptyText, selenium.getText(PEVT_DIV_P2));
assertEquals(portletText, selenium.getText(PEVT_DIV_P3));
-
+
}
-
+
+ /**
+ * Public parameters test. Test is adding values for each parameter and
+ * asserting that they appear in valid inputs. Then it removes all values
+ * and asserts that they not appear in valid inputs.
+ */
@Test(enabled = true)
public void publicParametersTest() {
selenium.click(PUB_LNK);
@@ -394,13 +511,20 @@
assertEquals("", selenium.getValue(PUB_DIV_3_JUU));
assertEquals("", selenium.getValue(PUB_DIV_3_BAR));
}
-
+
+ /**
+ * Secure test. Test is disabled. More information needed.
+ */
+ // TODO enable test - more information needed
@Test(enabled = false)
public void secureTest() {
-
-
+
}
-
+
+ /**
+ * Session test. Test adds parameters to portlet and application scope and
+ * asserts that they appear in attributes tables accordingly.
+ */
@Test(enabled = true)
public void sessionTest() {
selenium.click(SES_LNK);
@@ -409,66 +533,99 @@
selenium.type(SES_INP_VAL, "scopeval1");
selenium.click(SES_SUB_PSCOPE);
waitFor(AJAX_TIMEOUT);
-
+
int r = findTableRow(SES_TAB_PSCOPE, "scope1", 0);
- assertTrue(r>0);
+ assertTrue(r > 0);
assertEquals(findTableRow(SES_TAB_PSCOPE, "scopeval1", 1), r);
-
- //assertEquals("scope1", selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/table[1]/tbody/tr[2]/td[1]"));
- //assertEquals("scopeval1", selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/table[1]/tbody/tr[2]/td[2]"));
+
selenium.type(SES_INP_NAM, "app1");
selenium.type(SES_INP_VAL, "appval1");
selenium.click(SES_SUB_ASCOPE);
waitFor(AJAX_TIMEOUT);
-
+
r = findTableRow(SES_TAB_ASCOPE, "app1", 0);
- assertTrue(r>0);
+ assertTrue(r > 0);
assertEquals(findTableRow(SES_TAB_ASCOPE, "appval1", 1), r);
-
- //assertEquals("app1", selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/table[2]/tbody/tr[2]/td[1]"));
- //assertEquals("appval1", selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/table[2]/tbody/tr[2]/td[2]"));
-
+
selenium.click(SES_LNK_INVALIDATE);
waitFor(AJAX_TIMEOUT);
-
+
assertFalse(selenium.isTextPresent("Session id"));
}
-
- @Test(enabled = false)
+
+ /**
+ * Url portlet test. Fills in the two input boxes with "name" and "viliam" values. Then it clicks on the "red" link in the second box. Finally, it is asserted
+ * that the table in the second portlet is red and values are filled right as they were before clicking the "red" link.
+ */
+ @Test(enabled = true)
public void urlPortletTest() {
+ selenium.click(URL_LNK);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(URL_INP_NAME1, "name");
+ selenium.type(URL_INP_VALUE1, "viliam");
+
+ assertTrue(selenium.isElementPresent(URL_DIV2));
+ selenium.click(URL_LNK2_R);
+
+ waitFor(AJAX_TIMEOUT);
+
+ assertTrue(selenium.isElementPresent(URL_DIV2));
+
+ assertEquals(selenium.getValue(URL_INP_NAME1), "name");
+ assertEquals(selenium.getValue(URL_INP_VALUE1), "viliam");
}
-
+
+ /**
+ * Window id test. The page is opened and it is asserted, that only a text
+ * "Window ID is equals to /default/Test/Window id test/WindowIDPortletWindow"
+ * is present in portlet content.
+ */
@Test(enabled = true)
public void windowIdTest() {
selenium.click(WIN_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
- assertEquals("Window ID is equals to /default/TestWithAjax/Window id test/WindowIDPortletWindow", selenium.getText(WIN_DIV_CON));
+ assertEquals("Window ID is equals to /default/TestWithAjax/Window id test/WindowIDPortletWindow", selenium.getText(WIN_DIV_CON));
}
-
+
+ /**
+ * Serve resource demo test. Tests that repeat input really rewrites the
+ * text on screen, and clicks on all product links and assert that right
+ * addresses have appeared on screen.
+ */
@Test(enabled = true)
public void serveResourceDemoTest() {
-
+
selenium.click(RES_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.type(RES_INP, "valtest");
selenium.typeKeys(RES_INP, " ");
-
+
waitFor(AJAX_TIMEOUT);
-
+
assertEquals("valtest", selenium.getText(RES_DIV_RTEXT));
selenium.click(RES_LNK_P1);
waitFor(AJAX_TIMEOUT);
- assertEquals("Product ID: 1\n B BY BURTON ALPHA\nSale Price: $314.96", selenium.getText(RES_DIV_PTEXT));
+
+ assertTrue(selenium.isTextPresent(MSG_P1_L1));
+ assertTrue(selenium.isTextPresent(MSG_P1_L2));
+ assertTrue(selenium.isTextPresent(MSG_P1_L3));
+
selenium.click(RES_LNK_P2);
waitFor(AJAX_TIMEOUT);
- assertEquals("Product ID: 2\nFORUM DESTROYER LTD\n$319.99", selenium.getText(RES_DIV_PTEXT));
+
+ assertTrue(selenium.isTextPresent(MSG_P2_L1));
+ assertTrue(selenium.isTextPresent(MSG_P2_L2));
+ assertTrue(selenium.isTextPresent(MSG_P2_L3));
+
selenium.click(RES_LNK_P3);
waitFor(AJAX_TIMEOUT);
- assertEquals("Product ID: 3\n SANTA CRUZ ALLSTAR\n$256.00", selenium.getText(RES_DIV_PTEXT));
-
+
+ assertTrue(selenium.isTextPresent(MSG_P3_L1));
+ assertTrue(selenium.isTextPresent(MSG_P3_L2));
+ assertTrue(selenium.isTextPresent(MSG_P3_L3));
+
}
-
-
+
}
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalBookstoreSampleTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalBookstoreSampleTestCase.java (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalBookstoreSampleTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -0,0 +1,376 @@
+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.suf", " 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), "Catalog portlet has invalid title. Title should be: 'Portal Bookstore sample'.");
+ // Book Catalog portlet is minimized, so the "normalize portlet" icon is presented.
+ Assert.assertEquals(selenium.getAttribute(CATALOG_PORTLET_FIRST_ICON), PORTLET_MODE_NORMAL, "Link for normalize Catalog portlet is missing. The cause maybe that catalog portlet is not in minimized state.");
+ Assert.assertFalse(selenium.isTextPresent(CATALOG_PORTLET_CHOOSE), "Sign 'Please choose from our selections' is on Catalog portlet. But Catalog portlet should be in minimized state!");
+
+ // 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), "Link 'Start shopping' is missing in Bookstore portlet.");
+ clickAndWait(BOOKSTORE_PORTLET_START_SHOPPING_LINK);
+ Assert.assertEquals(selenium.getAttribute(CATALOG_PORTLET_FIRST_ICON), PORTLET_MODE_MINIMIZED, "Link for minimize Catalog portlet is missing. The cause maybe that catalog portlet is not in normal state.");
+ Assert.assertTrue(selenium.isTextPresent(CATALOG_PORTLET_CHOOSE), "Sign 'Please choose from our selections' is missing on Catalog portlet.");
+ }
+
+ /**
+ * 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), "Picture with book (book with id 1004) is presented in Book Detail portlet. But it should't be there.");
+ // Click to the detail link in Bookstore portlet
+ Assert.assertTrue(selenium.isElementPresent(BOOKSTORE_PORTLET_BOOK_DETAIL_LINK), "Link for book detail is missing in Bookstore portlet.");
+ 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), "Title of book with id 1004 is not shown in BookDetailPortlet.");
+ Assert.assertEquals(BOOK_1004_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR), "Author of book with id 1004 is not shown in BookDetailPortlet.");
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1004_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX), "Picture of book (book with id 1004) is missing in BookDetailPortlet.");
+ }
+
+ /**
+ * 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), "Book with id 1000 is not shown in BookCatalogPortlet.");
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX);
+ Assert.assertEquals(BOOK_1000_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE), "Title of book with id 1000 is invalid in BookDetailPortlet.");
+ Assert.assertEquals(BOOK_1000_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR), "Author of book with id 1000 is invalid in BookDetailPortlet.");
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1000_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX), "Picture of book (book with id 1000) is missing in BookDetailPortlet.");
+ // 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), "Book with id 1001 is not shown in BookCatalogPortlet.");
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX);
+ Assert.assertEquals(BOOK_1001_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE), "Title of book with id 1001 is invalid in BookDetailPortlet.");
+ Assert.assertEquals(BOOK_1001_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR), "Author of book with id 1001 is invalid in BookDetailPortlet.");
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1001_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX), "Picture of book (book with id 1001) is missing in BookDetailPortlet.");
+ // 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), "Book with id 1007 is not shown in BookCatalogPortlet.");
+ clickAndWait(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1007" + CATALOG_PORTLET_TABLE_TR_DETAIL_SUFFIX);
+ Assert.assertEquals(BOOK_1007_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE), "Title of book with id 1007 is invalid in BookDetailPortlet.");
+ Assert.assertEquals(BOOK_1007_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR), "Author of book with id 1007 is invalid in BookDetailPortlet.");
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1007_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX), "Picture of book (book with id 1007) is missing in BookDetailPortlet.");
+ }
+
+ /**
+ * 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), "Card shoud be empty but it's not.");
+ Assert.assertFalse(selenium.isElementPresent(SHOWCART_PORTLET_TABLE), "Card should be empty, but table with books is present in BookShowCartPortlet, which shouldn't be.");
+ // 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), "1 item is expected on Card.");
+ Assert.assertEquals("1", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1001" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX), "1 item of book with id 1001 is expected on Card.");
+ Assert.assertEquals(BOOK_1001_TITLE, selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1001" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX), "Invalid title of book with 1001 is on BookShowCartPortlet.");
+ Assert.assertEquals(4, countTableRows((SHOWCART_PORTLET_TABLE)), "Table with books in BookShowCartPortlet should have 4 rows.");
+ // 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), "Table with books in BookShowCartPortlet should have 7 rows.");
+ Assert.assertEquals(SHOWCART_PORTLET_CARD_ITEMS_PREFIX + "8" + SHOWCART_PORTLET_CARD_ITEMS_SUFFIX, selenium.getText(SHOWCART_PORTLET_HEADER), "8 items is expected on Card.");
+ Assert.assertEquals("2", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1000" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX), "2 items of book with id 1000 is expected on Card.");
+ Assert.assertEquals("4", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1001" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX), "4 items of book with id 1001 is expected on Card.");
+ Assert.assertEquals("1", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1005" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX), "1 item of book with id 1005 is expected on Card.");
+ Assert.assertEquals("1", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1007" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX), "1 item of book with id 1007 is expected on Card.");
+ Assert.assertEquals(BOOK_1000_TITLE, selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1000" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX), "Invalid title of book with 1000 is on BookShowCartPortlet.");
+ Assert.assertEquals(BOOK_1005_TITLE, selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1005" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX), "Invalid title of book with 1005 is on BookShowCartPortlet.");
+ Assert.assertEquals(BOOK_1007_TITLE, selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1007" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX), "Invalid title of book with 1007 is on BookShowCartPortlet.");
+ }
+
+ /**
+ * 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)), "Table with books in BookShowCartPortlet should have 6 rows.");
+ Assert.assertEquals(SHOWCART_PORTLET_CARD_ITEMS_PREFIX + "6" + SHOWCART_PORTLET_CARD_ITEMS_SUFFIX, selenium.getText(SHOWCART_PORTLET_HEADER), "6 items is expected on Card.");
+ Assert.assertEquals("2", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1000" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX), "2 items of book with id 1000 is expected on Card.");
+ Assert.assertEquals("3", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1001" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX), "3 items of book with id 1001 is expected on Card.");
+ Assert.assertEquals("1", selenium.getText(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1004" + SHOWCART_PORTLET_TABLE_TR_COUNT_SUFFIX), "1 item of book with id 1004 is expected on Card.");
+ }
+
+ /**
+ * 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), "Title of book with id 1000 is invalid in BookDetailPortlet.");
+ Assert.assertEquals(BOOK_1000_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR), "Author of book with id 1000 is invalid in BookDetailPortlet.");
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1000_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX), "Image of book with id 1000 is missing in BookDetailPortlet.");
+
+ clickAndWait(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1001" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX);
+ Assert.assertEquals(BOOK_1001_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE), "Title of book with id 1001 is invalid in BookDetailPortlet.");
+ Assert.assertEquals(BOOK_1001_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR), "Author of book with id 1001 is invalid in BookDetailPortlet.");
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1001_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX), "Image of book with id 1001 is missing in BookDetailPortlet.");
+
+ clickAndWait(SHOWCART_PORTLET_TABLE_TR_PREFIX + "1005" + SHOWCART_PORTLET_TABLE_TR_TITLE_SUFFIX);
+ Assert.assertEquals(BOOK_1005_TITLE, selenium.getText(DETAIL_PORTLET_BOOK_TITLE), "Title of book with id 1005 is invalid in BookDetailPortlet.");
+ Assert.assertEquals(BOOK_1005_AUTHOR, selenium.getText(DETAIL_PORTLET_BOOK_AUTHOR), "Author of book with id 1005 is invalid in BookDetailPortlet.");
+ Assert.assertTrue(selenium.isElementPresent(DETAIL_PORTLET_IMAGE_PREFIX + BOOK_1005_IMAGE + DETAIL_PORTLET_IMAGE_SUFFIX), "Image of book with id 1005 is missing in BookDetailPortlet.");
+ }
+
+ /**
+ * 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"), "Total currency value text is " + selenium.getText(CASHIER_PORTLET_AMOUNT) + " but total amount should be 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"), "Total currency value text is " + selenium.getText(CASHIER_PORTLET_AMOUNT) + " but total amount should be 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"), "Total currency value text is " + selenium.getText(CASHIER_PORTLET_AMOUNT) + " but total amount should be 124.93.");
+
+ // Clear card
+ clickAndWait(SHOWCART_PORTLET_CLEAR_CART_LINK);
+ // verify 4
+ Assert.assertTrue(valueEqualsCurrency(selenium.getText(CASHIER_PORTLET_AMOUNT), "0.0"), "Total currency value text is " + selenium.getText(CASHIER_PORTLET_AMOUNT) + " but total amount should be 0.0");
+ }
+
+ /**
+ * 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"), "Total currency value text is " + selenium.getText(CASHIER_PORTLET_AMOUNT) + " but total amount should be 214.83.");
+ Assert.assertEquals("3", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX), "3 books with id 1000 are expected in Book catalog. But there are " + selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX) + " books.");
+ Assert.assertEquals("4", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX), "4 books with id 1001 are expected in Book catalog. But there are " + selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX) + " books.");
+ Assert.assertEquals("9", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1004" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX), "9 books with id 1004 are expected in Book catalog. But there are " + selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1004" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX) + " books.");
+ // 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), "Sign about empty card should be in BookShowCartPortlet when order was submitted.");
+ Assert.assertEquals(RECEIPT_PORTLET_SUCCESS + "Joseph Carry.", selenium.getText(RECEIPT_PORTLET_HEADER), "Successfull message about the shopping is not correctly displayed in BookReceiptPortlet.");
+ Assert.assertEquals("1", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX), "1 book with id 1000 are expected in Book catalog. But there are " + selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX) + " books.");
+ Assert.assertEquals("3", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX), "3 books with id 1001 are expected in Book catalog. But there are " + selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX) + " books.");
+ Assert.assertEquals("7", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1004" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX), "7 books with id 1004 are expected in Book catalog. But there are " + selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1004" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX) + " books.");
+ // 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), "Sign about empty card should be in BookShowCartPortlet when order was submitted.");
+ Assert.assertEquals(RECEIPT_PORTLET_SUCCESS + "Martin Carry.", selenium.getText(RECEIPT_PORTLET_HEADER), "Successfull message about the shopping is not correctly displayed in BookReceiptPortlet.");
+ Assert.assertEquals("0", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX), "0 books with id 1000 are expected in Book catalog. But there are " + selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX) + " books.");
+ Assert.assertEquals("2", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX), "2 books with id 1001 are expected in Book catalog. But there are " + selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX) + " books.");
+ }
+
+ /**
+ * Test the SendReceiptEvent event and exceptionMessage public render parameters. The order of books is submited in Cashier portlet but the error message
+ * is shown in BookReceiptPortlet.
+ */
+ @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), "Failure about unsuccessfull order submit should be shown in BookReceiptPortlet.");
+ Assert.assertTrue(selenium.isTextPresent(RECEIPT_PORTLET_FAILURE_MESSAGE), "Failure about unsuccessfull order submit should be shown in BookReceiptPortlet.");
+ Assert.assertEquals(SHOWCART_PORTLET_CARD_ITEMS_PREFIX + "2" + SHOWCART_PORTLET_CARD_ITEMS_SUFFIX, selenium.getText(SHOWCART_PORTLET_HEADER), "2 items totally should be present on BookShowCart Portlet.");
+ // 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), "1 item totally should be present on BookShowCart Portlet.");
+ clickAndWait(CASHIER_PORTLET_SUBMIT);
+ // verify success
+ Assert.assertEquals(SHOWCART_PORTLET_EMPTY_CARD, selenium.getText(SHOWCART_PORTLET_HEADER), "Sign about empty card should be in BookShowCartPortlet when order was submitted.");
+ Assert.assertEquals(RECEIPT_PORTLET_SUCCESS + "Martin Carry.", selenium.getText(RECEIPT_PORTLET_HEADER), "Successfull message about the shopping is not correctly displayed in BookReceiptPortlet.");
+ Assert.assertEquals("0", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX), "0 books with id 1000 are expected in Book catalog. But there are " + selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1000" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX) + " books.");
+ Assert.assertEquals("1", selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX), "1 book with id 1001 are expected in Book catalog. But there are " + selenium.getText(CATALOG_PORTLET_TABLE_TR_PREFFIX + "1001" + CATALOG_PORTLET_TABLE_TR_COUNT_SUFFIX) + " books.");
+ }
+
+ /**
+ * 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, String valueString) {
+ String s = currencyString.replace(',', '.');
+ return s.contains(valueString);
+ }
+
+}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalSamplesTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalSamplesTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortalSamplesTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -5,145 +5,207 @@
import org.testng.annotations.Test;
import static org.testng.Assert.*;
-
+/**
+ * The Class PortalSamplesTestCase.
+ */
@Test(groups = { "test_samples" }, enabled = true)
public class PortalSamplesTestCase extends JBossPortalSeleniumTestCase {
-
+
+ /** prefix for locator properties = samples. */
+ public static String casePfx = "samples.";
+
+ private final String MSG_P3_L3 = getMess(casePfx + "p3.l3", "$256.00");
+ private final String MSG_P3_L2 = getMess(casePfx + "p3.l2", "SANTA CRUZ ALLSTAR");
+ private final String MSG_P3_L1 = getMess(casePfx + "p3.l1", "Product ID: 3");
+
+ private final String MSG_P2_L3 = getMess(casePfx + "p2.l3", "$319.99");
+ private final String MSG_P2_L2 = getMess(casePfx + "p2.l2", "FORUM DESTROYER LTD");
+ private final String MSG_P2_L1 = getMess(casePfx + "p2.l1", "Product ID: 2");
+
+ private final String MSG_P1_L3 = getMess(casePfx + "p1.l3", "Sale Price: $314.96");
+ private final String MSG_P1_L2 = getMess(casePfx + "p1.l2", "B BY BURTON ALPHA");
+ private final String MSG_P1_L1 = getMess(casePfx + "p1.l1", "Product ID: 1");
+
+ /** The AJAX timeout. */
public static long AJAX_TIMEOUT = 4500;
+
+ private final String SES_LNK_INVALIDATE = getLoc(casePfx + "ses.lnk.invalidate", "link=invalidate");
+ private final String RES_DIV_RTEXT = getLoc(casePfx + "res.div.rtext", "repeat-text");
+ private final String RES_DIV_PTEXT = getLoc(casePfx + "res.div.ptext", "product-text");
+ private final String RES_LNK_P3 = getLoc(casePfx + "res.lnk.p3", "link=Product3");
+ private final String RES_LNK_P2 = getLoc(casePfx + "res.lnk.p2", "link=Product2");
+ private final String RES_LNK_P1 = getLoc(casePfx + "res.lnk.p1", "link=Product1");
+ private final String RES_INP = getLoc(casePfx + "res.inp", "repeat");
+ private final String RES_LNK = getLoc(casePfx + "res.lnk", "link=serveResource Demo");
+ private final String WIN_DIV_CON = getLoc(casePfx + "win.div.con", "//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div");
+ private final String WIN_LNK = getLoc(casePfx + "win.lnk", "link=Window id test");
+ private final String SES_TAB_PSCOPE = getLoc(casePfx + "ses.tab.pscope", "//html/body/div[2]/div/div/div[2]/div[2]/div/table/tbody/tr[2]/td[2]/div/table");
+ private final String SES_TAB_ASCOPE = getLoc(casePfx + "ses.tab.ascope",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/table/tbody/tr[2]/td[2]/div/table[2]");
+ private final String SES_SUB_ASCOPE = getLoc(casePfx + "ses.sub.ascope", "application");
+ private final String SES_SUB_PSCOPE = getLoc(casePfx + "ses.sub.pscope", "portlet");
+ private final String SES_INP_VAL = getLoc(casePfx + "ses.inp.val", "value");
+ private final String SES_INP_NAM = getLoc(casePfx + "ses.inp.nam", "name");
+ private final String SES_LNK = getLoc(casePfx + "ses.lnk", "link=Session test");
+ private final String PUB_1_LNK_FOO_REM = getLoc(casePfx + "pub.1.lnk.foo.rem", "link=Remove");
+ private final String PUB_3_LNK_BAR_REM = getLoc(casePfx + "pub.3.lnk.bar.rem",
+ "//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[2]/td[2]/a");
+ private final String PUB_3_LNK_JUU_REM = getLoc(casePfx + "pub.3.lnk.juu.rem",
+ "//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[1]/td[2]/a");
+ private final String PUB_SUB_2 = getLoc(casePfx + "pub.sub.2", "//div[@id='regionB']/div[1]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[3]/td/input");
+ private final String PUB_SUB_1 = getLoc(casePfx + "pub.sub.1", "//input[@value='Update']");
+ private final String PUB_DIV_3_BAR = getLoc(casePfx + "pub.div.3.bar",
+ "//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[2]/td[2]/input");
+ private final String PUB_DIV_3_JUU = getLoc(casePfx + "pub.div.3.juu",
+ "//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[1]/td[2]/input");
+ private final String PUB_DIV_2_JUU = getLoc(casePfx + "pub.div.2.juu", "juu");
+ private final String PUB_DIV_2_FOO = getLoc(casePfx + "pub.div.2.foo",
+ "//div[@id='regionB']/div[1]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[1]/td[2]/input");
+ private final String PUB_DIV_1_BAR = getLoc(casePfx + "pub.div.1.bar", "bar");
+ private final String PUB_DIV_1_FOO = getLoc(casePfx + "pub.div.1.foo", "foo");
+ private final String PUB_LNK = getLoc(casePfx + "pub.lnk", "link=Public parameters test");
+ private final String PEVT_DIV_P3_MAX = getLoc(casePfx + "pevt.div.p3.max", "//div[@id='regionB']/div[3]/table/tbody/tr[1]/td[2]/div[2]/span[1]/a");
+ private final String PEVT_DIV_P2_MAX = getLoc(casePfx + "pevt.div.p2.max", "//div[@id='regionB']/div[2]/table/tbody/tr[1]/td[2]/div[2]/span[1]/a");
+ private final String PEVT_DIV_L3_MAX = getLoc(casePfx + "pevt.div.l3.max", "//div[@id='regionA']/div[3]/table/tbody/tr[1]/td[2]/div[2]/span[1]/a");
+ private final String PEVT_DIV_L2_MAX = getLoc(casePfx + "pevt.div.l2.max", "//div[@id='regionA']/div[2]/table/tbody/tr[1]/td[2]/div[2]/span[1]/a");
+ private final String PEVT_DIV_P3 = getLoc(casePfx + "pevt.div.p3", "//div[@id='regionB']/div[3]/table/tbody/tr[2]/td[2]/div/");
+ private final String PEVT_DIV_P2 = getLoc(casePfx + "pevt.div.p2", "//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/");
+ private final String PEVT_DIV_P1 = getLoc(casePfx + "pevt.div.p1", "//div[@id='regionB']/div[1]/table/tbody/tr[2]/td[2]/div/");
+ private final String PEVT_DIV_L3 = getLoc(casePfx + "pevt.div.l3", "//div[@id='regionA']/div[3]/table/tbody/tr[2]/td[2]/div/");
+ private final String PEVT_DIV_L2 = getLoc(casePfx + "pevt.div.l2", "//div[@id='regionA']/div[2]/table/tbody/tr[2]/td[2]/div/");
+ private final String PEVT_DIV_L1 = getLoc(casePfx + "pevt.div.l1", "//div[@id='regionA']/div[1]/table/tbody/tr[2]/td[2]/div/");
+ private final String PEVT_LNK = getLoc(casePfx + "pevt.lnk", "link=Page event test");
+ private final String MOD_DIV_CON = getLoc(casePfx + "mod.div.con", "//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div");
+ private final String MOD_LNK = getLoc(casePfx + "mod.lnk", "link=Mode test");
+ private final String MPOR_DIV_CON = getLoc(casePfx + "mpor.div.con", "content-container");
+ private final String MPOR_LNK = getLoc(casePfx + "mpor.lnk", "link=Missing portlet");
+ private final String MINS_DIV_CON = getLoc(casePfx + "mins.div.con", "content-container");
+ private final String MINS_LNK = getLoc(casePfx + "mins.lnk", "link=Missing instance");
+ private final String JS_LNK_SUBMIT = getLoc(casePfx + "js.lnk.submit", "link=submit");
+ private final String JS_OPT_3 = getLoc(casePfx + "js.opt.3", "//form[contains(@id,'_the_form')]/select/option[3]");
+ private final String JS_OPT_2 = getLoc(casePfx + "js.opt.2", "//form[contains(@id,'_the_form')]/select/option[2]");
+ private final String JS_OPT_1 = getLoc(casePfx + "js.opt.1", "//form[@id='jbpnsFormAutoSubmitPortletWindowsnpbj_the_form']/select/option[1]");
+ private final String JS_LAB_C = getLoc(casePfx + "js.lab.c", "label=C");
+ private final String JS_LAB_B = getLoc(casePfx + "js.lab.b", "label=B");
+ private final String JS_LAB_A = getLoc(casePfx + "js.lab.a", "label=A");
+ private final String JS_SEL_LETTER = getLoc(casePfx + "js.sel.letter",
+ "//select[@onclick=\"document.getElementById('jbpnsFormAutoSubmitPortletWindowsnpbj_the_form').submit()\"]");
+ private final String JS_LNK = getLoc(casePfx + "js.lnk", "link=Javascript test");
+ private final String HEAD_INP_CONTENT = getLoc(casePfx + "head.inp.content", "Introducing-HeaderContentInput");
+ private final String HEAD_DIV_CONTENT = getLoc(casePfx + "head.div.content", "Introducing-HeaderContent");
+ private final String HEAD_LNK = getLoc(casePfx + "head.lnk", "link=Header test");
+ private final String FS_LNK = getLoc(casePfx + "fs.lnk", "link=File system content");
+ private final String EXC_LNK_PORTLET = getLoc(casePfx + "exc.lnk.portlet", "link=render PortletException");
+ private final String EXC_LNK = getLoc(casePfx + "exc.lnk", "link=Exception test");
+ private final String EVT_SUB_COLOR = getLoc(casePfx + "evt.sub.color", "//input[@type='submit']");
+ private final String EVT_DIV_BLACK = getLoc(casePfx + "evt.div.black",
+ "//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[contains(@style,'black')]");
+ private final String EVT_DIV_RED = getLoc(casePfx + "evt.div.red", "//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[contains(@style,'red')]");
+ private final String EVT_DIV_BLUE = getLoc(casePfx + "evt.div.blue", "//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[contains(@style,'blue')]");
+ private final String EVT_SEL_LAB_BLACK = getLoc(casePfx + "evt.sel.lab.black", "label=black");
+ private final String EVT_SEL_LAB_RED = getLoc(casePfx + "evt.sel.lab.red", "label=red");
+ private final String EVT_SEL_LAB_BLUE = getLoc(casePfx + "evt.sel.lab.blue", "label=blue");
+ private final String EVT_SEL_COL = getLoc(casePfx + "evt.sel.col", "color");
+ private final String EVT_LNK = getLoc(casePfx + "evt.lnk", "link=Event test");
+ private final String ENC_LNK = getLoc(casePfx + "enc.lnk", "link=Encoding test");
+ private final String ENC_INP_REN = getLoc(casePfx + "enc.inp.ren", "text");
+ private final String ENC_SUB_ACT = getLoc(casePfx + "enc.sub.act", "//input[@value='Submit to action phase']");
+ private final String ENC_INP_ACT = getLoc(casePfx + "enc.inp.act", "//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/div[1]/form[2]/input[1]");
+ private final String ENC_TEXTAREA2 = getLoc(casePfx + "enc.textarea2", "//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/div[5]/textarea");
+ private final String ENC_TEXTAREA1 = getLoc(casePfx + "enc.textarea1", "//textarea[@name='text']");
+ private final String CHAR_ALL_SUB_CHECK = getLoc(casePfx + "char.all.sub.check",
+ "//html/body/div[2]/div/div/div[2]/div[2]/div/table/tbody/tr[2]/td[2]/div/div[8]/form/input[3]");
+ private final String CHAR_INP_TEXT_SUB_CHECK = getLoc(casePfx + "char.inp.text.sub.check",
+ "//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/div[8]/form/input[3]");
+ private final String CHAR_LNK_TEXTAREA_CHECK = getLoc(casePfx + "char.lnk.textarea.check", "//input[@value='check']");
+ private final String CHAR_INP_TEXT = getLoc(casePfx + "char.inp.text", "//input[@name='text']");
+ private final String CHAR_TEXTAREA = getLoc(casePfx + "char.textarea", "text");
+ private final String CHAR_SUB_CHANGE = getLoc(casePfx + "char.sub.change", "//input[@value='change']");
+ private final String CHAR_INP_TO = getLoc(casePfx + "char.inp.to", "to");
+ private final String CHAR_INP_FROM = getLoc(casePfx + "char.inp.from", "from");
+ private final String CHAR_LNK = getLoc(casePfx + "char.lnk", "link=Charset test");
+ private final String CACHE_LNK = getLoc(casePfx + "cache.lnk", "link=Cache test");
+ private final String CACHE_LNK_2REN = getLoc(casePfx + "cache.lnk.2ren", "//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[5]/a");
+ private final String CACHE_LNK_2ACT = getLoc(casePfx + "cache.lnk.2act", "//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[4]/a");
+ private final String CACHE_LNK_1REN = getLoc(casePfx + "cache.lnk.1ren", "link=render");
+ private final String CACHE_LNK_1ACT = getLoc(casePfx + "cache.lnk.1act", "link=action");
+ private final String CACHE_2RENDER = getLoc(casePfx + "cache.2render", "//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[2]/div");
+ private final String CACHE_1RENDER = getLoc(casePfx + "cache.1render", "//div[@id='regionB']/div[1]/table/tbody/tr[2]/td[2]/div/div[2]/div");
- public static String casePfx = "samples.";
+ private final String URL_LNK = getLoc(casePfx + "url.lnk", "");
+ private final String URL_INP_NAME1 = getLoc(casePfx + "url.inp.name1", "");
+ private final String URL_INP_VALUE1 = getLoc(casePfx + "url.inp.value1", "");
+ private final String URL_SUB1 = getLoc(casePfx + "url.sub1", "");
+ private final String URL_DIV1 = getLoc(casePfx + "url.div1", "");
+ private final String URL_LNK1_R = getLoc(casePfx + "url.lnk1.red", "");
+ private final String URL_LNK1_B = getLoc(casePfx + "url.lnk1.blue", "");
+ private final String URL_LNK1_W = getLoc(casePfx + "url.lnk1.white", "");
+ private final String URL_INP_NAME2 = getLoc(casePfx + "url.inp.name2", "");
+ private final String URL_INP_VALUE2 = getLoc(casePfx + "url.inp.value2", "");
+ private final String URL_SUB2 = getLoc(casePfx + "url.sub2", "");
+ private final String URL_DIV2 = getLoc(casePfx + "url.div2", "");
+ private final String URL_LNK2_R = getLoc(casePfx + "url.lnk2.red", "");
+ private final String URL_LNK2_B = getLoc(casePfx + "url.lnk2.blue", "");
+ private final String URL_LNK2_W = getLoc(casePfx + "url.lnk2.white", "");
- private final String SES_LNK_INVALIDATE = getProp(casePfx+"ses.lnk.invalidate","link=invalidate");
- private final String RES_DIV_RTEXT = getProp(casePfx+"res.div.rtext","repeat-text");
- private final String RES_DIV_PTEXT = getProp(casePfx+"res.div.ptext","product-text");
- private final String RES_LNK_P3 = getProp(casePfx+"res.lnk.p3","link=Product3");
- private final String RES_LNK_P2 = getProp(casePfx+"res.lnk.p2","link=Product2");
- private final String RES_LNK_P1 = getProp(casePfx+"res.lnk.p1","link=Product1");
- private final String RES_INP = getProp(casePfx+"res.inp","repeat");
- private final String RES_LNK = getProp(casePfx+"res.lnk","link=serveResource Demo");
- private final String WIN_DIV_CON = getProp(casePfx+"win.div.con","//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div");
- private final String WIN_LNK = getProp(casePfx+"win.lnk","link=Window id test");
- private final String SES_TAB_PSCOPE = getProp(casePfx+"ses.tab.pscope","//html/body/div[2]/div/div/div[2]/div[2]/div/table/tbody/tr[2]/td[2]/div/table");
- private final String SES_TAB_ASCOPE = getProp(casePfx+"ses.tab.ascope","//html/body/div[2]/div/div/div[2]/div[2]/div/table/tbody/tr[2]/td[2]/div/table[2]");
- private final String SES_SUB_ASCOPE = getProp(casePfx+"ses.sub.ascope","application");
- private final String SES_SUB_PSCOPE = getProp(casePfx+"ses.sub.pscope","portlet");
- private final String SES_INP_VAL = getProp(casePfx+"ses.inp.val","value");
- private final String SES_INP_NAM = getProp(casePfx+"ses.inp.nam","name");
- private final String SES_LNK = getProp(casePfx+"ses.lnk","link=Session test");
- private final String PUB_1_LNK_FOO_REM = getProp(casePfx+"pub.1.lnk.foo.rem","link=Remove");
- private final String PUB_3_LNK_BAR_REM = getProp(casePfx+"pub.3.lnk.bar.rem","//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[2]/td[2]/a");
- private final String PUB_3_LNK_JUU_REM = getProp(casePfx+"pub.3.lnk.juu.rem","//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[1]/td[2]/a");
- private final String PUB_SUB_2 = getProp(casePfx+"pub.sub.2","//div[@id='regionB']/div[1]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[3]/td/input");
- private final String PUB_SUB_1 = getProp(casePfx+"pub.sub.1","//input[@value='Update']");
- private final String PUB_DIV_3_BAR = getProp(casePfx+"pub.div.3.bar","//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[2]/td[2]/input");
- private final String PUB_DIV_3_JUU = getProp(casePfx+"pub.div.3.juu","//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[1]/td[2]/input");
- private final String PUB_DIV_2_JUU = getProp(casePfx+"pub.div.2.juu","juu");
- private final String PUB_DIV_2_FOO = getProp(casePfx+"pub.div.2.foo","//div[@id='regionB']/div[1]/table/tbody/tr[2]/td[2]/div/form/table/tbody/tr[1]/td[2]/input");
- private final String PUB_DIV_1_BAR = getProp(casePfx+"pub.div.1.bar","bar");
- private final String PUB_DIV_1_FOO = getProp(casePfx+"pub.div.1.foo","foo");
- private final String PUB_LNK = getProp(casePfx+"pub.lnk","link=Public parameters test");
- private final String PEVT_DIV_P3_MAX = getProp(casePfx+"pevt.div.p3.max","//div[@id='regionB']/div[3]/table/tbody/tr[1]/td[2]/div[2]/span[1]/a");
- private final String PEVT_DIV_P2_MAX = getProp(casePfx+"pevt.div.p2.max","//div[@id='regionB']/div[2]/table/tbody/tr[1]/td[2]/div[2]/span[1]/a");
- private final String PEVT_DIV_L3_MAX = getProp(casePfx+"pevt.div.l3.max","//div[@id='regionA']/div[3]/table/tbody/tr[1]/td[2]/div[2]/span[1]/a");
- private final String PEVT_DIV_L2_MAX = getProp(casePfx+"pevt.div.l2.max","//div[@id='regionA']/div[2]/table/tbody/tr[1]/td[2]/div[2]/span[1]/a");
- private final String PEVT_DIV_P3 = getProp(casePfx+"pevt.div.p3","//div[@id='regionB']/div[3]/table/tbody/tr[2]/td[2]/div/");
- private final String PEVT_DIV_P2 = getProp(casePfx+"pevt.div.p2","//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/");
- private final String PEVT_DIV_P1 = getProp(casePfx+"pevt.div.p1","//div[@id='regionB']/div[1]/table/tbody/tr[2]/td[2]/div/");
- private final String PEVT_DIV_L3 = getProp(casePfx+"pevt.div.l3","//div[@id='regionA']/div[3]/table/tbody/tr[2]/td[2]/div/");
- private final String PEVT_DIV_L2 = getProp(casePfx+"pevt.div.l2","//div[@id='regionA']/div[2]/table/tbody/tr[2]/td[2]/div/");
- private final String PEVT_DIV_L1 = getProp(casePfx+"pevt.div.l1","//div[@id='regionA']/div[1]/table/tbody/tr[2]/td[2]/div/");
- private final String PEVT_LNK = getProp(casePfx+"pevt.lnk","link=Page event test");
- private final String MOD_DIV_CON = getProp(casePfx+"mod.div.con","//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div");
- private final String MOD_LNK = getProp(casePfx+"mod.lnk","link=Mode test");
- private final String MPOR_DIV_CON = getProp(casePfx+"mpor.div.con","content-container");
- private final String MPOR_LNK = getProp(casePfx+"mpor.lnk","link=Missing portlet");
- private final String MINS_DIV_CON = getProp(casePfx+"mins.div.con","content-container");
- private final String MINS_LNK = getProp(casePfx+"mins.lnk","link=Missing instance");
- private final String JS_LNK_SUBMIT = getProp(casePfx+"js.lnk.submit","link=submit");
- private final String JS_OPT_3 = getProp(casePfx+"js.opt.3","//form[contains(@id,'_the_form')]/select/option[3]");
- private final String JS_OPT_2 = getProp(casePfx+"js.opt.2","//form[contains(@id,'_the_form')]/select/option[2]");
- private final String JS_OPT_1 = getProp(casePfx+"js.opt.1","//form[@id='jbpnsFormAutoSubmitPortletWindowsnpbj_the_form']/select/option[1]");
- private final String JS_LAB_C = getProp(casePfx+"js.lab.c","label=C");
- private final String JS_LAB_B = getProp(casePfx+"js.lab.b","label=B");
- private final String JS_LAB_A = getProp(casePfx+"js.lab.a","label=A");
- private final String JS_SEL_LETTER = getProp(casePfx+"js.sel.letter","//select[@onclick=\"document.getElementById('jbpnsFormAutoSubmitPortletWindowsnpbj_the_form').submit()\"]");
- private final String JS_LNK = getProp(casePfx+"js.lnk","link=Javascript test");
- private final String HEAD_INP_CONTENT = getProp(casePfx+"head.inp.content","Introducing-HeaderContentInput");
- private final String HEAD_DIV_CONTENT = getProp(casePfx+"head.div.content","Introducing-HeaderContent");
- private final String HEAD_LNK = getProp(casePfx+"head.lnk","link=Header test");
- private final String FS_LNK = getProp(casePfx+"fs.lnk","link=File system content");
- private final String EXC_LNK_PORTLET = getProp(casePfx+"exc.lnk.portlet","link=render PortletException");
- private final String EXC_LNK = getProp(casePfx+"exc.lnk","link=Exception test");
- private final String EVT_SUB_COLOR = getProp(casePfx+"evt.sub.color","//input[@type='submit']");
- private final String EVT_DIV_BLACK = getProp(casePfx+"evt.div.black","//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[contains(@style,'black')]");
- private final String EVT_DIV_RED = getProp(casePfx+"evt.div.red","//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[contains(@style,'red')]");
- private final String EVT_DIV_BLUE = getProp(casePfx+"evt.div.blue","//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[contains(@style,'blue')]");
- private final String EVT_SEL_LAB_BLACK = getProp(casePfx+"evt.sel.lab.black","label=black");
- private final String EVT_SEL_LAB_RED = getProp(casePfx+"evt.sel.lab.red","label=red");
- private final String EVT_SEL_LAB_BLUE = getProp(casePfx+"evt.sel.lab.blue","label=blue");
- private final String EVT_SEL_COL = getProp(casePfx+"evt.sel.col","color");
- private final String EVT_LNK = getProp(casePfx+"evt.lnk","link=Event test");
- private final String ENC_LNK = getProp(casePfx+"enc.lnk","link=Encoding test");
- private final String ENC_INP_REN = getProp(casePfx+"enc.inp.ren","text");
- private final String ENC_SUB_ACT = getProp(casePfx+"enc.sub.act","//input[@value='Submit to action phase']");
- private final String ENC_INP_ACT = getProp(casePfx+"enc.inp.act","//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/div[1]/form[2]/input[1]");
- private final String ENC_TEXTAREA2 = getProp(casePfx+"enc.textarea2","//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/div[5]/textarea");
- private final String ENC_TEXTAREA1 = getProp(casePfx+"enc.textarea1","//textarea[@name='text']");
- private final String CHAR_ALL_SUB_CHECK = getProp(casePfx+"char.all.sub.check","//html/body/div[2]/div/div/div[2]/div[2]/div/table/tbody/tr[2]/td[2]/div/div[8]/form/input[3]");
- private final String CHAR_INP_TEXT_SUB_CHECK = getProp(casePfx+"char.inp.text.sub.check","//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/div[8]/form/input[3]");
- private final String CHAR_LNK_TEXTAREA_CHECK = getProp(casePfx+"char.lnk.textarea.check","//input[@value='check']");
- private final String CHAR_INP_TEXT = getProp(casePfx+"char.inp.text","//input[@name='text']");
- private final String CHAR_TEXTAREA = getProp(casePfx+"char.textarea","text");
- private final String CHAR_SUB_CHANGE = getProp(casePfx+"char.sub.change","//input[@value='change']");
- private final String CHAR_INP_TO = getProp(casePfx+"char.inp.to","to");
- private final String CHAR_INP_FROM = getProp(casePfx+"char.inp.from","from");
- private final String CHAR_LNK = getProp(casePfx+"char.lnk","link=Charset test");
- private final String CACHE_LNK = getProp(casePfx+"cache.lnk","link=Cache test");
- private final String CACHE_LNK_2REN = getProp(casePfx+"cache.lnk.2ren","//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[5]/a");
- private final String CACHE_LNK_2ACT = getProp(casePfx+"cache.lnk.2act","//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[4]/a");
- private final String CACHE_LNK_1REN = getProp(casePfx+"cache.lnk.1ren","link=render");
- private final String CACHE_LNK_1ACT = getProp(casePfx+"cache.lnk.1act","link=action");
- private final String CACHE_2RENDER = getProp(casePfx+"cache.2render","//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[2]/div");
- private final String CACHE_1RENDER = getProp(casePfx+"cache.1render","//div[@id='regionB']/div[1]/table/tbody/tr[2]/td[2]/div/div[2]/div");
-
+ /**
+ * Login before test.
+ */
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
selenium.open("/portal/portal/default/default");
selenium.waitForPageToLoad(PAGE_LOAD);
}
+ /**
+ * Logout after test.
+ */
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ protected void logoutAfterTest() {
}
+
+ /**
+ * Cache test. Test clicks on action and render links in both portlets and
+ * assert the change of render call count values accordingly.
+ */
@Test(enabled = true)
public void cacheTest() {
selenium.click(CACHE_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
assertEquals("0", selenium.getText(CACHE_1RENDER));
assertEquals("0", selenium.getText(CACHE_2RENDER));
-
+
selenium.click(CACHE_LNK_1ACT);
selenium.waitForPageToLoad(PAGE_LOAD);
assertEquals("1", selenium.getText(CACHE_1RENDER));
assertEquals("1", selenium.getText(CACHE_2RENDER));
-
+
selenium.click(CACHE_LNK_1REN);
selenium.waitForPageToLoad(PAGE_LOAD);
assertEquals("1", selenium.getText(CACHE_1RENDER));
assertEquals("2", selenium.getText(CACHE_2RENDER));
-
+
selenium.click(CACHE_LNK_2ACT);
selenium.waitForPageToLoad(PAGE_LOAD);
assertEquals("1", selenium.getText(CACHE_1RENDER));
assertEquals("3", selenium.getText(CACHE_2RENDER));
-
+
selenium.click(CACHE_LNK_2REN);
selenium.waitForPageToLoad(PAGE_LOAD);
assertEquals("1", selenium.getText(CACHE_1RENDER));
- assertEquals("4", selenium.getText(CACHE_2RENDER));
+ assertEquals("4", selenium.getText(CACHE_2RENDER));
}
-
+
+ /**
+ * Charset test.
+ * <ul>
+ * <li>set the testing range and check</li>
+ * <li>change the testing range and check</li>
+ * <li>change text in textarea to incorrect and check</li>
+ * <li>change text in textarea to correct and check</li>
+ * </ul>
+ */
@Test(enabled = true)
public void charsetTest() {
selenium.click(CHAR_LNK);
@@ -152,28 +214,42 @@
selenium.type(CHAR_INP_TO, "75");
selenium.click(CHAR_SUB_CHANGE);
selenium.waitForPageToLoad(PAGE_LOAD);
+
assertEquals("ABCDEFGHIJ", selenium.getText(CHAR_TEXTAREA));
+
selenium.click(CHAR_LNK_TEXTAREA_CHECK);
selenium.waitForPageToLoad(PAGE_LOAD);
+
assertTrue(selenium.isTextPresent("Test result: The input matched the expected result"));
assertEquals("ABCDEFGHIJ", selenium.getValue(CHAR_INP_TEXT));
+
selenium.click(CHAR_INP_TEXT_SUB_CHECK);
selenium.waitForPageToLoad(PAGE_LOAD);
+
selenium.type(CHAR_INP_FROM, "55");
selenium.type(CHAR_INP_TO, "65");
selenium.click(CHAR_SUB_CHANGE);
selenium.waitForPageToLoad(PAGE_LOAD);
+
assertEquals("789:;<=>?@", selenium.getValue(CHAR_INP_TEXT));
+
selenium.type(CHAR_TEXTAREA, "789:;<=>?@4");
selenium.click(CHAR_LNK_TEXTAREA_CHECK);
selenium.waitForPageToLoad(PAGE_LOAD);
+
assertTrue(selenium.isTextPresent("Test result: The input did not matched the expected result"));
+
selenium.type(CHAR_INP_TEXT, "789:;<=>?@f");
selenium.click(CHAR_ALL_SUB_CHECK);
selenium.waitForPageToLoad(PAGE_LOAD);
- assertTrue(selenium.isTextPresent("Test result: The input matched the expected result"));
+
+ assertTrue(selenium.isTextPresent("Test result: The input matched the expected result"));
}
-
+
+ /**
+ * Encoding test. Test fills in inputs for "text to pass" and submit them to
+ * render and action phase. The text in textareas is asserted accordingly.
+ */
@Test(enabled = true)
public void encodingTest() {
selenium.click(ENC_LNK);
@@ -189,9 +265,13 @@
selenium.click("//input[@value='Submit to render phase']");
selenium.waitForPageToLoad(PAGE_LOAD);
assertEquals("", selenium.getValue(ENC_TEXTAREA1));
- assertEquals("action", selenium.getValue(ENC_TEXTAREA2));
+ assertEquals("action", selenium.getValue(ENC_TEXTAREA2));
}
-
+
+ /**
+ * Event test. The tests changes the colors for text and asserts that color
+ * was really changed.
+ */
@Test(enabled = true)
public void eventTest() {
selenium.click(EVT_LNK);
@@ -209,32 +289,48 @@
selenium.waitForPageToLoad(PAGE_LOAD);
assertTrue(selenium.isElementPresent(EVT_DIV_BLACK));
}
-
+
+ /**
+ * Exception test. After accessing the portlet, the string
+ * "javax.portlet.PortletException" is asserted to appear on the screen.
+ */
@Test(enabled = true)
public void exceptionTest() {
selenium.click(EXC_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(EXC_LNK_PORTLET);
selenium.waitForPageToLoad(PAGE_LOAD);
- assertTrue(selenium.isTextPresent("javax.portlet.PortletException"));
+ assertTrue(selenium.isTextPresent("javax.portlet.PortletException"));
}
-
+
+ /**
+ * File system content test. After accessing the portlet, the string
+ * "Bar content" is asserted to appear on the screen.
+ */
@Test(enabled = true)
public void fileSystemContentTest() {
selenium.click(FS_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
- assertTrue(selenium.isTextPresent("Bar content"));
+ assertTrue(selenium.isTextPresent("Bar content"));
}
-
+
+ /**
+ * Header test. Clicks on "call injected javascript" button and asserts that
+ * the correct alert message was popped up.
+ */
@Test(enabled = true)
public void headerTest() {
selenium.click(HEAD_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
- assertTrue(selenium.isElementPresent(HEAD_DIV_CONTENT));
+ assertTrue(selenium.isElementPresent(HEAD_DIV_CONTENT));
selenium.click(HEAD_INP_CONTENT);
assertEquals("hello from the injected java script!", selenium.getAlert());
}
-
+
+ /**
+ * Javascript test. Selects some values from the list and after refresh
+ * asserts that nothing was selected.
+ */
@Test(enabled = true)
public void javascriptTest() {
selenium.click(JS_LNK);
@@ -243,100 +339,122 @@
waitFor(AJAX_TIMEOUT);
selenium.click(JS_OPT_1);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
assertFalse(selenium.isSomethingSelected(JS_SEL_LETTER));
-
+
selenium.addSelection(JS_SEL_LETTER, JS_LAB_B);
waitFor(AJAX_TIMEOUT);
selenium.click(JS_OPT_2);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
assertFalse(selenium.isSomethingSelected(JS_SEL_LETTER));
-
+
selenium.addSelection(JS_SEL_LETTER, JS_LAB_C);
waitFor(AJAX_TIMEOUT);
selenium.click(JS_OPT_3);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
assertFalse(selenium.isSomethingSelected(JS_SEL_LETTER));
-
+
selenium.click(JS_LNK_SUBMIT);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
assertFalse(selenium.isSomethingSelected(JS_SEL_LETTER));
}
-
+
+ /**
+ * Missing instance test. The page is opened and it is asserted, that no
+ * portlet is on the screen.
+ */
@Test(enabled = true)
public void missingInstanceTest() {
selenium.click(MINS_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
- assertEquals("", selenium.getText(MINS_DIV_CON));
+ assertEquals("", selenium.getText(MINS_DIV_CON));
}
-
+
+ /**
+ * Missing portlet test. The page is opened and it is asserted, that no
+ * portlet is on the screen.
+ */
@Test(enabled = true)
public void missingPortletTest() {
selenium.click(MPOR_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
- assertEquals("", selenium.getText(MPOR_DIV_CON));
+ assertEquals("", selenium.getText(MPOR_DIV_CON));
}
-
+
+ /**
+ * Mode test. The page is opened and it is asserted, that only a text "view"
+ * is present in portlet content.
+ */
@Test(enabled = true)
public void modeTest() {
selenium.click(MOD_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
assertEquals("View", selenium.getText(MOD_DIV_CON));
}
-
+
+ /**
+ * Page event test. The test clicks on "normal" button for each portlet on
+ * the screen and asserts, that every other portlet in the column is
+ * minimalised.
+ */
@Test(enabled = true)
public void pageEventTest() {
final String portletText = "This is a simple showcase of Portal Node Event Listener. For this portal page it ensures that in every column, only one portlet window is in NORMAL state. Try to change the window state of other portlets and see what happens. To learn more, read InterPortlet Communication (IPC) chapter in JBoss Portal Reference Guide.";
final String emptyText = "";
-
+
selenium.click(PEVT_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
// Left column
-
+
assertEquals(portletText, selenium.getText(PEVT_DIV_L1));
assertEquals(emptyText, selenium.getText(PEVT_DIV_L2));
assertEquals(emptyText, selenium.getText(PEVT_DIV_L3));
-
+
selenium.click(PEVT_DIV_L2_MAX);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
assertEquals(emptyText, selenium.getText(PEVT_DIV_L1));
assertEquals(portletText, selenium.getText(PEVT_DIV_L2));
assertEquals(emptyText, selenium.getText(PEVT_DIV_L3));
-
+
selenium.click(PEVT_DIV_L3_MAX);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
assertEquals(emptyText, selenium.getText(PEVT_DIV_L1));
assertEquals(emptyText, selenium.getText(PEVT_DIV_L2));
assertEquals(portletText, selenium.getText(PEVT_DIV_L3));
-
+
// Right column
-
+
assertEquals(portletText, selenium.getText(PEVT_DIV_P1));
assertEquals(emptyText, selenium.getText(PEVT_DIV_P2));
assertEquals(emptyText, selenium.getText(PEVT_DIV_P3));
-
+
selenium.click(PEVT_DIV_P2_MAX);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
assertEquals(emptyText, selenium.getText(PEVT_DIV_P1));
assertEquals(portletText, selenium.getText(PEVT_DIV_P2));
assertEquals(emptyText, selenium.getText(PEVT_DIV_P3));
-
+
selenium.click(PEVT_DIV_P3_MAX);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
assertEquals(emptyText, selenium.getText(PEVT_DIV_P1));
assertEquals(emptyText, selenium.getText(PEVT_DIV_P2));
assertEquals(portletText, selenium.getText(PEVT_DIV_P3));
-
+
}
-
+
+ /**
+ * Public parameters test. Test is adding values for each parameter and
+ * asserting that they appear in valid inputs. Then it removes all values
+ * and asserts that they not appear in valid inputs.
+ */
@Test(enabled = true)
public void publicParametersTest() {
selenium.click(PUB_LNK);
@@ -399,13 +517,20 @@
assertEquals("", selenium.getValue(PUB_DIV_3_JUU));
assertEquals("", selenium.getValue(PUB_DIV_3_BAR));
}
-
+
+ /**
+ * Secure test. Test is disabled. More information needed.
+ */
+ // TODO enable test - more information needed
@Test(enabled = false)
public void secureTest() {
-
-
+
}
-
+
+ /**
+ * Session test. Test adds parameters to portlet and application scope and
+ * asserts that they appear in attributes tables accordingly.
+ */
@Test(enabled = true)
public void sessionTest() {
selenium.click(SES_LNK);
@@ -414,67 +539,102 @@
selenium.type(SES_INP_VAL, "scopeval1");
selenium.click(SES_SUB_PSCOPE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
int r = findTableRow(SES_TAB_PSCOPE, "scope1", 0);
- assertTrue(r>0);
+ assertTrue(r > 0);
assertEquals(findTableRow(SES_TAB_PSCOPE, "scopeval1", 1), r);
-
- //assertEquals("scope1", selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/table[1]/tbody/tr[2]/td[1]"));
- //assertEquals("scopeval1", selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/table[1]/tbody/tr[2]/td[2]"));
+
selenium.type(SES_INP_NAM, "app1");
selenium.type(SES_INP_VAL, "appval1");
selenium.click(SES_SUB_ASCOPE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
r = findTableRow(SES_TAB_ASCOPE, "app1", 0);
- assertTrue(r>0);
+ assertTrue(r > 0);
assertEquals(findTableRow(SES_TAB_ASCOPE, "appval1", 1), r);
-
- //assertEquals("app1", selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/table[2]/tbody/tr[2]/td[1]"));
- //assertEquals("appval1", selenium.getText("//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div/table[2]/tbody/tr[2]/td[2]"));
-
+
selenium.click(SES_LNK_INVALIDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
assertFalse(selenium.isTextPresent("Session id"));
}
-
- @Test(enabled = false)
+
+ /**
+ * Url portlet test. Fills in the two input boxes with "name" and "viliam" values. Then it clicks on the "red" link in the second box. Finally, it is asserted
+ * that the table in the second portlet is red and values are filled right as they were before clicking the "red" link.
+ */
+ // TODO enable test - more information needed
+ @Test(enabled = true)
public void urlPortletTest() {
+
+ selenium.click(URL_LNK);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(URL_INP_NAME1, "name");
+ selenium.type(URL_INP_VALUE1, "viliam");
+
+ assertTrue(selenium.isElementPresent(URL_DIV2));
+ selenium.click(URL_LNK2_R);
+
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ assertTrue(selenium.isElementPresent(URL_DIV2));
+
+ assertEquals(selenium.getValue(URL_INP_NAME1), "");
+ assertEquals(selenium.getValue(URL_INP_VALUE1), "");
+
}
-
+
+ /**
+ * Window id test. The page is opened and it is asserted, that only a text
+ * "Window ID is equals to /default/Test/Window id test/WindowIDPortletWindow"
+ * is present in portlet content.
+ */
@Test(enabled = true)
public void windowIdTest() {
selenium.click(WIN_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
- assertEquals("Window ID is equals to /default/Test/Window id test/WindowIDPortletWindow", selenium.getText(WIN_DIV_CON));
+ assertEquals("Window ID is equals to /default/Test/Window id test/WindowIDPortletWindow", selenium.getText(WIN_DIV_CON));
}
-
+
+ /**
+ * Serve resource demo test. Tests that repeat input really rewrites the
+ * text on screen, and clicks on all product links and assert that right
+ * addresses have appeared on screen.
+ */
@Test(enabled = true)
public void serveResourceDemoTest() {
-
selenium.click(RES_LNK);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.type(RES_INP, "valtest");
selenium.typeKeys(RES_INP, " ");
-
+
waitFor(AJAX_TIMEOUT);
-
+
assertEquals("valtest", selenium.getText(RES_DIV_RTEXT));
+
selenium.click(RES_LNK_P1);
waitFor(AJAX_TIMEOUT);
- assertEquals("Product ID: 1\n B BY BURTON ALPHA\nSale Price: $314.96", selenium.getText(RES_DIV_PTEXT));
+
+ assertTrue(selenium.isTextPresent(MSG_P1_L1));
+ assertTrue(selenium.isTextPresent(MSG_P1_L2));
+ assertTrue(selenium.isTextPresent(MSG_P1_L3));
+
selenium.click(RES_LNK_P2);
waitFor(AJAX_TIMEOUT);
- assertEquals("Product ID: 2\nFORUM DESTROYER LTD\n$319.99", selenium.getText(RES_DIV_PTEXT));
+
+ assertTrue(selenium.isTextPresent(MSG_P2_L1));
+ assertTrue(selenium.isTextPresent(MSG_P2_L2));
+ assertTrue(selenium.isTextPresent(MSG_P2_L3));
+
selenium.click(RES_LNK_P3);
waitFor(AJAX_TIMEOUT);
- assertEquals("Product ID: 3\n SANTA CRUZ ALLSTAR\n$256.00", selenium.getText(RES_DIV_PTEXT));
-
+
+ assertTrue(selenium.isTextPresent(MSG_P3_L1));
+ assertTrue(selenium.isTextPresent(MSG_P3_L2));
+ assertTrue(selenium.isTextPresent(MSG_P3_L3));
+
}
-
-
-
+
}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortletUserCreationTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortletUserCreationTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/PortletUserCreationTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -3,195 +3,293 @@
import org.testng.Assert;
import org.testng.annotations.Test;
+// TODO: Auto-generated Javadoc
/**
+ * PortletUserCreationTestCase was used for registering new user with portlet on a default homepage of portal. Because of captcha this test had to be disabled.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
@Test(groups = { "portlet_user_creation" }, enabled = true)
public class PortletUserCreationTestCase extends JBossPortalSeleniumTestCase {
+ /** prefix for locator properties = user.crea.port.*/
public String casePfx = "user.crea.port.";
-
- private final String SUBMIT_CREATE_CONF = getProp(casePfx+"submit.create.conf","//input[contains(@id,'confirm-form:user')]");
- public final String SUBMIT_CREATE_CONF_EDIT = getProp(casePfx+"submit.create.conf.edit","//input[contains(@id,'//input[contains(@id,'confirm-form:revise')]");
- private final String SUBMIT_CREATE_USER = getProp(casePfx+"submit.create.user","//input[contains(@id,'register-form:submit')]");
- private final String SUBMIT_CREATE_USER_CANCEL = getProp(casePfx+"submit.create.user.cancel","//input[contains(@id,'register-form:cancel')]");
- private final String INPUT_USERPASSWDCONF = getProp(casePfx+"input.userpasswdconf","//input[contains(@id,'register-form:passwordCheckv");
- private final String INPUT_USERPASSWD = getProp(casePfx+"input.userpasswd","//input[contains(@id,'register-form:password')]");
- private final String INPUT_USERMAIL = getProp(casePfx+"input.usermail","//input[contains(@id,'register-form:email')]");
- private final String INPUT_USERNAME = getProp(casePfx+"input.username","//input[contains(@id,'register-form:username')]");
- private final String LINK_CREATE_USER = getProp(casePfx+"link.create.user","//a[contains(@id,'create-account-form:register')]");
- private final String TAB_WELCOME = getProp(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");
-
- @Test(enabled = true, description = "Simple user creation.")
+ /**
+ * User creation test.
+ */
+ @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.")));
}
- @Test(enabled = true, description = "User creation using most of the active elements on page.")
+ /**
+ * User creation long test.
+ */
+ @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
Assert.assertTrue((selenium.isTextPresent("Your account has been successfully created. You may want to login now.")));
}
- @Test(enabled = true, description = "Canceling of editing during the user creation.")
+ /**
+ * User creation cancel edit test.
+ */
+ @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."));
}
- @Test(enabled = true, description = "Creation of already existing user.")
+ /**
+ * Existing user creation test.
+ */
+ @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"));
}
+ /**
+ * Invalid email.
+ */
@Test(enabled = false, description = "Using invalid e-mail within user creation.")
public void invalidEmail() {
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."));
}
- @Test(enabled = true, description = "Not matching password confirmation.")
+ /**
+ * Password not match.
+ */
+ @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.", groups = {"XSS"})
+ 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);
- @Test(enabled = true, description = "Using short password.")
+ 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 = 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/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserInterceptorPortletTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -6,7 +6,10 @@
import org.testng.Assert;
import org.testng.annotations.Test;
+
/**
+ * The Class UserInterceptorPortletTestCase is responsible for testing the log of logging of users.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
@Test(groups = { "cms_user_interceptor" }, enabled = true, description = "Checking the log of logging of users.")
@@ -15,12 +18,21 @@
private static final String LNK_USER_DETAILS = "link=UsersDetailPage";
private static final String DIV_LOGINFO = "//div[@id='regionB']/div/table/tbody/tr[2]/td[2]/div";
+ /**
+ * Test test user logger. The user is logged in two times, asserting, that the time of second logging was after the first login.
+ *
+ * @throws ParseException the parse exception
+ */
@Test(enabled = true, description = "Checking the logging dates for user.")
public void testTestUserLogger() throws ParseException {
-
Assert.assertTrue(dateDiff("user", "user", 1) > 0, "Second logging was not after the first for user.");
}
+ /**
+ * Test test admin logger. The admin is logged in two times, asserting, that the time of second logging was after the first login.
+ *
+ * @throws ParseException the parse exception
+ */
@Test(enabled = true, description = "Checking the logging dates for admin.")
public void testTestAdminLogger() throws ParseException {
Assert.assertTrue(dateDiff("admin", "admin", 3) > 0, "Second logging was not after the first for user.");
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/UserLoginTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -4,43 +4,52 @@
import org.testng.annotations.AfterClass;
import org.testng.annotations.Test;
-
/**
+ * Testcase responsible for testing of login form.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
@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 ADR_PORTAL = getProp(casePfx+"adr.portal","/portal");
- private final String FRM_MAIN = getProp(casePfx+"frm.main","relative=up");
- private final String SUB_CANCEL = getProp(casePfx+"sub.portal","cancel");
- private final String LNK_LOGOUT = getProp(casePfx+"lnk.logout","link=Logout");
- private final String SUB_LOGIN = getProp(casePfx+"sub.login","login");
- private final String INP_PASSWORD = getProp(casePfx+"inp.password","xpath=id('j_password')");
- private final String INP_USERNAME = getProp(casePfx+"inp.username","xpath=id('j_username')");
- private final String FRM_LOGINFORM = getProp(casePfx+"frm.login","login-content");
- private final String LNK_LOGIN = getProp(casePfx+"lnk.login","link=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");
+ private final String LNK_LOGOUT = getLoc(casePfx + "lnk.logout", "link=Logout");
+ private final String SUB_LOGIN = getLoc(casePfx + "sub.login", "login-submit");
+ private final String INP_PASSWORD = getLoc(casePfx + "inp.password", "xpath=id('j_password')");
+ private final String INP_USERNAME = getLoc(casePfx + "inp.username", "xpath=id('j_username')");
+ private final String FRM_LOGINFORM = getLoc(casePfx + "frm.login", "login-content");
+ private final String LNK_LOGIN = getLoc(casePfx + "lnk.login", "link=Login");
+
@AfterClass(enabled = true)
- public void logoutIfNeeded()
- {
+ private void logoutIfNeeded() {
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
-
- if (selenium.isElementPresent(LNK_LOGOUT)){
+
+ if (selenium.isElementPresent(LNK_LOGOUT)) {
selenium.click(LNK_LOGOUT);
selenium.waitForPageToLoad(PAGE_LOAD);
}
}
-
+
+ /**
+ * Test default user login.
+ *
+ * Login as user/user and check if the message with login information
+ * appears.
+ */
@Test(enabled = true, description = "login as default user 'user' with password 'user'.")
- public void testDefaultUserLogin() throws Exception {
+ public void testDefaultUserLogin() {
final String loginName = "user";
final String loginPass = "user";
-
+
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -52,18 +61,19 @@
waitForElement(INP_USERNAME);
waitForElement(INP_PASSWORD);
-
+
Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
selenium.type(INP_USERNAME, loginName);
Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
selenium.type(INP_PASSWORD, loginPass);
+ selenium.fireEvent(INP_PASSWORD, "keydown");
selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Logged in as: "+loginName), "\"Logged in as\" message missing.");
+ Assert.assertTrue(selenium.isTextPresent("Logged in as: " + loginName), "\"Logged in as\" message missing.");
Assert.assertTrue(selenium.isElementPresent(LNK_LOGOUT), "Expected DOM element for login link does not exist.");
Assert.assertEquals(selenium.getText(LNK_LOGOUT), "Logout", "Logout has wrong label.");
@@ -73,11 +83,17 @@
Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "\"Logged in as:\" message with no user logged in is missing.");
}
+ /**
+ * Test admin login.
+ *
+ * Login as admin/admin and check if the message with login information
+ * appears.
+ */
@Test(enabled = true, description = "login as admin user 'admin' with password 'admin'.")
- public void testAdminLogin() throws Exception {
+ public void testAdminLogin() {
final String loginName = "admin";
final String loginPass = "admin";
-
+
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
waitForElement(LNK_LOGIN);
@@ -89,13 +105,15 @@
waitForElement(INP_USERNAME);
waitForElement(INP_PASSWORD);
-
+
Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
selenium.type(INP_USERNAME, loginName);
Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
selenium.type(INP_PASSWORD, loginPass);
+ selenium.fireEvent(INP_PASSWORD, "keydown");
selenium.click(SUB_LOGIN);
+ // waitFor(AJAX_LOAD);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Logged in as: admin"), "\"Logged in as\" message missing.");
@@ -108,11 +126,16 @@
Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "\"Logged in as:\" message with no user logged in is missing.");
}
+ /**
+ * Test user login cancel.
+ *
+ * Fill the login form with user/user, but press cancel instead of login.
+ */
@Test(enabled = true, description = "canceling of the login form.")
- public void testUserLoginCancel() throws Exception {
+ public void testUserLoginCancel() {
final String loginName = "saki";
final String loginPass = "paki";
-
+
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -126,7 +149,7 @@
waitForElement(INP_USERNAME);
waitForElement(INP_PASSWORD);
-
+
Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
selenium.type(INP_USERNAME, loginName);
Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
@@ -140,12 +163,17 @@
Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "\"Logged in as:\" message with no user logged in is missing.");
}
-
+
+ /**
+ * Test false name login.
+ *
+ * Try to login with us2er/user and check that you are not logged in.
+ */
@Test(enabled = true, description = "login as 'us2er' which does not exist.")
- public void testFalseNameLogin() throws Exception {
+ public void testFalseNameLogin() {
final String loginName = "us2er";
final String loginPass = "user";
-
+
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -157,23 +185,29 @@
waitForElement(INP_USERNAME);
waitForElement(INP_PASSWORD);
-
+
Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
selenium.type(INP_USERNAME, loginName);
Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
selenium.type(INP_PASSWORD, loginPass);
+ 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 "), "\"Logged in as\" message missing.");
}
-
+
+ /**
+ * Test false password login.
+ *
+ * Try to login with user/us2er and check that you are not logged in.
+ */
@Test(enabled = true, description = "login as 'user' with wrong password 'us2er'.")
- public void testFalsePasswordLogin() throws Exception {
+ public void testFalsePasswordLogin() {
final String loginName = "user";
final String loginPass = "us2er";
-
+
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -185,11 +219,12 @@
waitForElement(INP_USERNAME);
waitForElement(INP_PASSWORD);
-
+
Assert.assertTrue(selenium.isElementPresent(INP_USERNAME), "Expected input DOM element for username doesn't exist.");
selenium.type(INP_USERNAME, loginName);
Assert.assertTrue(selenium.isElementPresent(INP_PASSWORD), "Expected input DOM element for password doesn't exist.");
selenium.type(INP_PASSWORD, loginPass);
+ selenium.fireEvent(INP_PASSWORD, "keydown");
selenium.click(SUB_LOGIN);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -197,4 +232,51 @@
Assert.assertTrue(selenium.isTextPresent("The user doesn't exist or the password is incorrect "), "\"Logged in as\" message missing.");
}
+ /**
+ * Test xss attacks on login form. Xss attack string is wirtten into
+ * password field for "user" and it is asserted, that "wrong password"
+ * message is present. Xss attack string is wirtten into userGname field for
+ * "user" and it is asserted, that "wrong password" message is present.
+ *
+ * Try to login with user/us2er and check that you are not logged in.
+ */
+ @Test(enabled = true, description = "xss login", groups = {"XSS"})
+ public void testXssLogin() {
+ final String loginName = "user";
+ final String loginPass = "us2er";
+
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
+
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
+
+ selenium.type(INP_USERNAME, loginName);
+ selenium.type(INP_PASSWORD, XSS_STR1);
+ selenium.fireEvent(INP_PASSWORD, "keydown");
+ selenium.click(SUB_LOGIN);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_LOGIN_WRONGPASS));
+
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click(LNK_LOGIN);
+ selenium.selectFrame(FRM_LOGINFORM);
+
+ waitForElement(INP_USERNAME);
+ waitForElement(INP_PASSWORD);
+
+ selenium.type(INP_USERNAME, XSS_STR1);
+ selenium.type(INP_PASSWORD, loginPass);
+ selenium.fireEvent(INP_PASSWORD, "keydown");
+ selenium.click(SUB_LOGIN);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_LOGIN_WRONGPASS), "\"Logged in as\" message missing.");
+ }
+
}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -6,98 +6,142 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+
/**
+ * The Class WSRPTestCase is reponsible for testing the WSRP GUI of JBoss
+ * Portal.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
@Test(groups = { "cms_wsrp" }, enabled = true, description = "WSRP test case.")
public class WSRPTestCase extends JBossPortalSeleniumTestCase {
-
+
+ /** prefix for locator properties */
public static String casePfx = "test.wsrp.";
- private final String INP_CONSUMER_NAME = getProp(casePfx+"inp.consumer.name","//input[contains(@id,'edit-cons-form:id')]");
- private final String SUB_REFRESH_CANCEL = getProp(casePfx+"submit.refresh.cancel","//a[contains(@id,'edit-cons-form:list-cons-link')]");
- private final String SUB_PROD_SAVE = getProp(casePfx+"submit.prod.save","//input[contains(@id,'producer-form:save-producer')]");
- private final String SUB_CONSDEL_CONF = getProp(casePfx+"submit.consdel.conf","//a[contains(@id,'confirm-delete-form:destroy-link')]");
- private final String SUB_CONS_REGVAL = getProp(casePfx+"submit.cons.regval","//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
- private final String SUB_REFRESHFINAL = getProp(casePfx+"submit.refreshfinal","//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
- private final String INPUT_CONS_REGVALUE = getProp(casePfx+"input.cons.regvalue","//input[contains(@id,'edit-cons-form:existingProps:0:prop-value-input')]");
- private final String SUBMIT_REFRESHSAVE = getProp(casePfx+"submit.refreshsave","//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
- private final String INPUT_CONSWSDL = getProp(casePfx+"input.conswsdl","//input[contains(@id,'edit-cons-form:wsdl')]");
- private final String INPUT_CACHEEXP = getProp(casePfx+"input.cacheexp","//input[contains(@id,'edit-cons-form:cache')]");
- private final String SUBMIT_ADDPROP_INIT = getProp(casePfx+"submit.addprop.init","//a[contains(@id,'producer-form:add-reg-prop')]");
- private final String SUBMIT_ADDPROP = getProp(casePfx+"submit.addprop","//a[contains(@id,'producer-form:add-reg-prop')]");
- private final String INPUT_PROPHINT = getProp(casePfx+"input.prophint","//input[contains(@id,'producer-form:reg-properties:0:hint')]");
- private final String INPUT_PROPLABEL = getProp(casePfx+"input.proplabel","//input[contains(@id,'producer-form:reg-properties:0:label')]");
- private final String INPUT_PROPNAME = getProp(casePfx+"input.propname","//input[contains(@id,'producer-form:reg-properties:0:name')]");
- private final String SUBMIT_CREATECONS = getProp(casePfx+"submit.createcons","//input[contains(@id,'createConsumer:createConsumerButton')]");
- private final String INPUT_CREATECONS = getProp(casePfx+"input.createcons","//input[contains(@id,'createConsumer:consumerName')]");
- private final String ID_LINK_PRODCONF = getProp(casePfx+"id.link.prodconf","//a[contains(@id,'cons-temp-form:producer-link')]");
- private final String ID_LINK_CONSCONF = getProp(casePfx+"id.link.consconf","//a[contains(@id,'producer-temp-form:consumersTab')]");
- private final String LINK_CONSUMER_HOME =getProp(casePfx+"link.consumer.home","//a[contains(@id,'cons-temp-form1:list-cons-link')]");
- private final String LINK_T_CONS_CON=getProp(casePfx+"link.t.cons.con","//a[contains(@id,''consumer-list-form:consumersList:{0}:configure'')]");
- private final String LINK_T_CONS_REF=getProp(casePfx+"link.t.cons.ref","//a[contains(@id,''consumer-list-form:consumersList:{0}:refresh'')]");
- private final String LINK_T_CONS_ACT=getProp(casePfx+"link.t.cons.act","//a[contains(@id,''consumer-list-form:consumersList:{0}:activate'')]");
- private final String LINK_T_CONS_DEA=getProp(casePfx+"link.t.cons.dea","//a[contains(@id,''consumer-list-form:consumersList:{0}:activate'')]");
- private final String LINK_T_CONS_REG=getProp(casePfx+"link.t.cons.reg","//a[contains(@id,''consumer-list-form:consumersList:{0}:register'')]");
- private final String LINK_T_CONS_DER=getProp(casePfx+"link.t.cons.der","//a[contains(@id,''consumer-list-form:consumersList:{0}:register'')]");
- private final String LINK_T_CONS_DEL=getProp(casePfx+"link.t.cons.del","//a[contains(@id,''consumer-list-form:consumersList:{0}:delete'')]");
- private final String WSRP_CONSUMER_TABLE = getProp(casePfx+"link.wsrp.consumer.table","//table[contains(@id,':consumer-list-form:consumersList')]");
+ 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')]");
+ private final String SUB_REFRESH_CANCEL = getLoc(casePfx + "submit.refresh.cancel", "//a[contains(@id,'edit-cons-form:list-cons-link')]");
+ private final String SUB_PROD_SAVE = getLoc(casePfx + "submit.prod.save", "//input[contains(@id,'producer-form:save-producer')]");
+ private final String SUB_CONSDEL_CONF = getLoc(casePfx + "submit.consdel.conf", "//a[contains(@id,'confirm-delete-form:destroy-link')]");
+ private final String SUB_CONS_REGVAL = getLoc(casePfx + "submit.cons.regval", "//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
+ private final String SUB_REFRESHFINAL = getLoc(casePfx + "submit.refreshfinal", "//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
+ private final String INPUT_CONS_REGVALUE = getLoc(casePfx + "input.cons.regvalue",
+ "//input[contains(@id,'edit-cons-form:existingProps:0:prop-value-input')]");
+ private final String SUBMIT_REFRESHSAVE = getLoc(casePfx + "submit.refreshsave", "//input[contains(@id,'edit-cons-form:refresh-cons-link')]");
+ private final String INPUT_CONSWSDL = getLoc(casePfx + "input.conswsdl", "//input[contains(@id,'edit-cons-form:wsdl')]");
+ private final String INPUT_CACHEEXP = getLoc(casePfx + "input.cacheexp", "//input[contains(@id,'edit-cons-form:cache')]");
+ private final String SUBMIT_ADDPROP_INIT = getLoc(casePfx + "submit.addprop.init", "//a[contains(@id,'producer-form:add-reg-prop')]");
+ private final String SUBMIT_ADDPROP = getLoc(casePfx + "submit.addprop", "//a[contains(@id,'producer-form:add-reg-prop')]");
+ private final String INPUT_PROPHINT = getLoc(casePfx + "input.prophint", "//input[contains(@id,'producer-form:reg-properties:0:hint')]");
+ private final String INPUT_PROPLABEL = getLoc(casePfx + "input.proplabel", "//input[contains(@id,'producer-form:reg-properties:0:label')]");
+ private final String INPUT_PROPNAME = getLoc(casePfx + "input.propname", "//input[contains(@id,'producer-form:reg-properties:0:name')]");
+ private final String SUBMIT_CREATECONS = getLoc(casePfx + "submit.createcons", "//input[contains(@id,'createConsumer:createConsumerButton')]");
+ private final String INPUT_CREATECONS = getLoc(casePfx + "input.createcons", "//input[contains(@id,'createConsumer:consumerName')]");
+ private final String ID_LINK_PRODCONF = getLoc(casePfx + "id.link.prodconf", "//a[contains(@id,'cons-temp-form:producer-link')]");
+ private final String ID_LINK_CONSCONF = getLoc(casePfx + "id.link.consconf", "//a[contains(@id,'producer-temp-form:consumersTab')]");
+ private final String LINK_CONSUMER_HOME = getLoc(casePfx + "link.consumer.home", "//a[contains(@id,'cons-temp-form1:list-cons-link')]");
+ private final String LINK_T_CONS_CON = getLoc(casePfx + "link.t.cons.con", "//a[contains(@id,''consumer-list-form:consumersList:{0}:configure'')]");
+ private final String LINK_T_CONS_REF = getLoc(casePfx + "link.t.cons.ref", "//a[contains(@id,''consumer-list-form:consumersList:{0}:refresh'')]");
+ private final String LINK_T_CONS_ACT = getLoc(casePfx + "link.t.cons.act", "//a[contains(@id,''consumer-list-form:consumersList:{0}:activate'')]");
+ private final String LINK_T_CONS_DEA = getLoc(casePfx + "link.t.cons.dea", "//a[contains(@id,''consumer-list-form:consumersList:{0}:activate'')]");
+ private final String LINK_T_CONS_REG = getLoc(casePfx + "link.t.cons.reg", "//a[contains(@id,''consumer-list-form:consumersList:{0}:register'')]");
+ private final String LINK_T_CONS_DER = getLoc(casePfx + "link.t.cons.der", "//a[contains(@id,''consumer-list-form:consumersList:{0}:register'')]");
+ private final String LINK_T_CONS_DEL = getLoc(casePfx + "link.t.cons.del", "//a[contains(@id,''consumer-list-form:consumersList:{0}:delete'')]");
+ private final String WSRP_CONSUMER_TABLE = getLoc(casePfx + "link.wsrp.consumer.table", "//table[contains(@id,':consumer-list-form:consumersList')]");
+
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ private void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
- //logout();
+ private void logoutAfterTest() {
+ // logout();
}
+ /**
+ * Test create bea consume is responsible for creating BEA consumer named
+ * <b>BEA</b>. Navigate to WSRP gui and create consumer with these
+ * parameters: <br/>
+ * <table>
+ * <tr>
+ * <td><b>Producer id:</b></td>
+ * <td>BEA</td>
+ * </tr>
+ * <tr>
+ * <td><b>Cache expiration:</b></td>
+ * <td>600</td>
+ * </tr>
+ * <tr>
+ * <td><b>Endpoint configuration:</b></td>
+ * <td>http://wsrp.bea.com:7001/producer/producer?WSDL (using WSDL)</td>
+ * </tr>
+ * <tr>
+ * <td><b>Registration information:</b></td>
+ * <td><code>{urn:bea:wlp:prop:reg:registration}consumerRole</code> : public
+ * </td>
+ * </tr>
+ * </table>
+ * <br/> After clicking refresh&save button, the test checks for text
+ * message about successful refresh. Then it check whether the BEA consumer
+ * is appearing in the main consumers table.
+ */
+ // TODO checking for the resulting consumer in table should be using
+ // 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");
-
+
selenium.click(SUBMIT_CREATECONS);
selenium.waitForPageToLoad(PAGE_LOAD);
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("Refresh failed (probably because the registration information was not valid)."));
+ //Assert.assertTrue(selenium.isTextPresent("Refresh failed (probably because the registration information was not valid)."));
Assert.assertTrue(selenium.isTextPresent("Missing value"));
selenium.type(INPUT_CONS_REGVALUE, "public");
selenium.click(SUB_CONS_REGVAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Refresh was successful."));
+ Assert.assertTrue(selenium.isTextPresent("configuration (active)"));
selenium.click(SUB_REFRESHFINAL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("BEA"));
}
+ /**
+ * Test bea consumer register is reponsible for registering previously
+ * deregistered consumer <b>BEAreg</b>. It finds the <b>BEAreg</b> consumer
+ * in the main consumer table and clicks on its register icon. After that,
+ * it checks whether the register icon changed its text to "deregister"
+ */
@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 ;
- selenium.click(MessageFormat.format(LINK_T_CONS_REG,r));
+ int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAreg", 0) - 1;
+ selenium.click(MessageFormat.format(LINK_T_CONS_REG, r));
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(SUBMIT_REFRESHSAVE);
@@ -106,119 +150,148 @@
selenium.click(LINK_CONSUMER_HOME);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertEquals(selenium.getText(MessageFormat.format(LINK_T_CONS_DER,r)), "Deregister");
+ Assert.assertEquals(selenium.getText(MessageFormat.format(LINK_T_CONS_DER, r)), "Deregister");
}
+ /**
+ * Test bea consumer deregister is responsible for deleting previously
+ * created BEA consumer. It creates BEA consumer with name BEA and values
+ * similiar to that from testCreateBeaConsumer. Then it clicks on deregister
+ * link for the consumer and checks whether deregister link has changed into
+ * register link.
+ */
@Test(enabled = true, dependsOnMethods = { "testCreateBeaConsumer" }, description = "Standard BEA consumer deregistering.")
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);
-
- int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAreg", 0) -1;
- selenium.click(MessageFormat.format(LINK_T_CONS_DER,r));
+ int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAreg", 0) - 1;
+
+ selenium.click(MessageFormat.format(LINK_T_CONS_DER, r));
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(SUB_REFRESH_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertEquals(selenium.getText(MessageFormat.format(LINK_T_CONS_DER,r)), "Register");
+ Assert.assertEquals(selenium.getText(MessageFormat.format(LINK_T_CONS_DER, r)), "Register");
}
+ /**
+ * Test bea consumer activate is responsible for activating previously
+ * deactivated consumer. It works with consumer named <b>BEAact</b> and
+ * checks whether the consumer has message showing it's inactive and refresh
+ * is needed. Then it click on activate link and check that the message has
+ * disappeared.
+ */
@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;
+ int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAact", 0) - 1;
Assert.assertTrue(selenium.isTextPresent("BEAact (inactive) (refresh needed)"));
- selenium.click(MessageFormat.format(LINK_T_CONS_ACT,r));
+ selenium.click(MessageFormat.format(LINK_T_CONS_ACT, r));
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent("BEAact (inactive) (refresh needed)"));
}
+ /**
+ * Test bea consumer deactivate is responsible for deactivating a bea
+ * consumer. Firstly it creates bea consumer named <b>BEAact</b> with
+ * parameters similiar to that from testCreateBeaConsumer. Then it asserts
+ * that message signalling the consumer non-active state is missing. After
+ * clicking on deactivation link it assert, that the message signalling
+ * non-active state of consumer has appeared.
+ */
@Test(enabled = true, dependsOnMethods = { "testCreateBeaConsumer" }, description = "Standard BEA consumer deactivating.")
public void testBeaConsumerDeactivate() {
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);
-
- int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAact", 0)-1;
+ int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAact", 0) - 1;
+
Assert.assertFalse(selenium.isTextPresent("BEAact (inactive) (refresh needed)"));
- selenium.click(MessageFormat.format(LINK_T_CONS_DEA,r));
+ selenium.click(MessageFormat.format(LINK_T_CONS_DEA, r));
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("BEAact (inactive) (refresh needed)"));
}
+ /**
+ * Test bea consumer configure. Test is disabled - deleting of the method
+ * should be considered.
+ */
+ // TODO deleting of the method should be considered.
@Test(enabled = false, dependsOnMethods = { "testCreateBeaConsumer" }, description = "Standard BEA consumer configuring.")
public void testBeaConsumerConfigure() {
}
+ /**
+ * Test bea consumer delete is responsible for deleting a bea consumer.
+ * Firstly it creates bea consumer named <b>BEAdel</b> with parameters
+ * similiar to that from testCreateBeaConsumer. It click on the delete icon
+ * for the consumer and then it asserts the consumer has disappeared from
+ * the table.
+ */
@Test(enabled = true, dependsOnMethods = { "testCreateBeaConsumer" }, description = "Standard BEA consumer deleting.")
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);
Assert.assertTrue(selenium.isTextPresent("BEAdel"));
-
- Assert.assertTrue(selenium.isElementPresent(WSRP_CONSUMER_TABLE),"Consumer table not available.");
- int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAdel", 0)-1;
- Assert.assertFalse(r < 0,"Consumer BEAdel not found");
- selenium.click(MessageFormat.format(LINK_T_CONS_DEL,r));
+ Assert.assertTrue(selenium.isElementPresent(WSRP_CONSUMER_TABLE), "Consumer table not available.");
+ int r = findTableRow(WSRP_CONSUMER_TABLE, "BEAdel", 0) - 1;
+ Assert.assertFalse(r < 0, "Consumer BEAdel not found");
+
+ selenium.click(MessageFormat.format(LINK_T_CONS_DEL, r));
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
Assert.assertTrue(selenium.isTextPresent("Delete 'BEAdel' consumer?"));
-
+
clickAndWait(SUB_CONSDEL_CONF);
Assert.assertFalse(selenium.isTextPresent("BEAdel"));
}
- @Test(enabled = true, description = "Basic configuring of WSRP producer.")
+ /**
+ * Test configure producer is used for basic configuring of WSRP producer.
+ * If fills up the registration properties with these values:
+ * <table>
+ * <tr>
+ * <td><b>Name</b></td>
+ * <td>testProp</td>
+ * <td><b>Label</b></td>
+ * <td>testProp label</td>
+ * <td><b>Hint</b></td>
+ * <td>tetsPropHint</td>
+ * </tr>
+ * </table>
+ *
+ * It saves the properties and checks they were saved. <br/> Missing: It
+ * doesn't test the function of cancel button and checkboxes in producer
+ * configuration.
+ */
+ // TODO the function of cancel button and checkboxes in producer
+ // configuration.
+ // TODO registration policy properties tests missing
+ @Test(enabled = true, dependsOnMethods = { "testCreateBeaConsumer" }, 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"));
@@ -227,11 +300,11 @@
selenium.type(INPUT_PROPNAME, "testProp");
selenium.type(INPUT_PROPLABEL, "testProp label");
selenium.type(INPUT_PROPHINT, "tetsPropHint");
-
+
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);
@@ -240,65 +313,216 @@
Assert.assertEquals("tetsPropHint", selenium.getValue(INPUT_PROPHINT));
}
-
- @Test(enabled = true, description = "Renaming a consumer through the configure button.")
+
+ /**
+ * Test configure consumer is responsible for configuring bea consumer.
+ * Firstly it creates bea consumer named <b>renameMe</b> with parameters
+ * similiar to that from testCreateBeaConsumer. Then it clicks on configure
+ * button for the consumer and rename it to <b>renameNewMe</b>. At the end
+ * it asserts that the previous name is missing in the consumers table and
+ * the new name has appeared.
+ */
+ @Test(enabled = true, dependsOnMethods = { "testCreateBeaConsumer" }, description = "Renaming a consumer through the configure button.")
public void testConfigureConsumer() {
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);
-
int r = findTableRow(WSRP_CONSUMER_TABLE, name, 0);
-
- Assert.assertTrue(r<0, "Not created consumer already in table");
-
+
+ Assert.assertTrue(r < 0, "Not created consumer already in table");
+
// create consumer to be renamed
createConsumer(name, "100", "http://wsrp.bea.com:7001/producer/producer?WSDL");
-
+
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
-
+
r = findTableRow(WSRP_CONSUMER_TABLE, name, 0);
- Assert.assertTrue(r>0, "Created consumer not found in table");
-
+ Assert.assertTrue(r > 0, "Created consumer not found in table");
+
// rename the consumer
- clickAndWait(MessageFormat.format(LINK_T_CONS_CON,r-1));
-
+ clickAndWait(MessageFormat.format(LINK_T_CONS_CON, r - 1));
+
selenium.type(INP_CONSUMER_NAME, nameNew);
- clickAndWait(SUBMIT_REFRESHSAVE);
-
+ clickAndWait(SUBMIT_REFRESHSAVE);
+
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
-
+
waitForElement(WSRP_CONSUMER_TABLE);
r = findTableRow(WSRP_CONSUMER_TABLE, name, 0);
- Assert.assertTrue(r<0, "Renamed consumer still in table");
-
+ Assert.assertTrue(r < 0, "Renamed consumer still in table");
+
r = findTableRow(WSRP_CONSUMER_TABLE, nameNew, 0);
- Assert.assertTrue(r>0, "Renamed consumer not found in table");
+ Assert.assertTrue(r > 0, "Renamed consumer not found in table");
}
-
- private void createConsumer(String name, String timeout, String address) {
+
+ /**
+ * 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, dependsOnMethods = { "testCreateBeaConsumer" }, groups = {"XSS"})
+ public void testXssConsumerManage() {
+ String beaName = "XssBeaConsumer";
+
+ goToWSRP();
+
+ clickIfVisible(ID_LINK_CONSCONF);
+ clickIfVisible(LINK_CONSUMER_HOME);
+
+ selenium.type(INPUT_CREATECONS, XSS_STR1);
+ selenium.click(SUBMIT_CREATECONS);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_CONS_NAME_VALID),"validation error message missing or other than expected.");
+
+ selenium.type(INPUT_CREATECONS, beaName);
+
+ selenium.click(SUBMIT_CREATECONS);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(INPUT_CACHEEXP, "600");
+
+ selenium.type(INPUT_CONSWSDL, XSS_STR1);
+ selenium.click(SUBMIT_REFRESHSAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ 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(MSG_CONS_EXP_VALID),"validation error message missing or other than expected.");
+
+ 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(MSG_CONS_NAME_VALID),"validation error message missing or other than expected.");
+
+ selenium.type(INP_PRODID, beaName);
+ 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);
+
+ selenium.type(INPUT_CONS_REGVALUE, XSS_STR1);
+ selenium.click(SUB_CONS_REGVAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ 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, groups = {"XSS"})
+ public void testXssProducerManage() {
+
+ goToProducers();
+ selenium.type("//input[contains(@id,'producer-form:registrationPolicy')]", XSS_STR1);
+ selenium.click(SUB_PROD_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ 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(MSG_PROP_REGPROP_VALID),"validation error message missing or other than expected.");
+
+ goToWSRP();
+
+ clickIfVisible(ID_LINK_PRODCONF);
+ Assert.assertTrue(selenium.isTextPresent("Producer configuration"));
+ clickAndWait(SUBMIT_ADDPROP_INIT);
+
+ selenium.type(INPUT_PROPNAME, "testProp");
+ selenium.type(INPUT_PROPLABEL, "testProp label");
+ selenium.type(INPUT_PROPHINT, "tetsPropHint");
+
+ selenium.click(SUB_PROD_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ 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");
+
+ selenium.click(SUB_PROD_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ // @jira JBPORTAL-2414
+ 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");
+
+ selenium.click(SUB_PROD_SAVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ 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);
+ 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) {
+ goToWSRP();
clickIfVisible(ID_LINK_CONSCONF);
selenium.type(INPUT_CREATECONS, name);
selenium.click(SUBMIT_CREATECONS);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
waitForElement(INPUT_CACHEEXP);
selenium.type(INPUT_CACHEEXP, timeout);
waitForElement(INPUT_CONSWSDL);
@@ -309,7 +533,7 @@
selenium.type(INPUT_CONS_REGVALUE, "public");
selenium.click(SUB_CONS_REGVAL);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
selenium.click(SUB_REFRESHFINAL);
selenium.waitForPageToLoad(PAGE_LOAD);
}
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/assert.properties
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/assert.properties (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/assert.properties 2009-07-10 14:25:44 UTC (rev 13537)
@@ -0,0 +1,102 @@
+selenium.timeout.page=180000
+selenium.timeout.ajax=3000
+selenium.timeout.elem=220
+
+portal.xxs.1=/Dave</option><script>alert(document.cookie);</script>
+#portal.xxs.2=
+#portal.xxs.3=
+
+iden.man.chk.role=Create new role
+
+cms.sec.denied=Access to this resource is denied
+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
+
+test.wsrp.msg.cons.add.valid=is not a valid URL
+
+portal.port.ins.msg.pi.prop.update.valid=is an invalid preference name
+portal.port.ins.msg.pi.prop.append.valid=is an invalid preference name
+
+portal.e2e.port1=Cart Portlet
+portal.e2e.port1.str=Cart Portlet
+portal.e2e.port2=Calendar and Calculators
+portal.e2e.port2.str=Calendar and Calculators
+portal.e2e.port3=Web Assurance
+portal.e2e.port3.str=web-assurance.net
+portal.e2e.port4=dir1/foo.txt
+portal.e2e.port4.str=File Portlet
+portal.e2e.port5=default/private/private1.html
+portal.e2e.port5.str=This is private 1 document
+
+samples.ajax.p3.l3=$256.00
+samples.ajax.p3.l2=SANTA CRUZ ALLSTAR
+samples.ajax.p3.l1=Product ID: 3
+
+samples.ajax.p2.l3=$319.99
+samples.ajax.p2.l2=FORUM DESTROYER LTD
+samples.ajax.p2.l1=Product ID: 2
+
+samples.ajax.p1.l3=Sale Price: $314.96
+samples.ajax.p1.l2=B BY BURTON ALPHA
+samples.ajax.p1.l1=Product ID: 1
+
+ajax.p3.l3=$256.00
+ajax.p3.l2=SANTA CRUZ ALLSTAR
+ajax.p3.l1=Product ID: 3
+
+ajax.p2.l3=$319.99
+ajax.p2.l2=FORUM DESTROYER LTD
+ajax.p2.l1=Product ID: 2
+
+ajax.p1.l3=Sale Price: $314.96
+ajax.p1.l2=B BY BURTON ALPHA
+ajax.p1.l1=Product ID: 1
+
+samples.bookstore.pmode.normal=portlet-mode-normal
+samples.bookstore.pmode.minimized=portlet-mode-minimized
+samples.bookstore.book.1000.title=Foundation Flash Cartoon Animation
+samples.bookstore.book.1000.author=Tim Jones
+samples.bookstore.book.1000.img=animation.jpg
+samples.bookstore.book.1001.title=Head First Design Patterns
+samples.bookstore.book.1001.author=Elisabeth Freeman
+samples.bookstore.book.1001.img=patterns.jpg
+samples.bookstore.book.1004.title=Java Servlet and JSP Cookbook
+samples.bookstore.book.1004.author=Bruce Perry
+samples.bookstore.book.1004.img=servlets.jpg
+samples.bookstore.book.1005.title=Mommywood
+samples.bookstore.book.1005.author=Tori Spelling
+samples.bookstore.book.1005.img=mommywood.jpg
+samples.bookstore.book.1007.title=The Picture of Dorian Gray
+samples.bookstore.book.1007.author=Oscar Wilde
+samples.bookstore.book.1007.img=dorian.jpg
+samples.bookstore.catalog.title=Book Catalog Portlet
+samples.bookstore.catalog.choose=Please choose from our selections:
+samples.bookstore.showcart.header.card.empty=Your cart is empty.
+samples.bookstore.showcart.header.card.pref=Your shopping cart contains
+samples.bookstore.showcart.header.card.suf=\ items.
+samples.bookstore.receipt.success=Thank you for purchasing your books from us
+samples.bookstore.receipt.failure=Your order could not be completed due to insufficient inventory.
+samples.bookstore.receipt.failure.mess=Not enough books with title: Foundation Flash Cartoon Animation in inventory.
+
+sso.cas.cas.invalid.auth=The credentials you provided cannot be determined to be authentic.
+sso.cas.cas.login.mess=Enter your JA-SIG NetID and Password.
+sso.cas.cas.logout.succ=Logout successful
+sso.cas.logged.in.mess=Logged in as:
+sso.cas.forbidden.mess=HTTP Status 403 -
+
+sso.josso.josso.invalid.auth=Invalid Authentication Information
+sso.josso.logged.in.mess=Logged in as:
+sso.josso.forbidden.mess=HTTP Status 403 -
+sso.josso.samples.ses.no=No session
+sso.josso.samples.ses.id=Session id
+
+sso.tomcatvalve.example.login.form=Login form
+sso.tomcatvalve.example.title.output=Tomcat SSO valve example servlet
+sso.tomcatvalve.logged.in.mess=Logged in as:
+sso.tomcatvalve.jmx.agnview=JMX Agent View
+sso.tomcatvalve.forbidden.mess=HTTP Status 403 -
+
+
+
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSArchiveUploadTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -9,51 +9,65 @@
import org.testng.annotations.Test;
/**
+ * CMSArchiveUploadTestCase is responsible for testing the upload of archives into JBoss Portal CMS. The test has set the selenium timeout of 10000ms due
+ * to CMS uploading speed limitation of portal. When no timeout is set, the testcase fails and crush the whole portal which is unusable after the crash.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
-@Test(groups = { "cms_archive_upload" }, enabled = true)
+@Test(groups = { "cms" }, enabled = true, description="Testing the upload of archives into JBoss Portal CMS")
public class CMSArchiveUploadTestCase extends JBossPortalSeleniumTestCase {
- private static final Integer ARCHIVE_WAITING = 7000;
- private static final int n = 70;
- private static final String STEP = "20000";
+ /** The constant defining the wait time (in ms) between attempts when checking if the file was uploaded. */
+ public static final int ARCHIVE_WAITING = 5000;
+
+ /** The constant defining the the number of attempts when checking if the file was uploaded. */
+ public static final int ATTEMPTS = 50;
/*
* uncomment following lines and set the right path to the workspace in the
* case you want to use this test case locally from eclipse
*/
-/*
+ /*
{
System.setProperty("workspace", "/home/vrockai/workspace/p2.7tests/ui-tests/");
}
-*/
-
- private final String casePfx = "cms.arch.";
- private final String SUB_CANCEL_ARCH_UPLOAD = getProp(casePfx+"sub.cancel.arch.upload","cancel");
- private final String LNK_ADMIN = getProp(casePfx+"lnk.admin","link=Admin");
- private final String LNK_CMS = getProp(casePfx+"lnk.cms","link=CMS");
- private final String SUB_SEND_ARCHIVE = getProp(casePfx+"sub.send.archive","submit");
- private final String INP_ARCHIVE_FILE = getProp(casePfx+"inp.archive.file","response");
- private final String DIV_ARCHIVE_STATUS = getProp(casePfx+"div.archive.status","//div[@id='center']/div/div/table/tbody/tr[2]/td/font");
- private final String SEL_ACTION = getProp(casePfx+"sel.action","//div[@id='center']/div/div/div[1]/div/select");
+ */
+ /** prefix for locator properties = cms.arch.*/
+ public final String casePfx = "cms.arch.";
+ private final String SUB_CANCEL_ARCH_UPLOAD = getLoc(casePfx+"sub.cancel.arch.upload","cancel");
+ private final String LNK_ADMIN = getLoc(casePfx+"lnk.admin","link=Admin");
+ private final String LNK_CMS = getLoc(casePfx+"lnk.cms","link=CMS");
+ private final String SUB_SEND_ARCHIVE = getLoc(casePfx+"sub.send.archive","submit");
+ private final String INP_ARCHIVE_FILE = getLoc(casePfx+"inp.archive.file","response");
+ private final String DIV_ARCHIVE_STATUS = getLoc(casePfx+"div.archive.status","//div[@id='center']/div/div/table/tbody/tr[2]/td/font");
+ private final String SEL_ACTION = getLoc(casePfx+"sel.action","//div[@id='center']/div/div/div[1]/div/select");
private final String WORKSPACE = System.getProperty("workspace");
private final String TEST_FILES_DIR = WORKSPACE + File.separatorChar + "test_files" + File.separatorChar;
-
+
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
// timeout hack
- selenium.setSpeed(STEP);
+ selenium.setSpeed("3000");
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ protected void logoutAfterTest() {
}
+ /**
+ * Test archive consisting of two files upload.
+ * The archive used in this test consists of one directory containing two files - one image file and one plain text file.
+ * The test tries to upload the archive into the root directory of CMS structure.
+ * At first it cancels the uploading of the file and asserts the archive wasn't uploaded. At the second attempt it really
+ * uploads the file and asserts that both of the files are in their locations.
+ *
+ * The archive file can be found on "test_files/archive.zip".
+ */
@Test(enabled = true, description = "Test archive consisting of two files upload.")
public void testArchiveUpload() {
// canceling at the first stage
@@ -65,8 +79,10 @@
selenium.select(SEL_ACTION, "label=Upload Archive");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
+
selenium.type(INP_ARCHIVE_FILE, TEST_FILES_DIR + "archive.zip");
- debugPrint("[selenium] : testArchiveUpload archive path: " + TEST_FILES_DIR + "archive.zip");
+ debugPrint("[selenium] : testArchiveUpload archive path2: " + TEST_FILES_DIR + "archive.zip");
+
selenium.click(SUB_CANCEL_ARCH_UPLOAD);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -74,7 +90,7 @@
"archive was accepted for processing afte cancelling the upload");
Assert.assertFalse(selenium.isElementPresent("link=archive"), "not uploaded (upload cancelled) archive found #1");
- selenium.open(ADDR_PORTAL);
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isElementPresent("link=archive"), "not uploaded (upload cancelled) archive found #2");
@@ -87,8 +103,8 @@
selenium.select(SEL_ACTION, "label=Upload Archive");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
- selenium.type(INP_ARCHIVE_FILE, TEST_FILES_DIR + "archive.zip");
- debugPrint("[selenium] : testArchiveUpload archive path2: " + TEST_FILES_DIR + "archive.zip");
+ selenium.type(INP_ARCHIVE_FILE, WORKSPACE + "/test_files/archive.zip");
+
selenium.click(SUB_SEND_ARCHIVE);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -99,7 +115,7 @@
selenium.click("link=Home");
selenium.waitForPageToLoad(PAGE_LOAD);
- if (i >= n) {
+ if (i >= ATTEMPTS) {
Assert.assertTrue(selenium.isElementPresent("link=archive"), "uploaded archive not found");
break;
}
@@ -117,6 +133,14 @@
Assert.assertTrue(selenium.isElementPresent("link=jbosslogo.png"), "content of uploaded file not found #2");
}
+ /**
+ * Test archive consisting of > 100 files upload.
+ * The archive used in this test consists of one directory containing more the 100 files in plain text format.
+ * The test tries to upload the archive into the root directory of CMS structure.
+ * It uploads the archive file and asserts that one of the files is in its location.
+ *
+ * The archive file can be found on "test_files/many_files.zip".
+ */
@Test(enabled = true, description = "Test archive consisting of > 100 files upload.")
public void testManyFilesArchiveUpload() {
@@ -128,8 +152,10 @@
selenium.select(SEL_ACTION, "label=Upload Archive");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
+
+ debugPrint("CMSArchiveUploadTestCase archive location: "+TEST_FILES_DIR);
selenium.type(INP_ARCHIVE_FILE, TEST_FILES_DIR + "many_files.zip");
- debugPrint("[selenium] : testManyFilesArchiveUpload archive path: " + TEST_FILES_DIR + "many_files.zip");
+
selenium.click(SUB_SEND_ARCHIVE);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -143,7 +169,7 @@
selenium.click("link=Home");
selenium.waitForPageToLoad(PAGE_LOAD);
- if (i >= n) {
+ if (i >= ATTEMPTS) {
Assert.assertTrue(selenium.isElementPresent("link=many_files"), "uploaded archive not found");
break;
}
@@ -159,6 +185,14 @@
Assert.assertTrue(selenium.isElementPresent("link=file31.txt"), "content of uploaded archive not found");
}
+ /**
+ * Test archive consisting of 21MB file upload.
+ * The archive used in this test consists of one directory containing one file which is larger then 21MB.
+ * The test tries to upload the archive into the root directory of CMS structure.
+ * It uploads the archive file and asserts that the file is in its location.
+ *
+ * The archive file can be found on "test_files/big_archive.zip".
+ */
@Test(enabled = true, description = "Test archive consisting of 21MB file upload.")
public void testBigArchiveUpload() {
@@ -170,8 +204,10 @@
selenium.select(SEL_ACTION, "label=Upload Archive");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.waitForPopUp("_top", PAGE_LOAD);
+
+ debugPrint("CMSArchiveUploadTestCase archive location: "+ WORKSPACE + "/test_files/big_archive.zip");
selenium.type(INP_ARCHIVE_FILE, TEST_FILES_DIR + "big_archive.zip");
- debugPrint("[selenium] : testBigArchiveUpload archive path: " + TEST_FILES_DIR + "big_archive.zip");
+
selenium.click(SUB_SEND_ARCHIVE);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -185,7 +221,7 @@
selenium.click("link=Home");
selenium.waitForPageToLoad(PAGE_LOAD);
- if (i >= n) {
+ if (i >= ATTEMPTS) {
Assert.assertTrue(selenium.isElementPresent("link=bigfile"), "uploaded archive not found");
break;
}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSDirectoryTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -7,160 +7,233 @@
import org.testng.annotations.Test;
/**
+ * CMSDirectoryTestCase is responsible for basic manipulation with directories in JBoss Portal CMS.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
-
-@Test(groups = { "cms_directory" }, enabled = true)
+//TODO refactoring of proeprties needed
+@Test(groups = { "cms" }, enabled = true, description="Basic manipulation with directories in JBoss Portal CMS")
public class CMSDirectoryTestCase extends JBossPortalSeleniumTestCase {
- private final String casePfx = "cms.dir.";
- private final String SEL_CMS_ACTION = getProp(casePfx + "sel.cms.action", "//div[@id='center']/div/div/div[1]/div/select");
- private final String ADR_CMS_INTERFACE = getProp(casePfx + "adr.cms.interface", "/portal/auth/portal/admin/CMS");
-
+
+ /** 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";
private final String moveDirName = "moveSrc";
- private final String CMS_FILE_TABLE = getProp(casePfx + "cms.file.table", "//div[@id='center']/div/div/div[3]/table");
+ private final String CMS_FILE_TABLE = getLoc(casePfx + "cms.file.table", "//div[@id='center']/div/div/div[3]/table");
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ protected void logoutAfterTest() {
}
+ /**
+ * Creates a directory.
+ *
+ * With action selector an action to create a directory is chosen.
+ * Directory named "tempDir" with description "test folder" is filled in to the directory creation form, but in the first attempt, the creation is canceled.
+ * In the second attempt, the directory is created. Then the name of a directory in the home directory is asserted.
+ */
+ //TODO asserts in the end have to be redone
@Test(enabled = true, description = "Directory creation.")
public void testCreateDirectory() {
- // cancelling of creating
+ // 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(ADDR_PORTAL);
+ 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 deleted
+ // assuring that the directory is created
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isElementPresent("//div[@id='center']/div/div/ul/li[3]"));
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.");
}
- @Test(enabled = true, dependsOnMethods = "testCreateDirectory", description = "Directory delete.")
- public void testDeleteDirectory() {
+ /**
+ * 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.", groups = {"XSS"})
+ public void testXssCreateDirectory() {
+
+ // XSS name
+
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
- // firstly cancel the delete process
+ 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);
+ }
- Assert.assertTrue(selenium.isElementPresent("link=" + tempDirName));
+
+ /**
+ * 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()}.
+ * At first, after warning message, the directory is not deleted, the deletion is canceled. At the second attempt
+ * the deletion is done. Then the name of a directory in the home directory is asserted not to appear there.
+ */
+ @Test(enabled = true, dependsOnMethods = "testCreateDirectory", description = "Directory delete.")
+ public void testDeleteDirectory() {
+
+ // firstly cancel the delete process
+
+ goToCms();
+
+ 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?"));
- selenium.click("cancel");
+ 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);
// really deleting
- selenium.open(ADDR_PORTAL);
+ 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));
+ 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?"));
- selenium.click("submit");
+ 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);
// assuring that the deletition was processed
- selenium.open(ADDR_PORTAL);
+ 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));
}
+ /**
+ * Copies a directory.
+ *
+ * With action selector an action to copy a directory is chosen. Before that a directory named "copySrc" was created.
+ * Then it was copied into "default" directory. Then the existence of the copied directory in both root and default directories is asserted.
+ */
@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.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("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]"));
@@ -173,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));
@@ -186,26 +259,29 @@
}
+ /**
+ * Cancels the copying of a directory.
+ *
+ * With action selector an action to copy a directory is chosen. The copying is canceled with cancel button.
+ * Assertion making sure the directory was not copied are then applied.
+ */
@Test(enabled = true, dependsOnMethods = "testCreateDirectory", description = "Canceling of copying of directory.")
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");
@@ -216,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));
@@ -227,25 +303,27 @@
}
+ /**
+ * Moves a directory.
+ *
+ * With action selector an action to move a directory is chosen. Before that a directory named "moveSrc" was created.
+ * Then it was copied into "default" directory. Then the existence of the moved directory in default and not in the root directory is asserted.
+ */
@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]"));
@@ -260,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]"));
@@ -274,26 +352,29 @@
}
+ /**
+ * Cancels the moving of a directory.
+ *
+ * With action selector an action to move a directory is chosen. The copying is canceled with cancel button.
+ * Assertion making sure the directory was not moved are then applied.
+ */
@Test(enabled = true, dependsOnMethods = "testCreateDirectory", description = "Canceling of moving a directory.")
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");
@@ -304,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/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSExportFolderTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSExportFolderTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSExportFolderTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -11,10 +11,13 @@
import com.thoughtworks.selenium.Selenium;
/**
+ * CMSExportFolderTestCase should tests the exporting of directories in JBoss Portal CMS.
+ * Unfortunatelly selenium is not capable to deal with such a task. The testcase is empty.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
-@Test(groups = { "cms_exportFolder" }, enabled = false)
+@Test(groups = { "cms" }, enabled = false)
public class CMSExportFolderTestCase {
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -7,29 +7,48 @@
import org.testng.annotations.Test;
/**
+ * CMSFileTestCase is used to test basic file manipulation in JBoss Portal CMS
+ * with the workflow turned off.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
-
-@Test(groups = { "cms_file" }, enabled = true)
+// TODO refactoring of field needed
+@Test(groups = { "cms" }, enabled = true, description = "Basic file manipulation in JBoss Portal CMS")
public class CMSFileTestCase extends JBossPortalSeleniumTestCase {
+ /** prefix for locator properties = cms.file. */
private final String casePfx = "cms.file.";
- private final String TBL_CMS_FILEVER = getProp(casePfx+"tbl.cms.filever","//div[@id='center']/div/div/table");
- public final String TBL_CMS_FILE = getProp(casePfx+"tbl.cms.file","//div[@id='center']/div/div/div[3]/table");
- public final String TBL_FILE_PENDING = getProp(casePfx+"tbl.file.pending","//div[@id='center']/div/div/table[2]");
+ 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");
+ 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]");
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
- }
-
- @AfterMethod( groups = { "log" })
- public void logoutAfterTest() {
-
}
-
+
+ @AfterMethod(groups = { "log" })
+ protected void logoutAfterTest() {
+
+ }
+
+ /**
+ * Common file structure browsing test. Simple clicking on default CMS
+ * structure of directories and files, asserting that elements are on right
+ * places.
+ */
@Test(enabled = true, description = "Common file structure browsing test.")
public void testDefaultBrowsing() {
selenium.click("link=Admin");
@@ -44,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"));
@@ -59,6 +77,9 @@
Assert.assertTrue(selenium.isElementPresent("link=epp4.3.gif"));
}
+ /**
+ * File properties checking. Clicking on index.html file and asserting that its properties (language, type, size, ...) are in default state.
+ */
@Test(enabled = true, description = "File properties checking.")
public void testFileProperties() {
selenium.click("link=Admin");
@@ -67,14 +88,12 @@
selenium.click("link=CMS");
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.open("/portal/auth/portal/admin/CMS/CMSAdminPortletWindow?op=main&action=2&path=%2F");
+ //selenium.open("/portal/auth/portal/admin/CMS/CMSAdminPortletWindow?op=main&action=2&path=%2F");
selenium.click("link=default");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=index.html");
selenium.waitForPageToLoad(PAGE_LOAD);
-
-
-
+
Assert.assertEquals("text/html", selenium.getText("link=text/html"));
Assert.assertEquals("English", selenium.getText("link=English"));
Assert.assertEquals("Type", selenium.getText("//div[@id='center']/div/div/table/tbody/tr[3]/td[1]/b"));
@@ -99,83 +118,163 @@
}
+ /**
+ * Simple file creation. File named "newFile" is created in the root directory of CMS module with main action selector.
+ * Attributes of the created file:
+ * <table>
+ * <tr>
+ * <td>filename</td><td>newFile</td>
+ * </tr>
+ * <tr>
+ * <td>description</td><td>newFile description</td>
+ * </tr>
+ * <tr>
+ * <td>title</td><td>newFile title</td>
+ * </tr>
+ * <tr>
+ * <td>language</td><td>Czech</td>
+ * </tr>
+ * </table>
+ *
+ * After the creation, the properties of the file are asserted to be the same as in the table above.
+ *
+ */
@Test(enabled = true, description = "Simple file creation.")
public void testCreateFile() {
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.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));
- Assert.assertTrue(findTableRow(TBL_FILE_PENDING, "text/plain", 0) >= 0);
- Assert.assertTrue(findTableRow(TBL_FILE_PENDING, "0kb", 1) >= 0);
- //Assert.assertTrue(findTableRow(CMS_FILE_PENDING_TABLE, "admin", 3) >= 0);
+ * Assert.assertTrue(selenium.isElementPresent(TBL_FILE_PENDING));
+ * Assert.assertTrue(findTableRow(TBL_FILE_PENDING, "text/plain", 0) >=
+ * 0); Assert.assertTrue(findTableRow(TBL_FILE_PENDING, "0kb", 1) >= 0);
+ * //Assert.assertTrue(findTableRow(CMS_FILE_PENDING_TABLE, "admin", 3)
+ * >= 0);
+ *
+ * selenium.click("link=Approve");
+ * selenium.waitForPageToLoad(PAGE_LOAD);
+ */
+
+ Assert.assertEquals("Czech", selenium.getText("link=Czech"));
+ Assert.assertTrue(findTableRow(TBL_CMS_FILEVER, "text/plain", 0) >= 0);
+ Assert.assertTrue(findTableRow(TBL_CMS_FILEVER, "0kb", 1) >= 0);
+ Assert.assertTrue(findTableRow(TBL_CMS_FILEVER, "1.0", 2) >= 0);
+ Assert.assertTrue(findTableRow(TBL_CMS_FILEVER, "newFile title", 5) >= 0);
+
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertEquals("newFile", selenium.getText("link=newFile"));
+
+ }
+
+ /**
+ * 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.", groups = {"XSS"})
+ 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.click("link=Approve");
+ 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.assertEquals("Czech", selenium.getText("link=Czech"));
- Assert.assertTrue(findTableRow(TBL_CMS_FILEVER, "text/plain", 0)>=0);
- Assert.assertTrue(findTableRow(TBL_CMS_FILEVER, "0kb", 1)>=0);
- Assert.assertTrue(findTableRow(TBL_CMS_FILEVER, "1.0", 2)>=0);
- Assert.assertTrue(findTableRow(TBL_CMS_FILEVER, "newFile title", 5)>=0);
+ Assert.assertTrue(selenium.isTextPresent(MSG_VAL_INVALID_FILENAME), "Input validation for filename is missing.");
- selenium.click("link=Home");
+ 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.assertEquals("newFile", selenium.getText("link=newFile"));
+ 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.");
}
-
- @Test(enabled = true, description = "Editing of file.")
+
+ /**
+ * 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() {
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.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;
-
+
+ int row = findTableRow(TBL_CMS_FILEVER, "1.0", 2) + 1;
+
Assert.assertEquals("Czech", selenium.getText("link=Czech"));
Assert.assertEquals("text/plain", selenium.getText("link=text/plain"));
- Assert.assertEquals("1.0", selenium.getText("//div[@id='center']/div/div/table/tbody/tr["+ row +"]/td[3]"));
- Assert.assertEquals("0kb", selenium.getText("//div[@id='center']/div/div/table/tbody/tr["+ row +"]/td[2]"));
- Assert.assertEquals("file2edit title", selenium.getText("//div[@id='center']/div/div/table/tbody/tr["+ row +"]/td[6]"));
-
+ Assert.assertEquals("1.0", selenium.getText("//div[@id='center']/div/div/table/tbody/tr[" + row + "]/td[3]"));
+ Assert.assertEquals("0kb", selenium.getText("//div[@id='center']/div/div/table/tbody/tr[" + row + "]/td[2]"));
+ Assert.assertEquals("file2edit title", selenium.getText("//div[@id='center']/div/div/table/tbody/tr[" + row + "]/td[6]"));
+
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"));
-
-
+
selenium.click("link=Home");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals("file2edit", selenium.getText("link=file2edit"));
}
- @Test(enabled = true, dependsOnMethods = "testDeleteFile", description = "Creation of existing file.")
+ /**
+ * 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() {
String filename = "existingFile";
@@ -185,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"));
@@ -206,20 +305,26 @@
deleteFile(filename);
}
+ /**
+ * 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() {
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.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"));
@@ -229,84 +334,101 @@
selenium.click("link=Home");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals("fileToMove", selenium.getText("link=fileToMove"));
-
- int row = findTableRow(TBL_CMS_FILE, "fileToMove", 0)+1;
-
- selenium.select("//div[@id='center']/div/div/div[3]/table/tbody/tr["+row+"]/td[2]/form/select", "label=Move");
- 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");
+
+ int row = findTableRow(TBL_CMS_FILE, "fileToMove", 0) + 1;
+
+ selenium.select("//div[@id='center']/div/div/div[3]/table/tbody/tr[" + row + "]/td[2]/form/select", "label=Move");
+ 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=fileToMove"));
-
+
selenium.click("link=Home");
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
Assert.assertFalse(selenium.isElementPresent("link=fileToMove"));
}
-
+
+ /**
+ * 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() {
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.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;
-
+
+ int row = findTableRow(TBL_CMS_FILEVER, "1.0", 2) + 1;
+
Assert.assertEquals("Czech", selenium.getText("link=Czech"));
Assert.assertEquals("text/plain", selenium.getText("link=text/plain"));
- Assert.assertEquals("1.0", selenium.getText("//div[@id='center']/div/div/table/tbody/tr["+row+"]/td[3]"));
- Assert.assertEquals("0kb", selenium.getText("//div[@id='center']/div/div/table/tbody/tr["+row+"]/td[2]"));
- Assert.assertEquals("file2copy title", selenium.getText("//div[@id='center']/div/div/table/tbody/tr["+row+"]/td[6]"));
+ Assert.assertEquals("1.0", selenium.getText("//div[@id='center']/div/div/table/tbody/tr[" + row + "]/td[3]"));
+ Assert.assertEquals("0kb", selenium.getText("//div[@id='center']/div/div/table/tbody/tr[" + row + "]/td[2]"));
+ Assert.assertEquals("file2copy title", selenium.getText("//div[@id='center']/div/div/table/tbody/tr[" + row + "]/td[6]"));
selenium.click("link=Home");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals("file2copy", selenium.getText("link=file2copy"));
-
- 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");
+
+ 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"));
}
+ /**
+ * Not implemented!
+ */
@Test(enabled = false, description = "Not implemented!")
public void testMoveOverwriteFile() {
}
+ /**
+ * Not implemented!
+ */
@Test(enabled = false, description = "Not implemented!")
public void testMoveNotOverwriteFile() {
}
+ /**
+ * Simple file delete. The file created by the {@link CMSFileTestCase#testCreateFile()} method is used to test the delete function.
+ * The test tries to delete the file, firstly canceling the deletion and then confirming the deletion in the second attempt.
+ */
+ //TODO assert that file is deleted in the end
@Test(enabled = true, dependsOnMethods = "testCreateFile", description = "Simple file delete.")
public void testDeleteFile() {
selenium.click("link=Admin");
@@ -314,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!"));
@@ -335,6 +462,9 @@
selenium.waitForPageToLoad(PAGE_LOAD);
}
+ /**
+ * Not implemented!
+ */
@Test(enabled = false)
public void testDeleteCancelFile() {
@@ -345,14 +475,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"));
@@ -363,7 +493,8 @@
selenium.click("link=Home");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertEquals(name, selenium.getText("link=" + name));
- logout();login("admin","admin");
+ logout();
+ login("admin", "admin");
}
private void deleteFile(String name) {
@@ -373,15 +504,18 @@
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!"));
Assert.assertTrue(selenium.isTextPresent("Are you sure you want to delete this resource?"));
selenium.click("submit");
selenium.waitForPageToLoad(PAGE_LOAD);
- logout();login("admin","admin");
+ logout();
+ login("admin", "admin");
}
}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileUploadTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileUploadTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileUploadTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -9,35 +9,49 @@
import org.testng.annotations.Test;
/**
+ * CMSFileUploadTestCase is responsible for testing of file uploading.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
-
-@Test(groups = { "cms_file_upload" }, enabled = true)
+//TODO refactoring needed
+@Test(groups = { "cms" }, enabled = true)
public class CMSFileUploadTestCase extends JBossPortalSeleniumTestCase {
- /* uncomment following lines and set the right path to the workspace in the case
- * you want to use this test case locally from eclipse */
/*
- {
- System.setProperty("workspace","/home/vrockai/workspace/selenium/selenium/"
- ); }
- */
+ * uncomment following lines and set the right path to the workspace in the
+ * case you want to use this test case locally from eclipse
+ */
+ /*
+ * {
+ * System.setProperty("workspace","/home/vrockai/workspace/selenium/selenium/"
+ * ); }
+ */
+
+ /** prefix for locator properties = cms.file.up. */
private final String casePfx = "cms.file.up.";
- private final String CMS_FILE_TABLE = getProp(casePfx+"cms.file.table","//div[@id='center']/div/div/div[3]/table");
+ private final String CMS_FILE_TABLE = getLoc(casePfx + "cms.file.table", "//div[@id='center']/div/div/div[3]/table");
private final String WORKSPACE = System.getProperty("workspace");
private final String TEST_FILES_DIR = WORKSPACE + File.separatorChar + "test_files" + File.separatorChar;
-
+
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
-
+ protected void logoutAfterTest() {
+
}
+ /**
+ * Canceling of file upload. The form for uploading file is filled with
+ * relevant values and the file located in "test_files/testFile.txt" is
+ * chosen for uploading into the default directory. Instead of submit
+ * button, the cancel button is pressed. The assertion are made to count the
+ * number of rows in file tables asserting the number of rows didn't change
+ * after canceling of upload.
+ */
@Test(enabled = true, description = "canceling of file upload")
public void testFileUploadCancel() {
selenium.click("link=Admin");
@@ -61,6 +75,7 @@
selenium.type("description", "myFile");
selenium.type("title", "file to upload");
selenium.select("language", "label=Afar");
+ selenium.type("response", WORKSPACE + "/test_files/testFile.txt");
selenium.click("link=default");
selenium.click("cancel");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -79,9 +94,16 @@
Assert.assertEquals(rc_d_after, rc_d_before, "The row count in CMS file table has changes after canceling the upload of file in the default dir.");
}
+ /**
+ * File upload test. The form for uploading file is filled with relevant
+ * values and the file located in "test_files/testFile.txt" is chosen for
+ * uploading into the root directory. Submit button is pressed and the
+ * upload should take the action. The existence of the file in root
+ * directory is asserted.
+ */
@Test(enabled = true, description = "File upload test")
public void testFileUpload() {
-
+
selenium.click("link=Admin");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=CMS");
@@ -93,16 +115,15 @@
selenium.type("description", "myFile");
selenium.type("title", "file to upload");
selenium.select("language", "label=Afar");
-
selenium.type("response", TEST_FILES_DIR + "testFile.txt");
selenium.click("submit");
selenium.waitForPageToLoad(PAGE_LOAD);
-/*
- selenium.click("link=Approve");
- selenium.waitForPageToLoad(PAGE_LOAD);
-*/
+ /*
+ * selenium.click("link=Approve");
+ * 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");
@@ -114,5 +135,5 @@
Assert.assertEquals(selenium.getText("link=testFile.txt"), "testFile.txt");
}
-
+
}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -9,75 +9,86 @@
import org.testng.annotations.Test;
/**
+ * Testing file actions of CMS which require workflow security.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
-@Test(groups = { "cms_file_workflow" }, enabled = true)
+@Test(groups = { "cms" }, enabled = true)
public class CMSFileWorkflowTestCase extends JBossPortalSeleniumTestCase {
- private static final String SUB_MOVE = "submit";
+
+ /** prefix for locator properties = cms.file.work. */
public final String casePfx = "cms.file.work.";
- private final String LAB_LANG_CZECH = getProp(casePfx+"lab.lang.czech","label=Czech");
- private final String LNK_DENY = getProp(casePfx+"lnk.deny","link=Deny");
- private final String LNK_PREVIEW = getProp(casePfx+"lnk.preview","link=Preview");
- private final String LNK_APPROVE = getProp(casePfx+"lnk.approve","link=Approve");
- private final String SUB_FILE_CREATE = getProp(casePfx+"sub.file.create","save");
- private final String SUB_FILE_CREATE_CANCEL = getProp(casePfx+"sub.file.create.cancel","cancel");
- private final String SEL_LANG = getProp(casePfx+"sel.lang","language");
- private final String INP_TITLE = getProp(casePfx+"inp.title","title");
- private final String INP_DESC = getProp(casePfx+"inp.desc","description");
- private final String INP_FILENAME = getProp(casePfx+"inp.filename","filename");
- private final String LAB_CREATE_FILE = getProp(casePfx+"lab.create.file","label=Create File");
- private final String LNK_CMS = getProp(casePfx+"lnk.cms","link=CMS");
- private final String LNK_ADMIN = getProp(casePfx+"lnk.admin","link=Admin");
+ private final String LAB_LANG_CZECH = getLoc(casePfx + "lab.lang.czech", "label=Czech");
+ private final String SUB_MOVE = getLoc(casePfx + "sub.move", "submit");
+ private final String LNK_HOME = getLoc(casePfx + "lnk.home", "link=Home");
+ private final String LNK_DENY = getLoc(casePfx + "lnk.deny", "link=Deny");
+ private final String LNK_PREVIEW = getLoc(casePfx + "lnk.preview", "link=Preview");
+ private final String LNK_APPROVE = getLoc(casePfx + "lnk.approve", "link=Approve");
+ private final String SUB_FILE_CREATE = getLoc(casePfx + "sub.file.create", "save");
+ private final String SUB_FILE_CREATE_CANCEL = getLoc(casePfx + "sub.file.create.cancel", "cancel");
+ private final String SEL_LANG = getLoc(casePfx + "sel.lang", "language");
+ private final String INP_TITLE = getLoc(casePfx + "inp.title", "title");
+ private final String INP_DESC = getLoc(casePfx + "inp.desc", "description");
+ private final String INP_FILENAME = getLoc(casePfx + "inp.filename", "filename");
+ private final String LAB_CREATE_FILE = getLoc(casePfx + "lab.create.file", "label=Create File");
+ private final String LNK_CMS = getLoc(casePfx + "lnk.cms", "link=CMS");
+ private final String LNK_ADMIN = getLoc(casePfx + "lnk.admin", "link=Admin");
- public final String SELECT_CMS_MAIN = getProp(casePfx+"select.cms.main","//div[@id='center']/div/div/div[1]/div/select");
- public final String CMS_FILE_TABLE = getProp(casePfx+"cms.file.table","//div[@id='center']/div/div/div[3]/table");
-
- public final String CMS_T_SELECT = getProp(casePfx+"cms.t.select","//div[@id=''center'']/div/div/div[3]/table/tbody/tr[{0}]/td[2]/form/select");
- public final String CMS_T_SUBMIT = getProp(casePfx+"cms.t.submit","//div[@id=''center'']/div/div/div[3]/table/tbody/tr[{0}]/td[2]/form/input");
-
- public final String CMS_WF_TABLE = getProp(casePfx+"cms.wf.table","//div[@id='center']/div/div/table[2]");
- public final String CMS_FV_TABLE = getProp(casePfx+"cms.fv.table","//div[@id='center']/div/div/table");
- public final String CMS_T_VER = getProp(casePfx+"cms.t.ver","//div[@id=''center'']/div/div/table/tbody/tr[{0}]/td[1]/a");
- public final String WYSIWYG_EDITOR_LOCATOR = getProp(casePfx+"wysiwyg.editor.locator","mce_editor_0");
-
+ public final String SELECT_CMS_MAIN = getLoc(casePfx + "select.cms.main", "//div[@id='center']/div/div/div[1]/div/select");
+ public final String CMS_FILE_TABLE = getLoc(casePfx + "cms.file.table", "//div[@id='center']/div/div/div[3]/table");
+
+ public final String CMS_T_SELECT = getLoc(casePfx + "cms.t.select", "//div[@id=''center'']/div/div/div[3]/table/tbody/tr[{0}]/td[2]/form/select");
+ public final String CMS_T_SUBMIT = getLoc(casePfx + "cms.t.submit", "//div[@id=''center'']/div/div/div[3]/table/tbody/tr[{0}]/td[2]/form/input");
+
+ public final String CMS_WF_TABLE = getLoc(casePfx + "cms.wf.table", "//div[@id='center']/div/div/table[2]");
+ public final String CMS_FV_TABLE = getLoc(casePfx + "cms.fv.table", "//div[@id='center']/div/div/table");
+ public final String CMS_T_VER = getLoc(casePfx + "cms.t.ver", "//div[@id=''center'']/div/div/table/tbody/tr[{0}]/td[1]/a");
+ public final String WYSIWYG_EDITOR_LOCATOR = getLoc(casePfx + "wysiwyg.editor.locator", "mce_editor_0");
+
@BeforeMethod(groups = { "log" })
public void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
- }
-
- @AfterMethod( groups = { "log" })
+ }
+
+ @AfterMethod(groups = { "log" })
public void logoutAfterTest() {
-
+
}
-
+
+ /**
+ * Creates new file with no content. At first attempt it cancels the action
+ * and file is not created. At the second attempt it really creates the
+ * file. The file is approved and it is asserted that only one file with the
+ * specified file name exists in the file table.
+ */
@Test(enabled = true, description = "Simple file creation.")
public void testCreateFileApprove() {
-
+
// canceling first
-
+
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CMS);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.select(SELECT_CMS_MAIN, LAB_CREATE_FILE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
selenium.waitForPopUp("_top", PAGE_LOAD);
selenium.type(INP_FILENAME, "newFile");
selenium.type(INP_DESC, "newFile description");
selenium.type(INP_TITLE, "newFile title");
selenium.select(SEL_LANG, LAB_LANG_CZECH);
-
+
selenium.click(SUB_FILE_CREATE_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
// saving
- selenium.open(ADDR_PORTAL);
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -85,32 +96,37 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.select(SELECT_CMS_MAIN, LAB_CREATE_FILE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
selenium.waitForPopUp("_top", PAGE_LOAD);
selenium.type(INP_FILENAME, "newFile");
selenium.type(INP_DESC, "newFile description");
selenium.type(INP_TITLE, "newFile title");
selenium.select(SEL_LANG, LAB_LANG_CZECH);
-
+
selenium.click(SUB_FILE_CREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
int row = countTableRows(CMS_WF_TABLE) - 1;
Assert.assertEquals(row, 1, "More instances of newly created document exists.");
-
+
Assert.assertTrue(selenium.isTextPresent("Pending Approval Queue"));
Assert.assertTrue(selenium.isElementPresent(LNK_PREVIEW));
Assert.assertTrue(selenium.isElementPresent(LNK_APPROVE));
Assert.assertTrue(selenium.isElementPresent(LNK_DENY));
-
+
selenium.click(LNK_APPROVE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
row = countTableRows(CMS_FV_TABLE) - 1;
Assert.assertEquals(row, 3, "More then 2 version of recently created and approved file found.");
}
-
+
+ /**
+ * The file named "newFileDeny" is created, but then is denied in the
+ * workflow process. It is asserted that the file is not appearing in the
+ * file table.
+ */
@Test(enabled = true, description = "Simple file creation.")
public void testCreateFileDeny() {
selenium.click(LNK_ADMIN);
@@ -126,32 +142,36 @@
selenium.select(SEL_LANG, LAB_LANG_CZECH);
selenium.click(SUB_FILE_CREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
int row = countTableRows(CMS_WF_TABLE) - 1;
Assert.assertEquals(row, 1, "More instances of newly created document exists.");
-
+
Assert.assertTrue(selenium.isTextPresent("Pending Approval Queue"));
Assert.assertTrue(selenium.isElementPresent(LNK_PREVIEW));
Assert.assertTrue(selenium.isElementPresent(LNK_APPROVE));
Assert.assertTrue(selenium.isElementPresent(LNK_DENY));
-
+
selenium.click(LNK_DENY);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
Assert.assertFalse(selenium.isTextPresent("newFileDeny"));
}
+ /**
+ * File named "file2preview" with content "vivat!" is created and then
+ * previewed. The content of file is asserted to be appearing on the screen.
+ */
@Test(enabled = true, description = "Simple file creation.")
- public void testCreateFilePreview(){
+ public void testCreateFilePreview() {
String name = "file2preview";
-
- selenium.open(ADDR_PORTAL);
+
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CMS);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Home");
+ selenium.click(LNK_HOME);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.select(SELECT_CMS_MAIN, LAB_CREATE_FILE);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -163,15 +183,25 @@
fillInEditor("vivat!");
selenium.click(SUB_FILE_CREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
selenium.click(LNK_PREVIEW);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
Assert.assertTrue(selenium.isTextPresent("Pending Approval Queue"));
+
+ selenium.selectFrame(WYSIWYG_EDITOR_LOCATOR);
Assert.assertTrue(selenium.isTextPresent("vivat!"));
-
+ selenium.selectFrame("relative=top");
+
}
-
+
+ /**
+ * The file from {@link CMSFileWorkflowTestCase#testDeleteFile()} is used in
+ * this test. The file is deleted. In the first approach the deletion is
+ * canceled. In the second approach the file deletion is affirmed and the
+ * file is deleted. The file is then asserted not to appear in the file
+ * table.
+ */
@Test(enabled = true, dependsOnMethods = "testCreateFileApprove", description = "Simple file delete Cancel in first step, and then delete.")
public void testDeleteFile() {
selenium.click(LNK_ADMIN);
@@ -181,64 +211,74 @@
selenium.waitForPageToLoad(PAGE_LOAD);
int row = findTableRow(CMS_FILE_TABLE, "newFile", 0) + 1;
-
- selenium.select(MessageFormat.format(CMS_T_SELECT,row), "label=Delete");
- selenium.click(MessageFormat.format(CMS_T_SUBMIT,row));
+
+ selenium.select(MessageFormat.format(CMS_T_SELECT, row), "label=Delete");
+ selenium.click(MessageFormat.format(CMS_T_SUBMIT, row));
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(SUB_FILE_CREATE_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
row = findTableRow(CMS_FILE_TABLE, "newFile", 0) + 1;
-
- selenium.select(MessageFormat.format(CMS_T_SELECT,row), "label=Delete");
- selenium.click(MessageFormat.format(CMS_T_SUBMIT,row));
-
+
+ selenium.select(MessageFormat.format(CMS_T_SELECT, row), "label=Delete");
+ selenium.click(MessageFormat.format(CMS_T_SUBMIT, row));
+
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(SUB_MOVE);
selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertFalse(selenium.isTextPresent("newFile"));
}
-
+
+ /**
+ * Moving of the file. File named "fileToMove" is created in the root
+ * directory. The file is then moved into the "default" directory. At first
+ * attempt the file move is canceled and it is asserted that the file wasnt
+ * moved (it is not appearing in the "default" directory). At the second
+ * attempt the file is really moved to the destination directory and it is
+ * asserted that the file is not present in the root directory but is
+ * present in the "default" directory.
+ */
@Test(enabled = true, description = "File creation and moving to default directory.")
public void testMoveFile() {
- createFile("fileToMove","");
-
- //canceling first
-
+ createFile("fileToMove", "");
+
+ // canceling first
+
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CMS);
selenium.waitForPageToLoad(PAGE_LOAD);
int row = findTableRow(CMS_FILE_TABLE, "fileToMove", 0) + 1;
;
- selenium.select(MessageFormat.format(CMS_T_SELECT,row), "label=Move");
- selenium.click(MessageFormat.format(CMS_T_SUBMIT,row));
+ selenium.select(MessageFormat.format(CMS_T_SELECT, row), "label=Move");
+ selenium.click(MessageFormat.format(CMS_T_SUBMIT, row));
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=default");
selenium.click(SUB_FILE_CREATE_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
// assuming file is not moved
-
+
selenium.click("link=default");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isElementPresent("link=fileToMove"));
- selenium.click("link=Home");
+ selenium.click(LNK_HOME);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isElementPresent("link=fileToMove"));
-
+
// really moving file
- selenium.open(ADDR_PORTAL);
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -246,37 +286,42 @@
selenium.waitForPageToLoad(PAGE_LOAD);
row = findTableRow(CMS_FILE_TABLE, "fileToMove", 0) + 1;
- selenium.select(MessageFormat.format(CMS_T_SELECT,row), "label=Move");
- selenium.click(MessageFormat.format(CMS_T_SUBMIT,row));
+ selenium.select(MessageFormat.format(CMS_T_SELECT, row), "label=Move");
+ selenium.click(MessageFormat.format(CMS_T_SUBMIT, row));
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=default");
selenium.click(SUB_MOVE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
// assuming file is moved
-
+
selenium.click("link=default");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isElementPresent("link=fileToMove"));
- selenium.click("link=Home");
+ selenium.click(LNK_HOME);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isElementPresent("link=fileToMove"));
}
+ /**
+ * Copying of a file. The file named "file2copy" is created in the root
+ * directory and then is copied into the default directory. File is then
+ * asserted to appear in both root and the "default" directories.
+ */
@Test(enabled = true, dependsOnMethods = "testCreateFileApprove", description = "File creation and copying to default directory.")
public void testCopyFile() {
- createFile("file2copy","");
+ createFile("file2copy", "");
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CMS);
selenium.waitForPageToLoad(PAGE_LOAD);
int row = findTableRow(CMS_FILE_TABLE, "file2copy", 0) + 1;
- selenium.select(MessageFormat.format(CMS_T_SELECT,row), "label=Copy");
- selenium.click(MessageFormat.format(CMS_T_SUBMIT,row));
+ selenium.select(MessageFormat.format(CMS_T_SELECT, row), "label=Copy");
+ selenium.click(MessageFormat.format(CMS_T_SUBMIT, row));
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=default");
selenium.click(SUB_MOVE);
@@ -286,90 +331,99 @@
Assert.assertTrue(selenium.isElementPresent("link=file2copy"));
- selenium.click("link=Home");
+ selenium.click(LNK_HOME);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isElementPresent("link=file2copy"));
}
-
- @Test(enabled = true, dependsOnMethods = "testCreateFileApprove", description="File Creation and editing.")
- public void testEditFile(){
-
+
+ /**
+ * Basic editing on a file - changing it content. The file "file2edit" is
+ * created. The string "contentstring1" is inserted as a content of this
+ * file. At the first attempt the file creation is canceled at the second
+ * attpemt the file is created and approved. The content of the file is then
+ * changed to "contentstring2" and the change is approved. The content of
+ * the file is then changed to "contentstring3" and the change is denied. At
+ * the end it is asserted that the file content is "contentstring2".
+ */
+ @Test(enabled = true, dependsOnMethods = "testCreateFileApprove", description = "File Creation and editing.")
+ public void testEditFile() {
+
int row = -1;
String file = "file2edit";
-
- createFile(file,"contentstring1");
-
+
+ createFile(file, "contentstring1");
+
// canceling for the first time
-
+
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CMS);
selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link="+file);
+
+ selenium.click("link=" + file);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
row = findTableRow(CMS_FV_TABLE, "1.1", 2) + 1;
selenium.click(MessageFormat.format(CMS_T_VER, row));
selenium.waitForPageToLoad(PAGE_LOAD);
fillInEditor("contentstring2");
selenium.click(SUB_FILE_CREATE_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
// really creating and approving
- selenium.open(ADDR_PORTAL);
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CMS);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Home");
+ selenium.click(LNK_HOME);
selenium.waitForPageToLoad(PAGE_LOAD);
-
- selenium.click("link="+file);
+
+ selenium.click("link=" + file);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
row = findTableRow(CMS_FV_TABLE, "1.1", 2) + 1;
selenium.click(MessageFormat.format(CMS_T_VER, row));
selenium.waitForPageToLoad(PAGE_LOAD);
fillInEditor("contentstring2");
selenium.click(SUB_FILE_CREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
selenium.click(LNK_APPROVE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
row = findTableRow(CMS_FV_TABLE, "1.3", 2) + 1;
selenium.click(MessageFormat.format(CMS_T_VER, row));
selenium.waitForPageToLoad(PAGE_LOAD);
fillInEditor("contentstring3");
selenium.click(SUB_FILE_CREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
selenium.click(LNK_DENY);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
Assert.assertFalse(selenium.isTextPresent("1.5"));
-
+
row = findTableRow(CMS_FV_TABLE, "1.3", 2) + 1;
selenium.click(MessageFormat.format(CMS_T_VER, row));
selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.selectFrame(WYSIWYG_EDITOR_LOCATOR);
Assert.assertTrue(selenium.isTextPresent("contentstring2"));
-
+ selenium.selectFrame("relative=top");
}
-
-
- private void createFile(String name,String content) {
-
+
+ private void createFile(String name, String content) {
+
// save and approve
- selenium.open(ADDR_PORTAL);
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_CMS);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Home");
+ selenium.click(LNK_HOME);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.select(SELECT_CMS_MAIN, LAB_CREATE_FILE);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -378,21 +432,22 @@
selenium.type(INP_DESC, name + " description");
selenium.type(INP_TITLE, "existingFile title");
selenium.select(SEL_LANG, LAB_LANG_CZECH);
-
+
selenium.click(SUB_FILE_CREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
selenium.click(LNK_APPROVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.click("link=Home");
+ selenium.click(LNK_HOME);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
Assert.assertEquals(name, selenium.getText("link=" + name));
- logout();login("admin","admin");
+ logout();
+ login("admin", "admin");
}
-
- private void fillInEditor(String content){
- selenium.getEval("selenium.fillInEditor('"+WYSIWYG_EDITOR_LOCATOR+"','"+content+"')");
+
+ private void fillInEditor(String content) {
+ selenium.getEval("selenium.fillInEditor('" + WYSIWYG_EDITOR_LOCATOR + "','" + content + "')");
}
}
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowUploadTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowUploadTestCase.java (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowUploadTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -0,0 +1,235 @@
+package org.jboss.portal.test.selenium.cms;
+
+import java.io.File;
+
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * CMSFileUploadTestCase is responsible for testing of file uploading. Files
+ * used in these tests are stored in the path defined by the system variable
+ * workspace (-Dworkspace).
+ *
+ * @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
+ */
+@Test(groups = { "cms" }, enabled = true)
+public class CMSFileWorkflowUploadTestCase extends JBossPortalSeleniumTestCase {
+ /** prefix for locator properties = cms.file.up. */
+ private final String casePfx = "cms.file.up.";
+
+ private final String SUB_FIL_SUBMIT = getLoc(casePfx + "sub.fil.submit", "submit");
+ private final String SUB_FIL_CANCEL = getLoc(casePfx + "sub.fil.cancel", "cancel");
+ private final String INP_FIL_FIL = getLoc(casePfx + "inp.fil.fil", "response");
+ private final String INP_FIL_LAN = getLoc(casePfx + "inp.fil.lan", "language");
+ private final String INP_FIL_TIT = getLoc(casePfx + "inp.fil.tit", "title");
+ private final String INP_FIL_DES = getLoc(casePfx + "inp.fil.des", "description");
+ private final String LNK_DENY = getLoc(casePfx + "lnk.deny", "link=Deny");
+ private final String LNK_PREVIEW = getLoc(casePfx + "lnk.preview", "link=Preview");
+ private final String LNK_APPROVE = getLoc(casePfx + "lnk.approve", "link=Approve");
+ private final String CMS_FILE_TABLE = getLoc(casePfx + "cms.file.table", "//div[@id='center']/div/div/div[3]/table");
+ private final String WORKSPACE = System.getProperty("workspace");
+ private final String TEST_FILES_DIR = WORKSPACE + File.separatorChar + "test_files" + File.separatorChar;
+ private final String SEL_ACTION = getLoc(casePfx + "sel.action", "//div[@id='center']/div/div/div[1]/div/select");
+ private final String LNK_CMS_ROOT = getLoc(casePfx + "lnk.cms.root", "link=Home");
+ private final String TAB_FILE_VER = getLoc(casePfx + "tab.file.ver", "//div[@id='center']/div/div/table");
+
+ @BeforeMethod(groups = { "log" })
+ protected void loginBeforeTest() {
+ logoutIfPossible();
+ login("admin", "admin");
+ }
+
+ @AfterMethod(groups = { "log" })
+ protected void logoutAfterTest() {
+
+ }
+
+ /**
+ * Canceling of file upload. The form for uploading file is filled with
+ * relevant values and the file located in "test_files/testFile.txt" is
+ * chosen for uploading into the default directory. Instead of submit
+ * button, the cancel button is pressed. The assertion are made to count the
+ * number of rows in file tables asserting the number of rows didn't change
+ * after canceling of upload.
+ */
+ @Test(enabled = true, description = "canceling of file upload")
+ public void testFileUploadCancel() {
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ int rc_m_before = countTableRows(CMS_FILE_TABLE);
+
+ selenium.click("link=default");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ int rc_d_before = countTableRows(CMS_FILE_TABLE);
+
+ selenium.click(LNK_CMS_ROOT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.select(SEL_ACTION, "label=Upload File");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+ selenium.type(INP_FIL_DES, "myFile");
+ selenium.type(INP_FIL_TIT, "file to upload");
+ selenium.select(INP_FIL_LAN, "label=Afar");
+ selenium.type(INP_FIL_FIL, WORKSPACE + "/test_files/testFile.txt");
+ selenium.click("link=default");
+ selenium.click(SUB_FIL_CANCEL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ int rc_m_after = countTableRows(CMS_FILE_TABLE);
+
+ selenium.click("link=default");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ int rc_d_after = countTableRows(CMS_FILE_TABLE);
+
+ selenium.click(LNK_CMS_ROOT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertEquals(rc_m_after, rc_m_before, "The row count in CMS file table has changes after canceling the upload of file in the root dir.");
+ Assert.assertEquals(rc_d_after, rc_d_before, "The row count in CMS file table has changes after canceling the upload of file in the default dir.");
+ }
+
+ /**
+ * File upload test. The form for uploading file is filled with relevant
+ * values and the file located in "test_files/testFile.txt" is chosen for
+ * uploading into the root directory. Submit button is pressed and the
+ * upload should take the action and afterwards the file is approved. The
+ * existence of the file in root directory is asserted.
+ */
+ @Test(enabled = true, description = "File upload test")
+ public void testFileApproveUpload() {
+ String fileName = "testFile.txt";
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.select(SEL_ACTION, "label=Upload File");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+ selenium.type(INP_FIL_DES, "myFile");
+ selenium.type(INP_FIL_TIT, "file to upload");
+ selenium.select(INP_FIL_LAN, "label=Afar");
+ selenium.type(INP_FIL_FIL, TEST_FILES_DIR + fileName);
+ selenium.click(SUB_FIL_SUBMIT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isElementPresent(LNK_PREVIEW));
+ Assert.assertTrue(selenium.isElementPresent(LNK_APPROVE));
+ Assert.assertTrue(selenium.isElementPresent(LNK_DENY));
+
+ selenium.click(LNK_APPROVE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent(fileName));
+ Assert.assertTrue(selenium.isElementPresent("link=text/plain"));
+
+ int r = findTableRow(TAB_FILE_VER, "file to upload", 5);
+
+ Assert.assertTrue(r > -1, "File title not found in the file table");
+
+ Assert.assertTrue(selenium.isElementPresent("link=Afar"));
+ Assert.assertTrue(selenium.isTextPresent(fileName));
+
+ selenium.click(LNK_CMS_ROOT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertEquals(selenium.getText("link=" + fileName), fileName);
+ }
+
+ /**
+ * File upload test. The form for uploading file is filled with relevant
+ * values and the file located in "test_files/testFileDeny.txt" is chosen
+ * for uploading into the root directory. Submit button is pressed and the
+ * upload should take the action and afterwards the file is denied. The
+ * non-existence of the file in root directory is asserted.
+ */
+ @Test(enabled = true, description = "File upload test")
+ public void testFileDenyUpload() {
+ String filename = "testFileDeny.txt";
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.select(SEL_ACTION, "label=Upload File");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+ selenium.type(INP_FIL_DES, "myFile");
+ selenium.type(INP_FIL_TIT, "file to deny upload");
+ selenium.select(INP_FIL_LAN, "label=Afar");
+ selenium.type(INP_FIL_FIL, TEST_FILES_DIR + filename);
+ selenium.click(SUB_FIL_SUBMIT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isElementPresent(LNK_PREVIEW));
+ Assert.assertTrue(selenium.isElementPresent(LNK_APPROVE));
+ Assert.assertTrue(selenium.isElementPresent(LNK_DENY));
+
+ selenium.click(LNK_DENY);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertFalse(selenium.isTextPresent(filename));
+
+ selenium.click(LNK_CMS_ROOT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertFalse(selenium.isElementPresent("link=" + filename));
+ }
+
+ /**
+ * Selenium doesn't support file downloading, therefore the test is
+ * disabled. The form for uploading file is filled with relevant values and
+ * the file located in "test_files/testFilePrev.txt" is chosen for uploading
+ * into the root directory. Submit button is pressed and the upload should
+ * take the action and afterwards the file is previewed and denied.
+ * non-existence of the file in root directory is asserted.
+ */
+ @Test(enabled = false, description = "File upload test")
+ public void testFilePreviewUpload() {
+ String filename = "testFilePrev.txt";
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=CMS");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.select(SEL_ACTION, "label=Upload File");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.waitForPopUp("_top", PAGE_LOAD);
+ selenium.type(INP_FIL_DES, "myFile");
+ selenium.type(INP_FIL_TIT, "file to deny upload");
+ selenium.select(INP_FIL_LAN, "label=Afar");
+ selenium.type(INP_FIL_FIL, TEST_FILES_DIR + filename);
+ selenium.click(SUB_FIL_SUBMIT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isElementPresent(LNK_PREVIEW));
+ Assert.assertTrue(selenium.isElementPresent(LNK_APPROVE));
+ Assert.assertTrue(selenium.isElementPresent(LNK_DENY));
+
+ selenium.click(LNK_PREVIEW);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click(LNK_DENY);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertFalse(selenium.isTextPresent(filename));
+
+ selenium.click(LNK_CMS_ROOT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertFalse(selenium.isElementPresent("link=" + filename));
+ }
+
+}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSSecureTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -10,53 +10,64 @@
import org.testng.annotations.Test;
/**
+ * CMSSecureTestCase is reponsible for testing of security of CMS module in
+ * JBoss Portal.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
-
-@Test(groups = { "cms_secure" }, enabled = true, description = "Setting permissions on the default portlet.")
+//TODO tests testing write and manage security are missing
+@Test(groups = { "cms" }, enabled = true, description = "Setting permissions on the default portlet.")
public class CMSSecureTestCase extends JBossPortalSeleniumTestCase {
- private static final String ACCESS_DENIED = "Access to this resource is denied";
+ private static final String IMG_PORTAL = "//img[@alt='Enterprise Portal Platform 4.3']";
+ /**
+ *
+ */
+ /** prefix for locator properties = cms.sec. */
private final String casePfx = "cms.sec.";
- private final String LNK_EXPLORE = getProp(casePfx + "lnk.explore", "//area[@href='/portal/content/default/epp.html']");
- private final String LNK_CMS_EXPLORE = getProp(casePfx + "lnk.cms.explore", "Link=private1.html");
- private final String LNK_MEMBERS = getProp(casePfx + "lnk.members", "link=Members");
- private final String SUB_SECURITY_SET = getProp(casePfx + "sub.security.set", "//input[contains(@name,'submit')]");
- private final String SEL_SECUREUSERS_MANAGE = getProp(casePfx + "sel.secureusers.manage", "//select[contains(@name,'secureusers:manage')]");
- private final String SEL_SECUREROLES_MANAGE = getProp(casePfx + "sel.secureroles.manage", "//select[contains(@name,'secureroles:manage')]");
- private final String SEL_SECUREUSERS_WRITE = getProp(casePfx + "sel.secureusers.write", "//select[contains(@name,'secureusers:write')]");
- private final String SEL_SECUREROLES_WRITE = getProp(casePfx + "sel.secureroles.write", "//select[contains(@name,'secureroles:write')]");
- private final String SEL_SECUREUSERS_READ = getProp(casePfx + "sel.secureusers.read", "//select[contains(@name,'secureusers:read')]");
- private final String SEL_SECUREROLES_READ = getProp(casePfx + "sel.secureroles.read", "//select[contains(@name,'secureroles:read')]");
- private final String LNK_INDEX_HTML = getProp(casePfx + "lnk.index.html", "link=index.html");
- private final String LNK_DEFAULT = getProp(casePfx + "lnk.default", "link=default");
- private final String LNK_CMS = getProp(casePfx + "lnk.cms", "link=CMS");
- private final String LNK_ADMIN = getProp(casePfx + "lnk.admin", "link=Admin");
- private final String LNK_LOGOUT = getProp(casePfx + "lnk.logout", "link=Logout");
- private final String SEL_CMS_ACTION = getProp(casePfx + "sel.cms.action", "//div[@id='center']/div/div/div[1]/div/select");
+ private final String MSG_ACCESS_DENIED = getMess(casePfx + "denied", "You are nt allowed to access the resource");
+
+ private final String LNK_EXPLORE = getLoc(casePfx + "lnk.explore", "//area[@href='/portal/content/default/epp.html']");
+ private final String LNK_CMS_EXPLORE = getLoc(casePfx + "lnk.cms.explore", "Link=private1.html");
+ private final String LNK_MEMBERS = getLoc(casePfx + "lnk.members", "link=Members");
+ private final String SUB_SECURITY_SET = getLoc(casePfx + "sub.security.set", "//input[contains(@name,'submit')]");
+ private final String SEL_SECUREUSERS_MANAGE = getLoc(casePfx + "sel.secureusers.manage", "//select[contains(@name,'secureusers:manage')]");
+ private final String SEL_SECUREROLES_MANAGE = getLoc(casePfx + "sel.secureroles.manage", "//select[contains(@name,'secureroles:manage')]");
+ private final String SEL_SECUREUSERS_WRITE = getLoc(casePfx + "sel.secureusers.write", "//select[contains(@name,'secureusers:write')]");
+ private final String SEL_SECUREROLES_WRITE = getLoc(casePfx + "sel.secureroles.write", "//select[contains(@name,'secureroles:write')]");
+ private final String SEL_SECUREUSERS_READ = getLoc(casePfx + "sel.secureusers.read", "//select[contains(@name,'secureusers:read')]");
+ private final String SEL_SECUREROLES_READ = getLoc(casePfx + "sel.secureroles.read", "//select[contains(@name,'secureroles:read')]");
+ private final String LNK_INDEX_HTML = getLoc(casePfx + "lnk.index.html", "link=index.html");
+ private final String LNK_DEFAULT = getLoc(casePfx + "lnk.default", "link=default");
+ private final String LNK_CMS = getLoc(casePfx + "lnk.cms", "link=CMS");
+ private final String LNK_ADMIN = getLoc(casePfx + "lnk.admin", "link=Admin");
+ private final String LNK_LOGOUT = getLoc(casePfx + "lnk.logout", "link=Logout");
+ private final String SEL_CMS_ACTION = getLoc(casePfx + "sel.cms.action", "//div[@id='center']/div/div/div[1]/div/select");
+ /** prefix for locator properties = user.login. */
public String caseIPfx = "iden.man.";
- public final String LNK_ROLETAB = getProp(caseIPfx + "lnk.roletab", "//a[contains(@id,'user-temp-form:role-mgm-link')]");
- public final String LNK_ROLEMAIN = getProp(caseIPfx + "lnk.rolemain", "//a[contains(@id, 'role-temp-form1:role-admin-link')]");
- public final String LNK_ROLE_CREATE = getProp(caseIPfx + "lnk.role.create", "//a[contains(@id, 'create-role-form:create-role-link')]");
- public final String INP_ROLEDISNAME = getProp(caseIPfx + "inp.roledisname", "//input[contains(@id,'create-role-form:roledisplayname')]");
- public final String INP_ROLENAME = getProp(caseIPfx + "inp.rolename", "//input[contains(@id,'create-role-form:rolename')]");
- public final String SUB_ROLE_CREATE = getProp(caseIPfx + "sub.role.create", "//input[contains(@id,'create-role-form:submit')]");
- public final String SUB_ASSIGN_ROLE = getProp(caseIPfx + "sub.assign.role", "//input[contains(@id,'assign-roles-form:submit')]");
- public final String CHK_ROLE = getProp(caseIPfx + "chk.role", "//input[contains(@name,''assign-roles-form:roles'') and @value=''{0}'']");
- public final String LNK_USERTAB = getProp(caseIPfx + "lnk.usertab", "//a[contains(@id,'role-temp-form:manage-users')]");
- public final String LNK_USERMAIN = getProp(caseIPfx + "lnk.usermain", "//a[contains(@id,'user-temp-form1:user-adm-link')]");
- public final String LNK_USERMANG_MAIN = getProp(caseIPfx + "lnk.usermang.main", "//a[contains(@id,'user-temp-form1:assign-role-link')]");
- public final String SUB_SEARCH_USER = getProp(caseIPfx + "sub.search.user", "//input[contains(@id,'search-user-form:search') and @type='submit']");
- public final String INP_SEARCH_USER = getProp(caseIPfx + "inp.search.user", "//input[contains(@id,'search-user-form:searchString')]");
- public final String LNK_SEARCH_USER = getProp(caseIPfx + "lnk.search.user", "//a[contains(@id,'user-form:search-user-link')]");
- public final String TBL_USERLIST = getProp(caseIPfx + "tbl.userlist", "//table[contains(@id,'search-user-form1:userlist')]");
- public final String LNK_T_USRLIST_ROLES = getProp(caseIPfx + "lnk.t.usrlist.roles",
+
+ private final String LNK_ROLETAB = getLoc(caseIPfx + "lnk.roletab", "//a[contains(@id,'user-temp-form:role-mgm-link')]");
+ private final String LNK_ROLEMAIN = getLoc(caseIPfx + "lnk.rolemain", "//a[contains(@id, 'role-temp-form1:role-admin-link')]");
+ private final String LNK_ROLE_CREATE = getLoc(caseIPfx + "lnk.role.create", "//a[contains(@id, 'create-role-form:create-role-link')]");
+ private final String INP_ROLEDISNAME = getLoc(caseIPfx + "inp.roledisname", "//input[contains(@id,'create-role-form:roledisplayname')]");
+ private final String INP_ROLENAME = getLoc(caseIPfx + "inp.rolename", "//input[contains(@id,'create-role-form:rolename')]");
+ private final String SUB_ROLE_CREATE = getLoc(caseIPfx + "sub.role.create", "//input[contains(@id,'create-role-form:submit')]");
+ private final String SUB_ASSIGN_ROLE = getLoc(caseIPfx + "sub.assign.role", "//input[contains(@id,'assign-roles-form:submit')]");
+ private final String CHK_ROLE = getLoc(caseIPfx + "chk.role", "//input[contains(@name,''assign-roles-form:roles'') and @value=''{0}'']");
+ private final String LNK_USERTAB = getLoc(caseIPfx + "lnk.usertab", "//a[contains(@id,'role-temp-form:manage-users')]");
+ private final String LNK_USERMAIN = getLoc(caseIPfx + "lnk.usermain", "//a[contains(@id,'user-temp-form1:user-adm-link')]");
+ private final String LNK_USERMANG_MAIN = getLoc(caseIPfx + "lnk.usermang.main", "//a[contains(@id,'user-temp-form1:assign-role-link')]");
+ private final String SUB_SEARCH_USER = getLoc(caseIPfx + "sub.search.user", "//input[contains(@id,'search-user-form:search') and @type='submit']");
+ private final String INP_SEARCH_USER = getLoc(caseIPfx + "inp.search.user", "//input[contains(@id,'search-user-form:searchString')]");
+ private final String LNK_SEARCH_USER = getLoc(caseIPfx + "lnk.search.user", "//a[contains(@id,'user-form:search-user-link')]");
+ private final String TBL_USERLIST = getLoc(caseIPfx + "tbl.userlist", "//table[contains(@id,'search-user-form1:userlist')]");
+ private final String LNK_T_USRLIST_ROLES = getLoc(caseIPfx + "lnk.t.usrlist.roles",
"//a[contains(@id,''search-user-form1:userlist:{0}:assign-role-link'')]");
@AfterMethod(groups = { "log" })
- public void logoutAfterTestIfPossible() {
+ private void logoutAfterTestIfPossible() {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -92,7 +103,7 @@
}
@BeforeClass()
- public void createRoles() {
+ private void createRoles() {
String roleName = "secRole";
String roleDisplayName = "secRoleDisp";
@@ -116,11 +127,17 @@
logout();
}
+ /**
+ * Sets admin read permissions, login as user. Sets permissions of
+ * default/index.html to Administrators/admin;#/#;#/#. Assert is then based
+ * on a fact, that logged admin is able to see the content of index html (on
+ * homepage) and non visible to not logged in user or "user".
+ */
@Test(enabled = true, description = "Set admin read permissions, login as user.")
public void testSetAdminReadPer() {
login("admin", "admin");
- Assert.assertFalse(selenium.isTextPresent(ACCESS_DENIED), "Non secured resource is not visible.#1");
+ Assert.assertFalse(selenium.isTextPresent(MSG_ACCESS_DENIED), "Non secured resource is not visible.#1");
Assert.assertFalse(selenium.isTextPresent("You are not allowed to access the following resource - /default/index.html"),
"Non secured resource is not visible.#2");
@@ -144,22 +161,32 @@
logout();
- Assert.assertTrue(selenium.isTextPresent(ACCESS_DENIED), "Secured resource is visible.#1");
+ Assert.assertTrue(selenium.isTextPresent(MSG_ACCESS_DENIED), "Secured resource is visible.#1");
login("user", "user");
- Assert.assertTrue(selenium.isTextPresent(ACCESS_DENIED), "Secured resource is visible.#2");
+ Assert.assertTrue(selenium.isTextPresent(MSG_ACCESS_DENIED), "Secured resource is visible.#2");
logout();
+ login("admin", "admin");
+ Assert.assertFalse(selenium.isTextPresent(MSG_ACCESS_DENIED), "Secured resource is visible.#2");
}
+ /**
+ * Sets user read permissions, login as user. Sets permissions of
+ * default/index.html to Administrators/user;#/#;#/#. At first attempt the
+ * setting of permissions is canceled, at the second attempt, it is
+ * submitted. Assert is then based on a fact, that logged "user" is able to
+ * see the content of index html (on homepage) and non visible to not logged
+ * in user.
+ */
@Test(enabled = true, description = "Set user read permissions, login as user.")
public void testSetUserReadPer() {
- // cancelling at first stage
+ // canceling at first stage
login("admin", "admin");
- Assert.assertFalse(selenium.isTextPresent(ACCESS_DENIED), "Non secured resource is not visible.#1");
+ Assert.assertFalse(selenium.isTextPresent(MSG_ACCESS_DENIED), "Non secured resource is not visible.#1");
Assert.assertFalse(selenium.isTextPresent("You are not allowed to access the following resource - /default/index.html"),
"Non secured resource is not visible.#2");
@@ -184,7 +211,7 @@
login("admin", "admin");
- Assert.assertFalse(selenium.isTextPresent(ACCESS_DENIED), "Non secured resource is not visible.#1");
+ Assert.assertFalse(selenium.isTextPresent("Access to this resource is denied "), "Non secured resource is not visible.#1");
selenium.click(LNK_ADMIN);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -203,21 +230,28 @@
logout();
- Assert.assertTrue(selenium.isTextPresent(ACCESS_DENIED), "Secured resource is visible.#1");
+ Assert.assertTrue(selenium.isTextPresent(MSG_ACCESS_DENIED), "Secured resource is visible.#1");
login("user", "user");
- Assert.assertFalse(selenium.isTextPresent(ACCESS_DENIED), "Secured resource is visible.#2");
+ Assert.assertFalse(selenium.isTextPresent(MSG_ACCESS_DENIED), "Secured resource is visible.#2");
logout();
}
+ /**
+ * Sets user read permissions, login as user. It assigns role "secRole" to
+ * user "user". Sets permissions for default/index.html to
+ * secRoleDisp/admin;#/#;#/#. Assert is then based on a fact, that logged
+ * "user" is able to see the content of index html (on homepage) and non
+ * visible to not logged in user.
+ */
@Test(enabled = true, description = "Set admin/secRole read permissions, login as user w secRole.")
public void testSetRoleReadPer1() {
login("admin", "admin");
assignRole("user", "user(a)portal.com", "secRole", "secRoleDisp");
- Assert.assertFalse(selenium.isTextPresent(ACCESS_DENIED), "Non secured resource is not visible.#1");
+ Assert.assertFalse(selenium.isTextPresent(MSG_ACCESS_DENIED), "Non secured resource is not visible.#1");
Assert.assertFalse(selenium.isTextPresent("You are not allowed to access the following resource - /default/index.html"),
"Non secured resource is not visible.#2");
@@ -237,22 +271,27 @@
selenium.waitForPageToLoad(PAGE_LOAD);
logout();
-
- Assert.assertTrue(selenium.isTextPresent(ACCESS_DENIED), "Secured resource is visible after logout.");
+ Assert.assertTrue(selenium.isTextPresent(MSG_ACCESS_DENIED), "Secured resource is visible after logout.");
login("user", "user");
- Assert.assertFalse(selenium.isTextPresent(ACCESS_DENIED), "Non secured resource is not visible for the \"user\".");
+ Assert.assertFalse(selenium.isTextPresent(MSG_ACCESS_DENIED), "Non secured resource is not visible for the \"user\".");
logout();
}
+ /**
+ * Sets user read permissions, login as user. It deassigns role "secRole" from
+ * user "user". Sets permissions for default/index.html to
+ * secRoleDisp/admin;#/#;#/#. Assert is then based on a fact, that logged
+ * "user" is not able to see the content of index html (on homepage) and neither not logged in user is able to see the resources.
+ */
@Test(enabled = true, dependsOnMethods = { "testSetRoleReadPer1" }, description = "Set admin/secRole read permissions, login as user w/o secRole.")
public void testSetRoleReadPer2() {
login("admin", "admin");
deassignRole("user", "user(a)portal.com", "secRole", "secRoleDisp");
- Assert.assertFalse(selenium.isTextPresent(ACCESS_DENIED));
+ Assert.assertFalse(selenium.isTextPresent(MSG_ACCESS_DENIED));
Assert.assertFalse(selenium.isTextPresent("You are not allowed to access the following resource - /default/index.html"));
selenium.click(LNK_ADMIN);
@@ -272,22 +311,26 @@
logout();
- Assert.assertTrue(selenium.isTextPresent(ACCESS_DENIED));
+ Assert.assertTrue(selenium.isTextPresent(MSG_ACCESS_DENIED));
login("user", "user");
- Assert.assertTrue(selenium.isTextPresent(ACCESS_DENIED));
+ Assert.assertTrue(selenium.isTextPresent(MSG_ACCESS_DENIED));
logout();
}
+ /**
+ * Unknown
+ */
+ //TODO implementation missing!
@Test(enabled = false, description = "Recursive permission test")
public void testRecursiveSecurity() {
login("admin", "admin");
deassignRole("user", "user(a)portal.com", "secRole", "secRoleDisp");
- Assert.assertFalse(selenium.isTextPresent(ACCESS_DENIED));
+ Assert.assertFalse(selenium.isTextPresent("Access Denied"));
Assert.assertFalse(selenium.isTextPresent("You are not allowed to access the following resource - /default/index.html"));
selenium.click(LNK_ADMIN);
@@ -308,19 +351,25 @@
logout();
}
+ /**
+ * Sets user read permissions, login as user. It deassigns role "secRole" from
+ * user "user". Sets permissions for default/index.html to
+ * Administrators/admin;Administrators/admin;Administrators/admin. Assert is then based on a fact, that not logged
+ * user is not able to see the subpage of (explore page) of the CMS module.
+ */
@Test(enabled = true, dependsOnMethods = { "testSetRoleReadPer1" }, description = "Subpage permission test")
public void testSubpageSecurity() {
- selenium.open("/portal/portal/default");
+ selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
login("admin","admin");
Assert.assertFalse(selenium.isTextPresent("Enteprise Portal Platform"));
- Assert.assertTrue(selenium.isElementPresent("//img[@alt='Enterprise Portal Platform 4.3']"));
+ Assert.assertTrue(selenium.isElementPresent(IMG_PORTAL));
//selenium.click(LNK_EXPLORE);
selenium.open("/portal/content/default/private/private1.html");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("This is private 1 document"),"private page text missing");
- Assert.assertFalse(selenium.isElementPresent("//img[@alt='Enterprise Portal Platform 4.3']"));
+ Assert.assertFalse(selenium.isElementPresent(IMG_PORTAL));
logout();
login("admin", "admin");
selenium.click(LNK_ADMIN);
@@ -346,13 +395,13 @@
logout();
Assert.assertFalse(selenium.isTextPresent("Enteprise Portal Platform"));
- Assert.assertTrue(selenium.isElementPresent("//img[@alt='Enterprise Portal Platform 4.3']"));
+ Assert.assertTrue(selenium.isElementPresent(IMG_PORTAL));
selenium.open("/portal/portal/default");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.open("/portal/content/default/private/private1.html");
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertFalse(selenium.isTextPresent("This is private 1 document"));
- Assert.assertFalse(selenium.isElementPresent("//img[@alt='Enterprise Portal Platform 4.3']"));
+ Assert.assertFalse(selenium.isElementPresent(IMG_PORTAL));
}
@@ -418,21 +467,15 @@
selenium.click(LNK_SEARCH_USER);
selenium.waitForPageToLoad(PAGE_LOAD);
- //selenium.setSpeed("5000");
+ // selenium.setSpeed("5000");
selenium.type(INP_SEARCH_USER, username);
- //System.out.println(SUB_SEARCH_USER);
selenium.click(SUB_SEARCH_USER);
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ waitFor(10000);
Assert.assertTrue(selenium.isTextPresent(username), "Username was not found.");
Assert.assertTrue(selenium.isTextPresent(email), "User email adress was not found.");
- //selenium.setSpeed("0");
+ // selenium.setSpeed("0");
}
private String butUsrRol_id(String userName) {
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/locator.properties
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/locator.properties 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/locator.properties 2009-07-10 14:25:44 UTC (rev 13537)
@@ -1,7 +1,7 @@
# JBossPortalSeleniumTestCase
portal.lnk.logout=link=Logout
-portal.sub.login=login
+portal.sub.login=//input[contains(@name,'login')]
portal.adr.portal=/portal/
portal.frm.login.content=login-content
portal.inp.password=//input[contains(@id,'j_password')]
@@ -14,7 +14,7 @@
user.login.frm.main=relative=up
user.login.sub.portal=cancel
user.login.lnk.logout=link=Logout
-user.login.sub.login=login
+user.login.sub.login=//input[contains(@name,'login')]
user.login.inp.password=//input[contains(@id,'j_password')]
user.login.inp.username=//input[contains(@id,'j_username')]
user.login.frm.login=login-content
@@ -68,8 +68,8 @@
iden.man.lnk.search.user=//a[contains(@id,'user-form:search-user-link')]
iden.man.lnk.usertab=//a[contains(@id,'role-temp-form:manage-users')]
iden.man.lnk.usermain=//a[contains(@id,'user-temp-form1:user-adm-link')]
-iden.man.lnk.roletab=//a[contains(@id,'user-temp-form:role-mgm-link')]
-iden.man.lnk.rolemain=//a[contains(@id, 'role-temp-form1:role-admin-link')]
+iden.man.lnk.roletab=//a[contains(@id,'role-mgm-link')]
+iden.man.lnk.rolemain=//a[contains(@id, 'role-adm-link')]
iden.man.lnk.usermang.main=//a[contains(@id,'user-temp-form1:assign-role-link')]
iden.man.lnk.usermang.main2=//a[contains(@id,'user-temp-form1:user-mgm-link')]
iden.man.lnk.create.user=//a[contains(@id,':user-form:create-user-link')]
@@ -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')]
@@ -194,7 +194,7 @@
cms.file.work.cms.wf.table=//div[@id='center']/div/div/table[2]
cms.file.work.cms.fv.table=//div[@id='center']/div/div/table
cms.file.work.cms.t.ver=//div[@id=''center'']/div/div/table/tbody/tr[{0}]/td[1]/a
-cms.file.work.wysiwyg.editor.locator=mce_editor_0
+cms.file.work.wysiwyg.editor.locator=elm1_ifr
# CMSSecureTestCase
@@ -283,6 +283,25 @@
portal.admin.sel.pp.listener=//select[contains(@id,'edit-prop-form:listener')]
portal.admin.tbl.pp.props=//table[contains(@id,'common-manage-prop-form:prop-data-table')]
+# AdminPortalWizardTestCase
+
+portal.admin.wiz.sub.sub=_jbpnsAdminPortletWindowsnpbj:j_id20:wiz-conf-form:confirm
+portal.admin.wiz.sub.can=_jbpnsAdminPortletWindowsnpbj:j_id20:wiz-conf-form:cancel
+portal.admin.wiz.lnk.reg.c=_jbpnsAdminPortletWindowsnpbj:j_id28:region-wiz-form:region-1
+portal.admin.wiz.sub.portlet.type=_jbpnsAdminPortletWindowsnpbj:j_id169:portlet-wiz-form:wiz-change
+portal.admin.wiz.sel.portlet.type=_jbpnsAdminPortletWindowsnpbj:j_id169:portlet-wiz-form:menu
+portal.admin.wiz.lnk.wiz.mode=Link=*Switch to wizard mode*
+portal.admin.wiz.inp.submit.pagecreate=//input[contains(@id,'create-page-form:create-page')]
+portal.admin.wiz.inp.pagename=//input[contains(@id,'create-page-form:pageName')]
+portal.admin.wiz.inp.portalname=//input[contains(@id,'create-portal-form:name')]
+portal.admin.wiz.inp.submit.createportal=//input[contains(@id,'create-portal-form:create-portal')]
+portal.admin.wiz.tab.portalobj.id=Link=Admin
+portal.admin.wiz.lnk.portals.id=link=*Portal Objects*
+portal.admin.wiz.tab.portal.admin=//table[contains(@id,'obj-nav-form:portal-datatable')]
+portal.admin.wiz.por.tl.main=//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]
+portal.admin.wiz.ul.paginator=//body/div[2]/div/div/div[2]/table/tbody/tr/td/div/div/div/div/div[6]/form[2]/ul[2]
+portal.admin.wiz.ul.paginator=//html/body/div[2]/div/div/div[2]/table/tbody/tr/td/div/div/div/div/div[6]/form[2]/table
+
# DashboardsTestCase
portal.dash.t.dh.sub.update=//form[contains(@id,'common-edit-theme-form')]/input[@type='submit']
@@ -433,6 +452,19 @@
portal.e2e.pag.tl.coord=//a[contains(@id,''pages-datatable:{0}:edit-coord'')]
portal.e2e.div.por.cont=content-container
+portal.e2e.inp.goo.search=query-input
+portal.e2e.sub.goo.search=submit-button
+portal.e2e.inp.net.search=//div[@id='bilto']/div/div[3]/form/input[1]
+portal.e2e.sub.net.search=//div[@id='bilto']/div/div[3]/form/input[2]
+
+# AdminPortalWizardTestCase
+
+portal.admin.wiz.sel.portlet.type=//select[contains(@id,'portlet-wiz-form:menu')]
+portal.admin.wiz.sub.portlet.type=//input[contains(@id,'portlet-wiz-form:wiz-change')]
+portal.admin.wiz.lnk.reg.c=//a[contains(@id,'region-wiz-form:region-1')]
+portal.admin.wiz.sub.sub=//input[contains(@id,'wiz-conf-form:confirm')]
+portal.admin.wiz.sub.can=//input[contains(@id,'wiz-conf-form:cancel')]
+
# PortalSamplesTestCase
samples.ses.lnk.invalidate=link=invalidate
@@ -528,6 +560,22 @@
samples.cache.2render=//div[@id='regionB']/div[2]/table/tbody/tr[2]/td[2]/div/div[2]/div
samples.cache.1render=//div[@id='regionB']/div[1]/table/tbody/tr[2]/td[2]/div/div[2]/div
+samples.url.lnk=link=URL portlet
+samples.url.inp.name1=name
+samples.url.inp.value1=value
+samples.url.sub1=
+samples.url.div1=
+samples.url.lnk1.blue
+samples.url.lnk1.red=
+samples.url.lnk1.white
+samples.url.inp.name2=
+samples.url.inp.value2=
+samples.url.sub2=
+samples.url.div2=//html/body/div[2]/div/div/div[2]/div[2]/div[2]/table/tbody/tr[2]/td[2]/div/table
+samples.url.lnk2.blue=
+samples.url.lnk2.red=//html/body/div[2]/div/div/div[2]/div[2]/div[2]/table/tbody/tr[2]/td[2]/div/a[2]
+samples.url.lnk2.white=
+
# PortalAjaxSamplesTestCase
samples.ajax.ses.lnk.invalidate=link=invalidate
@@ -556,7 +604,7 @@
samples.ajax.pub.div.3.juu=//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr/td[2]/input
samples.ajax.pub.div.2.juu=juu
samples.ajax.pub.div.2.foo=//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr/td[2]/input
-samples.ajax.pub.div.1.bar=bar
+samples.ajax.pub.div.1.bar=//html/body/div[2]/div/div/div[2]/div/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/form/table/tbody/tr[2]/td[2]/input
samples.ajax.pub.div.1.foo=foo
samples.ajax.pub.lnk=//ul[@id='tabsHeader']/li[4]/ul/li[12]/a
samples.ajax.pevt.div.p3.max=//html/body/div[2]/div/div/div[2]/div[2]/div/div[3]/div/div/table/tbody/tr/td[2]/div/div[2]/span/a
@@ -621,3 +669,101 @@
samples.ajax.cache.lnk.1act=link=action
samples.ajax.cache.div.2.render=//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/div[2]/div
samples.ajax.cache.div.1.render=//html/body/div[2]/div/div/div[2]/div[2]/div/div/div/div/table/tbody/tr[2]/td[2]/div/div/div[2]/div
+
+samples.ajax.url.lnk=//ul[@id='tabsHeader']/li[4]/ul/li[15]/a
+samples.ajax.url.inp.name1=name
+samples.ajax.url.inp.value1=value
+samples.ajax.url.sub1=
+samples.ajax.url.div1=
+samples.ajax.url.lnk1.blue
+samples.ajax.url.lnk1.red=
+samples.ajax.url.lnk1.white
+samples.ajax.url.inp.name2=
+samples.ajax.url.inp.value2=
+samples.ajax.url.sub2=
+samples.ajax.url.div2=//html/body/div[2]/div/div/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/table
+samples.ajax.url.lnk2.blue=
+samples.ajax.url.lnk2.red=//div[contains(@id,'expander')]/div[2]/div[2]/div/div[2]/div/div/table/tbody/tr[2]/td[2]/div/div/a[2]
+samples.ajax.url.lnk2.white=
+
+samples.bookstore.adr=/portal/portal/default/Bookstore+sample
+samples.bookstore.bookstore.lnk.start=link=Start Shopping
+samples.bookstore.bookstore.lnk.detail=link=Java Servlet and JSP Cookbook
+samples.bookstore.catalog.icon=//div[@id='regionA']/div[2]/table/tbody/tr[1]/td[2]/div[2]/span[1]/a@class
+samples.bookstore.catalog.tr.pref=//tr[@id='BookCatalogPortlet_
+samples.bookstore.catalog.tr.suf.detail=']/td[1]/a/strong
+samples.bookstore.catalog.tr.suf.add=']/td[4]/p/strong/a
+samples.bookstore.catalog.tr.suf.count=']/td[3]
+samples.bookstore.detail.image.pref=//img[@alt='
+samples.bookstore.detail.image.suf=']
+samples.bookstore.detail.bktitle=bookDetailPortlet_title
+samples.bookstore.detail.bkauthor=bookDetailPortlet_author
+samples.bookstore.detail.lnk.add=BookDetailPortlet_AddBookLink
+samples.bookstore.showcart.lnk.clear=link=Clear Cart
+samples.bookstore.showcart.header=BookShowCartPortlet_header
+samples.bookstore.showcart.table=BookShowCartPortlet_cardTable
+samples.bookstore.showcart.table.tr.pref=//tr[@id='BookShowCartPortlet_cardTable_
+samples.bookstore.showcart.table.tr.count.suf=']/td[1]
+samples.bookstore.showcart.table.tr.title.suf=']/td[2]/strong/a
+samples.bookstore.showcart.table.tr.remove.suf=']/td[4]/strong/a
+samples.bookstore.cashier.amount=BookCashierPortlet_amount
+samples.bookstore.cashier.inp.name=cardname
+samples.bookstore.cashier.inp.num=cardnum
+samples.bookstore.cashier.submit=cashierSubmit
+samples.bookstore.receipt.header=BookReceiptPortlet_header
+
+sso.cas.adr.portal=/portal
+sso.cas.adr.portal.admin=/portal/auth/portal/admin
+sso.cas.adr.portal.default=/portal/auth/portal/default
+sso.cas.lnk.login=link=Login
+sso.cas.lnk.admin=link=Admin
+sso.cas.lnk.weather=link=Weather
+sso.cas.lnk.cp.dashboard=link=Copy to my dashboard
+sso.cas.lnk.conf.dashboard=link=Configure dashboard
+sso.cas.lnk.dashboard=link=Dashboard
+sso.cas.lnk.logout=link=Logout
+sso.cas.forbidden.element=//h1
+sso.cas.cas.input.username=username
+sso.cas.cas.input.password=password
+sso.cas.cas.submit.login=//input[@value='LOGIN']
+sso.cas.cas.image=//img[@alt='Central Authentication Service']
+
+sso.josso.adr.portal=/portal
+sso.josso.adr.portal.admin=/portal/auth/portal/admin
+sso.josso.adr.portal.default=/portal/auth/portal/default
+sso.josso.adr.portal.test.session=/portal/auth/portal/default/Test/Session+test
+sso.josso.lnk.login=link=Login
+sso.josso.lnk.admin=link=Admin
+sso.josso.lnk.weather=link=Weather
+sso.josso.lnk.cp.dashboard=link=Copy to my dashboard
+sso.josso.lnk.conf.dashboard=link=Configure dashboard
+sso.josso.lnk.dashboard=link=Dashboard
+sso.josso.lnk.logout=link=Logout
+sso.josso.forbidden.element=//h1
+sso.josso.josso.input.username=josso_username
+sso.josso.josso.input.password=josso_password
+sso.josso.josso.submit.login=//input[@value='Login']
+sso.josso.josso.image=//img[@alt='Java Open Single SignOn']
+sso.josso.cms.file.tbl.cms.file=//div[@id='center']/div/div/div[3]/table
+sso.josso.samples.ses.sub.pscope=portlet
+sso.josso.samples.ses.inp.val=value
+sso.josso.samples.ses.inp.nam=name
+
+sso.tomcatvalve.adr.portal=/portal
+sso.tomcatvalve.adr.example=/TomcatSSOValveExampleApp
+sso.tomcatvalve.adr.jmx=/jmx-console/
+sso.tomcatvalve.ex.title=//h1
+sso.tomcatvalve.ex.inp.username=j_username
+sso.tomcatvalve.ex.inp.password=j_password
+sso.tomcatvalve.ex.login=//input[@value='Login']
+sso.tomcatvalve.ex.logout=//input[@value='Logout']
+sso.tomcatvalve.ex.logged.user.label=//tr[1]/td[2]/b
+sso.tomcatvalve.ex.logged.role.auth.label=//tr[4]/td[2]/b
+sso.tomcatvalve.jmx.title.element=//h1
+sso.tomcatvalve.jmx.image=//img[@alt='JBoss']
+sso.tomcatvalve.lnk.login=link=Login
+sso.tomcatvalve.lnk.logout=link=Logout
+sso.tomcatvalve.lnk.default=link=default
+sso.tomcatvalve.lnk.admin=link=Admin
+sso.tomcatvalve.lnk.wsrp=link=WSRP
+sso.tomcatvalve.lnk.default.dashboard=link=Dashboard
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -9,90 +9,182 @@
import org.testng.annotations.Test;
/**
+ * AdminPortalTestCase is responsible for testing fundamental portal admin
+ * features of JBoss Portal.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
+ *
*/
-@Test(groups = { "admin_portal" }, enabled = true, description = "Partal administrating.")
+// TODO - adding of simple portlet - more portlet types
+@Test(enabled = true, groups="portal_admin")
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 LNK_PP_PROP_DELETE = getProp(casePfx+"lnk.pp.prop.delete","//a[contains(@id,''common-manage-prop-form:prop-data-table:{0}:delete'')]");
- private final String SUB_PP_PROPVAL_UPDATE = getProp(casePfx+"sub.pp.propval.update","//input[contains(@id,'common-manage-prop-form:update')]");
- private final String INP_PP_PROP_VAL = getProp(casePfx+"inp.pp.prop.val","//input[contains(@id,''common-manage-prop-form:prop-data-table:{0}:prop-value-input'')]");
- private final String SUB_PPA_FORM_UPDATE = getProp(casePfx+"sub.ppa.form.update","//input[contains(@id,'common-edit-page-error-form:update')]");
- private final String INP_PPA_RES_SELECT = getProp(casePfx+"inp.ppa.res.select","//input[contains(@id,'common-edit-page-error-form:page-res-select')]");
- private final String SEL_PPA_NF_SELECT = getProp(casePfx+"sel.ppa.nf.select","//select[contains(@id,'common-edit-page-error-form:page-not-found-select')]");
- private final String SEL_PPA_INTERNAL_SELECT = getProp(casePfx+"sel.ppa.internal.select","//select[contains(@id,'common-edit-page-error-form:page-internal-select')]");
- private final String SEL_PPA_ERROR_SELECT = getProp(casePfx+"sel.ppa.error.select","//select[contains(@id,'common-edit-page-error-form:page-error-select')]");
- private final String SEL_PPA_CONTROL_SELECT = getProp(casePfx+"sel.ppa.control.select","//select[contains(@id,'common-edit-page-error-form:page-control-select')]");
- private final String SEL_PPA_ACCESS_SELECT = getProp(casePfx+"sel.ppa.access.select","//select[contains(@id,'common-edit-page-error-form:page-access-select')]");
- private final String CHK_PPA_RES_CHECK = getProp(casePfx+"chk.ppa.res.check","//input[contains(@id,'common-edit-page-error-form:page-res-check')]");
- private final String CHK_PPA_NF_CHECK = getProp(casePfx+"chk.ppa.nf.check","//input[contains(@id,'common-edit-page-error-form:page-not-found-check')]");
- private final String CHK_PPA_INTERNAL_CHECK = getProp(casePfx+"chk.ppa.internal.check","//input[contains(@id,'common-edit-page-error-form:page-internal-check')]");
- private final String CHK_PPA_ERROR_CHECK = getProp(casePfx+"chk.ppa.error.check","//input[contains(@id,'common-edit-page-error-form:page-error-check')]");
- private final String CHK_PPA_CONTROL_CHECK = getProp(casePfx+"chk.ppa.control.check","//input[contains(@id,'common-edit-page-error-form:page-control-check')]");
- private final String CHK_PPA_ACCESS_CHECK = getProp(casePfx+"chk.ppa.access.check","//input[contains(@id,'common-edit-page-error-form:page-access-check')]");
- private final String SUB_PP_ERROR_FORM_UPDATE = getProp(casePfx+"sub.pp.error.form.update","//input[contains(@id,'common-edit-portal-error-form:update')]");
- private final String INP_PP_RES_INPUT = getProp(casePfx+"inp.pp.res.input","//input[contains(@id,'common-edit-portal-error-form:portal-res-input')]");
- private final String SEL_PP_NF_SELECT = getProp(casePfx+"sel.pp.nf.select","//select[contains(@id,'common-edit-portal-error-form:portal-not-found-select')]");
- private final String SEL_PP_INTERNAL_SELECT = getProp(casePfx+"sel.pp.internal.select","//select[contains(@id,'common-edit-portal-error-form:portal-internal-select')]");
- private final String SEL_PP_ERROR_SELECT = getProp(casePfx+"sel.pp.error.select","//select[contains(@id,'common-edit-portal-error-form:portal-error-select')]");
- private final String SEL_PP_UNAVAIL_SELECT = getProp(casePfx+"sel.pp.unavail.select","//select[contains(@id,'common-edit-portal-error-form:portal-unavail-select')]");
- private final String SEL_PP_ACCESS_SELECT = getProp(casePfx+"sel.pp.access.select","//select[contains(@id,'common-edit-portal-error-form:portal-access-select')]");
- private final String CHK_PP_RES_CHECK = getProp(casePfx+"chk.pp.res.check","//input[contains(@id,'common-edit-portal-error-form:portal-res-check')]");
- private final String CHK_PP_NF_CHECK = getProp(casePfx+"chk.pp.nf.check","//input[contains(@id,'common-edit-portal-error-form:portal-not-found-check')]");
- private final String CHK_PP_INTERNAL_CHECK = getProp(casePfx+"chk.pp.internal.check","//input[contains(@id,'common-edit-portal-error-form:portal-internal-check')]");
- private final String CHK_PP_ERROR_CHECK = getProp(casePfx+"chk.pp.error.check","//input[contains(@id,'common-edit-portal-error-form:portal-error-check')]");
- private final String CHK_PP_ACCESS_CHECK = getProp(casePfx+"chk.pp.access.check","//input[contains(@id,'common-edit-portal-error-form:portal-access-check')]");
- private final String CHK_PP_UNAVAIL_CHECK = getProp(casePfx+"chk.pp.unavail.check","//input[contains(@id,'common-edit-portal-error-form:portal-unavail-check')]");
- private final String SUB_PP_PROPADD = getProp(casePfx+"sub.pp.propadd","//input[contains(@id,'common-edit-prop-form:add-property')]");
- private final String INP_PP_PROPNAME = getProp(casePfx+"inp.pp.propname","//input[contains(@id,'common-edit-prop-form:property')]");
- private final String SUB_PP_LISTENER = getProp(casePfx+"sub.pp.listener","//input[contains(@id,'edit-prop-form:update')]");
- private final String SEL_PP_LISTENER = getProp(casePfx+"sel.pp.listener","//select[contains(@id,'edit-prop-form:listener')]");
- private final String TBL_PP_PROPS = getProp(casePfx+"tbl.pp.props","//table[contains(@id,'common-manage-prop-form:prop-data-table')]");
+ 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')]");
- private final String SUB_LAYOUT_ADD_CENTER = getProp(casePfx + "sub.layout.add.center", "//input[contains(@id,'layoutForm:a_center')]");
- private final String INP_WINDOW_NAME = getProp(casePfx + "inp.window.name", "//input[contains(@id,'windowForm:windowName')]");
- private final String SUBMIT_RENAME_PORTAL = getProp(casePfx + "submit.rename.portal", "//input[contains(@id,'renameForm:rename')]");
- private final String INPUT_RENAME_PORTAL = getProp(casePfx + "input.rename.portal", "//input[contains(@id,'renameForm:newName')]");
- private final String SUBMIT_DELETE_PORTAL_CONF = getProp(casePfx + "submit.delete.portal.conf", "//input[contains(@id,'delete-view:confirm-form:delete')]");
- private final String INPUT_SUBMIT_PAGECREATE = getProp(casePfx + "input.submit.pagecreate", "//input[contains(@id,'create-page-form:create-page')]");
- private final String INPUT_PAGENAME = getProp(casePfx + "input.pagename", "//input[contains(@id,'create-page-form:pageName')]");
- private final String INPUT_PORTALNAME = getProp(casePfx + "input.portalname", "//input[contains(@id,'create-portal-form:name')]");
- private final String INPUT_SUBMIT_CREATEPORTAL = getProp(casePfx + "input.submit.createportal", "//input[contains(@id,'create-portal-form:create-portal')]");
- private final String TAB_PORTALOBJ_ID = getProp(casePfx + "tab.portalobj.id", "Link=Admin");
- private final String LINK_PORTALS_ID = getProp(casePfx + "link.portals.id", "link=*Portal Objects*");
- private final String LINK_PORTAL_HOME = getProp(casePfx + "link.portal.home", "//a[contains(@id,'obj-temp-form:object-link-0')]");
- private final String TABLE_PORTAL_ADMIN = getProp(casePfx + "table.portal.admin", "//table[contains(@id,'obj-nav-form:portal-datatable')]");
- private final String POR_TL_MAIN = getProp(casePfx + "por.tl.main", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]");
- private final String POR_TL_SECURITY = getProp(casePfx + "por.tl.security", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:security-link'')]");
- private final String POR_TL_PROPERTIES = getProp(casePfx + "por.tl.properties", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:prop-link'')]");
- private final String POR_TL_THEME = getProp(casePfx + "por.tl.theme", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:theme-link'')]");
- private final String POR_TL_RENAME = getProp(casePfx + "por.tl.rename", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:rename'')]");
- private final String POR_TL_DELETE = getProp(casePfx + "por.tl.delete", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:delete'')]");
- private final String POR_TL_MAKEDEF = getProp(casePfx + "por.tl.makedef", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:default-link'')]");
- private final String TABLE_PORTALPAGE_ADMIN = getProp(casePfx + "table.portalpage.admin", "//table[contains(@id,'obj-nav-form:pages-datatable')]");
- private final String PAG_TL_MAIN = getProp(casePfx + "pag.tl.main", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:object-link'')]");
- private final String PAG_TL_LAYOUT = getProp(casePfx + "pag.tl.layout", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:edit-page-layout'')]");
- private final String PAG_TL_SECURITY = getProp(casePfx + "pag.tl.security", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:security-link'')]");
- private final String PAG_TL_PROPERTIES = getProp(casePfx + "pag.tl.properties", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:prop-link'')]");
- private final String PAG_TL_THEME = getProp(casePfx + "pag.tl.theme", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:theme-link'')]");
- private final String PAG_TL_RENAME = getProp(casePfx + "pag.tl.rename", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-link'')]");
- private final String PAG_TL_DISPLAY = getProp(casePfx + "pag.tl.display", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-display'')]");
- private final String PAG_TL_DELETE = getProp(casePfx + "pag.tl.delete", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:delete-link'')]");
- private final String PAG_TL_MAKEDEF = getProp(casePfx + "pag.tl.makedef", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:default-link'')]");
+ private final String CHK_SEC_RUN_PR = getLoc(casePfx + "chk.sec.run.pr", "//input[contains(@id,'common-edit-security-form:cars_2:3')]");
+ private final String CHK_SEC_RUN_P = getLoc(casePfx + "chk.sec.run.p", "//input[contains(@id,'common-edit-security-form:cars_2:2')]");
+ private final String CHK_SEC_RUN_VR = getLoc(casePfx + "chk.sec.run.vr", "//input[contains(@id,'common-edit-security-form:cars_2:1')]");
+ private final String CHK_SEC_RUN_V = getLoc(casePfx + "chk.sec.run.v", "//input[contains(@id,'common-edit-security-form:cars_2:0')]");
+ private final String CHK_SEC_RU_PR = getLoc(casePfx + "chk.sec.ru.pr", "//input[contains(@id,'common-edit-security-form:cars_1:3')]");
+ private final String CHK_SEC_RU_P = getLoc(casePfx + "chk.sec.ru.p", "//input[contains(@id,'common-edit-security-form:cars_1:2')]");
+ private final String CHK_SEC_RU_VR = getLoc(casePfx + "chk.sec.ru.vr", "//input[contains(@id,'common-edit-security-form:cars_1:1')]");
+ private final String CHK_SEC_RU_V = getLoc(casePfx + "chk.sec.ru.v", "//input[contains(@id,'common-edit-security-form:cars_1:0')]");
+ private final String CHK_SEC_RA_PR = getLoc(casePfx + "chk.sec.ra.pr", "//input[contains(@id,'common-edit-security-form:cars_0:3')]");
+ private final String CHK_SEC_RA_P = getLoc(casePfx + "chk.sec.ra.p", "//input[contains(@id,'common-edit-security-form:cars_0:2')]");
+ private final String CHK_SEC_RA_VR = getLoc(casePfx + "chk.sec.ra.vr", "//input[contains(@id,'common-edit-security-form:cars_0:1')]");
+ private final String CHK_SEC_RA_V = getLoc(casePfx + "chk.sec.ra.v", "//input[contains(@id,'common-edit-security-form:cars_0:0')]");
+
+ private final String MES_P1 = getMess(casePfx + "p1", "Who's online portlet");
+ private final String MES_P1_T = getMess(casePfx + "p1.t", "Current users");
+ private final String MES_P1_W = getMess(casePfx + "p1.w", "CurrentUsersPortletWindow");
+ private final String MES_P2 = getMess(casePfx + "p1", "CharsetPortletInstance");
+ private final String MES_P2_T = getMess(casePfx + "p1.t", "Test charset");
+ private final String MES_P2_W = getMess(casePfx + "p1.w", "CharsetPortletInstance");
+ private final String MES_P3 = getMess(casePfx + "p1", "ModePortletInstance");
+ private final String MES_P3_T = getMess(casePfx + "p1.t", "Mode Portlet");
+ private final String MES_P3_W = getMess(casePfx + "p1.w", "ModePortletWindow");
+ private final String MES_P4 = getMess(casePfx + "p1", "Catalog Portlet");
+ private final String MES_P4_T = getMess(casePfx + "p1.t", "Catalog Portlet");
+ private final String MES_P4_W = getMess(casePfx + "p1.w", "Catalog Portlet");
+ private final String LNK_PP_PROP_DELETE = getLoc(casePfx + "lnk.pp.prop.delete",
+ "//a[contains(@id,''common-manage-prop-form:prop-data-table:{0}:delete'')]");
+ private final String SUB_PP_PROPVAL_UPDATE = getLoc(casePfx + "sub.pp.propval.update", "//input[contains(@id,'common-manage-prop-form:update')]");
+ private final String INP_PP_PROP_VAL = getLoc(casePfx + "inp.pp.prop.val",
+ "//input[contains(@id,''common-manage-prop-form:prop-data-table:{0}:prop-value-input'')]");
+ private final String SUB_PPA_FORM_UPDATE = getLoc(casePfx + "sub.ppa.form.update", "//input[contains(@id,'common-edit-page-error-form:update')]");
+ private final String INP_PPA_RES_SELECT = getLoc(casePfx + "inp.ppa.res.select", "//input[contains(@id,'common-edit-page-error-form:page-res-select')]");
+ private final String SEL_PPA_NF_SELECT = getLoc(casePfx + "sel.ppa.nf.select",
+ "//select[contains(@id,'common-edit-page-error-form:page-not-found-select')]");
+ private final String SEL_PPA_INTERNAL_SELECT = getLoc(casePfx + "sel.ppa.internal.select",
+ "//select[contains(@id,'common-edit-page-error-form:page-internal-select')]");
+ private final String SEL_PPA_ERROR_SELECT = getLoc(casePfx + "sel.ppa.error.select",
+ "//select[contains(@id,'common-edit-page-error-form:page-error-select')]");
+ private final String SEL_PPA_CONTROL_SELECT = getLoc(casePfx + "sel.ppa.control.select",
+ "//select[contains(@id,'common-edit-page-error-form:page-control-select')]");
+ private final String SEL_PPA_ACCESS_SELECT = getLoc(casePfx + "sel.ppa.access.select",
+ "//select[contains(@id,'common-edit-page-error-form:page-access-select')]");
+ private final String CHK_PPA_RES_CHECK = getLoc(casePfx + "chk.ppa.res.check", "//input[contains(@id,'common-edit-page-error-form:page-res-check')]");
+ private final String CHK_PPA_NF_CHECK = getLoc(casePfx + "chk.ppa.nf.check", "//input[contains(@id,'common-edit-page-error-form:page-not-found-check')]");
+ private final String CHK_PPA_INTERNAL_CHECK = getLoc(casePfx + "chk.ppa.internal.check",
+ "//input[contains(@id,'common-edit-page-error-form:page-internal-check')]");
+ private final String CHK_PPA_ERROR_CHECK = getLoc(casePfx + "chk.ppa.error.check", "//input[contains(@id,'common-edit-page-error-form:page-error-check')]");
+ private final String CHK_PPA_CONTROL_CHECK = getLoc(casePfx + "chk.ppa.control.check",
+ "//input[contains(@id,'common-edit-page-error-form:page-control-check')]");
+ private final String CHK_PPA_ACCESS_CHECK = getLoc(casePfx + "chk.ppa.access.check",
+ "//input[contains(@id,'common-edit-page-error-form:page-access-check')]");
+ private final String SUB_PP_ERROR_FORM_UPDATE = getLoc(casePfx + "sub.pp.error.form.update",
+ "//input[contains(@id,'common-edit-portal-error-form:update')]");
+ private final String INP_PP_RES_INPUT = getLoc(casePfx + "inp.pp.res.input", "//input[contains(@id,'common-edit-portal-error-form:portal-res-input')]");
+ private final String SEL_PP_NF_SELECT = getLoc(casePfx + "sel.pp.nf.select",
+ "//select[contains(@id,'common-edit-portal-error-form:portal-not-found-select')]");
+ private final String SEL_PP_INTERNAL_SELECT = getLoc(casePfx + "sel.pp.internal.select",
+ "//select[contains(@id,'common-edit-portal-error-form:portal-internal-select')]");
+ private final String SEL_PP_ERROR_SELECT = getLoc(casePfx + "sel.pp.error.select",
+ "//select[contains(@id,'common-edit-portal-error-form:portal-error-select')]");
+ private final String SEL_PP_UNAVAIL_SELECT = getLoc(casePfx + "sel.pp.unavail.select",
+ "//select[contains(@id,'common-edit-portal-error-form:portal-unavail-select')]");
+ private final String SEL_PP_ACCESS_SELECT = getLoc(casePfx + "sel.pp.access.select",
+ "//select[contains(@id,'common-edit-portal-error-form:portal-access-select')]");
+ private final String CHK_PP_RES_CHECK = getLoc(casePfx + "chk.pp.res.check", "//input[contains(@id,'common-edit-portal-error-form:portal-res-check')]");
+ private final String CHK_PP_NF_CHECK = getLoc(casePfx + "chk.pp.nf.check", "//input[contains(@id,'common-edit-portal-error-form:portal-not-found-check')]");
+ private final String CHK_PP_INTERNAL_CHECK = getLoc(casePfx + "chk.pp.internal.check",
+ "//input[contains(@id,'common-edit-portal-error-form:portal-internal-check')]");
+ private final String CHK_PP_ERROR_CHECK = getLoc(casePfx + "chk.pp.error.check",
+ "//input[contains(@id,'common-edit-portal-error-form:portal-error-check')]");
+ private final String CHK_PP_ACCESS_CHECK = getLoc(casePfx + "chk.pp.access.check",
+ "//input[contains(@id,'common-edit-portal-error-form:portal-access-check')]");
+ private final String CHK_PP_UNAVAIL_CHECK = getLoc(casePfx + "chk.pp.unavail.check",
+ "//input[contains(@id,'common-edit-portal-error-form:portal-unavail-check')]");
+ private final String SUB_PP_PROPADD = getLoc(casePfx + "sub.pp.propadd", "//input[contains(@id,'common-edit-prop-form:add-property')]");
+ private final String INP_PP_PROPNAME = getLoc(casePfx + "inp.pp.propname", "//input[contains(@id,'common-edit-prop-form:property')]");
+ private final String SUB_PP_LISTENER = getLoc(casePfx + "sub.pp.listener", "//input[contains(@id,'edit-prop-form:update')]");
+ private final String SEL_PP_LISTENER = getLoc(casePfx + "sel.pp.listener", "//select[contains(@id,'edit-prop-form:listener')]");
+ private final String TBL_PP_PROPS = getLoc(casePfx + "tbl.pp.props", "//table[contains(@id,'common-manage-prop-form:prop-data-table')]");
+
+ private final String SUB_LAYOUT_ADD_CENTER = getLoc(casePfx + "sub.layout.add.center", "//input[contains(@id,'layoutForm:a_center')]");
+ private final String SUB_LAYOUT_ADD_LEFT = getLoc(casePfx + "sub.layout.add.left", "//input[contains(@id,'layoutForm:a_left')]");
+ private final String INP_WINDOW_NAME = getLoc(casePfx + "inp.window.name", "//input[contains(@id,'windowForm:windowName')]");
+ private final String SUBMIT_RENAME_PORTAL = getLoc(casePfx + "submit.rename.portal", "//input[contains(@id,'renameForm:rename')]");
+ private final String INPUT_RENAME_PORTAL = getLoc(casePfx + "input.rename.portal", "//input[contains(@id,'renameForm:newName')]");
+ private final String SUBMIT_DELETE_PORTAL_CONF = getLoc(casePfx + "submit.delete.portal.conf", "//input[contains(@id,'delete-view:confirm-form:delete')]");
+ private final String INPUT_SUBMIT_PAGECREATE = getLoc(casePfx + "input.submit.pagecreate", "//input[contains(@id,'create-page-form:create-page')]");
+ private final String INPUT_PAGENAME = getLoc(casePfx + "input.pagename", "//input[contains(@id,'create-page-form:pageName')]");
+ private final String INPUT_PORTALNAME = getLoc(casePfx + "input.portalname", "//input[contains(@id,'create-portal-form:name')]");
+ private final String INPUT_SUBMIT_CREATEPORTAL = getLoc(casePfx + "input.submit.createportal", "//input[contains(@id,'create-portal-form:create-portal')]");
+ private final String TAB_PORTALOBJ_ID = getLoc(casePfx + "tab.portalobj.id", "Link=Admin");
+ private final String LINK_PORTALS_ID = getLoc(casePfx + "link.portals.id", "link=*Portal Objects*");
+ private final String LINK_PORTAL_HOME = getLoc(casePfx + "link.portal.home", "//a[contains(@id,'obj-temp-form:object-link-0')]");
+ private final String TABLE_PORTAL_ADMIN = getLoc(casePfx + "table.portal.admin", "//table[contains(@id,'obj-nav-form:portal-datatable')]");
+ private final String POR_TL_MAIN = getLoc(casePfx + "por.tl.main", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]");
+ private final String POR_TL_SECURITY = getLoc(casePfx + "por.tl.security", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:security-link'')]");
+ private final String POR_TL_PROPERTIES = getLoc(casePfx + "por.tl.properties", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:prop-link'')]");
+ private final String POR_TL_THEME = getLoc(casePfx + "por.tl.theme", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:theme-link'')]");
+ private final String POR_TL_RENAME = getLoc(casePfx + "por.tl.rename", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:rename'')]");
+ private final String POR_TL_DELETE = getLoc(casePfx + "por.tl.delete", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:delete'')]");
+ private final String POR_TL_MAKEDEF = getLoc(casePfx + "por.tl.makedef", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:default-link'')]");
+ private final String TABLE_PORTALPAGE_ADMIN = getLoc(casePfx + "table.portalpage.admin", "//table[contains(@id,'obj-nav-form:pages-datatable')]");
+ private final String PAG_TL_MAIN = getLoc(casePfx + "pag.tl.main", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:object-link'')]");
+ private final String PAG_TL_LAYOUT = getLoc(casePfx + "pag.tl.layout", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:edit-page-layout'')]");
+ private final String PAG_TL_SECURITY = getLoc(casePfx + "pag.tl.security", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:security-link'')]");
+ private final String PAG_TL_PROPERTIES = getLoc(casePfx + "pag.tl.properties", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:prop-link'')]");
+ private final String PAG_TL_THEME = getLoc(casePfx + "pag.tl.theme", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:theme-link'')]");
+ private final String PAG_TL_RENAME = getLoc(casePfx + "pag.tl.rename", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-link'')]");
+ private final String PAG_TL_DISPLAY = getLoc(casePfx + "pag.tl.display", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-display'')]");
+ private final String PAG_TL_DELETE = getLoc(casePfx + "pag.tl.delete", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:delete-link'')]");
+ private final String PAG_TL_MAKEDEF = getLoc(casePfx + "pag.tl.makedef", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:default-link'')]");
+
+ private final String PAG_THE_LAY = getLoc(casePfx + "pag.the.lay", "//select[contains(@id,'common-edit-theme-form:layout')]");
+ private final String PAG_THE_THE = getLoc(casePfx + "pag.the.the", "//select[contains(@id,'common-edit-theme-form:theme')]");
+ private final String PAG_THE_REN = getLoc(casePfx + "pag.the.ren", "//select[contains(@id,'common-edit-theme-form:renderSet')]");
+
+ private final String PAG_THE_CAN = getLoc(casePfx + "pag.the.can", "//html/body/div[2]/div/div/div[2]/table/tbody/tr/td/div/div/div/div/div/form/input[3]");
+ private final String PAG_THE_SUB = getLoc(casePfx + "pag.the.sub", "//html/body/div[2]/div/div/div[2]/table/tbody/tr/td/div/div/div/div/div/form/input[2]");
+
+ private final String PAG_REN_INP = getLoc(casePfx + "pag.ren.inp", "//input[contains(@id,'renameForm:newName')]");
+ private final String PAG_REN_SUB = getLoc(casePfx + "pag.ren.sub", "//input[contains(@id,'renameForm:rename')]");
+ private final String PAG_REN_CAN = getLoc(casePfx + "pag.ren.sub", "//input[contains(@id,'renameForm:cancel')]");
+
+ private final String PAG_LAY_C_SEL = getLoc(casePfx + "pag.lay.c.sel", "//select[contains(@id,'selectMany_center')]");
+ private final String PAG_LAY_L_SEL = getLoc(casePfx + "pag.lay.l.sel", "//select[contains(@id,'selectMany_left')]");
+
+ private final String PAG_LAY_C_UP = getLoc(casePfx + "pag.lay.c.up", "//input[contains(@id,'layoutForm:u_center')]");
+ private final String PAG_LAY_C_DOWN = getLoc(casePfx + "pag.lay.c.down", "//input[contains(@id,'layoutForm:d_center')]");
+ private final String PAG_LAY_C_DEL = getLoc(casePfx + "pag.lay.c.del", "//input[contains(@id,'layoutForm:l_center')]");
+ private final String PAG_LAY_L_UP = getLoc(casePfx + "pag.lay.l.up", "//input[contains(@id,'layoutForm:u_left')]");
+ private final String PAG_LAY_L_DOWN = getLoc(casePfx + "pag.lay.l.down", "//input[contains(@id,'layoutForm:d_left')]");
+ private final String PAG_LAY_L_DEL = getLoc(casePfx + "pag.lay.l.del", "//input[contains(@id,'layoutForm:l_left')]");
+
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ protected void logoutAfterTest() {
}
- @Test(enabled = true)
+ /**
+ * Creates a new portal.
+ *
+ * Uses portal admin interface to create a new portal. TODO: the existence
+ * of new portal should be tested in a more stronger way. The test only
+ * asserts the existence of portal name in the portals table and it asserts
+ * the existence of it's tool links, too.
+ */
+ // TODO: the existence of new portal should be tested in a more stronger way
+ @Test(enabled = true, description = "Creates a new portal")
public void testPortalCreate() {
selenium.click("link=Admin");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -108,20 +200,28 @@
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");
}
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate" })
+ /**
+ * Renames a portal. Firstly a portal name "TestRenPortal" is created the
+ * same way as in {@link AdminPortalTestCase#testPortalCreate()}. In portal
+ * admin interface, rename link is used to rename the portal to
+ * "AestPortal". At the end it checks that the former name of portal is not
+ * on the screen and the new name is appearing when listing portals.
+ */
+ // TODO findintable should be used for final assertions
+ @Test(enabled = true, dependsOnMethods = { "testPortalCreate" }, description = "Renames a portal")
public void testPortalRename() {
// first create a portal
@@ -147,9 +247,9 @@
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 created page already exist.");
+ Assert.assertFalse(selenium.isTextPresent(portalRenamed), "Not renamed page already exist.");
int r = findTableRow(TABLE_PORTAL_ADMIN, portalToRename, 0) - 1;
@@ -160,11 +260,18 @@
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");
}
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate" })
+ /**
+ * Deletes a portal. Firstly a portal name "TestDelete" is created the same
+ * way as in {@link AdminPortalTestCase#testPortalCreate()}. In portal admin
+ * interface, delete link is used to delete the portal. At the end it checks
+ * that the former name of portal is not on the screen.
+ */
+ // TODO findintable should be used for final assertions
+ @Test(enabled = true, dependsOnMethods = { "testPortalCreate" }, description = "Deletes a portal")
public void testPortalDelete() {
// first create a portal
@@ -194,15 +301,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(
@@ -210,11 +317,25 @@
clickIfVisible("link=Admin");
clickIfVisible(TAB_PORTALOBJ_ID);
- Assert.assertFalse(selenium.isTextPresent(portalToDelete));
+ Assert.assertFalse(selenium.isTextPresent(portalToDelete), "deleted portal name was found");
}
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate" })
+ /**
+ * Testing properties of portal. Firstly a portal name "TestProperties" is
+ * created the same way as in {@link AdminPortalTestCase#testPortalCreate()}
+ * . In portal admin interface, properties link is used to delete the
+ * portal. Following actions are then proceeded and their final states are
+ * asserted after logout/login:
+ * <ul>
+ * <li>change listener at first to release_sessions_listener_self and then
+ * to user_listener.</li>
+ * <li>add two properties: viliamProp/hier! and danielProp/ohne! and then
+ * delete viliamProp.</li>
+ * <li>change everything in Portal & Page Error Handling tables.</li>
+ * </ul>
+ */
+ @Test(enabled = true, dependsOnMethods = { "testPortalCreate" }, description = "Testing properties of portal")
public void testPortalProperties() {
// first create a portal
@@ -243,7 +364,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;
@@ -255,7 +376,7 @@
selenium.select(SEL_PP_LISTENER, "label=release_sessions_listener_self");
selenium.click(SUB_PP_LISTENER);
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.select(SEL_PP_LISTENER, "label=user_listener");
+ selenium.select(SEL_PP_LISTENER, "label=session_listener");
selenium.click(SUB_PP_LISTENER);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -265,29 +386,30 @@
final String propVal1 = "hier!";
final String propName2 = "danielProp";
final String propVal2 = "ohne!";
-
+
selenium.type(INP_PP_PROPNAME, propName1);
selenium.click(SUB_PP_PROPADD);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
r = findTableRow(TBL_PP_PROPS, propName1, 0) - 1;
-
- selenium.type(MessageFormat.format(INP_PP_PROP_VAL,r), propVal1);
+
+ selenium.type(MessageFormat.format(INP_PP_PROP_VAL, r), propVal1);
selenium.click(SUB_PP_PROPVAL_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
+
selenium.type(INP_PP_PROPNAME, propName2);
selenium.click(SUB_PP_PROPADD);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
r = findTableRow(TBL_PP_PROPS, propName2, 0) - 1;
-
- selenium.type(MessageFormat.format(INP_PP_PROP_VAL,r), propVal2);
+
+ selenium.type(MessageFormat.format(INP_PP_PROP_VAL, r), propVal2);
selenium.click(SUB_PP_PROPVAL_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
r = findTableRow(TBL_PP_PROPS, propName1, 0) - 1;
-
- selenium.click(MessageFormat.format(LNK_PP_PROP_DELETE,r));
+
+ selenium.click(MessageFormat.format(LNK_PP_PROP_DELETE, r));
selenium.waitForPageToLoad(PAGE_LOAD);
// Portal & Page Error Handling
@@ -345,10 +467,10 @@
selenium.waitForPageToLoad(PAGE_LOAD);
// logout login and property again
-
+
logout();
- login("admin","admin");
-
+ login("admin", "admin");
+
selenium.click("link=Admin");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -359,51 +481,60 @@
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;
selenium.click(MessageFormat.format(POR_TL_PROPERTIES, r));
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
// assert time!
-
- Assert.assertEquals(selenium.getSelectedLabel(SEL_PP_LISTENER),"user_listener");
-
+
+ Assert.assertEquals(selenium.getSelectedLabel(SEL_PP_LISTENER), "session_listener");
+
r = findTableRow(TBL_PP_PROPS, propName1, 0) - 1;
- Assert.assertFalse(r>0, propName1+" was deleted previously but now it's found in property table");
+ Assert.assertFalse(r > 0, propName1 + " was deleted previously but now it's found in property table");
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.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");
- Assert.assertEquals(selenium.getSelectedLabel(SEL_PP_INTERNAL_SELECT),"Display the default error message");
- 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.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");
- Assert.assertEquals(selenium.getSelectedLabel(SEL_PPA_INTERNAL_SELECT),"Display the default error message");
- Assert.assertEquals(selenium.getSelectedLabel(SEL_PPA_NF_SELECT),"Redirect to the specified resource");
- Assert.assertEquals(selenium.getValue(INP_PPA_RES_SELECT),"/WEB-INF/jsp/error/pagey.jsp");
-
+ 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),"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");
+ Assert.assertEquals(selenium.getSelectedLabel(SEL_PP_INTERNAL_SELECT), "Display the default error message");
+ 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),"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");
+ Assert.assertEquals(selenium.getSelectedLabel(SEL_PPA_INTERNAL_SELECT), "Display the default error message");
+ Assert.assertEquals(selenium.getSelectedLabel(SEL_PPA_NF_SELECT), "Redirect to the specified resource");
+ Assert.assertEquals(selenium.getValue(INP_PPA_RES_SELECT), "/WEB-INF/jsp/error/pagey.jsp");
+
}
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate" })
+ /**
+ * Adds a page to a portal. Firstly a portal name "TestAddPagePortal" is
+ * created the same way as in {@link AdminPortalTestCase#testPortalCreate()}
+ * . In portal admin interface, main link (title of portal) is used to
+ * navigate to its own tools. Form for creation of new page is then used to
+ * create page named "tToAddPage". At the end it checks that the name of pa
+ * is is appearing in "TestAddPagePortal" portal pages list.
+ */
+ // TODO findintable should be used for final assertions
+ @Test(enabled = true, dependsOnMethods = { "testPortalCreate" }, description = "Adds a page to a portal")
public void testAddPage() {
final String portalName = "TestAddPagePortal";
@@ -425,15 +556,27 @@
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");
}
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate", "testAddPage" })
+ /**
+ * Removes a page from a portal. Firstly a portal name
+ * "TestRemovePagePortal" is created the same way as in
+ * {@link AdminPortalTestCase#testPortalCreate()}. In portal admin
+ * interface, main link (title of portal) is used to navigate to its own
+ * tools. Form for creation of new page is then used to create page named
+ * "tRemPage" the same way as in {@link AdminPortalTestCase#testAddPage()}.
+ * The page is removed with the remove button afterwards. At the end it
+ * checks that the name of page is not appearing in "TestRemovePagePortal"
+ * portal pages list.
+ */
+ // TODO findintable should be used for final assertions
+ @Test(enabled = true, dependsOnMethods = { "testPortalCreate", "testAddPage" }, description = "Removes a page from a portal")
public void testRemovePage() {
final String portalName = "TestRemovePagePortal";
@@ -459,13 +602,26 @@
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");
}
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate", "testAddPage" })
+ /**
+ * Creates a "window" on a page. Firstly a portal name "toAddWindowPortal"
+ * is created the same way as in
+ * {@link AdminPortalTestCase#testPortalCreate()}. In portal admin
+ * interface, main link (title of portal) is used to navigate to its own
+ * tools. Form for creation of new page is then used to create page named
+ * "windowContainer" the same way as in
+ * {@link AdminPortalTestCase#testAddPage()}. The link "page layout" of
+ * "testAddPage" page is then clicked to add a window to this page.
+ * "Who's online portlet" is then added to windows called "myFancyWindow" on
+ * this page. Existence of text containing the name of window is asserted.
+ * At the page is loaded and the existence of the added portlet is asserted.
+ */
+ @Test(enabled = true, dependsOnMethods = { "testPortalCreate", "testAddPage" }, description = "Creates a 'window' on a page")
public void testCreateWindow() {
final String portalName = "toAddWindowPortal";
@@ -475,13 +631,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);
@@ -494,12 +644,7 @@
// click on the page layout
selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
+ waitFor(AJAX_LOAD);
selenium.click("link=Who's online portlet");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -508,28 +653,41 @@
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");
}
- @Test(enabled = true, dependsOnMethods = { "testPortalCreate", "testAddPage" })
+ /**
+ * Renames a page of a portal. Firstly a portal name "TestPortal" is created
+ * the same way as in {@link AdminPortalTestCase#testPortalCreate()}. In
+ * portal admin interface, main link (title of portal) is used to navigate
+ * to its own tools. Form for creation of new page is then used to create
+ * page named "PageToRename" the same way as in
+ * {@link AdminPortalTestCase#testAddPage()}.
+ *
+ * The rename link on the page is then clicked. The page is renamed to
+ * "PageWasRenamed". At first attempt the renaming is canceled, at the
+ * second attempt the new name is submitted. It is asserted that the new
+ * name is present in the page table and the previous name is not present.
+ */
+ @Test(enabled = true, dependsOnMethods = { "testPortalCreate", "testAddPage" }, description = "Renames a page of a portal")
public void testPageRename() {
String portalName = "TestPortal";
String pageName = "PageToRename";
+ String pageNewName = "PageWasRenamed";
- createPage("TestPortal", "PageToRename");
+ createPage(portalName, pageName);
openAndWait("/portal");
clickAndWait("link=Admin");
clickIfVisible(TAB_PORTALOBJ_ID);
clickIfVisible(LINK_PORTALS_ID);
- // selenium.setSpeed("8000");
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));
@@ -538,42 +696,424 @@
clickAndWait(MessageFormat.format(PAG_TL_RENAME, r));
+ selenium.type(PAG_REN_INP, pageNewName);
+ clickAndWait(PAG_REN_CAN);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ clickAndWait(MessageFormat.format(POR_TL_MAIN, r));
+
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageNewName, 0) - 1;
+ Assert.assertTrue(r < 0, "Not Renamed page was found in the table.");
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ 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_RENAME, r));
+
+ selenium.type(PAG_REN_INP, pageNewName);
+ clickAndWait(PAG_REN_SUB);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ clickAndWait(MessageFormat.format(POR_TL_MAIN, r));
+
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageNewName, 0) - 1;
+ Assert.assertTrue(r > -1, "Renamed page was not found in the table.");
+
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
+ Assert.assertTrue(r < 0, "Renamed page was found with the old name.");
+
}
- @Test(enabled = false)
+ /**
+ * Page security testing. New page "PageToSecure" is created in
+ * "TestPortal". The security page for the page is opened. It is asserted
+ * that all checkboxes are off by default. All checkboxes are set to
+ * "checked" and cancel is clicked. The security page is loaded again and it
+ * is asserted that all checkboxes are off after cancel. All checkboxes are
+ * then set to "checked" and update button is clicked. The security page is
+ * loaded again and it is asserted that all the checkboxes are in the
+ * "checked" state.
+ */
+ @Test(enabled = true, dependsOnMethods = { "testPortalCreate", "testAddPage" }, description = "Tests page security")
public void testPageSecurity() {
+
+ String portalName = "TestPortal";
+ String pageName = "PageToSecure";
+
+ createPage(portalName, pageName);
+
+ // cancel
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ 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_SECURITY, r));
+
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RA_V), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RA_VR), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RA_P), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RA_PR), "Checkbox should not be checked");
+
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RU_V), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RU_VR), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RU_P), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RU_PR), "Checkbox should not be checked");
+
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RUN_V), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RUN_VR), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RUN_P), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RUN_PR), "Checkbox should not be checked");
+
+ selenium.click(CHK_SEC_RA_V);
+ selenium.click(CHK_SEC_RA_VR);
+ selenium.click(CHK_SEC_RA_P);
+ selenium.click(CHK_SEC_RA_PR);
+
+ selenium.click(CHK_SEC_RU_V);
+ selenium.click(CHK_SEC_RU_VR);
+ selenium.click(CHK_SEC_RU_P);
+ selenium.click(CHK_SEC_RU_PR);
+
+ selenium.click(CHK_SEC_RUN_V);
+ selenium.click(CHK_SEC_RUN_VR);
+ selenium.click(CHK_SEC_RUN_P);
+ selenium.click(CHK_SEC_RUN_PR);
+
+ selenium.click(SUB_SEC_CANCEL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // update
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ 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));
+
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
+
+ clickAndWait(MessageFormat.format(PAG_TL_SECURITY, r));
+
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RA_V), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RA_VR), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RA_P), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RA_PR), "Checkbox should not be checked");
+
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RU_V), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RU_VR), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RU_P), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RU_PR), "Checkbox should not be checked");
+
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RUN_V), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RUN_VR), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RUN_P), "Checkbox should not be checked");
+ Assert.assertFalse(selenium.isChecked(CHK_SEC_RUN_PR), "Checkbox should not be checked");
+
+ selenium.click(CHK_SEC_RA_V);
+ selenium.click(CHK_SEC_RA_VR);
+ selenium.click(CHK_SEC_RA_P);
+ selenium.click(CHK_SEC_RA_PR);
+
+ selenium.click(CHK_SEC_RU_V);
+ selenium.click(CHK_SEC_RU_VR);
+ selenium.click(CHK_SEC_RU_P);
+ selenium.click(CHK_SEC_RU_PR);
+
+ selenium.click(CHK_SEC_RUN_V);
+ selenium.click(CHK_SEC_RUN_VR);
+ selenium.click(CHK_SEC_RUN_P);
+ selenium.click(CHK_SEC_RUN_PR);
+
+ selenium.click(SUB_SEC_SUBMIT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // assert
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ 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));
+
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
+
+ clickAndWait(MessageFormat.format(PAG_TL_SECURITY, r));
+
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RA_V), "Checkbox should be checked");
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RA_VR), "Checkbox should be checked");
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RA_P), "Checkbox should be checked");
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RA_PR), "Checkbox should be checked");
+
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RU_V), "Checkbox should be checked");
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RU_VR), "Checkbox should be checked");
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RU_P), "Checkbox should be checked");
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RU_PR), "Checkbox should be checked");
+
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RUN_V), "Checkbox should be checked");
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RUN_VR), "Checkbox should be checked");
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RUN_P), "Checkbox should be checked");
+ Assert.assertTrue(selenium.isChecked(CHK_SEC_RUN_PR), "Checkbox should be checked");
+
}
- @Test(enabled = false)
+ /**
+ * Changing the values of selectors in page theme properties. New page name
+ * "PageToTheme" is created in "TestPortal". The three values in the theme
+ * page are changed, but cancel is clicked. The theme page is reloaded and
+ * asserted, that default values are present. At the second attempt, the
+ * values are submited and after the reloading of theme page it is asserted,
+ * that they have formerly selected values and not the default ones.
+ */
+ @Test(enabled = true, dependsOnMethods = { "testPortalCreate", "testAddPage" }, description = "Changing selectors in theme details of a page.")
public void testPageTheme() {
+
+ String portalName = "TestPortal";
+ String pageName = "PageToTheme";
+
+ createPage(portalName, pageName);
+
+ openAndWait("/portal");
+ clickAndWait("link=Admin");
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ 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),"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");
+ selenium.click(PAG_THE_CAN);
+ selenium.waitForPageToLoad("30000");
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ 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),"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");
+ selenium.click(PAG_THE_SUB);
+ selenium.waitForPageToLoad("30000");
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ 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("3columns", selenium.getSelectedLabel(PAG_THE_LAY));
+ Assert.assertEquals("maple", selenium.getSelectedLabel(PAG_THE_THE));
+ Assert.assertEquals("emptyRenderer", selenium.getSelectedLabel(PAG_THE_REN));
}
- @Test(enabled = false)
+ /**
+ * Page layout testing. Page named "pageToLayout" is created in
+ * "TestPortal". Four portlets are added to the page. Two to the center and
+ * two to the left column. Their order on the page is asserted. One portlet
+ * is selected in each columns and they are moved down, their order is
+ * asserted again. The same portlets are then moved up and again, their
+ * order is asserted. The portlets are then deleted and it is asserted they
+ * don't appear on screen.
+ */
+ // TODO assert messages should be in property files
+ @Test(enabled = true, dependsOnMethods = { "testPortalCreate", "testAddPage" }, description = "Page layout testing.")
public void testPageLayout() {
- }
- private void createPortal(String name) {
- selenium.open("/portal/");
+ final String portalName = "TestPortal";
+ final String pageName = "pageToLayout";
+ createPortal(portalName);
+ createPage(portalName, pageName);
+
+ goToPortalAdmin();
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
selenium.waitForPageToLoad(PAGE_LOAD);
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
+ selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
+ waitFor(AJAX_LOAD);
+ selenium.click("link=" + MES_P1);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_LAYOUT_ADD_CENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=" + MES_P2);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_LAYOUT_ADD_CENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=" + MES_P3);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_LAYOUT_ADD_LEFT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("link=" + MES_P4);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_LAYOUT_ADD_LEFT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.open("/portal/auth/portal/" + portalName + "/" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ assertTextOrder(MES_P3_T+";"+MES_P4_T+";"+MES_P1_T+";"+MES_P2_T);
+
+ // down
+
selenium.click("link=Admin");
selenium.waitForPageToLoad(PAGE_LOAD);
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
+ selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
+ waitFor(AJAX_LOAD);
+ selenium.addSelection(PAG_LAY_C_SEL, "label="+MES_P1_W);
+ selenium.click(PAG_LAY_C_DOWN);
+ waitFor(AJAX_LOAD);
+ selenium.addSelection(PAG_LAY_L_SEL, "label="+MES_P3_W);
+ selenium.click(PAG_LAY_L_DOWN);
+ waitFor(AJAX_LOAD);
+ selenium.open("/portal/auth/portal/" + portalName + "/" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ assertTextOrder(MES_P4_T+";"+MES_P3_T+";"+MES_P2_T+";"+MES_P1_T);
+
+ // up
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(TAB_PORTALOBJ_ID);
clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
+ selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
+ waitFor(AJAX_LOAD);
- selenium.type(INPUT_PORTALNAME, name);
+ selenium.addSelection(PAG_LAY_C_SEL, "label="+MES_P1_W);
+ selenium.click(PAG_LAY_C_UP);
+ waitFor(AJAX_LOAD);
+ selenium.addSelection(PAG_LAY_L_SEL, "label="+MES_P3_W);
+ selenium.click(PAG_LAY_L_UP);
+ waitFor(AJAX_LOAD);
+ selenium.open("/portal/auth/portal/" + portalName + "/" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ assertTextOrder(MES_P3_T+";"+MES_P4_T+";"+MES_P1_T+";"+MES_P2_T);
+ //
+ // delete
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+ r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
+ selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
+ waitFor(AJAX_LOAD);
+
+ selenium.addSelection(PAG_LAY_C_SEL, "label="+MES_P1_W);
+ selenium.click(PAG_LAY_C_DEL);
+ waitFor(AJAX_LOAD);
+ selenium.addSelection(PAG_LAY_L_SEL, "label="+MES_P3_W);
+ selenium.click(PAG_LAY_L_DEL);
+ waitFor(AJAX_LOAD);
+ selenium.open("/portal/auth/portal/" + portalName + "/" + pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ assertTextOrder(MES_P4_T+";"+MES_P2_T);
+ Assert.assertFalse(selenium.isTextPresent(MES_P3_T), "Deleted portlet present.");
+ Assert.assertFalse(selenium.isTextPresent(MES_P1_T), "Deleted portlet present.");
+
+ }
+
+ /**
+ * 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, groups = {"XSS"})
+ public void testXssPortalCreate() {
+ goToPortalAdmin();
+
+ clickIfVisible(LINK_PORTALS_ID);
+
+ selenium.type(INPUT_PORTALNAME, XSS_STR1);
selenium.click(INPUT_SUBMIT_CREATEPORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isTextPresent("is an invalid portal name"));
}
- private void createPage(String portalName, String pageName) {
+
+ 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, groups = {"XSS"})
+ public void testXssPageCreate() {
+ final String portalName = "XssPortal";
+
+ createPortal(portalName);
+
+ goToPortalAdmin();
clickIfVisible(LINK_PORTALS_ID);
int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
@@ -581,6 +1121,143 @@
selenium.click(MessageFormat.format(POR_TL_MAIN, r));
selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(INPUT_PAGENAME, XSS_STR1);
+ selenium.click(INPUT_SUBMIT_PAGECREATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ 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, groups = {"XSS"})
+ public void testXssWindowCreate() {
+ final String portalName = "XssPortal";
+ final String pageName = "XssPage";
+
+ createPortal(portalName);
+ createPage(portalName, pageName);
+
+ goToPortalAdmin();
+ clickIfVisible(LINK_PORTALS_ID);
+ clickIfVisible(LINK_PORTAL_HOME);
+
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ r = findTableRow(TABLE_PORTALPAGE_ADMIN, pageName, 0) - 1;
+
+ // click on the page layout
+ selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
+
+ waitFor(AJAX_LOAD);
+
+ selenium.click("link=Who's online portlet");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INP_WINDOW_NAME, XSS_STR1);
+
+ selenium.click(SUB_LAYOUT_ADD_CENTER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ 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, groups = {"XSS"})
+ public void testXssPortalProperties() {
+ final String portalName = "XssPropertiesPortal";
+
+ createPortal(portalName);
+
+ // then click on its properties button
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LINK_PORTALS_ID);
+
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+
+ selenium.click(MessageFormat.format(POR_TL_PROPERTIES, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // Properties
+
+ selenium.type(INP_PP_PROPNAME, XSS_STR1);
+ selenium.click(SUB_PP_PROPADD);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ 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);
+ waitFor(AJAX_LOAD);
+ selenium.type(INP_PP_RES_INPUT, XSS_STR1);
+ selenium.click(SUB_PP_ERROR_FORM_UPDATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ 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(MSG_PAGE_ERR_VALID));
+
+ }
+
+ private void createPortal(String name) {
+ goToPortalAdmin();
+ clickIfVisible(LINK_PORTALS_ID);
+
+ selenium.type(INPUT_PORTALNAME, name);
+ selenium.click(INPUT_SUBMIT_CREATEPORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+
+ private void createPage(String portalName, String pageName) {
+ goToPortalAdmin();
+ clickIfVisible(LINK_PORTALS_ID);
+
+ int r = findTableRow(TABLE_PORTAL_ADMIN, portalName, 0) - 1;
+
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
selenium.type(INPUT_PAGENAME, pageName);
selenium.click(INPUT_SUBMIT_PAGECREATE);
selenium.waitForPageToLoad(PAGE_LOAD);
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalWizardTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalWizardTestCase.java (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/AdminPortalWizardTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -0,0 +1,189 @@
+package org.jboss.portal.test.selenium.portal;
+
+import java.text.MessageFormat;
+
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+import org.testng.Assert;
+import org.testng.annotations.AfterMethod;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * AdminPortalTestCase is responsible for testing fundamental portal admin wizard interface
+ * features of JBoss Portal.
+ *
+ * @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
+ *
+ */
+// TODO - adding of simple portlet - more portlet types
+@Test(enabled = true, groups="portal_admin")
+public class AdminPortalWizardTestCase extends JBossPortalSeleniumTestCase {
+
+ /** prefix for locator properties = portal.admin. */
+ public final String casePfx = "portal.admin.wiz.";
+
+ private final String SUB_SUB = getLoc(casePfx + "sub.sub", "_jbpnsAdminPortletWindowsnpbj:j_id20:wiz-conf-form:confirm");
+ private final String SUB_CAN = getLoc(casePfx + "sub.can", "_jbpnsAdminPortletWindowsnpbj:j_id20:wiz-conf-form:cancel");
+ private final String LNK_REG_C = getLoc(casePfx + "lnk.reg.c", "_jbpnsAdminPortletWindowsnpbj:j_id28:region-wiz-form:region-1");
+ private final String SUB_PORTLET_TYPE = getLoc(casePfx + "sub.portlet.type", "_jbpnsAdminPortletWindowsnpbj:j_id169:portlet-wiz-form:wiz-change");
+ private final String SEL_PORTLET_TYPE = getLoc(casePfx + "sel.portlet.type", "_jbpnsAdminPortletWindowsnpbj:j_id169:portlet-wiz-form:menu");
+ private final String LNK_WIZ_MODE = getLoc(casePfx + "lnk.wiz.mode", "Link=*Switch to wizard mode*");
+ private final String INP_SUBMIT_PAGECREATE = getLoc(casePfx + "inp.submit.pagecreate", "//input[contains(@id,'create-page-form:create-page')]");
+ private final String INP_PAGENAME = getLoc(casePfx + "inp.pagename", "//input[contains(@id,'create-page-form:pageName')]");
+ private final String INP_PORTALNAME = getLoc(casePfx + "inp.portalname", "//input[contains(@id,'create-portal-form:name')]");
+ private final String INP_SUBMIT_CREATEPORTAL = getLoc(casePfx + "inp.submit.createportal", "//input[contains(@id,'create-portal-form:create-portal')]");
+ private final String TAB_PORTALOBJ_ID = getLoc(casePfx + "tab.portalobj.id", "Link=Admin");
+ private final String LNK_PORTALS_ID = getLoc(casePfx + "lnk.portals.id", "link=*Portal Objects*");
+ private final String TAB_PORTAL_ADMIN = getLoc(casePfx + "tab.portal.admin", "//table[contains(@id,'obj-nav-form:portal-datatable')]");
+ private final String POR_TL_MAIN = getLoc(casePfx + "por.tl.main", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]");
+ private final String UL_PAGINATOR = getLoc(casePfx + "ul.paginator", "//body/div[2]/div/div/div[2]/table/tbody/tr/td/div/div/div/div/div[6]/form[2]/ul[2]");
+ private final String TAB_PORTLET_INSTANCES = getLoc(casePfx + "ul.paginator", "//html/body/div[2]/div/div/div[2]/table/tbody/tr/td/div/div/div/div/div[6]/form[2]/table");
+
+ @BeforeMethod(groups = { "log" })
+ protected void loginBeforeTest() {
+ logoutIfPossible();
+ login("admin", "admin");
+ }
+
+ @AfterMethod(groups = { "log" })
+ protected void logoutAfterTest() {
+ }
+
+ /**
+ * Simple adding of counter portlet to "TestPortal" portal into page "PageToWizard".
+ */
+ @Test(enabled = true, description = "Creates a new portal")
+ public void testSimpleWizard() {
+
+ String portalName = "TestWizPortal";
+ String pageName = "PageToWizard";
+ String portletType = "local";
+ String portletName = "Counter Portlet";
+
+ createPortal(portalName);
+ createPage(portalName, pageName);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LNK_PORTALS_ID);
+
+ selenium.click(LNK_WIZ_MODE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickPortlet(portletType, portletName);
+
+ selenium.click("Link="+portalName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("Link="+pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_REG_C);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_CAN);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ openAndWait("/portal/auth/portal/TestPortal/PageToWizard");
+ Assert.assertFalse(selenium.isTextPresent("Counter portlet"));
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LNK_PORTALS_ID);
+
+ clickPortlet(portletType, portletName);
+
+ selenium.click("Link="+portalName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click("Link="+pageName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(LNK_REG_C);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.click(SUB_SUB);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ openAndWait("/portal/auth/portal/"+portalName+"/"+pageName);
+ Assert.assertTrue(selenium.isTextPresent("Counter portlet"));
+
+ }
+
+ private void clickPortlet(String type, String portletName){
+ selenium.select(SEL_PORTLET_TYPE, "label="+type);
+ selenium.click(SUB_PORTLET_TYPE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ if (traversePortlets(portletName, 0)>-1){
+ selenium.click("link="+portletName);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+
+ }
+
+ private void createPortal(String name) {
+ selenium.open("/portal/");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LNK_PORTALS_ID);
+
+ selenium.type(INP_PORTALNAME, name);
+ selenium.click(INP_SUBMIT_CREATEPORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+
+ 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);
+ clickIfVisible(LNK_PORTALS_ID);
+
+ int r = findTableRow(TAB_PORTAL_ADMIN, portalName, 0) - 1;
+
+ selenium.click(MessageFormat.format(POR_TL_MAIN, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INP_PAGENAME, pageName);
+ selenium.click(INP_SUBMIT_PAGECREATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ }
+
+ private int traversePortlets(String instance_name, int row) {
+
+ int r = -1;
+
+ r = findTableRow(TAB_PORTLET_INSTANCES, instance_name, row);
+
+ if (r >= 0)
+ return r;
+
+ String pages[] = getPages(UL_PAGINATOR);
+ for (String page : pages) {
+ if ("".equals(page.trim()))
+ continue;
+ selenium.click("link=" + page);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ r = findTableRow(TAB_PORTLET_INSTANCES, instance_name, row);
+
+ if (r >= 0)
+ break;
+ }
+
+ return r;
+ }
+
+ private String[] getPages(String paginator_location) {
+
+ String pagi = selenium.getText(paginator_location);
+ String[] pages = pagi.split(" ");
+
+ return pages;
+ }
+
+}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/DashboardsTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -8,51 +8,70 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+/**
+ * DashboardsTestCase responsible for testing of dashboards settings in portal
+ * admin.
+ *
+ * @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
+ */
+@Test(enabled = true, groups="portal_admin")
public class DashboardsTestCase extends JBossPortalSeleniumTestCase {
+
+ /** prefix for locator properties = portal.dash. */
+ public final String casePfx = "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 = getProp(casePfx+"t.dh.sub.update","//form[contains(@id,'common-edit-theme-form')]/input[@type='submit']");
- private final String T_DH_SEL_RENDERSET = getProp(casePfx+"t.dh.sel.renderset","//select[contains(@id,'common-edit-theme-form:renderSet')]");
- private final String T_DH_SEL_THEME = getProp(casePfx+"t.dh.sel.theme","//select[contains(@id,'common-edit-theme-form:theme')]");
- private final String T_DH_SEL_LAYOUT = getProp(casePfx+"t.dh.sel.layout","//select[contains(@id,'common-edit-theme-form:layout')]");
- private final String T_PA_SUB_UPDATE = getProp(casePfx+"t.pa.sub.update","//input[contains(@id,'common-edit-page-error-form:update')]");
- private final String T_PO_SUB_UPDATE = getProp(casePfx+"t.po.sub.update","//input[contains(@id,'common-edit-portal-error-form:update')]");
- private final String T_PA_INP_PAGEADD = getProp(casePfx+"t.pa.inp.pageadd","//input[contains(@id,'common-edit-page-error-form:page-res-select')]");
- private final String T_PO_INP_PAGEADD = getProp(casePfx+"t.po.inp.pageadd","//input[contains(@id,'common-edit-portal-error-form:portal-res-input')]");
- private final String T_PA_SEL_PNF = getProp(casePfx+"t.pa.sel.pnf","//select[contains(@id,'common-edit-page-error-form:page-not-found-select')]");
- private final String T_PA_SEL_INTERN = getProp(casePfx+"t.pa.sel.intern","//select[contains(@id,'common-edit-page-error-form:page-internal-select')]");
- private final String T_PA_SEL_ERROR = getProp(casePfx+"t.pa.sel.error","//select[contains(@id,'common-edit-page-error-form:page-error-select')]");
- private final String T_PA_SEL_CONTROL = getProp(casePfx+"t.pa.sel.control","//select[contains(@id,'common-edit-page-error-form:page-control-select')]");
- private final String T_PA_SEL_ACCESS = getProp(casePfx+"t.pa.sel.access","//select[contains(@id,'common-edit-page-error-form:page-access-select')]");
- private final String T_PO_SEL_PNF = getProp(casePfx+"t.po.sel.pnf","//select[contains(@id,'common-edit-portal-error-form:portal-not-found-select')]");
- private final String T_PO_SEL_UNAVAIL = getProp(casePfx+"t.po.sel.unavail","//select[contains(@id,'common-edit-portal-error-form:portal-unavail-select')]");
- private final String T_PO_SEL_ACCESS = getProp(casePfx+"t.po.sel.access","//select[contains(@id,'common-edit-portal-error-form:portal-access-select')]");
- private final String SUBMIT_UPDATE_VALUE = getProp(casePfx+"submit.update.value","//input[contains(@id,'common-manage-prop-form:update')]");
- private final String TABLE_PROPS = getProp(casePfx+"table.props","//table[contains(@id,'common-manage-prop-form:prop-data-table')]");
- private final String T_PROPS_INPUT_VALUE = getProp(casePfx+"t.props.input.value","//input[contains(@id,''common-manage-prop-form:prop-data-table:{0}:prop-value-input'')]");
- private final String T_PROPS_LINK_DEL = getProp(casePfx+"t.props.link.del","//a[contains(@id,''common-manage-prop-form:prop-data-table:{0}:delete'')]");
- private final String TABLE_PA_ERR = getProp(casePfx+"table.pa.err","//form[@id='common-edit-page-error-form']/table");
- private final String TABLE_PO_ERR = getProp(casePfx+"table.po.err","//form[@id='common-edit-portal-error-form']/table");
- private final String TABLE_DH_THM = getProp(casePfx+"table.dh.thm","//form[@id='common-edit-theme-form']/table");
- private final String INPUT_PROP_NAME = getProp(casePfx+"input.prop.name","//input[contains(@id,'common-edit-prop-form:property')]");
- private final String SUBMIT_ADD_PROP = getProp(casePfx+"submit.add.prop","//input[contains(@id,'common-edit-prop-form:add-property')]");
- private final String LINK_ADMIN = getProp(casePfx+"link.admin","link=Admin");
- private final String LINK_TAB_DASH = getProp(casePfx+"link.tab.dash","//a[contains(@id,'admin-subtab-form:dashboard-link')]");
+ 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')]");
+ private final String T_DH_SEL_LAYOUT = getLoc(casePfx + "t.dh.sel.layout", "//select[contains(@id,'common-edit-theme-form:layout')]");
+ private final String T_PA_SUB_UPDATE = getLoc(casePfx + "t.pa.sub.update", "//input[contains(@id,'common-edit-page-error-form:update')]");
+ private final String T_PO_SUB_UPDATE = getLoc(casePfx + "t.po.sub.update", "//input[contains(@id,'common-edit-portal-error-form:update')]");
+ private final String T_PA_INP_PAGEADD = getLoc(casePfx + "t.pa.inp.pageadd", "//input[contains(@id,'common-edit-page-error-form:page-res-select')]");
+ private final String T_PO_INP_PAGEADD = getLoc(casePfx + "t.po.inp.pageadd", "//input[contains(@id,'common-edit-portal-error-form:portal-res-input')]");
+ private final String T_PA_SEL_PNF = getLoc(casePfx + "t.pa.sel.pnf", "//select[contains(@id,'common-edit-page-error-form:page-not-found-select')]");
+ private final String T_PA_SEL_INTERN = getLoc(casePfx + "t.pa.sel.intern", "//select[contains(@id,'common-edit-page-error-form:page-internal-select')]");
+ private final String T_PA_SEL_ERROR = getLoc(casePfx + "t.pa.sel.error", "//select[contains(@id,'common-edit-page-error-form:page-error-select')]");
+ private final String T_PA_SEL_CONTROL = getLoc(casePfx + "t.pa.sel.control", "//select[contains(@id,'common-edit-page-error-form:page-control-select')]");
+ private final String T_PA_SEL_ACCESS = getLoc(casePfx + "t.pa.sel.access", "//select[contains(@id,'common-edit-page-error-form:page-access-select')]");
+ private final String T_PO_SEL_PNF = getLoc(casePfx + "t.po.sel.pnf", "//select[contains(@id,'common-edit-portal-error-form:portal-not-found-select')]");
+ private final String T_PO_SEL_UNAVAIL = getLoc(casePfx + "t.po.sel.unavail",
+ "//select[contains(@id,'common-edit-portal-error-form:portal-unavail-select')]");
+ private final String T_PO_SEL_ACCESS = getLoc(casePfx + "t.po.sel.access", "//select[contains(@id,'common-edit-portal-error-form:portal-access-select')]");
+ private final String SUBMIT_UPDATE_VALUE = getLoc(casePfx + "submit.update.value", "//input[contains(@id,'common-manage-prop-form:update')]");
+ private final String TABLE_PROPS = getLoc(casePfx + "table.props", "//table[contains(@id,'common-manage-prop-form:prop-data-table')]");
+ private final String T_PROPS_INPUT_VALUE = getLoc(casePfx + "t.props.input.value",
+ "//input[contains(@id,''common-manage-prop-form:prop-data-table:{0}:prop-value-input'')]");
+ private final String T_PROPS_LINK_DEL = getLoc(casePfx + "t.props.link.del", "//a[contains(@id,''common-manage-prop-form:prop-data-table:{0}:delete'')]");
+ private final String TABLE_PA_ERR = getLoc(casePfx + "table.pa.err", "//form[@id='common-edit-page-error-form']/table");
+ private final String TABLE_PO_ERR = getLoc(casePfx + "table.po.err", "//form[@id='common-edit-portal-error-form']/table");
+ private final String TABLE_DH_THM = getLoc(casePfx + "table.dh.thm", "//form[@id='common-edit-theme-form']/table");
+ private final String INPUT_PROP_NAME = getLoc(casePfx + "input.prop.name", "//input[contains(@id,'common-edit-prop-form:property')]");
+ private final String SUBMIT_ADD_PROP = getLoc(casePfx + "submit.add.prop", "//input[contains(@id,'common-edit-prop-form:add-property')]");
+ private final String LINK_ADMIN = getLoc(casePfx + "link.admin", "link=Admin");
+ private final String LINK_TAB_DASH = getLoc(casePfx + "link.tab.dash", "//a[contains(@id,'admin-subtab-form:dashboard-link')]");
-
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
goToDash();
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
-
+ protected void logoutAfterTest() {
+
}
+ /**
+ * Testing property addition. Simple adding of "SelenProp" property. Only
+ * the appearance of text "SelenProp" on the dashboards screen is used for
+ * final assertion.
+ */
@Test(enabled = true)
public void testPropAdd() {
final String propName = "SelenProp";
@@ -64,6 +83,27 @@
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, groups = {"XSS"})
+ public void testXssPropAdd() {
+
+ selenium.type(INPUT_PROP_NAME, XSS_STR1);
+ selenium.click(SUBMIT_ADD_PROP);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_PROP_ADD_VALID));
+ }
+
+ /**
+ * Testing of property update. Simple adding of "SelenValueProp" property
+ * and setting it the value "updatedValue". The value is then assrted to be
+ * appearing in the property table.
+ */
@Test(enabled = true)
public void testPropUpdate() {
final String propName = "SelenValueProp";
@@ -74,16 +114,47 @@
selenium.click(SUBMIT_ADD_PROP);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(propName));
+
+ int r = findTableRow(TABLE_PROPS, propName, 1);
+
+ selenium.type(MessageFormat.format(T_PROPS_INPUT_VALUE, r - 1), value);
+ selenium.click(SUBMIT_UPDATE_VALUE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertEquals(selenium.getValue(MessageFormat.format(T_PROPS_INPUT_VALUE, r - 1)), value, "Updated value not found.");
+
+ }
+
+ /**
+ * 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, groups = {"XSS"})
+ public void testXssPropUpdate() {
+ final String propName = "XssStrProp";
+ Assert.assertFalse(selenium.isTextPresent(propName));
+ selenium.type(INPUT_PROP_NAME, propName);
+ selenium.click(SUBMIT_ADD_PROP);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(propName));
+
int r = findTableRow(TABLE_PROPS, propName, 1);
-
- selenium.type(MessageFormat.format(T_PROPS_INPUT_VALUE, r-1),value);
+
+ selenium.type(MessageFormat.format(T_PROPS_INPUT_VALUE, r - 1), XSS_STR1);
selenium.click(SUBMIT_UPDATE_VALUE);
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(MSG_PROP_UPDATE_VALID));
}
+ /**
+ * Testing property deletion. Property named "SelenDeleteProp" is added and
+ * deleted. Final assertion is about non-appearance of that property in
+ * property table.
+ */
@Test(enabled = true)
public void testPropDelete() {
final String propName = "SelenDeleteProp";
@@ -91,60 +162,144 @@
Assert.assertFalse(selenium.isTextPresent(propName));
selenium.type(INPUT_PROP_NAME, propName);
selenium.click(SUBMIT_ADD_PROP);
+
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(propName));
-
+
int r = findTableRow(TABLE_PROPS, propName, 0);
-
- selenium.click(MessageFormat.format(T_PROPS_LINK_DEL, r-1));
+
+ selenium.click(MessageFormat.format(T_PROPS_LINK_DEL, r - 1));
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
Assert.assertFalse(selenium.isTextPresent(propName));
-
+
}
+ /**
+ * Testing of portal error handling. in
+ * "Configure how the system handles errors on portal level." changing
+ * several (access, unavailable, page not found) items and changing of
+ * redirection is done. There is no final assertion.
+ */
+ // TODO - not all elements tested
+ // 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, groups = {"XSS"})
+ 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(MSG_PORTAL_ERR_VALID));
+ }
+ /**
+ * Testing of page error handling. in
+ * "Configure how the system handles errors on page level." changing all
+ * items and changing of redirection is done. There is no final assertion.
+ */
+ // 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, groups = {"XSS"})
+ 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(MSG_PAGE_ERR_VALID));
+ }
+ /**
+ * Testing of dashboard theme. The layout, theme and renderset are changed,
+ * but no assertion is done.
+ */
@Test(enabled = true)
public void testDashboardTheme() {
-
safeSelect(T_DH_SEL_LAYOUT, "1column");
-
+ safeSelect(T_DH_SEL_THEME, "maple");
+ safeSelect(T_DH_SEL_RENDERSET, "default");
+ clickAndWait(T_DH_SUB_UPDATE);
-
- safeSelect(T_DH_SEL_RENDERSET, "default");
+ logoutIfPossible();
+ login("admin","admin");
+ goToDash();
- safeSelect(T_DH_SEL_THEME, "nphalanx");
- clickAndWait(T_DH_SUB_UPDATE);
+ 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");
+ */
+
}
private void goToDash() {
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -12,95 +12,256 @@
import org.testng.annotations.Test;
/**
+ * EndtoEndPortalAdminTestCase is responsible for end-to-end testing of portal
+ * admin. Creating of new portal, adding pages to it and setting it as a default
+ * portal is the main goal of this test case.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
@Test(groups = { "end2end" }, enabled = true, description = "Creating of new portal with content.")
public class EndtoEndPortalAdminTestCase extends JBossPortalSeleniumTestCase {
+ /** prefix for locator properties = portal.e2e. */
public static String casePfx = "portal.e2e.";
- private final String ADR_PORTAL = getProp(casePfx + "adr.home", "/portal");
- public final String SEL_PORTLET_TYPE = getProp(casePfx + "sel.portlet.type", "//select[contains(@id,'windowForm:instanceId')]");
- private final String SUB_LAYOUT_ADD_CENTER = getProp(casePfx + "sub.layout.add.center", "//input[contains(@id,'layoutForm:a_center')]");
- private final String INP_WINDOW_NAME = getProp(casePfx + "inp.window.name", "//input[contains(@id,'windowForm:windowName')]");
- private final String SUB_RENAME_PORTAL = getProp(casePfx + "sub.rename.portal", "//input[contains(@id,'renameForm:rename')]");
- private final String INP_RENAME_PORTAL = getProp(casePfx + "inp.rename.portal", "//input[contains(@id,'renameForm:newName')]");
- private final String SUB_DELETE_PORTAL_CONF = getProp(casePfx + "sub.delete.portal.conf", "//input[contains(@id,'delete-view:confirm-form:delete')]");
- private final String INP_SUBMIT_PAGECREATE = getProp(casePfx + "inp.submit.pagecreate", "//input[contains(@id,'create-page-form:create-page')]");
- private final String INP_PAGENAME = getProp(casePfx + "inp.pagename", "//input[contains(@id,'create-page-form:pageName')]");
- private final String INP_PORTALNAME = getProp(casePfx + "inp.portalname", "//input[contains(@id,'create-portal-form:name')]");
- private final String INP_SUBMIT_CREATEPORTAL = getProp(casePfx + "inp.submit.createportal", "//input[contains(@id,'create-portal-form:create-portal')]");
- private final String TAB_PORTALOBJ_ID = getProp(casePfx + "tab.portalobj.id", "Link=Admin");
- private final String LNK_PORTALS_ID = getProp(casePfx + "lnk.portals.id", "link=*Portal Objects*");
- private final String LNK_PORTAL_HOME = getProp(casePfx + "lnk.portal.home", "//a[contains(@id,'obj-temp-form:object-link-0')]");
- private final String TBL_PORTAL_ADMIN = getProp(casePfx + "tbl.portal.admin", "//table[contains(@id,'obj-nav-form:portal-datatable')]");
- private final String POR_TL_MAIN = getProp(casePfx + "por.tl.main", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]");
- private final String POR_TL_SECURITY = getProp(casePfx + "por.tl.security", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:security-link'')]");
- private final String POR_TL_PROPERTIES = getProp(casePfx + "por.tl.properties", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:prop-link'')]");
- private final String POR_TL_THEME = getProp(casePfx + "por.tl.theme", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:theme-link'')]");
- private final String POR_TL_RENAME = getProp(casePfx + "por.tl.rename", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:rename'')]");
- private final String POR_TL_DELETE = getProp(casePfx + "por.tl.delete", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:delete'')]");
- private final String POR_TL_MAKEDEF = getProp(casePfx + "por.tl.makedef", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:default-link'')]");
- private final String TBL_PORTALPAGE_ADMIN = getProp(casePfx + "tbl.portalpage.admin", "//table[contains(@id,'obj-nav-form:pages-datatable')]");
- private final String PAG_TL_MAIN = getProp(casePfx + "pag.tl.main", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:object-link'')]");
- private final String PAG_TL_LAYOUT = getProp(casePfx + "pag.tl.layout", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:edit-page-layout'')]");
- private final String PAG_TL_SECURITY = getProp(casePfx + "pag.tl.security", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:security-link'')]");
- private final String PAG_TL_PROPERTIES = getProp(casePfx + "pag.tl.properties", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:prop-link'')]");
- private final String PAG_TL_THEME = getProp(casePfx + "pag.tl.theme", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:theme-link'')]");
- private final String PAG_TL_RENAME = getProp(casePfx + "pag.tl.rename", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-link'')]");
- private final String PAG_TL_DISPLAY = getProp(casePfx + "pag.tl.display", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-display'')]");
- private final String PAG_TL_DELETE = getProp(casePfx + "pag.tl.delete", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:delete-link'')]");
- private final String PAG_TL_MAKEDEF = getProp(casePfx + "pag.tl.makedef", "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:default-link'')]");
- private final String DIV_PORT_CONTENT = getProp(casePfx + "div.por.cont", "conrrerertent-container");
- private final String INP_GOO_SEARCH = getProp(casePfx + "inp.goo.search", "//div[contains(@id,'directory_search_div')]/form/input[@name='query']");
- private final String SUB_GOO_SEARCH = getProp(casePfx + "sup.goo.search", "//div[contains(@id,'directory_search_div')]/form/input[@type='submit']");
- private final String INP_NET_SEARCH = getProp(casePfx + "inp.goo.search", "//div[contains(@id,'directory_search_div')]/form/input[@name='query']");
- private final String SUB_NET_SEARCH = getProp(casePfx + "sub.goo.search", "//div[contains(@id,'directory_search_div')]/form/input[@type='submit']");
+ private final String SEL_PREDEF_PROP = getLoc(casePfx + "sel.predef.prop",
+ "//select[contains(@id,'predefined-properties:predefinedProperty')]");
+ private final String SUB_POR_PROPS_UPDATE = getLoc(casePfx
+ + "sub.por.props.update",
+ "//input[contains(@id,'common-manage-prop-form:update')]");
+ private final String SUB_POR_PROPERTY = getLoc(
+ casePfx + "sub.por.property",
+ "//input[contains(@id,'common-edit-prop-form:add-property')]");
+ private final String INP_POR_PROPERTY = getLoc(
+ casePfx + "inp.por.property",
+ "//input[contains(@id,'common-edit-prop-form:property')]");
+ private final String SUB_POR_LISTENER = getLoc(
+ casePfx + "sub.por.listener",
+ "//input[contains(@id,'edit-prop-form:update')]");
+ private final String SEL_POR_LISTENER = getLoc(
+ casePfx + "sel.por.listener",
+ "//select[contains(@id,'edit-prop-form:listener')]");
+ private final String SUB_PAL = getLoc(casePfx + "sub.pal",
+ "//input[contains(@id,'common-edit-page-error-form:update')]");
+ private final String INP_PAL_PR = getLoc(casePfx + "inp.pal.pr",
+ "//input[contains(@id,'common-edit-page-error-form:page-res-select')]");
+ private final String SEL_PAL_PN = getLoc(casePfx + "sel.pal.pn",
+ "//select[contains(@id,'common-edit-page-error-form:page-not-found-select')]");
+ private final String SEL_PAL_PI = getLoc(casePfx + "sel.pal.pi",
+ "//select[contains(@id,'common-edit-page-error-form:page-internal-select')]");
+ private final String SEL_PAL_PE = getLoc(casePfx + "sel.pal.pe",
+ "//select[contains(@id,'common-edit-page-error-form:page-error-select')]");
+ private final String SEL_PAL_PC = getLoc(casePfx + "sel.pal.pc",
+ "//select[contains(@id,'common-edit-page-error-form:page-control-select')]");
+ private final String SEL_PAL_PA = getLoc(casePfx + "sel.pal.pa",
+ "//select[contains(@id,'common-edit-page-error-form:page-access-select')]");
+ private final String SUB_POL = getLoc(casePfx + "sub.pol",
+ "//input[contains(@id,'common-edit-portal-error-form:update')]");
+ private final String INP_POL_PR = getLoc(casePfx + "inp.pol.pr",
+ "//input[contains(@id,'common-edit-portal-error-form:portal-res-input')]");
+ private final String SEL_POL_PN = getLoc(
+ casePfx + "sel.pol.pn",
+ "//select[contains(@id,'common-edit-portal-error-form:portal-not-found-select')]");
+ private final String SEL_POL_PI = getLoc(
+ casePfx + "sel.pol.pi",
+ "//select[contains(@id,'common-edit-portal-error-form:portal-internal-select')]");
+ private final String SEL_POL_PE = getLoc(casePfx + "sel.pol.pe",
+ "//select[contains(@id,'common-edit-portal-error-form:portal-error-select')]");
+ private final String SEL_POL_PU = getLoc(casePfx + "sel.pol.pu",
+ "//select[contains(@id,'common-edit-portal-error-form:portal-unavail-select')]");
+ private final String SEL_POL_PA = getLoc(casePfx + "sel.pol.pa",
+ "//select[contains(@id,'common-edit-portal-error-form:portal-access-select')]");
- private long AJAX_WAIT=10000;
- /*
- * - create a new portal - add couple of page to the portal - add few
- * portlets of different kinds (csm, widget, regular portlets) in each page
- * - verify that new portal, pages and portlets get added correctly. - Make
- * the new portal default and verify that it becomes default portal
- */
+ private final String ADR_PORTAL = getLoc(casePfx + "adr.home", "/portal");
+ public final String SEL_PORTLET_TYPE = getLoc(casePfx + "sel.portlet.type",
+ "//select[contains(@id,'windowForm:instanceId')]");
+ private final String SUB_LAYOUT_ADD_CENTER = getLoc(casePfx
+ + "sub.layout.add.center",
+ "//input[contains(@id,'layoutForm:a_center')]");
+ private final String INP_WINDOW_NAME = getLoc(casePfx + "inp.window.name",
+ "//input[contains(@id,'windowForm:windowName')]");
+ private final String SUB_RENAME_PORTAL = getLoc(casePfx
+ + "sub.rename.portal", "//input[contains(@id,'renameForm:rename')]");
+ private final String INP_RENAME_PORTAL = getLoc(casePfx
+ + "inp.rename.portal",
+ "//input[contains(@id,'renameForm:newName')]");
+ private final String SUB_DELETE_PORTAL_CONF = getLoc(casePfx
+ + "sub.delete.portal.conf",
+ "//input[contains(@id,'delete-view:confirm-form:delete')]");
+ private final String INP_SUBMIT_PAGECREATE = getLoc(casePfx
+ + "inp.submit.pagecreate",
+ "//input[contains(@id,'create-page-form:create-page')]");
+ private final String INP_PAGENAME = getLoc(casePfx + "inp.pagename",
+ "//input[contains(@id,'create-page-form:pageName')]");
+ private final String INP_PORTALNAME = getLoc(casePfx + "inp.portalname",
+ "//input[contains(@id,'create-portal-form:name')]");
+ private final String INP_SUBMIT_CREATEPORTAL = getLoc(casePfx
+ + "inp.submit.createportal",
+ "//input[contains(@id,'create-portal-form:create-portal')]");
+ private final String TAB_PORTALOBJ_ID = getLoc(
+ casePfx + "tab.portalobj.id", "Link=Admin");
+ private final String LNK_PORTALS_ID = getLoc(casePfx + "lnk.portals.id",
+ "link=*Portal Objects*");
+ private final String LNK_PORTAL_HOME = getLoc(casePfx + "lnk.portal.home",
+ "//a[contains(@id,'obj-temp-form:object-link-0')]");
+ private final String TBL_PORTAL_ADMIN = getLoc(
+ casePfx + "tbl.portal.admin",
+ "//table[contains(@id,'obj-nav-form:portal-datatable')]");
+ private final String POR_TL_MAIN = getLoc(casePfx + "por.tl.main",
+ "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]");
+ private final String POR_TL_SECURITY = getLoc(casePfx + "por.tl.security",
+ "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:security-link'')]");
+ private final String POR_TL_PROPERTIES = getLoc(casePfx
+ + "por.tl.properties",
+ "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:prop-link'')]");
+ private final String POR_TL_THEME = getLoc(casePfx + "por.tl.theme",
+ "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:theme-link'')]");
+ private final String POR_TL_RENAME = getLoc(casePfx + "por.tl.rename",
+ "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:rename'')]");
+ private final String POR_TL_DELETE = getLoc(casePfx + "por.tl.delete",
+ "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:delete'')]");
+ private final String POR_TL_MAKEDEF = getLoc(casePfx + "por.tl.makedef",
+ "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:default-link'')]");
+ private final String TBL_PORTALPAGE_ADMIN = getLoc(casePfx
+ + "tbl.portalpage.admin",
+ "//table[contains(@id,'obj-nav-form:pages-datatable')]");
+ private final String PAG_TL_MAIN = getLoc(casePfx + "pag.tl.main",
+ "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:object-link'')]");
+ private final String PAG_TL_LAYOUT = getLoc(casePfx + "pag.tl.layout",
+ "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:edit-page-layout'')]");
+ private final String PAG_TL_SECURITY = getLoc(casePfx + "pag.tl.security",
+ "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:security-link'')]");
+ private final String PAG_TL_PROPERTIES = getLoc(casePfx
+ + "pag.tl.properties",
+ "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:prop-link'')]");
+ private final String PAG_TL_THEME = getLoc(casePfx + "pag.tl.theme",
+ "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:theme-link'')]");
+ private final String PAG_TL_RENAME = getLoc(casePfx + "pag.tl.rename",
+ "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-link'')]");
+ private final String PAG_TL_DISPLAY = getLoc(casePfx + "pag.tl.display",
+ "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:rename-display'')]");
+ private final String PAG_TL_DELETE = getLoc(casePfx + "pag.tl.delete",
+ "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:delete-link'')]");
+ private final String PAG_TL_MAKEDEF = getLoc(casePfx + "pag.tl.makedef",
+ "//a[contains(@id,''obj-nav-form:pages-datatable:{0}:default-link'')]");
+ private final String DIV_PORT_CONTENT = getLoc(casePfx + "div.por.cont",
+ "conrrerertent-container");
+ private final String INP_GOO_SEARCH = getLoc(casePfx + "inp.goo.search",
+ "//div[contains(@id,'directory_search_div')]/form/input[@name='query']");
+ private final String SUB_GOO_SEARCH = getLoc(casePfx + "sup.goo.search",
+ "//div[contains(@id,'directory_search_div')]/form/input[@type='submit']");
+ private final String INP_NET_SEARCH = getLoc(casePfx + "inp.net.search",
+ "//div[contains(@id,'directory_search_div')]/form/input[@name='query']");
+ private final String SUB_NET_SEARCH = getLoc(casePfx + "sub.net.search",
+ "//div[contains(@id,'directory_search_div')]/form/input[@type='submit']");
+ private final String TAB_PROPERTIES = getLoc(casePfx + "tab.properties",
+ "//table[contains(@id,'common-manage-prop-form:prop-data-table')]");
+ private final String TAB_PROP_VAL = getLoc(
+ casePfx + "tab.prop.val",
+ "//input[contains(@id,''common-manage-prop-form:prop-data-table:{0}:prop-value-input'')]");
+ private final String TAB_PROP_DEL = getLoc(casePfx + "tab.prop.val",
+ "//a[contains(@id,''common-manage-prop-form:prop-data-table:{0}:delete'')]");
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ protected void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ protected void logoutAfterTest() {
}
final String portalName = "UseCasePortal";
+ final String portalManName = "UseManagePortal";
+
final String page1Name = "firstPage";
final String page2Name = "anotherPage";
final String page3Name = "lastPage with whitespace";
final String page4Name = "dseer";
final String page5Name = "cemese";
- final String PORTLET1 = "Cart Portlet";
- final String por1str = "Cart Portlet";
- final String PORTLET2 = "Band Culinaria";
- final String por2str = "Band Culinaria";
- final String PORTLET3 = "Cahuete.com";
- final String por3str = "Cahuete.com";
- final String PORTLET4 = "dir1/foo.txt";
- final String por4str = "File Portlet";
- final String PORTLET5 = "default/index.html";
- final String por5str = "Powered by JBoss Enterprise Portal Platform";
+ final String page1ManName = "firstManPage";
+
+ final String PORTLET1 = getMess(casePfx + "port1", "Cart Portlet");
+ final String por1str = getMess(casePfx + "port1.str", "Cart Portlet");
+ final String PORTLET2 = getMess(casePfx + "port2",
+ "Calendar and Calculators");
+ final String por2str = getMess(casePfx + "port2.str",
+ "Calendar and Calculators");
+ final String PORTLET3 = getMess(casePfx + "port3", "Web Assurance");
+ final String por3str = getMess(casePfx + "port3.str", "web-assurance.net");
+ final String PORTLET4 = getMess(casePfx + "port4", "dir1/foo.txt");
+ final String por4str = getMess(casePfx + "port4.str", "File Portlet");
+ final String PORTLET5 = getMess(casePfx + "port5", "default/project.html");
+ final String por5str = getMess(casePfx + "port5.str",
+ "Our wiki knowledge base");
+
+ /**
+ * Usecase for creating small portal with content. Portal named
+ * "UseCasePortal" is created similar way as in
+ * {@link AdminPortalTestCase#testPortalCreate()}. Then few pages are added
+ * similar way as in {@link AdminPortalTestCase#testAddPage()}. A portlet is
+ * added to each page similar way as in
+ * {@link AdminPortalTestCase#testCreateWindow()}. The important information
+ * about pages and portlets are listed in the table below
+ *
+ * <table>
+ * <caption>Important information about portlets in
+ * EndtoEndPortalAdminTestCase</caption> <thead>
+ * <tr>
+ * <th>page name</th>
+ * <th>portlet name</th>
+ * <th>asserted string</th>
+ * <th>portlet type</th>
+ * </tr>
+ * </thead>
+ * <tr>
+ * <td>firstPage</td>
+ * <td>Cart Portlet</td>
+ * <td>Cart Portlet</td>
+ * <td>portlet</td>
+ * </tr>
+ * <tr>
+ * <td>anotherPage</td>
+ * <td>Band Culinaria</td>
+ * <td>Band Culinaria</td>
+ * <td>widget/google</td>
+ * </tr>
+ * <tr>
+ * <td>lastPage with whitespace</td>
+ * <td>Cahuete.com</td>
+ * <td>Cahuete.com</td>
+ * <td>widget/netvibes</td>
+ * </tr>
+ * <tr>
+ * <td>dseer</td>
+ * <td>dir1/foo.txt</td>
+ * <td>File Portlet</td>
+ * <td>filesystem</td>
+ * </tr>
+ * <tr>
+ * <td>cemese</td>
+ * <td>default/project.html</td>
+ * <td>Our wiki knowledge base</td>
+ * <td>cms</td>
+ * </tr>
+ * </table>
+ *
+ * Final assertions are made by clicking on the pages listed above and
+ * asserting that each page contains the string specific for the portlet
+ * used (again listed in table).
+ *
+ */
@Test(enabled = true, description = "Usecase for creating small portal with content.")
public void testCreatePortalUsecase() {
createPortal(portalName);
- addPage(page1Name);
- addPage(page2Name);
- addPage(page3Name);
- addPage(page4Name);
- addPage(page5Name);
+ addPage(portalName, page1Name);
+ addPage(portalName, page2Name);
+ addPage(portalName, page3Name);
+ addPage(portalName, page4Name);
+ addPage(portalName, page5Name);
addPortlet(portalName, page1Name, PORTLET1, "portlet");
addPortlet(portalName, page2Name, PORTLET2, "widget/google");
@@ -129,20 +290,309 @@
}
- public void testManagePortal() {
+ /**
+ * Test for managing portal listeners. Manage portals screen is loaded and
+ * "test_listener" is submited as a listener for this context. The screen is
+ * loaded again and it is asserted, that previously selected listener is
+ * still selected. The selection is changed to "user_listener", page is
+ * loaded again and "user_listener" is asserted to be the selected listener.
+ */
+ @Test(enabled = true, description = "Usecase for managing portals - listeners.")
+ public void testManagePortalListernersUsecase() {
+ int r = -1;
+ // createPortal(portalManName);
+ // addPage(portalManName,page1ManName);
+ // - Verify that you can add listener
+ goToProperties();
+
+ selenium.select(SEL_POR_LISTENER, "label=session_listener");
+ selenium.click(SUB_POR_LISTENER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ goToProperties();
+ Assert.assertEquals(selenium.getSelectedLabel(SEL_POR_LISTENER),
+ "session_listener",
+ "Previously selected label not being the current label.");
+
+ selenium.select(SEL_POR_LISTENER, "label=current_user_listener");
+ selenium.click(SUB_POR_LISTENER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ goToProperties();
+ Assert.assertEquals(selenium.getSelectedLabel(SEL_POR_LISTENER),
+ "current_user_listener",
+ "Previously selected label not being the current label.");
}
+ /**
+ * Test for managing portal properties. Manage portals screen is loaded and
+ * it is asserted that the property table is not present on the screen - no
+ * property was added before the test. Then a custom property "dragadrop" is
+ * added, the page is reloaded and it is asserted, that "dragadrop" is
+ * present in properties table.
+ *
+ */
+ @Test(enabled = true, description = "Usecase for managing portals - properties.")
+ public void testManagePortalPropertiesUsecase() {
+ int r = -1;
+
+ goToProperties();
+ // - assert no property is added
+ Assert.assertFalse(selenium.isElementPresent(TAB_PROPERTIES));
+
+ // - add d&d prop
+ selenium.type(INP_POR_PROPERTY, "dragadrop");
+ selenium.click(SUB_POR_PROPERTY);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ r = findTableRow(TAB_PROPERTIES, "dragadrop", 0) - 1;
+ selenium.type(MessageFormat.format(TAB_PROP_VAL, r), "dragicek");
+ selenium.click(SUB_POR_PROPS_UPDATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ goToProperties();
+ // - assert d&d is added
+ r = findTableRow(TAB_PROPERTIES, "dragadrop", 0) - 1;
+ Assert
+ .assertTrue(r > -1,
+ "Previously added property drag&drop not found in the property table");
+
+ // - add custom partial refresh prop
+ selenium.type(INP_POR_PROPERTY, "partialRef");
+ selenium.click(SUB_POR_PROPERTY);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // set it's value
+ r = findTableRow(TAB_PROPERTIES, "partialRef", 0) - 1;
+ selenium.type(MessageFormat.format(TAB_PROP_VAL, r), "partialicek");
+ selenium.click(SUB_POR_PROPS_UPDATE);
+ selenium.waitForPageToLoad("30000");
+
+ goToProperties();
+ // - assert partial refresh is added
+ r = findTableRow(TAB_PROPERTIES, "partialRef", 0) - 1;
+
+ Assert
+ .assertTrue(r > -1,
+ "Previously added property partial refresh not found in the property table");
+
+ String propVal = selenium.getValue(MessageFormat
+ .format(TAB_PROP_VAL, r));
+ Assert
+ .assertEquals(propVal, "partialicek",
+ "Previously added property partial refresh not found in the property table");
+
+ // - delete d&d prop
+ r = findTableRow(TAB_PROPERTIES, "dragadrop", 0) - 1;
+ selenium.click(MessageFormat.format(TAB_PROP_DEL, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ goToProperties();
+ // - assert d&d is not present
+ r = findTableRow(TAB_PROPERTIES, "dragadrop", 0) - 1;
+ Assert.assertTrue(r < 0,
+ "Deleted property drag and drop was found in property table.");
+
+ // - delete partial refresh prop
+ r = findTableRow(TAB_PROPERTIES, "partialRef", 0) - 1;
+ selenium.click(MessageFormat.format(TAB_PROP_DEL, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ goToProperties();
+ // - assert partial refresh is not added
+ Assert.assertFalse(selenium.isElementPresent(TAB_PROPERTIES));
+
+ 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);
+
+ r = findTableRow(TAB_PROPERTIES, "Drag and drop", 0) - 1;
+ Assert
+ .assertTrue(r > -1,
+ "Predefined property drag and drop was not found in property table.");
+
+ goToProperties();
+
+ r = findTableRow(TAB_PROPERTIES, "Drag and drop", 0) - 1;
+ selenium.click(MessageFormat.format(TAB_PROP_DEL, r));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ goToProperties();
+
+ Assert.assertFalse(selenium.isElementPresent(TAB_PROPERTIES));
+
+ }
+
+ @Test(enabled = true, description = "Usecase for managing portals - error handling.")
+ public void testPortalErrorHandlingUsecase() {
+
+ String LAB_RED = "Redirect to the specified resource";
+ String LAB_ERR = "Display the default error message";
+ String LAB_REM = "Remove the resource from page";
+
+ // ***
+ // *** Portal level
+ // ***
+
+ // select RED handling
+ goToProperties();
+ selectIfNotSelected(SEL_POL_PA, LAB_RED);
+ selectIfNotSelected(SEL_POL_PU, LAB_RED);
+ selectIfNotSelected(SEL_POL_PE, LAB_RED);
+ selectIfNotSelected(SEL_POL_PI, LAB_RED);
+ selectIfNotSelected(SEL_POL_PN, LAB_RED);
+ selenium.type(INP_POL_PR, "/WEB-INF/jsp/error/portal.jsp");
+ selenium.click(SUB_POL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // assert RED handling
+ logout();
+ login("user", "user");
+ openAndAssert("/portal/auth/portal/admin", "ACCESS_DENIED");
+ openAndAssert("/portal/auth/portal/admin",
+ "View permission not granted has denied access");
+ logout();
+ login("admin", "admin");
+
+ openAndAssert(
+ "/portal/auth/portal/default/Test/Exception+test/ExceptionPortletWindow?op=error&action=1",
+ "ERROR");
+ openAndAssert(
+ "/portal/auth/portal/default/Test/Exception+test/ExceptionPortletWindow?op=error&action=1",
+ "Powered by JBoss Enterprise Portal Platform");
+ openAndAssert(
+ "/portal/portal/default/Test/Exception+test/ExceptionPortletWindow?op=ioexception&action=1",
+ "ERROR");
+ openAndAssert(
+ "/portal/portal/default/Test/Exception+test/ExceptionPortletWindow?op=ioexception&action=1",
+ "Cause: java.io.IOException");
+
+ // select ERR handling
+ goToProperties();
+ selectIfNotSelected(SEL_POL_PA, LAB_ERR);
+ selectIfNotSelected(SEL_POL_PU, LAB_ERR);
+ selectIfNotSelected(SEL_POL_PE, LAB_ERR);
+ selectIfNotSelected(SEL_POL_PI, LAB_ERR);
+ selectIfNotSelected(SEL_POL_PN, LAB_ERR);
+ selenium.type(INP_POL_PR, "/WEB-INF/jsp/error/portal.jsp");
+ selenium.click(SUB_POL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // assert ERR handling
+ logout();
+ login("user", "user");
+ openAndAssert("http://localhost:8080/portal/auth/portal/admin",
+ "HTTP Status 403 - ");
+ logout();
+ login("admin", "admin");
+
+ openAndAssert(
+ "/portal/auth/portal/default/Test/Exception+test/ExceptionPortletWindow?op=error&action=1",
+ "HTTP Status 500");
+ openAndAssert(
+ "/portal/portal/default/Test/Exception+test/ExceptionPortletWindow?op=ioexception&action=1",
+ "HTTP Status 500 -");
+
+ // ***
+ // *** Page level
+ // ***
+
+ // select RED handling
+ goToProperties();
+ selectIfNotSelected(SEL_PAL_PA, LAB_RED);
+ selectIfNotSelected(SEL_PAL_PC, LAB_RED);
+ selectIfNotSelected(SEL_PAL_PE, LAB_RED);
+ selectIfNotSelected(SEL_PAL_PI, LAB_RED);
+ selectIfNotSelected(SEL_PAL_PN, LAB_RED);
+ selenium.type(INP_PAL_PR, "/WEB-INF/jsp/error/page.jsp");
+ selenium.click(SUB_PAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // assert RED handling
+ openAndAssert("/portal/auth/portal/default/Test/Exception+test",
+ "An error occured");
+ //openAndAssert("/portal/auth/portal/default/Test/Exception+test",
+ // "NOT_FOUND ");
+ openAndAssert("/portal/auth/portal/default/Test/Exception+test",
+ "null");
+
+ // select ERR handling
+ goToProperties();
+ selectIfNotSelected(SEL_PAL_PA, LAB_ERR);
+ selectIfNotSelected(SEL_PAL_PC, LAB_ERR);
+ selectIfNotSelected(SEL_PAL_PE, LAB_ERR);
+ selectIfNotSelected(SEL_PAL_PI, LAB_ERR);
+ selectIfNotSelected(SEL_PAL_PN, LAB_ERR);
+ selenium.type(INP_PAL_PR, "/WEB-INF/jsp/error/page.jsp");
+ selenium.click(SUB_PAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // assert ERR handling
+ openAndAssert("/portal/auth/portal/default/Test/Exception+test",
+ "HTTP Status 404");
+
+ // select REM handling
+ goToProperties();
+ selectIfNotSelected(SEL_PAL_PA, LAB_REM);
+ selectIfNotSelected(SEL_PAL_PC, LAB_REM);
+ selectIfNotSelected(SEL_PAL_PE, LAB_REM);
+ selectIfNotSelected(SEL_PAL_PI, LAB_REM);
+ selectIfNotSelected(SEL_PAL_PN, LAB_REM);
+ selenium.type(INP_PAL_PR, "/WEB-INF/jsp/error/page.jsp");
+ selenium.click(SUB_PAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // assert REM handling
+ openAndAssert(
+ "/portal/auth/portal/default/Test/Exception+test/ExceptionPortletWindow?op=error&action=1",
+ "ERROR", false);
+ openAndAssert(
+ "/portal/auth/portal/default/Test/Exception+test/ExceptionPortletWindow?op=error&action=1",
+ "Powered by JBoss Enterprise Portal Platform", false);
+ }
+
+ private void openAndAssert(String add, String ass) {
+ openAndAssert(add, ass, true);
+ }
+
+ private void openAndAssert(String add, String ass, boolean b) {
+ selenium.open(add);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ if (b)
+ Assert.assertTrue(selenium.isTextPresent(ass), "Text: {\"" + ass
+ + "\"} not found on the page");
+ else
+ Assert.assertFalse(selenium.isTextPresent(ass), "Text: {\"" + ass
+ + "\"} was found on the page");
+ }
+
+ private void goToProperties() {
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.click("link=Admin");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ clickIfVisible(TAB_PORTALOBJ_ID);
+ clickIfVisible(LNK_PORTALS_ID);
+ clickIfVisible(LNK_PORTAL_HOME);
+
+ selenium.click("link=Properties");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+
private void assertPageContains(String pageName, String awaitStr) {
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
+
if (selenium.isAlertPresent()) {
- debugPrint("[selenium] debug alert before link: "+selenium.getAlert());
+ selenium.getAlert();
+ debugPrint("[EndtoEndPortalAdminTestCase] - alert was caught");
}
+
selenium.click("link=" + pageName);
- if (selenium.isAlertPresent()) {
- debugPrint("[selenium] debug alert before link: "+selenium.getAlert());
- }
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent(awaitStr));
@@ -159,7 +609,8 @@
clickIfVisible(LNK_PORTALS_ID);
clickIfVisible(LNK_PORTAL_HOME);
- Assert.assertFalse(selenium.isTextPresent(portalName), "Not created page already exist.");
+ Assert.assertFalse(selenium.isTextPresent(portalName),
+ "Not created page already exist.");
selenium.type(INP_PORTALNAME, portalName);
selenium.click(INP_SUBMIT_CREATEPORTAL);
@@ -168,7 +619,7 @@
Assert.assertTrue(selenium.isTextPresent(portalName));
}
- private void addPage(String pageName) {
+ private void addPage(String portalName, String pageName) {
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -188,7 +639,8 @@
selenium.click(MessageFormat.format(POR_TL_MAIN, r));
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertFalse(selenium.isTextPresent(pageName), "Portal page already present");
+ Assert.assertFalse(selenium.isTextPresent(pageName),
+ "Portal page already present");
Assert.assertTrue(selenium.isTextPresent("Create a page named:"));
selenium.type(INP_PAGENAME, pageName);
@@ -197,7 +649,8 @@
Assert.assertTrue(selenium.isTextPresent(pageName));
}
- private void addPortlet(String portalName, String pageName, String portletName, String type) {
+ private void addPortlet(String portalName, String pageName,
+ String portletName, String type) {
selenium.open(ADR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -217,27 +670,16 @@
// click on the page layout
selenium.click(MessageFormat.format(PAG_TL_LAYOUT, r));
- try {
- Thread.sleep(AJAX_WAIT);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ waitFor(AJAX_LOAD);
// hack
selenium.select(SEL_PORTLET_TYPE, "label=" + "cms");
- try {
- Thread.sleep(AJAX_WAIT);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ waitFor(AJAX_LOAD);
selenium.select(SEL_PORTLET_TYPE, "label=" + type);
- try {
- Thread.sleep(AJAX_WAIT);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
+ waitFor(AJAX_LOAD);
+ selenium.setSpeed("5000");
if ("portlet".equals(type)) {
} else if ("widget/google".equals(type)) {
@@ -245,26 +687,32 @@
selenium.click(SUB_GOO_SEARCH);
selenium.waitForPageToLoad(PAGE_LOAD);
} else if ("widget/netvibes".equals(type)) {
+
selenium.type(INP_NET_SEARCH, portletName);
selenium.click(SUB_NET_SEARCH);
selenium.waitForPageToLoad(PAGE_LOAD);
} else if ("cms".equals(type)) {
String[] links = portletName.split("/");
- selenium.click("link=" + links[0]);
- selenium.waitForPageToLoad(PAGE_LOAD);
- portletName = links[1];
+ for (int i = 0; i < links.length - 1; i++) {
+ selenium.click("link=" + links[i]);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+ portletName = links[links.length-1];
+
} else if ("filesystem".equals(type)) {
String[] links = portletName.split("/");
- selenium.click("link=" + links[0]);
- selenium.waitForPageToLoad(PAGE_LOAD);
- portletName = links[1];
+ for (int i = 0; i < links.length - 1; i++) {
+ selenium.click("link=" + links[i]);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ }
+ portletName = links[links.length-1];
}
-
+ selenium.setSpeed("0");
+
selenium.click("link=*" + portletName + "*");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click(SUB_LAYOUT_ADD_CENTER);
selenium.waitForPageToLoad(PAGE_LOAD);
-
}
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PageCoordinationTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PageCoordinationTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PageCoordinationTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -8,6 +8,11 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+/**
+ * The Class PageCoordinationTestCase is responsible for testing of basic coordination configuration on "/portal/auth/portal/default/Coordination+Samples" page.
+ */
+//TODO refactoring needed
+@Test(enabled = true, groups="portal_admin")
public class PageCoordinationTestCase extends JBossPortalSeleniumTestCase {
private final String INP_ALIAS_REN = "//input[contains(@name,'renameForm:newName')]";
private final String SUB_ALIAS_RENAME_SUBMIT = "//input[contains(@name,'renameForm:j_id35')]";
@@ -24,26 +29,69 @@
private final String INP_ALIAS_NAME = "//input[contains(@id,'create-alias-form:aliasName')]";
private final String LIS_RENDER_PAR = "//select[contains(@id,'create-alias-form:alias')]";
+ /** prefix for locator properties = portal.admin.*/
public final String casePfx = "portal.admin.";
- private final String TAB_PORTALOBJ_ID = getProp(casePfx + "tab.portalobj.id", "Link=Admin");
- private final String LINK_PORTALS_ID = getProp(casePfx + "link.portals.id", "link=*Portal Objects*");
- private final String LINK_PORTAL_HOME = getProp(casePfx + "link.portal.home", "//a[contains(@id,'obj-temp-form:object-link-0')]");
- private final String TABLE_PORTAL_ADMIN = getProp(casePfx + "table.portal.admin", "//table[contains(@id,'obj-nav-form:portal-datatable')]");
- private final String POR_TL_MAIN = getProp(casePfx + "por.tl.main", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]");
- private final String TABLE_PORTALPAGE_ADMIN = getProp(casePfx + "table.portalpage.admin", "//table[contains(@id,'obj-nav-form:pages-datatable')]");
- private final String PAG_TL_COORDINATION = getProp(casePfx + "pag.tl.coord", "//a[contains(@id,''pages-datatable:{0}:edit-coord'')]");
+ private final String TAB_PORTALOBJ_ID = getLoc(casePfx + "tab.portalobj.id", "Link=Admin");
+ private final String LINK_PORTALS_ID = getLoc(casePfx + "link.portals.id", "link=*Portal Objects*");
+ private final String LINK_PORTAL_HOME = getLoc(casePfx + "link.portal.home", "//a[contains(@id,'obj-temp-form:object-link-0')]");
+ private final String TABLE_PORTAL_ADMIN = getLoc(casePfx + "table.portal.admin", "//table[contains(@id,'obj-nav-form:portal-datatable')]");
+ private final String POR_TL_MAIN = getLoc(casePfx + "por.tl.main", "//a[contains(@id,''obj-nav-form:portal-datatable:{0}:object-iid-link'')]");
+ private final String TABLE_PORTALPAGE_ADMIN = getLoc(casePfx + "table.portalpage.admin", "//table[contains(@id,'obj-nav-form:pages-datatable')]");
+ private final String PAG_TL_COORDINATION = getLoc(casePfx + "pag.tl.coord", "//a[contains(@id,''pages-datatable:{0}:edit-coord'')]");
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ private void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ private void logoutAfterTest() {
}
-
+
+
+ /**
+ * Tests default page coordination. Four URLs are opened and depending on used parameters the output of coordination portlet is asserted.
+ * <table>
+ * <tr>
+ * <td>1.</td>
+ * <td>"/portal/auth/portal/default/Coordination+Samples"</td>
+ * <td>
+ * "Weather for (my_zipcode):null"
+ * <br/>
+ * "Map for (your_zipcode):null"
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>2.</td>
+ * <td>"/portal/auth/portal/default/Coordination+Samples?zipcode=10101"</td>
+ * <td>
+ * "Weather for (my_zipcode):null"
+ * <br/>
+ * "Map for (your_zipcode):10101"
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>3.</td>
+ * <td>"/portal/auth/portal/default/Coordination+Samples?zip=10102"</td>
+ * <td>
+ * "Weather for (my_zipcode):10102"
+ * <br/>
+ * "Map for (your_zipcode):10102"
+ * </td>
+ * </tr>
+ * <tr>
+ * <td>4.</td>
+ * <td>"/portal/auth/portal/default/Coordination+Samples?zipcode=10103"</td>
+ * <td>
+ * "Weather for (my_zipcode):null"
+ * <br/>
+ * "Map for (your_zipcode):10103"
+ * </td>
+ * </tr>
+ * </table>
+ */
@Test(enabled = true)
public void testDefaultPageCoordination(){
openAndWait("/portal/auth/portal/default/Coordination+Samples");
@@ -63,6 +111,15 @@
Assert.assertTrue(selenium.isTextPresent("Map for (your_zipcode):10103"));
}
+ /**
+ * Tests page coordination. New alias is created on "Coordination Samples" page on "default" portal. It is named "aliasBindTest" and it is bind to "zipcode". At first attempt the creation is canceled,
+ * on the second attpemt it is submited. The final assert is made on "/portal/auth/portal/default/Coordination+Samples?aliasBindTest=222333" and it's asserting this text:
+ * <pre>
+ * "Weather for (my_zipcode):null"
+ * "Map for (your_zipcode):222333"
+ * </pre>
+ *
+ */
@Test(enabled = true, dependsOnMethods ={"testDefaultPageCoordination"})
public void testPageCoordination(){
String portalName = "default";
@@ -103,6 +160,14 @@
}
+ /**
+ * Tests delete alias. New alias is created on "Coordination Samples" page on "default" portal. It is named "aliasBindDelete" and it is bind to "{urn:jboss:portal:samples:coor}zipcode" similar way as in
+ * {@link PageCoordinationTestCase#testPageCoordination()}. The alias is next deleted and it is asserted, that the alias doesnt exist by opening
+ * "/portal/auth/portal/default/Coordination+Samples?aliasBindDelete=222333"
+ * and asserting
+ * "Weather for (my_zipcode):null"
+ * "Map for (your_zipcode):null"
+ */
@Test(enabled = true, dependsOnMethods ={"testDefaultPageCoordination"})
public void testDeleteAlias(){
int count = 0;
@@ -175,6 +240,26 @@
Assert.assertTrue(selenium.isTextPresent("Map for (your_zipcode):null"));
}
+ /**
+ * Tests renaming of an alias. New alias is created on "Coordination Samples" page on "default" portal. It is named "aliasBingRename" and it is bind to "{urn:jboss:portal:samples:coor}zipcode" similar way as in
+ * {@link PageCoordinationTestCase#testPageCoordination()}. The alias is renamed to "aliasBindWasRenamed" and it is asserted, that the previously named alias doesnt exist by opening
+ *
+ * "/portal/auth/portal/default/Coordination+Samples?aliasBingRename=222333"
+ * and asserting
+ * <pre>
+ * "Weather for (my_zipcode):null"
+ * "Map for (your_zipcode):null"
+ * </pre>
+ *
+ * and that the new name is working by opening
+ * "/portal/auth/portal/default/Coordination+Samples?aliasBindWasRenamed=222333"
+ * and asserting
+ * <pre>
+ * "Weather for (my_zipcode):222334"
+ * "Map for (your_zipcode):null"
+ * </pre>
+ */
+ //TODO deeper logic needed
@Test(enabled = true, dependsOnMethods ={"testDefaultPageCoordination"})
public void testRenameAlias(){
String portalName = "default";
@@ -233,6 +318,9 @@
Assert.assertTrue(selenium.isTextPresent("Map for (your_zipcode):null"));
}
+ /**
+ * Tests parameter binding. Parameter bindings flag is turned on and the coordination samples coordination settings page is reloaded. It is asserted that the checkbox is still turned on.
+ */
@Test(enabled = true, dependsOnMethods ={"testDefaultPageCoordination"})
public void testParamBinding(){
String portalName = "default";
@@ -278,6 +366,10 @@
Assert.assertTrue(selenium.isChecked(CHK_PARAM_BIND));
}
+ /**
+ * Tests explicit wiring. Explicit wiring flag is turned on and the coordination samples coordination settings page is reloaded. It is asserted that the checkbox is still turned on.
+ */
+ //TODO deeper logic needed
@Test(enabled = true, dependsOnMethods ={"testDefaultPageCoordination"})
public void testExplicitWiring(){
String portalName = "default";
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletDefinitionsTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -8,47 +8,63 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+/**
+ * The Class PortletDefinitionsTestCase is responsible for testing portlet definitions testing in JBoss Portal.
+ */
+@Test(enabled = true, groups="portal_admin")
public class PortletDefinitionsTestCase extends JBossPortalSeleniumTestCase{
+
+ /** prefix for locator properties = portal.port.def.*/
public final String casePfx = "portal.port.def.";
- private final String T_LINK_PREF = getProp(casePfx+"t.link.pref","//a[contains(@id,''def-list:portlet-pref-{0}'')]");
- private final String SUBMIT_CREATE_INST = getProp(casePfx+"submit.create.inst","//input[contains(@name,'add_instance_form:j_id19')]");
- private final String INPUT_INSTANCE_NAME = getProp(casePfx+"input.instance.name","//input[contains(@id,'add_instance_form:instanceId')]");
- private final String T_LINK_CREATE = getProp(casePfx+"t.link.create","//a[contains(@id,''def-list:create-instance-{0}'')]");
- private final String SUBMIT_PROVIDER_VIEW = getProp(casePfx+"submit.provider.view","//input[contains(@id,'definition-form:view-portlets')]");
- private final String SELECT_PROVIDER = getProp(casePfx+"select.provider","//select[contains(@id,'definition-form:menu')]");
- private final String TABLE_PORTLET = getProp(casePfx+"table.portlet","//form[contains(@id,'def-list')]/table");
- private final String LINK_NAME_ADMIN_PORT = getProp(casePfx+"link.name.admin.port","//a[contains(@id,'common-show-portlet-detail-form:field1:select')]");
- private final String LINK_ADMIN_PORT = getProp(casePfx+"link.admin.port","//a[contains(@id,'def-list:portlet-def-0')]");
- private final String LINK_ADMIN = getProp(casePfx+"link.admin","link=Admin");
- private final String LINK_TAB_PD = getProp(casePfx+"link.tab.pd","//a[contains(@id,'admin-subtab-form:portlet-def-link')]");
- private final String LINK_PD_MAIN = getProp(casePfx+"link.pd.main","//a[contains(@id,'man-form:def-link')]");
+ 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')]");
+ private final String T_LINK_CREATE = getLoc(casePfx+"t.link.create","//a[contains(@id,''def-list:create-instance-{0}'')]");
+ private final String SUBMIT_PROVIDER_VIEW = getLoc(casePfx+"submit.provider.view","//input[contains(@id,'definition-form:view-portlets')]");
+ private final String SELECT_PROVIDER = getLoc(casePfx+"select.provider","//select[contains(@id,'definition-form:menu')]");
+ private final String TABLE_PORTLET = getLoc(casePfx+"table.portlet","//form[contains(@id,'def-list')]/table");
+ private final String LINK_NAME_ADMIN_PORT = getLoc(casePfx+"link.name.admin.port","//a[contains(@id,'common-show-portlet-detail-form:field1:select')]");
+ private final String LINK_ADMIN_PORT = getLoc(casePfx+"link.admin.port","//a[contains(@id,'def-list:portlet-def-0')]");
+ private final String LINK_ADMIN = getLoc(casePfx+"link.admin","link=Admin");
+ private final String LINK_TAB_PD = getLoc(casePfx+"link.tab.pd","//a[contains(@id,'admin-subtab-form:portlet-def-link')]");
+ private final String LINK_PD_MAIN = getLoc(casePfx+"link.pd.main","//a[contains(@id,'man-form:def-link')]");
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ private void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
goToPD();
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ private void logoutAfterTest() {
logout();
}
+ /**
+ * Tests showing of information for portlet definition. In portlet definitions table, test clicks on admin portlet link. Various infomartion about portlet is shown. This
+ * test assert some of them to appear on the screen.
+ */
@Test(enabled = true)
public void testShowInfo(){
selenium.click(LINK_ADMIN_PORT);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("Administration Portlet details "));
+ Assert.assertTrue(selenium.isTextPresent("Administration Portlet details"));
Assert.assertTrue(selenium.isTextPresent("Administration Portlet"));
Assert.assertTrue(selenium.isTextPresent("Management Portlet"));
Assert.assertTrue(selenium.isTextPresent("management,admin"));
Assert.assertTrue(selenium.isTextPresent("Portlet Modes"));
}
+ /**
+ * Testing of creating an instance. In portlet definitions table, test clicks on admin portlet "create instance" button. The instance is named "littleAdmin".
+ * Final assertion is made by the presence of "littleAdmin portlet details" on the screen (after filling the name and clicking "create new instance").
+ */
+ //TODO final assert - better to find it in portlet instances table
@Test(enabled = true)
public void testCreateInstance(){
@@ -63,6 +79,10 @@
Assert.assertTrue(selenium.isTextPresent("littleAdmin portlet details"));
}
+ /**
+ * Testing of creating an instance with uncommon string defining its name. This test does the same as {@link PortletDefinitionsTestCase#testCreateInstance()}.
+ * The only diffenence is in the name of created instance. In this test the string "str.nge.n.me" is used.
+ */
@Test(enabled = true)
public void testCreateInstanceUncommonName(){
@@ -71,12 +91,31 @@
selenium.click(MessageFormat.format(T_LINK_CREATE,r-1));
selenium.waitForPageToLoad(PAGE_LOAD);
- selenium.type(INPUT_INSTANCE_NAME, "str.nge.n.me");
+ selenium.type(INPUT_INSTANCE_NAME, "str|nge|n|me");
selenium.click(SUBMIT_CREATE_INST);
selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertTrue(selenium.isTextPresent("str.nge.n.me"+" portlet details"));
+ Assert.assertTrue(selenium.isTextPresent("str|nge|n|me"+" portlet details"),"instance name not found on screen");
}
+ @Test(enabled = true, groups = {"XSS"})
+ public void testXssCreateInstance(){
+
+ int r = findTableRow(TABLE_PORTLET, "Administration Portlet", 0);
+
+ selenium.click(MessageFormat.format(T_LINK_CREATE,r-1));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INPUT_INSTANCE_NAME, XSS_STR1);
+ selenium.click(SUBMIT_CREATE_INST);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(MSG_INS_NAME_VALID));
+ }
+
+ /**
+ * Tests preferences screen of portlet definition. It clicks on preferences link for "Current Users Portlet" definition and asserts that the string "guestNumber"
+ * is appearing on the screen.
+ */
+ //TODO more asserts needed
@Test(enabled = true)
public void testPreferences(){
@@ -88,6 +127,10 @@
Assert.assertTrue(selenium.isTextPresent("guestNumber"));
}
+ /**
+ * Tests switching the provider. After switching the provider to "self" it's asserted that "Administration portlet" is not present in the portlet definitions table.
+ * After switching th provider to "local" it is asserted, that "Administration portlet" is present in the portlet definitions table.
+ */
@Test(enabled = true)
public void testSwitchProvider(){
selenium.select(SELECT_PROVIDER, "label=self");
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java 2009-07-10 06:06:40 UTC (rev 13536)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/PortletInstancesTestCase.java 2009-07-10 14:25:44 UTC (rev 13537)
@@ -1,5 +1,9 @@
package org.jboss.portal.test.selenium.portal;
+import java.io.BufferedWriter;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.PrintWriter;
import java.text.MessageFormat;
import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
@@ -8,60 +12,79 @@
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+/**
+ * The Class PortletInstancesTestCase is responsible for testing
+ * "portlet instance" configuration features
+ */
+@Test(enabled = true, groups="portal_admin")
public class PortletInstancesTestCase extends JBossPortalSeleniumTestCase {
+
+ /** prefix for locator properties = portal.port.ins. */
public final String casePfx = "portal.port.ins.";
- private final String TAB_PORTLET_INSTANCES = getProp(casePfx + "tab.portlet.instances", "//table[contains(@id,'instancesTable2')]");
- private final String UL_PAGINATOR = getProp(casePfx + "ul.paginator", "//ul[@class='pagination property-container']");
- private final String SUBMIT_SECURITY_UPDATE = getProp(casePfx + "submit.security.update", "//input[contains(@id,'common-edit-security-form:update')]");
- private final String SUBMIT_SECURITY_CANCEL = getProp(casePfx + "submit.security.cancel", "//input[contains(@id,'common-edit-security-form:cancel')]");
- private final String LINK_20_PAGE = getProp(casePfx + "link.20.page", "link=20");
- private final String LINK_PREF_WELCOMEPORT = getProp(casePfx + "link.pref.welcomeport", "//a[contains(@id,'security-JSPPortletInstance')]");
- private final String TABLE_PREF_KEY = getProp(casePfx + "table.pref.key", "//form[contains(@id,'common-edit-pref-form')]/table");
- private final String SUBMIT_PREF_DELETE = getProp(casePfx + "submit.pref.delete", "//input[contains(@id,'common-edit-exisiting-form:row_0')]");
- private final String LINK_PREF_GUESTNUM = getProp(casePfx + "link.pref.guestnum", "//a[contains(@id,'common-edit-pref-form:pref-link-0')]");
- private final String INPUT_PREF_NEWVAL = getProp(casePfx + "input.pref.newval", "//input[contains(@id,'common-append-form:new_value')]");
- private final String SUBMIT_PREF_UPDATE = getProp(casePfx + "submit.pref.update", "//input[contains(@id,'common-append-form:append-button')]");
- private final String SUBMIT_PREF_SAVE = getProp(casePfx + "submit.pref.save", "//input[contains(@id,':save')]");
- private final String INPUT_PREF_UPDATE = getProp(casePfx + "input.pref.update", "//input[contains(@id,'common-edit-exisiting-form:update')]");
- private final String INPUT_PREF_APPEND = getProp(casePfx + "input.pref.append", "//input[contains(@id,'common-edit-exisiting-form:pref-input-0')]");
- private final String SUBMIT_PREF_CANCEL = getProp(casePfx + "submit.pref.cancel", "//input[contains(@id,':cancel')]");
- private final String LINK_CURUSER_PREFERENCES = getProp(casePfx + "link.curuser.preferences","//a[contains(@id,'instances-form:preference-CurrentUsersPortletInstance')]");
- private final String LINK_DEL_EXCEPTPORT = getProp(casePfx + "link.del.exceptport", "//a[contains(@id,'instances-form:delete-GoogleMapPortletInstance')]");
- private final String SUBMIT_PI_DELETE_CONF = getProp(casePfx + "submit.pi.delete.conf", "//input[contains(@id,'confirm-delete-form1:delete')]");
- private final String SUBMIT_PI_DELETE_CANC = getProp(casePfx + "submit.pi.delete.canc", "//input[contains(@id,'confirm-delete-form1:cancel')]");
- private final String T_LINK_DELETENAME = getProp(casePfx + "t.link.deletename","//a[contains(@id,''instance-display-form:locale-datatable:{0}:delete-link'')]");
- private final String T_LINK_MODIFYNAME = getProp(casePfx + "t.link.modifyname","//a[contains(@id,''instance-display-form:locale-datatable:{0}:edit-link'')]");
- private final String LINK_COUNTPORT = getProp(casePfx + "link.countport", "//a[contains(@id,'instances-form:CurrentUsersPortletInstance')]");
- private final String NAME_COUNTPORT = getProp(casePfx + "name.countport", "CurrentUsersPortletInstance");
- private final String SUBMIT_MODIFY_NAME = getProp(casePfx + "submit.modify.name", "//input[contains(@id,'add-display-name-form:addDisplay')]");
- private final String INPUT_NAME = getProp(casePfx + "input.name", "//input[contains(@id,'add-display-name-form:newName')]");
- private final String SELECT_LANGUAGE = getProp(casePfx + "select.language", "//select[contains(@id,'add-display-name-form:locales')]");
- private final String LINK_ADMIN = getProp(casePfx + "link.admin", "link=Admin");
- private final String LINK_TAB_PI = getProp(casePfx + "link.tab.pi", "//a[contains(@id,'admin-subtab-form:portlet-instance-link')]");
- private final String LINK_PI_MAIN = getProp(casePfx + "link.pi.main", "//a[contains(@id,'instance-form1:instance-link')]");
- private final String TABLE_DISPNAMES = getProp(casePfx + "table.dispnames", "//table[contains(@id,'instance-display-form:locale-datatable')]");
- private final String LNK_SEC_BUTTON = getProp(casePfx + "lnk.sec.button","//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''Security'')]");
- private final String LNK_PREF_BUTTON = getProp(casePfx + "lnk.pref.button","//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''actionPreferences'')]");
- private final String LNK_DEL_BUTTON = getProp(casePfx + "lnk.del.button","//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''actionDeleteInstance'')]");
- private final String LNK_INSTANCE_BUTTON = getProp(casePfx + "lnk.instance.button", "//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td[1]/a[1]");
+ private final String PORTLET_INSTANCE = getMess(casePfx+"msg.portlet.name","NewsPortletInstance2");
+ 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')]");
+ private final String SUBMIT_SECURITY_CANCEL = getLoc(casePfx + "submit.security.cancel", "//input[contains(@id,'common-edit-security-form:cancel')]");
+ private final String LINK_20_PAGE = getLoc(casePfx + "link.20.page", "link=20");
+ private final String LINK_PREF_WELCOMEPORT = getLoc(casePfx + "link.pref.welcomeport", "//a[contains(@id,'security-JSPPortletInstance')]");
+ private final String TABLE_PREF_KEY = getLoc(casePfx + "table.pref.key", "//form[contains(@id,'common-edit-pref-form')]/table");
+ private final String SUBMIT_PREF_DELETE = getLoc(casePfx + "submit.pref.delete", "//input[contains(@id,'common-edit-exisiting-form:row_0')]");
+ private final String LINK_PREF_GUESTNUM = getLoc(casePfx + "link.pref.guestnum", "//a[contains(@id,'common-edit-pref-form:pref-link-0')]");
+ private final String INPUT_PREF_NEWVAL = getLoc(casePfx + "input.pref.newval", "//input[contains(@id,'common-append-form:new_value')]");
+ private final String SUBMIT_PREF_UPDATE = getLoc(casePfx + "submit.pref.update", "//input[contains(@id,'common-append-form:append-button')]");
+ private final String SUBMIT_PREF_SAVE = getLoc(casePfx + "submit.pref.save", "//input[contains(@id,':save')]");
+ private final String INPUT_PREF_UPDATE = getLoc(casePfx + "input.pref.update", "//input[contains(@id,'common-edit-exisiting-form:update')]");
+ private final String INPUT_PREF_APPEND = getLoc(casePfx + "input.pref.append", "//input[contains(@id,'common-edit-exisiting-form:pref-input-0')]");
+ private final String SUBMIT_PREF_CANCEL = getLoc(casePfx + "submit.pref.cancel", "//input[contains(@id,':cancel')]");
+ private final String LINK_CURUSER_PREFERENCES = getLoc(casePfx + "link.curuser.preferences",
+ "//a[contains(@id,'instances-form:preference-CurrentUsersPortletInstance')]");
+ private final String LINK_DEL_EXCEPTPORT = getLoc(casePfx + "link.del.exceptport", "//a[contains(@id,'instances-form:delete-GoogleMapPortletInstance')]");
+ private final String SUBMIT_PI_DELETE_CONF = getLoc(casePfx + "submit.pi.delete.conf", "//input[contains(@id,'confirm-delete-form1:delete')]");
+ private final String SUBMIT_PI_DELETE_CANC = getLoc(casePfx + "submit.pi.delete.canc", "//input[contains(@id,'confirm-delete-form1:cancel')]");
+ private final String T_LINK_DELETENAME = getLoc(casePfx + "t.link.deletename",
+ "//a[contains(@id,''instance-display-form:locale-datatable:{0}:delete-link'')]");
+ private final String T_LINK_MODIFYNAME = getLoc(casePfx + "t.link.modifyname",
+ "//a[contains(@id,''instance-display-form:locale-datatable:{0}:edit-link'')]");
+ private final String LINK_COUNTPORT = getLoc(casePfx + "link.countport", "//a[contains(@id,'instances-form:CurrentUsersPortletInstance')]");
+ private final String NAME_COUNTPORT = getLoc(casePfx + "name.countport", "CurrentUsersPortletInstance");
+ private final String SUBMIT_MODIFY_NAME = getLoc(casePfx + "submit.modify.name", "//input[contains(@id,'add-display-name-form:addDisplay')]");
+ private final String INPUT_NAME = getLoc(casePfx + "input.name", "//input[contains(@id,'add-display-name-form:newName')]");
+ private final String SELECT_LANGUAGE = getLoc(casePfx + "select.language", "//select[contains(@id,'add-display-name-form:locales')]");
+ private final String LINK_ADMIN = getLoc(casePfx + "link.admin", "link=Admin");
+ private final String LINK_TAB_PI = getLoc(casePfx + "link.tab.pi", "//a[contains(@id,'admin-subtab-form:portlet-instance-link')]");
+ private final String LINK_PI_MAIN = getLoc(casePfx + "link.pi.main", "//a[contains(@id,'instance-form1:instance-link')]");
+ private final String TABLE_DISPNAMES = getLoc(casePfx + "table.dispnames", "//table[contains(@id,'instance-display-form:locale-datatable')]");
+ private final String LNK_SEC_BUTTON = getLoc(casePfx + "lnk.sec.button",
+ "//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''Security'')]");
+ private final String LNK_PREF_BUTTON = getLoc(casePfx + "lnk.pref.button",
+ "//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''actionPreferences'')]");
+ private final String LNK_DEL_BUTTON = getLoc(casePfx + "lnk.del.button",
+ "//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td/table/tbody/tr/td/a[contains(@class,''actionDeleteInstance'')]");
+ private final String LNK_INSTANCE_BUTTON = getLoc(casePfx + "lnk.instance.button", "//table[contains(@id,''instancesTable2'')]/tbody/tr[{0}]/td[1]/a[1]");
- // private final String LNK_PREF_WELCOMEPORT =
- // "//a[contains(@id,'security-JSPPortletInstance')]";
-
@BeforeMethod(groups = { "log" })
- public void loginBeforeTest() {
+ private void loginBeforeTest() {
logoutIfPossible();
login("admin", "admin");
goToPI();
}
@AfterMethod(groups = { "log" })
- public void logoutAfterTest() {
+ private void logoutAfterTest() {
}
+ /**
+ * Tests adding name for portlet instance. Adds a name "Administracning" for
+ * CurrentUsersPortletInstance in "English" language. The existence of new
+ * name is then asserted in names table.
+ */
@Test(enabled = true)
public void testAddName() {
int r = traversePortlets(NAME_COUNTPORT, 0);
@@ -75,6 +98,33 @@
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, groups = {"XSS"})
+ public void testXssAddName() {
+ int r = traversePortlets(NAME_COUNTPORT, 0);
+ clickAndWait(MessageFormat.format(LNK_INSTANCE_BUTTON, r));
+
+ safeSelect(SELECT_LANGUAGE, "English");
+
+ selenium.type(INPUT_NAME, XSS_STR1);
+ clickAndWait(SUBMIT_MODIFY_NAME);
+
+ Assert.assertTrue(selenium.isTextPresent(MSG_INV_DIS_NAME));
+ }
+
+ /**
+ * Tests deleting a name for portlet instance.A new name "Aduminu" in
+ * "Japanese" language is added for CurrentUsersPortletInstance similar way
+ * as in {@link PortletInstancesTestCase#testAddName()}. The name is then
+ * deleted and it is asserted that it is no longer present in portlet
+ * instance languages table.
+ */
@Test(enabled = true)
public void testDeleteName() {
// adding the name
@@ -98,6 +148,14 @@
Assert.assertFalse(findTableRow(TABLE_DISPNAMES, name, r) >= 0);
}
+ /**
+ * Tests modifying a name for portlet instance.A new name "Adminisimo" in
+ * "Japanese" language is added for CurrentUsersPortletInstance similar way
+ * as in {@link PortletInstancesTestCase#testAddName()}. The name is then
+ * modified to new name "Adminisimo" and it is asserted that the new name is
+ * present in portlet instance languages table.
+ */
+ // TODO assert that old name is not present
@Test(enabled = true)
public void testModifyName() {
int r = traversePortlets(NAME_COUNTPORT, 0);
@@ -125,15 +183,234 @@
Assert.assertTrue(findTableRow(TABLE_DISPNAMES, nameNew, 1) >= 0);
}
+ /**
+ * Tests security of portlet instance. Portlet JSPPortletInstance is set to
+ * two different security states. The first state is:
+ * <table class="datatable full-width">
+ * <thead class="portlet-section-header">
+ * <tr>
+ * <th>Roles</th>
+ * <th>Permissions</th>
+ * </tr>
+ * </thead> <tbody>
+ * <tr class="portlet-section-body">
+ * <td><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * >
+ *
+ * Role Administrators:</label></td>
+ * <td>
+ * <table id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" value="view" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:0"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" value="admin" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:1"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-alternate">
+ * <td><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * >
+ *
+ * Role Users:</label></td>
+ * <td>
+ * <table id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" value="view" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:0"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" value="admin" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:1"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-body">
+ * <td><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * >
+ *
+ * Role Unchecked:</label></td>
+ * <td>
+ * <table id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" checked="checked" value="view" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:0"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" value="admin" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:1"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-alternate">
+ * <td><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * >
+ *
+ * Role secRoleDisp:</label></td>
+ * <td>
+ * <table id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" value="view" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:0"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" value="admin" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:1"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * </tbody>
+ * </table>
+ *
+ * and it is asserted that the portlet is visible after it. Then the
+ * security is changed to:
+ *
+ * <table class="datatable full-width">
+ * <thead class="portlet-section-header">
+ * <tr>
+ * <th>Roles</th>
+ * <th>Permissions</th>
+ * </tr>
+ * </thead> <tbody>
+ * <tr class="portlet-section-body">
+ * <td><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * >
+ *
+ * Role Administrators:</label></td>
+ * <td>
+ * <table id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" checked="checked" value="view" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:0"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" checked="checked" value="admin" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:1"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_0:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-alternate">
+ * <td><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * >
+ *
+ * Role Users:</label></td>
+ * <td>
+ * <table id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" checked="checked" value="view" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:0"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" checked="checked" value="admin" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:1"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_1:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-body">
+ * <td><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * >
+ *
+ * Role Unchecked:</label></td>
+ * <td>
+ * <table id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" value="view" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:0"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" checked="checked" value="admin" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:1"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_2:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * <tr class="portlet-section-alternate">
+ * <td><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * >
+ *
+ * Role secRoleDisp:</label></td>
+ * <td>
+ * <table id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3">
+ * <tbody>
+ * <tr>
+ * <td>
+ * <input type="checkbox" value="view" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:0"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:0"
+ * > View</label></td>
+ * <td>
+ * <input type="checkbox" value="admin" id="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:1"
+ * name="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3"
+ * /><label for="_jbpns_2fadmin_2fdefault_2fAdminPortletWindowsnpbj:j_id384:common-edit-security-form:cars_3:1"
+ * > Admin</label></td>
+ * </tr>
+ * </tbody>
+ * </table>
+ * </td>
+ * </tr>
+ * </tbody>
+ * </table>
+ *
+ * and it is asserted, that portlet instance is not visible. Canceling of setting of permissions is tested, too.
+ *
+ */
+ //TODO reconsider adding more security tests
@Test(enabled = true)
public void testSecure() {
String instance_name = "JSPPortletInstance";
- // String table = TAB_PORTLET_INSTANCES;
- // selenium.click(LINK_20_PAGE);
- // selenium.waitForPageToLoad(PAGE_LOAD);
+ int c = 0;
- // int r = findTableRow(table, instance_name, 0);
int r = traversePortlets(instance_name, 0);
selenium.click(MessageFormat.format(LNK_SEC_BUTTON, r));
@@ -154,10 +431,6 @@
// then cancel
goToPI();
- // selenium.click(LINK_20_PAGE);
- // selenium.waitForPageToLoad(PAGE_LOAD);
-
- // r = findTableRow(table, instance_name, 0);
r = traversePortlets(instance_name, 0);
selenium.click(MessageFormat.format(LNK_SEC_BUTTON, r));
@@ -167,6 +440,7 @@
selenium.click("//input[contains(@name,'common-edit-security-form:cars_0') and @value='admin']");
selenium.click("//input[contains(@name,'common-edit-security-form:cars_2') and @value='admin']");
selenium.click("//input[contains(@name,'common-edit-security-form:cars_1')]");
+
selenium.click(SUBMIT_SECURITY_CANCEL);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.open("/portal/auth/portal/default/");
@@ -175,10 +449,7 @@
// then really stop the greetings portlet
goToPI();
- // selenium.setSpeed("5000");
- // selenium.click(LINK_20_PAGE);
- // selenium.waitForPageToLoad(PAGE_LOAD);
- // r = findTableRow(table, instance_name, 0);
+
r = traversePortlets(instance_name, 0);
selenium.click(MessageFormat.format(LNK_SEC_BUTTON, r));
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -187,6 +458,7 @@
selenium.click("//input[contains(@name,'common-edit-security-form:cars_0') and @value='admin']");
selenium.click("//input[contains(@name,'common-edit-security-form:cars_2') and @value='admin']");
selenium.click("//input[contains(@name,'common-edit-security-form:cars_1')]");
+
selenium.click(SUBMIT_SECURITY_UPDATE);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -195,13 +467,17 @@
Assert.assertFalse(selenium.isTextPresent("Greetings !"));
}
+ /**
+ * Tests deleting of an instance. The instance WeatherPortletInstance is canceled at 1st attempt and deleted at 2nd from the list of instances. It is asserted
+ * that instance is no longer in instances list (with a use of paginator).
+ */
@Test(enabled = true)
public void testDeleteInstance() {
// cancel first
- String instance_name = "RSS portlet Yahoo finance RHT";
- // selenium.setSpeed("5000");
- int r = traversePortlets(instance_name, 1);
-
+ String instance_name = PORTLET_INSTANCE;
+ //selenium.setSpeed("10000");
+ int r = traversePortlets(instance_name, 0);
+ System.out.println(MessageFormat.format(LNK_INSTANCE_BUTTON, r));
Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(LNK_INSTANCE_BUTTON, r)), instance_name + " portlet not found.");
clickAndWait(MessageFormat.format(LNK_DEL_BUTTON, r));
@@ -212,7 +488,7 @@
// delete
goToPI();
- r = traversePortlets(instance_name, 1);
+ r = traversePortlets(instance_name, 0);
Assert.assertTrue(selenium.isElementPresent(MessageFormat.format(LNK_INSTANCE_BUTTON, r)), instance_name + " portlet not found.");
clickAndWait(MessageFormat.format(LNK_DEL_BUTTON, r));
@@ -221,11 +497,14 @@
selenium.click(SUBMIT_PI_DELETE_CONF);
selenium.waitForPageToLoad(PAGE_LOAD);
- r = traversePortlets(instance_name, 1);
+ r = traversePortlets(instance_name, 0);
Assert.assertFalse(selenium.isElementPresent(MessageFormat.format(LNK_INSTANCE_BUTTON, r)), "previously deleted " + instance_name + " portlet found.");
}
-
+
+ /**
+ * Tests paginator of user instances. Every link on paginator is clicked and it is asserted, that the number of portlet instances on the screen is positive.
+ */
@Test(enabled = true)
public void testPaginator() {
@@ -238,12 +517,18 @@
selenium.click("link=" + page);
selenium.waitForPageToLoad(PAGE_LOAD);
r = countTableRows(TAB_PORTLET_INSTANCES);
-
- Assert.assertTrue(r>0,"on instances on paginator page");
+
+ Assert.assertTrue(r > 0, "no instances on paginator page");
}
}
+ /**
+ * Tests preferences of portlet instances. CurrentUsersPortletInstance is used for this test. It's property guestNumber is changed several times and it is asserted, that
+ * the change value is remembered.
+ */
+ //TODO refactor - using locators in code
+ //TODO change more values
@Test(enabled = true)
public void testPreferences() {
@@ -284,10 +569,59 @@
Assert.assertEquals(selenium.getText(TABLE_PREF_KEY + "/tbody/tr[" + r + "]/td[4]"), "[viliam]");
selenium.click(SUBMIT_PREF_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
}
- // acquiring link names from paginator
+ /**
+ * 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, groups = {"XSS"})
+ public void testXssPreferences() {
+
+ int r = traversePortlets(NAME_COUNTPORT, 0);
+ clickAndWait(MessageFormat.format(LNK_PREF_BUTTON, r));
+
+ 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));
+
+ Assert.assertTrue(findTableRow(TABLE_PREF_KEY, "guestNumber", 0) >= 0);
+ selenium.click(LINK_PREF_GUESTNUM);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INPUT_PREF_APPEND, "xssString");
+ selenium.click(INPUT_PREF_UPDATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ selenium.type(INPUT_PREF_APPEND, XSS_STR1);
+ selenium.click(INPUT_PREF_UPDATE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ 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(MSG_PI_PROP_UPDATE_VALID), "validation message wrong or missing.");
+ }
+
+ /**
+ * Gets pages. acquiring link names from paginator
+ *
+ * @param paginator_location
+ * the paginator_location
+ *
+ * @return the pages
+ */
private String[] getPages(String paginator_location) {
String pagi = selenium.getText(paginator_location);
@@ -296,17 +630,24 @@
return pages;
}
- /*
- * function for traversing the portles in the portles table. when a string
- * in selected columns is not found, links form paginator are used to look
- * to the next page
+ /**
+ * Traverses portlets. function for traversing the portles in the portles
+ * table. when a string in selected columns is not found, links form
+ * paginator are used to look to the next page
+ *
+ * @param instance_name
+ * the instance_name
+ * @param row
+ * the row
+ *
+ * @return the int
*/
private int traversePortlets(String instance_name, int row) {
int r = -1;
-
+ Assert.assertTrue(selenium.isElementPresent(TAB_PORTLET_INSTANCES), "portlet instances table not found");
r = findTableRow(TAB_PORTLET_INSTANCES, instance_name, row);
-
+
if (r >= 0)
return r;
@@ -316,6 +657,7 @@
continue;
selenium.click("link=" + page);
selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isElementPresent(TAB_PORTLET_INSTANCES), "portlet instances table not found");
r = findTableRow(TAB_PORTLET_INSTANCES, instance_name, row);
if (r >= 0)
@@ -326,7 +668,7 @@
}
private void goToPI() {
- selenium.open(ADDR_PORTAL);
+ selenium.open(ADR_PORTAL);
clickIfVisible(LINK_ADMIN);
clickIfVisible(LINK_ADMIN);
clickIfVisible(LINK_TAB_PI);
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-cms-wf.xml
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-cms-wf.xml (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-cms-wf.xml 2009-07-10 14:25:44 UTC (rev 13537)
@@ -0,0 +1,37 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="SeleniumTest">
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSFileWorkflowTestCase"
+ verbose="2" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSFileWorkflowTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSSecureTestCase"
+ verbose="2" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSSecureTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSDirectoryTestCase"
+ verbose="2" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSDirectoryTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSFileWorkflowUploadTestCase"
+ verbose="2" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSFileWorkflowUploadTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSArchiveUploadTestCase"
+ verbose="2" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSArchiveUploadTestCase"></class></classes>
+ </test>
+
+<listeners>
+ <listener class-name="org.jboss.portal.test.selenium.JBossSeleniumTestListener"/>
+</listeners>
+</suite>
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-cms.xml
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-cms.xml (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-cms.xml 2009-07-10 14:25:44 UTC (rev 13537)
@@ -0,0 +1,37 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="SeleniumTest">
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSFileTestCase"
+ verbose="2" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSFileTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSSecureTestCase"
+ verbose="2" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSSecureTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSDirectoryTestCase"
+ verbose="2" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSDirectoryTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSFileUploadTestCase"
+ verbose="2" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSFileUploadTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSArchiveUploadTestCase"
+ verbose="2" annotations="JDK">
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSArchiveUploadTestCase"></class></classes>
+ </test>
+
+<listeners>
+ <listener class-name="org.jboss.portal.test.selenium.JBossSeleniumTestListener"/>
+</listeners>
+</suite>
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-noxss.xml
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-noxss.xml (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/testng-noxss.xml 2009-07-10 14:25:44 UTC (rev 13537)
@@ -0,0 +1,164 @@
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<suite name="SeleniumTest">
+
+ <test verbose="2" name="org.jboss.portal.test.selenium.UserLoginTestCase" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.UserLoginTestCase"/>
+ </classes>
+ </test>
+<!--
+ <test name="org.jboss.portal.test.selenium.IdentityAdminTestCase - MultipleLogins" verbose="2"
+ annotations="JDK">
+ <groups>
+ <run>
+ <exclude name="single"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.IdentityAdminTestCase"></class></classes>
+ </test>
+-->
+ <test name="org.jboss.portal.test.selenium.WSRPTestCase" verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.WSRPTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.UserInterceptorPortletTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.UserInterceptorPortletTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.DashboardTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.DashboardTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.portal.AdminPortalTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.portal.AdminPortalTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.portal.AdminPortalWizardTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.portal.AdminPortalWizardTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.portal.PortletDefinitionsTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.portal.PortletDefinitionsTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.portal.PortletInstancesTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.portal.PortletInstancesTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.portal.PageCoordinationTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.portal.PageCoordinationTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSFileTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSFileTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSSecureTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSSecureTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSDirectoryTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSDirectoryTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSFileUploadTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSFileUploadTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.CoordinationSamplesTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.CoordinationSamplesTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.PortalSamplesTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.PortalSamplesTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.PortalAjaxSamplesTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.PortalAjaxSamplesTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.PortalBookstoreSampleTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.PortalBookstoreSampleTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.EndToEndBeaPortlet"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.EndToEndBeaPortlet"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.portal.EndtoEndPortalAdminTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.portal.EndtoEndPortalAdminTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.cms.CMSArchiveUploadTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.cms.CMSArchiveUploadTestCase"></class></classes>
+ </test>
+
+ <test name="org.jboss.portal.test.selenium.core.HttpHeaderTestCase"
+ verbose="2" annotations="JDK">
+ <groups><run><exclude name="XSS"></exclude></run></groups>
+ <classes>
+ <class name="org.jboss.portal.test.selenium.core.HttpHeaderTestCase"></class></classes>
+ </test>
+
+<listeners>
+<!-- <listener class-name="org.testng.reporters.JUnitXMLReporter"></listener>
+-->
+ <listener class-name="org.jboss.portal.test.selenium.JBossSeleniumTestListener"/>
+</listeners>
+</suite>
16 years, 10 months
JBoss Portal SVN: r13536 - jbossexo/modules/common.
by portal-commits@lists.jboss.org
Author: julien_viet
Date: 2009-07-10 02:06:40 -0400 (Fri, 10 Jul 2009)
New Revision: 13536
Added:
jbossexo/modules/common/branches/
Log:
just added a branch were I can add a sanitized version of common
16 years, 10 months
JBoss Portal SVN: r13535 - jbossexo/modules/common.
by portal-commits@lists.jboss.org
Author: mwringe
Date: 2009-07-09 15:19:30 -0400 (Thu, 09 Jul 2009)
New Revision: 13535
Added:
jbossexo/modules/common/trunk/
Log:
Copy over common module (Revision 13534)
Copied: jbossexo/modules/common/trunk (from rev 13534, modules/common/trunk)
16 years, 10 months
JBoss Portal SVN: r13534 - jbossexo/modules.
by portal-commits@lists.jboss.org
Author: mwringe
Date: 2009-07-09 15:15:54 -0400 (Thu, 09 Jul 2009)
New Revision: 13534
Added:
jbossexo/modules/common/
Log:
Add the common module directory
16 years, 10 months
JBoss Portal SVN: r13533 - in branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium: sso and 1 other directory.
by portal-commits@lists.jboss.org
Author: mposolda(a)redhat.com
Date: 2009-07-09 11:41:36 -0400 (Thu, 09 Jul 2009)
New Revision: 13533
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java
Log:
SSO selenium test classes merged to the epp branch.
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/CASSeleniumTestCase.java 2009-07-09 15:41:36 UTC (rev 13533)
@@ -0,0 +1,246 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * The Class CASSeleniumTestCase is reponsible for testing of the JBoss Portal with cooperation of CAS (Central Authentication Service).
+ *
+ * @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 SSOSeleniumTestCase {
+
+ /** prefix for locator properties */
+ public String casePfx = "sso.cas.";
+
+ private final String PORTAL_ADMIN_USERNAME = "admin";
+ private final String PORTAL_ADMIN_PASSWORD = "admin";
+ private final String PORTAL_USER_USERNAME = "user";
+ private final String PORTAL_USER_PASSWORD = "user";
+ private final String PORTAL_CYRIL_USERNAME = "cyril";
+ private final String PORTAL_CYRIL_PASSWORD = "password";
+ private final String PORTAL_CYRIL_MAIL = "cyril(a)redhat.com";
+ private final String PORTAL_CYRIL_ROLE = "Cyril";
+
+ // TODO: uncomment and remove getProp part
+
+ /*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 LINK_LOGIN = getLoc(casePfx+"lnk.login", "link=Login");
+ private final String LINK_ADMIN = getLoc(casePfx+"lnk.admin", "link=Admin");
+ private final String LINK_WEATHER = getLoc(casePfx+"lnk.weather", "link=Weather");
+ private final String LINK_COPY_DASHBOARD = getLoc(casePfx+"lnk.cp.dashboard", "link=Copy to my dashboard");
+ private final String LINK_CONFIGURE_DASHBOARD = getLoc(casePfx+"lnk.conf.dashboard", "link=Configure dashboard");
+ private final String LINK_DASHBOARD = getLoc(casePfx+"lnk.dashboard", "link=Dashboard");
+ private final String LINK_LOGOUT = getLoc(casePfx+"lnk.logout", "link=Logout");
+ private final String FORBIDDEN_ELEMENT = getLoc(casePfx+"forbidden.element", "//h1");
+
+ private final String CAS_INPUT_USERNAME = getLoc(casePfx + "cas.input.username", "username");
+ private final String CAS_INPUT_PASSWORD = getLoc(casePfx + "cas.input.password", "password");
+ private final String CAS_SUBMIT_LOGIN = getLoc(casePfx + "cas.submit.login", "//input[@value='LOGIN']");
+ private final String CAS_IMAGE = getLoc(casePfx + "cas.image", "//img[@alt='Central Authentication Service']");
+
+ private final String CAS_INVALID_AUTH = getMess(casePfx + "cas.invalid.auth", "The credentials you provided cannot be determined to be authentic.");
+ private final String CAS_LOGIN_MESSAGE = getMess(casePfx + "cas.login.mess", "Enter your JA-SIG NetID and Password.");
+ private final String CAS_LOGOUT_SUCCESSFULL = getMess(casePfx + "cas.logout.succ", "Logout successful");
+
+ 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 ADR_PORTAL = getProp(casePfx+"adr.portal","/portal");
+ private final String ADR_PORTAL_ADMIN = getProp(casePfx+"adr.portal.admin","/portal/auth/portal/admin");
+ private final String ADR_PORTAL_DEFAULT = getProp(casePfx+"adr.portal.default","/portal/auth/portal/default");
+
+ private final String LINK_LOGIN = getProp(casePfx+"lnk.login", "link=Login");
+ private final String LINK_ADMIN = getProp(casePfx+"lnk.admin", "link=Admin");
+ private final String LINK_WEATHER = getProp(casePfx+"lnk.weather", "link=Weather");
+ private final String LINK_COPY_DASHBOARD = getProp(casePfx+"lnk.cp.dashboard", "link=Copy to my dashboard");
+ private final String LINK_CONFIGURE_DASHBOARD = getProp(casePfx+"lnk.conf.dashboard", "link=Configure dashboard");
+ private final String LINK_DASHBOARD = getProp(casePfx+"lnk.dashboard", "link=Dashboard");
+ private final String LINK_LOGOUT = getProp(casePfx+"lnk.logout", "link=Logout");
+ private final String FORBIDDEN_ELEMENT = getProp(casePfx+"forbidden.element", "//h1");
+
+ private final String CAS_INPUT_USERNAME = getProp(casePfx + "cas.input.username", "username");
+ private final String CAS_INPUT_PASSWORD = getProp(casePfx + "cas.input.password", "password");
+ private final String CAS_SUBMIT_LOGIN = getProp(casePfx + "cas.submit.login", "//input[@value='LOGIN']");
+ private final String CAS_IMAGE = getProp(casePfx + "cas.image", "//img[@alt='Central Authentication Service']");
+
+ private final String CAS_INVALID_AUTH = getProp(casePfx + "cas.invalid.auth", "The credentials you provided cannot be determined to be authentic.");
+ private final String CAS_LOGIN_MESSAGE = getProp(casePfx + "cas.login.mess", "Enter your JA-SIG NetID and Password.");
+ private final String CAS_LOGOUT_SUCCESSFULL = getProp(casePfx + "cas.logout.succ", "Logout successful");
+
+ private final String PORTAL_LOGGED_IN_AS_MESSAGE = getProp(casePfx + "logged.in.mess", "Logged in as: ");
+ private final String PORTAL_FORBIDDEN_MESS = getProp(casePfx + "forbidden.mess", "HTTP Status 403 -");
+
+ @BeforeMethod(groups = { "log" })
+ private void logoutBeforeTest() {
+ logoutIfPossible();
+ }
+
+ /**
+ * This method tests couple of bad login attempts with usage of CAS.
+ * After click to "Login" link from portal, the user is redirected to CAS login screen and then he tries to login with credentials:
+ * "admin:adminadmin" , "cyril:cyril", "cyril:password"
+ */
+ @Test(enabled = true)
+ public void badLoginsToCAS() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_ADMIN_USERNAME, "adminadmin");
+ Assert.assertTrue(selenium.isTextPresent(CAS_INVALID_AUTH), "Message about invalid credentials should be shown.");
+ tryToLogin(PORTAL_CYRIL_USERNAME, "cyril");
+ Assert.assertTrue(selenium.isTextPresent(CAS_INVALID_AUTH), "Message about invalid credentials should be shown.");
+ tryToLogin(PORTAL_CYRIL_USERNAME, "password");
+ Assert.assertTrue(selenium.isTextPresent(CAS_INVALID_AUTH), "Message about invalid credentials should be shown.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of CAS.
+ * After click to "Login" link from portal, the user is redirected to CAS login screen and then he tries to login with credentials:
+ * "user:user". He is logged in and then he goes to some page. He tries the admin portal, but he ends with 403 error. Then he is logged out. After
+ * logging out, he should be redirected to default portal page.
+ */
+ @Test(enabled = true)
+ public void loginAsUserAndLoggedOut() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_USER_USERNAME), "Message about 'Logged in as:' should be shown. But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE), "CAS page should not be shown after successfull login.");
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link 'configure dashboard' should be shown.");
+ // try to go to "admin" portal. This must end with 403 error, because user doesn't have permission to go to this portal.
+ openAndWait(ADR_PORTAL_ADMIN);
+ Assert.assertEquals(PORTAL_FORBIDDEN_MESS, selenium.getText(FORBIDDEN_ELEMENT), "Forbidden message should be shown while trying to go to 'admin' portal.");
+ // go to default portal and logout
+ openAndWait(ADR_PORTAL_DEFAULT);
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE), "CAS page should be shown after logout from JBoss Portal.");
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL), "Logout successfull message should be shown on CAS page.");
+ }
+
+ /**
+ * After opening URL like: http://localhost:8080/portal/auth/portal/admin the user should be redirected to CAS login page.
+ * The User "user" should have 403 error while trying to go to admin portal, but he should be able to go to http://localhost:8080/portal/auth/portal/default
+ */
+ @Test(enabled = true)
+ public void loginAsUserWhileGoingToAuthURL() {
+ // 403 error after trying to go to admin portal as user
+ openAndWait(ADR_PORTAL_ADMIN);
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE), "CAS page should be shown while trying to access admin portal.");
+ tryToLogin(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
+ Assert.assertEquals(PORTAL_FORBIDDEN_MESS, selenium.getText(FORBIDDEN_ELEMENT), "Forbidden message should be shown while trying to go to 'admin' portal.");
+ // going to default portal. Everythink should be ok.
+ openAndWait(ADR_PORTAL_DEFAULT);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_USER_USERNAME), "Message about 'Logged in as:' should be shown. But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE), "CAS page should not be shown after successfull login.");
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link 'configure dashboard' should be shown.");
+ // logout (redirected to CAS page)
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE), "CAS page should be shown after logout from JBoss Portal.");
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL), "Logout successfull message should be shown on CAS page.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of CAS.
+ * After clicks to "Login" link from portal, the user is redirected to CAS login screen and then he tries to login with credentials:
+ * "admin:admin". He is logged in and then he goes to admin portal, and he creates role "Cyril" and user "cyril" with password "password". Then admin logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = { "badLoginsToCAS" })
+ public void loginAsAdminAndCreateNewRoleAndUser() {
+ loginToPortalAsAdmin();
+ createRole(PORTAL_CYRIL_ROLE, PORTAL_CYRIL_ROLE);
+ 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), "Message about 'Logged in as: admin' should be shown. But it's not here.");
+ logoutIfPossible();
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL), "Logout successfull message should be shown on CAS page.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of CAS.
+ * After clicks to "Login" link from portal the user is redirected to CAS login screen and then he tries to login with credentials:
+ * "cyril:cyril", which is bad and then "cyril:password" which is good. Then cyril tries to do some dashboard operations and then logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = { "loginAsAdminAndCreateNewRoleAndUser" })
+ public void loginAsCyrilAndPlayWithDashboard() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_CYRIL_USERNAME, PORTAL_CYRIL_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_CYRIL_USERNAME), "Message about 'Logged in as: cyril' should be shown. But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE), "CAS page should not be shown after successfull login.");
+ // TODO: uncomment this after fixing the CMS bug with Access denied
+ // Assert.assertFalse(selenium.isTextPresent("Access Denied"));
+ waitFor(3000);
+ clickAndWait(LINK_WEATHER);
+ Assert.assertTrue(selenium.isElementPresent(LINK_COPY_DASHBOARD), "Link 'copy to dashboard' should be shown.");
+ clickAndWait(LINK_COPY_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link 'configure dashboard' should be shown.");
+ logoutIfPossible();
+ }
+
+ /**
+ * This test loggs admin in and then admin deletes Cyril role and cyril user. Then logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = { "loginAsCyrilAndPlayWithDashboard" })
+ public void deleteCyrilRoleAndUser() {
+ loginToPortalAsAdmin();
+ deleteRole(PORTAL_CYRIL_ROLE);
+ deleteUser(PORTAL_CYRIL_USERNAME, PORTAL_CYRIL_MAIL);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "Message about 'Logged in as: admin' should be shown. But it's not here.");
+ logoutIfPossible();
+ }
+
+ /**
+ * Loggs into portal as admin with usage of CAS.
+ */
+ private void loginToPortalAsAdmin() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "Message about 'Logged in as: admin' should be shown. But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(CAS_IMAGE), "CAS page should not be shown after successfull login.");
+ Assert.assertTrue(selenium.isElementPresent(LINK_ADMIN), "Link to admin portal should be shown when admin is logged to JBoss Portal.");
+ }
+
+ /**
+ * This helper method is used to open portal page (http://localhost:8080/portal) then click to 'Login' link and verifies if
+ * CAS login page is shown. Method shouldn't be called when some user is logged into portal.
+ */
+ private void openPortalAndClickToLogin() {
+ openAndWait(ADR_PORTAL);
+ clickAndWait(LINK_LOGIN);
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGIN_MESSAGE), "CAS page should be shown after click to 'login' link in JBoss Portal.");
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE), "CAS page should be shown after click to 'login' link in JBoss Portal.");
+ }
+
+ /**
+ * This method tries to login into CAS. The condition is, that CAS login page is shown when this method is called.
+ * Any test (whether login was success or not) are not performed during this method.
+ * @param username
+ * @param password
+ */
+ private void tryToLogin(String username, String password) {
+ selenium.type(CAS_INPUT_USERNAME, username);
+ selenium.type(CAS_INPUT_PASSWORD, password);
+ clickAndWait(CAS_SUBMIT_LOGIN);
+ }
+
+ /**
+ * Overriden method. Because after click to logout, the CAS page is shown.
+ */
+ @Test(enabled = false)
+ public void logoutIfPossible() {
+ selenium.open(ADR_PORTAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ if (selenium.isElementPresent(LINK_LOGOUT)) {
+ selenium.click(LINK_LOGOUT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isElementPresent(CAS_IMAGE), "CAS page should be shown after logout from JBoss Portal.");
+ Assert.assertTrue(selenium.isTextPresent(CAS_LOGOUT_SUCCESSFULL), "Logout successfull message should be shown on CAS page.");
+ }
+ }
+
+}
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/JOSSOSeleniumTestCase.java 2009-07-09 15:41:36 UTC (rev 13533)
@@ -0,0 +1,347 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * The Class JOSSOSeleniumTestCase is reponsible for testing of the JBoss Portal with cooperation of JOSSO (Java Open Single Sign On).
+ *
+ * @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 SSOSeleniumTestCase {
+
+ /** prefix for locator properties */
+ public String casePfx = "sso.josso.";
+
+ private final String PORTAL_ADMIN_USERNAME = "admin";
+ private final String PORTAL_ADMIN_PASSWORD = "admin";
+ private final String PORTAL_USER_USERNAME = "user";
+ private final String PORTAL_USER_PASSWORD = "user";
+ private final String PORTAL_JOSEPH_USERNAME = "joseph";
+ private final String PORTAL_JOSEPH_PASSWORD = "password";
+ private final String PORTAL_JOSEPH_MAIL = "joseph(a)redhat.com";
+ private final String PORTAL_JOSEPH_ROLE = "Joseph";
+
+ // TODO: uncomment and remove getProp part
+
+ /*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");
+ private final String LINK_WEATHER = getLoc(casePfx+"lnk.weather", "link=Weather");
+ private final String LINK_COPY_DASHBOARD = getLoc(casePfx+"lnk.cp.dashboard", "link=Copy to my dashboard");
+ private final String LINK_CONFIGURE_DASHBOARD = getLoc(casePfx+"lnk.conf.dashboard", "link=Configure dashboard");
+ private final String LINK_DASHBOARD = getLoc(casePfx+"lnk.dashboard", "link=Dashboard");
+ private final String LINK_LOGOUT = getLoc(casePfx+"lnk.logout", "link=Logout");
+ private final String FORBIDDEN_ELEMENT = getLoc(casePfx+"forbidden.element", "//h1");
+
+ private final String JOSSO_INPUT_USERNAME = getLoc(casePfx + "josso.input.username", "josso_username");
+ private final String JOSSO_INPUT_PASSWORD = getLoc(casePfx + "josso.input.password", "josso_password");
+ private final String JOSSO_SUBMIT_LOGIN = getLoc(casePfx + "josso.submit.login", "//input[@value='Login']");
+ private final String JOSSO_IMAGE = getLoc(casePfx + "josso.image", "//img[@alt='Java Open Single SignOn']");
+
+ 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_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");
+ */
+
+ private final String ADR_PORTAL = getProp(casePfx+"adr.portal","/portal");
+ private final String ADR_PORTAL_ADMIN = getProp(casePfx+"adr.portal.admin","/portal/auth/portal/admin");
+ private final String ADR_PORTAL_DEFAULT = getProp(casePfx+"adr.portal.default","/portal/auth/portal/default");
+ private final String ADR_PORTAL_SESSION_TEST = getProp(casePfx+"adr.portal.test.session","/portal/auth/portal/default/Test/Session+test");
+
+ private final String LINK_LOGIN = getProp(casePfx+"lnk.login", "link=Login");
+ private final String LINK_ADMIN = getProp(casePfx+"lnk.admin", "link=Admin");
+ private final String LINK_WEATHER = getProp(casePfx+"lnk.weather", "link=Weather");
+ private final String LINK_COPY_DASHBOARD = getProp(casePfx+"lnk.cp.dashboard", "link=Copy to my dashboard");
+ private final String LINK_CONFIGURE_DASHBOARD = getProp(casePfx+"lnk.conf.dashboard", "link=Configure dashboard");
+ private final String LINK_DASHBOARD = getProp(casePfx+"lnk.dashboard", "link=Dashboard");
+ private final String LINK_LOGOUT = getProp(casePfx+"lnk.logout", "link=Logout");
+ private final String FORBIDDEN_ELEMENT = getProp(casePfx+"forbidden.element", "//h1");
+
+ private final String JOSSO_INPUT_USERNAME = getProp(casePfx + "josso.input.username", "josso_username");
+ private final String JOSSO_INPUT_PASSWORD = getProp(casePfx + "josso.input.password", "josso_password");
+ private final String JOSSO_SUBMIT_LOGIN = getProp(casePfx + "josso.submit.login", "//input[@value='Login']");
+ private final String JOSSO_IMAGE = getProp(casePfx + "josso.image", "//img[@alt='Java Open Single SignOn']");
+
+ private final String JOSSO_INVALID_AUTH = getProp(casePfx + "josso.invalid.auth", "Invalid Authentication Information");
+
+ private final String PORTAL_LOGGED_IN_AS_MESSAGE = getProp(casePfx + "logged.in.mess", "Logged in as: ");
+ private final String PORTAL_FORBIDDEN_MESS = getProp(casePfx + "forbidden.mess", "HTTP Status 403 -");
+ private final String PORTAL_SESSION_TEST_NO_SESSION = getProp("samples.ses.no", "No session");
+ private final String PORTAL_SESSION_TEST_ID = getProp("samples.ses.id", "Session id");
+
+ public final String TBL_CMS_FILE = getProp("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 = getProp("samples.ses.sub.pscope", "portlet");
+ private final String SES_INP_VAL = getProp("samples.ses.inp.val", "value");
+ private final String SES_INP_NAM = getProp("samples.ses.inp.nam", "name");
+
+ @BeforeMethod(groups = { "log" })
+ private void logoutBeforeTest() {
+ logoutIfPossible();
+ }
+
+ /**
+ * This method tests couple of bad login attempts with usage of JOSSO.
+ * After clicks to "Login" link from portal, the user is redirected to JOSSO login screen and then he tries to login with credentials:
+ * "admin:adminadmin" , "joseph:joseph", "joseph:password"
+ */
+ @Test(enabled = true)
+ public void badLoginsToJOSSO() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_ADMIN_USERNAME, "adminadmin");
+ Assert.assertTrue(selenium.isTextPresent(JOSSO_INVALID_AUTH), "Message about invalid credentials should be shown.");
+ tryToLogin(PORTAL_JOSEPH_USERNAME, "joseph");
+ Assert.assertTrue(selenium.isTextPresent(JOSSO_INVALID_AUTH), "Message about invalid credentials should be shown.");
+ // Joseph is not created right now, so authentication can't be good
+ tryToLogin(PORTAL_JOSEPH_USERNAME, PORTAL_JOSEPH_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(JOSSO_INVALID_AUTH), "Message about invalid credentials should be shown.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of JOSSO.
+ * After clicks to "Login" link from portal, the user is redirected to JOSSO login screen and then he tries to login with credentials:
+ * "user:user". He is logged in and then he goes to some page. He tries the admin portal, but he ends with 403 error. Then he is logged out. After
+ * logging out, he should be redirected to default portal page.
+ */
+ @Test(enabled = true)
+ public void loginAsUserAndLoggedOut() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_USER_USERNAME), "Message about 'Logged in as: user' should be shown. But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not be shown after successfull login.");
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link 'configure dashboard' should be shown.");
+ // try to go to "admin" portal. This must end with 403 error, because user doesn't have permission to go to this portal.
+ openAndWait(ADR_PORTAL_ADMIN);
+ Assert.assertEquals(PORTAL_FORBIDDEN_MESS, selenium.getText(FORBIDDEN_ELEMENT), "Forbidden message should be shown while trying to go to 'admin' portal.");
+ // go to default portal and logout
+ openAndWait(ADR_PORTAL_DEFAULT);
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not be shown after successfull logout.");
+ Assert.assertTrue(selenium.isElementPresent(LINK_LOGIN), "Link 'login' should be shown on JBoss Portal while user logges out.");
+ }
+
+ /**
+ * After opening URL like: http://localhost:8080/portal/auth/portal/admin the user should be redirected to JOSSO login page.
+ * The User "user" should have 403 error while trying to go to admin portal, but he should be able to go to http://localhost:8080/portal/auth/portal/default
+ */
+ @Test(enabled = true)
+ public void loginAsUserWhileGoingToAuthURL() {
+ // 403 error after trying to go to admin portal as user
+ openAndWait(ADR_PORTAL_ADMIN);
+ Assert.assertTrue(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not be shown after successfull login.");
+ tryToLogin(PORTAL_USER_USERNAME, PORTAL_USER_PASSWORD);
+ Assert.assertEquals(PORTAL_FORBIDDEN_MESS, selenium.getText(FORBIDDEN_ELEMENT), "Forbidden message should be shown while trying to go to 'admin' portal.");
+ // going to default portal. Everythink should be ok.
+ openAndWait(ADR_PORTAL_DEFAULT);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_USER_USERNAME), "Message about 'Logged in as: user' should be shown. But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not be shown after successfull login.");
+ // click to dashboard as user.
+ clickAndWait(LINK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link 'configure dashboard' should be shown.");
+ // logout
+ clickAndWait(LINK_LOGOUT);
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not be shown after successfull logout.");
+ Assert.assertTrue(selenium.isElementPresent(LINK_LOGIN), "Link 'login' should be shown on JBoss Portal while user logges out.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of JOSSO.
+ * After clicks to "Login" link from portal, the user is redirected to JOSSO login screen and then he tries to login with credentials:
+ * "admin:admin". He is logged in and then he goes to admin portal, and he creates role "Joseph" and user "joseph" with password "password". Then admin logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = { "badLoginsToJOSSO" })
+ public void loginAsAdminAndCreateNewRoleAndUser() {
+ loginToPortalAsAdmin();
+ createRole(PORTAL_JOSEPH_ROLE, PORTAL_JOSEPH_ROLE);
+ 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), "Message about 'Logged in as: joseph' should be shown. But it's not here.");
+ logout();
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not be shown after successfull logout.");
+ }
+
+ /**
+ * This method tests good login attempt with usage of JOSSO.
+ * After clicks to "Login" link from portal, the user is redirected to JOSSO login screen and then he tries to login with credentials:
+ * "joseph:joseph", which is bad and then "joseph:password" which is good. Then joseph tries to do some dashboard stuff and then logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = { "loginAsAdminAndCreateNewRoleAndUser" })
+ public void loginAsJosephAndPlayWithDashboard() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_JOSEPH_USERNAME, PORTAL_JOSEPH_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_JOSEPH_USERNAME), "Message about 'Logged in as: joseph' should be shown. But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not be shown after successfull login.");
+ // TODO: uncomment this after fixing the CMS bug with Access denied
+ // Assert.assertFalse(selenium.isTextPresent("Access Denied"));
+ waitFor(3000);
+ clickAndWait(LINK_WEATHER);
+ Assert.assertTrue(selenium.isElementPresent(LINK_COPY_DASHBOARD), "Link 'copy dashboard' should be present.");
+ clickAndWait(LINK_COPY_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LINK_CONFIGURE_DASHBOARD), "Link 'configure dashboard' should be present.");
+ logout();
+ }
+
+ /**
+ * This test loggs admin in and then admin deletes Joseph role and joseph user. Then logges out.
+ */
+ @Test(enabled = true, dependsOnMethods = { "loginAsJosephAndPlayWithDashboard" })
+ public void deleteJosephRoleAndUser() {
+ loginToPortalAsAdmin();
+ deleteRole(PORTAL_JOSEPH_ROLE);
+ deleteUser(PORTAL_JOSEPH_USERNAME, PORTAL_JOSEPH_MAIL);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "Message about 'Logged in as: admin' should be shown. But it's not here.");
+ logout();
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not be shown after successfull logout.");
+ }
+
+ /**
+ * 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), "Sign 'No session' should be in session test, but it isn't.");
+ 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), "Sign about session should be in session test, but it isn't. Session should be present.");
+
+ // 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), "Sign 'No session' should be in session test, but it isn't.");
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "Message about 'Logged in as: admin' should be still here after session timeout. But it's not here.");
+ }
+
+ /**
+ * 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"), "newFile should be created and shown in CMS 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.
+ * 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"), "Link text/plain should be here.");
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertEquals("file2copy", selenium.getText("link=file2copy"), "File file2copy should be here.");
+
+ 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"), "Link 'file2copy' should be her but it isn't.");
+
+ selenium.click("link=Home");
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ Assert.assertTrue(selenium.isElementPresent("link=file2copy"), "Link file2copy should be here but it isn't.");
+ }
+
+ /**
+ * Loggs into portal as admin with usage of JOSSO.
+ */
+ private void loginToPortalAsAdmin() {
+ openPortalAndClickToLogin();
+ tryToLogin(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should be shown. But it's not here.");
+ Assert.assertFalse(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should not be shown after successfull login to JBoss Portal.");
+ Assert.assertTrue(selenium.isElementPresent(LINK_ADMIN), "Link 'admin' should be present when user is logged as admin.");
+ }
+
+ /**
+ * This helper method is used to open portal page (http://localhost:8080/portal) then click to 'Login' link and verifies if
+ * JOSSO login page is shown. Method shouldn't be called when some user is logged into portal.
+ */
+ private void openPortalAndClickToLogin() {
+ openAndWait(ADR_PORTAL);
+ clickAndWait(LINK_LOGIN);
+ Assert.assertTrue(selenium.isElementPresent(JOSSO_IMAGE), "JOSSO page should be shown after click to 'login' link on JBoss Portal.");
+ }
+
+ /**
+ * This method tries to login into JOSSO. The condition is, that JOSSO login page is shown when this method is called.
+ * Any test (whether login was success or not) are not performed during this method.
+ * @param username
+ * @param password
+ */
+ private void tryToLogin(String username, String password) {
+ selenium.type(JOSSO_INPUT_USERNAME, username);
+ selenium.type(JOSSO_INPUT_PASSWORD, password);
+ clickAndWait(JOSSO_SUBMIT_LOGIN);
+ }
+
+}
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/SSOSeleniumTestCase.java 2009-07-09 15:41:36 UTC (rev 13533)
@@ -0,0 +1,226 @@
+package org.jboss.portal.test.selenium.sso;
+
+import java.text.MessageFormat;
+
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+import org.testng.Assert;
+
+/**
+ * The class is used for inheritance by other SSO test cases (CASSeleniumTestCase, JOSSOSeleniumTestCase, ...) It contains helper methods
+ * for manipulation with users and roles (creating new user, creating role, delete user, etc.) nad other stuff which is
+ * shared by all SSO test cases.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+class SSOSeleniumTestCase extends JBossPortalSeleniumTestCase {
+
+ /** prefix for locator properties */
+ public String casePfx = "iden.man.";
+
+ // TODO: uncomment and remove getProp part
+
+ /*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 String TBL_ROLELIST = getProp(casePfx + "tbl.rolelist", "//table[contains(@id,'roles-form:userlist')]");
+
+ private final String LNK_T_ROLLIST_DEL = getProp(casePfx + "lnk.t.rollist.del", "//a[contains(@id,''roles-form:userlist:{0}:delete-role-link'')]");
+
+ private final String SUB_CONF_CREATE_USER = getProp(casePfx + "sub.conf.create.user", "//input[contains(@id,'confirm-form:admin')]");
+ private final String SUB_DELETE_ROLE = getProp(casePfx + "sub.delete.role", "//input[contains(@id,'delete-role-form:confirm')]");
+ private final String SUB_ROLE_CREATE = getProp(casePfx + "sub.role.create", "//input[contains(@id,'create-role-form:submit')]");
+ private final String INP_ROLEDISNAME = getProp(casePfx + "inp.roledisname", "//input[contains(@id,'create-role-form:roledisplayname')]");
+ private final String INP_ROLENAME = getProp(casePfx + "inp.rolename", "//input[contains(@id,'create-role-form:rolename')]");
+ private final String TBL_USERLIST = getProp(casePfx + "tbl.userlist", "//table[contains(@id,'search-user-form1:userlist')]");
+ private final String LNK_ROLE_CREATE = getProp(casePfx + "lnk.role.create", "//a[contains(@id, 'create-role-form:create-role-link')]");
+ private final String SUB_DEL_USER = getProp(casePfx + "sub.del.user", "//input[contains(@id,'delete-user-form:submit')]");
+
+ private final String SUB_USER_ROLE = getProp(casePfx + "sub.user.role", "//input[contains(@id,'register-role-form:submit')]");
+ private final String SUB_CREATE_USER = getProp(casePfx + "sub.create.user", "//input[contains(@id,'register-form:submit')]");
+ private final String INP_PASSWORD_CHK = getProp(casePfx + "inp.password.chk", "//input[contains(@id,'register-form:passwordCheck')]");
+ private final String INP_PASSWORD = getProp(casePfx + "inp.password", "//input[contains(@id,'register-form:password')]");
+ private final String INP_USEREMAIL = getProp(casePfx + "inp.useremail", "//input[contains(@id,'register-form:email')]");
+ private final String INP_USERNAME = getProp(casePfx + "inp.username", "//input[contains(@id,'register-form:username')]");
+ private final String SUB_SEARCH_USER = getProp(casePfx + "sub.search.user", "//input[contains(@id,'search-user-form:search') and @type='submit']");
+ private final String INP_SEARCH_USER = getProp(casePfx + "inp.search.user", "//input[contains(@id,'search-user-form:searchString')]");
+ private final String LNK_SEARCH_USER = getProp(casePfx + "lnk.search.user", "//a[contains(@id,'user-form:search-user-link')]");
+ private final String LNK_USERTAB = getProp(casePfx + "lnk.usertab", "//a[contains(@id,'role-temp-form:manage-users')]");
+ private final String LNK_USERMAIN = getProp(casePfx + "lnk.usermain", "//a[contains(@id,'user-temp-form1:user-adm-link')]");
+ private final String LNK_T_USRLIST_DEL = getProp(casePfx + "lnk.t.usrlist.del", "//a[contains(@id,''search-user-form1:userlist:{0}:delete-user-link'')]");
+ private final String LNK_ROLETAB = getProp(casePfx + "lnk.roletab", "//a[contains(@id,'user-temp-form:role-mgm-link')]");
+
+ private final String LNK_ROLEMAIN = getProp(casePfx + "lnk.rolemain", "//a[contains(@id, 'role-temp-form1:role-admin-link')]");
+ private final String LNK_USERMANG_MAIN = getProp(casePfx + "lnk.usermang.main", "//a[contains(@id,'user-temp-form1:assign-role-link')]");
+ private final String LNK_USERMANG_MAIN2 = getProp(casePfx + "lnk.usermang.main2", "//a[contains(@id,'user-temp-form1:user-mgm-link')]");
+ private final String LNK_CREATE_USER = getProp(casePfx + "lnk.create.user", "//a[contains(@id,':user-form:create-user-link')]");
+
+ //private final String CHK_ROLE = getProp(casePfx + "chk.role", "//input[contains(@name,''assign-roles-form:roles'') and @value=''{0}'']");
+ private final String CHK_REGISTER_ROLE = getProp(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);
+ }
+}
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveDisabledTestCase.java 2009-07-09 15:41:36 UTC (rev 13533)
@@ -0,0 +1,116 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * The Class TomcatSSOValveDisabledTestCase is reponsible for testing of the Tomcat SSO Valve when the valve is disabled.
+ * It uses JBoss Portal with TomcatSSOValveExampleApp (sample third-party web application) and jmx-console application. Various scenarios of tests are performed.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+@Test(groups = { "sso_tests" }, enabled = true, description = "Tomcat SSO valve disabled test case.")
+public class TomcatSSOValveDisabledTestCase extends TomcatSSOValveTestCase {
+
+
+ @BeforeMethod(groups = { "log" })
+ private void logoutBeforeTest() {
+ logoutIfPossible();
+ logoutFromExampleIfPossible();
+ }
+
+ /**
+ * Login to TomcatSSOValveExampleApplication and then check if nobody is logged into portal.
+ * After login to JBoss Portal and logout from it, the user is still logged in TomcatSSOValveExampleApplication.
+ */
+ @Test(enabled = true)
+ public void loginInExampleAndCheckPortalNotLogged() {
+ // going to portal. 'logged in as: admin' page is not shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should not be shown in JBoss Portal. Admin shouldn't be logged in, but it seems that he is logged.");
+
+ // login to example app
+ logIntoExampleApp(EXAMPLE_ADMIN_USERNAME, EXAMPLE_ADMIN_PASSWORD);
+ Assert.assertTrue("false".equals(selenium.getText(EXAMPLE_AUTHORIZED_ROLE_OUTPUT)), "User 'admin' shouldn't be in role 'Authorized' but it seems that he is in this role.");
+
+ // going to portal. 'logged in as:' page is not shown, because user still not logged in portal. Only to example app
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE), "'Logged in as' sign is shown which is bad. User shouldn't be logged to JBoss Portal but it seems that he is logged in.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Link 'login' should be present in JBoss Portal.");
+ // login to portal
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+ clickAndWait(LNK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LNK_ADMIN), "Link 'admin' should be in the portal page while user 'admin' is logged.");
+ // logout from portal
+ logout();
+ // Going to example app. User is still logged in even if not logged in the portal.
+ openAndWait(ADR_EXAMPLE);
+ Assert.assertTrue(EXAMPLE_TITLE_OUTPUT.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)), "User should be still logged to example application but it seems that he is not logged.");
+ Assert.assertTrue(EXAMPLE_ADMIN_USERNAME.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)), "User 'admin' should be logged to example application but it seems that he is not logged.");
+ }
+
+ /**
+ * Login to JBoss Portal and then check if nobody is logged into TomcatSSOValveExampleApp.
+ * After login to example application as "user", the "admin" is still logged in JBOss Portal.
+ */
+ @Test(enabled = true)
+ public void loginIntoPortalAndCheckExample() {
+ // going to portal. 'logged in as: admin' page is not shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME));
+ // login to portal
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+
+ // Going to example app. User is not logged in even if logged in the portal.
+ openAndWait(ADR_EXAMPLE);
+ Assert.assertTrue(EXAMPLE_LOGIN_FORM.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)), "Nobody should be logged in TomcatSSOValveExampleApp but it seems that user is logged in.");
+ // login to example app as user
+ logIntoExampleApp(EXAMPLE_USER_USERNAME, EXAMPLE_USER_PASSWORD);
+ Assert.assertTrue(EXAMPLE_TITLE_OUTPUT.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)), "User 'user' should be logged in example app, but it seems that he is not logged.");
+ Assert.assertTrue(EXAMPLE_USER_USERNAME.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)), "User 'user' should be logged in example app, but it seems that he is not logged.");
+
+ // Check portal. 'admin' is still logged in. Not user.
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "User 'admin' should be logged in JBoss Portal, but it seems that he is not logged.");
+ // go to example and logout
+ openAndWait(ADR_EXAMPLE);
+ Assert.assertTrue(EXAMPLE_USER_USERNAME.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)), "User 'user' should be logged in example app, but it seems that he is not logged.");
+ clickAndWait(EXAMPLE_LOGOUT);
+ Assert.assertTrue(EXAMPLE_LOGIN_FORM.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)), "Nobody should be logged in TomcatSSOValveExampleApp but it seems that user is logged in.");
+
+ // Check portal. 'admin' is still logged in.
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "User 'admin' should be logged in JBoss Portal, but it seems that he is not logged.");
+ }
+
+ /**
+ * Login to jmx-console and then check if nobody is logged in JBoss Portal.
+ * After login and logour from JBoss Portal, the user is still logged in jmx-console web application.
+ */
+ @Test(enabled = true)
+ public void loginToJMXConsoleAndCheckPortal() {
+ // going to portal. 'logged in as: admin' page is not shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "admin should not be logged in JBoss Portal but it seems that he is logged in.");
+
+ // login to jmx console
+ loginToJMXConsole(JMX_ADMIN_USERNAME, JMX_ADMIN_PASSWORD);
+
+ // going to portal. 'logged in as:' page is not shown, because user still not logged in portal. Only to example app
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE), "Nobody should be logged in JBoss Portal but it seems that user is logged in.");
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Nobody should be logged in JBoss Portal but it seems that user is logged in.");
+ // login to portal
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+ clickAndWait(LNK_DASHBOARD);
+ Assert.assertTrue(selenium.isElementPresent(LNK_ADMIN), "Link 'admin' should be in the portal page while user 'admin' is logged.");
+ // logout from portal
+ logout();
+ // 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), "User should be logged to JMX console but it seems that he is not logged.");
+ Assert.assertTrue(selenium.getText(JMX_TITLE_ELEMENT).contains(JMX_AGENT_VIEW), "User should be logged to JMX console but it seems that he is not logged.");
+ }
+
+}
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveTestCase.java 2009-07-09 15:41:36 UTC (rev 13533)
@@ -0,0 +1,128 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.jboss.portal.test.selenium.JBossPortalSeleniumTestCase;
+import org.testng.Assert;
+
+/**
+ *
+ * Helper class which is used for inheritance by other TomcatSSOValve test classes. This class contains constants and some basic functions like login
+ * to JMX console via selenium, login to TomcatSSOValveExampleApp etc.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+class TomcatSSOValveTestCase extends JBossPortalSeleniumTestCase {
+
+ /** prefix for locator properties */
+ public String casePfx = "sso.tomcatvalve.";
+
+ // TODO: uncomment and remove getProp part
+
+ /*
+ protected final String ADR_PORTAL = getLoc(casePfx+"adr.portal","/portal");
+ protected final String ADR_EXAMPLE = getLoc(casePfx+"adr.example","/TomcatSSOValveExampleApp");
+ protected final String ADR_JMX_CONSOLE = getLoc(casePfx+"adr.jmx","/jmx-console/");
+ protected final String EXAMPLE_TITLE_ELEMENT = getLoc(casePfx+"ex.title","//h1");
+ protected final String EXAMPLE_INP_USERNAME = getLoc(casePfx+"ex.inp.username","j_username");
+ protected final String EXAMPLE_INP_PASSWORD = getLoc(casePfx+"ex.inp.password","j_password");
+ protected final String EXAMPLE_LOGIN = getLoc(casePfx+"ex.login","//input[@value='Login']");
+ protected final String EXAMPLE_LOGOUT = getLoc(casePfx+"ex.logout","//input[@value='Logout']");
+ protected final String EXAMPLE_LOGGED_USER_OUTPUT = getLoc(casePfx+"ex.logged.user.label","//tr[1]/td[2]/b");
+ protected final String EXAMPLE_AUTHORIZED_ROLE_OUTPUT = getLoc(casePfx+"ex.logged.role.auth.label","//tr[4]/td[2]/b");
+ protected final String JMX_TITLE_ELEMENT = getLoc(casePfx+"jmx.title.element", "//h1");
+ protected final String JMX_IMAGE = getLoc(casePfx+"jmx.image", "//img[@alt='JBoss']");
+
+ protected final String LNK_LOGIN = getLoc(casePfx+"lnk.login","link=Login");
+ protected final String LNK_LOGOUT = getLoc(casePfx+"lnk.logout","link=Logout");
+ protected final String LNK_DEFAULT = getLoc(casePfx+"lnk.default","link=default");
+ protected final String LNK_ADMIN = getLoc(casePfx+"lnk.admin","link=Admin");
+ protected final String LNK_WSRP = getLoc(casePfx+"lnk.wsrp","link=WSRP");
+ protected final String LNK_DASHBOARD = getLoc(casePfx+"lnk.default.dashboard","link=Dashboard");
+
+ protected final String EXAMPLE_LOGIN_FORM = getMess(casePfx+"example.login.form", "Login form");
+ protected final String EXAMPLE_TITLE_OUTPUT = getMess(casePfx+"example.title.output", "Tomcat SSO valve example servlet");
+ protected final String LOGGED_IN_AS_MESSAGE = getMess(casePfx+"logged.in.mess", "Logged in as: ");
+ protected final String JMX_AGENT_VIEW = getMess(casePfx+"jmx.agnview", "JMX Agent View");
+ protected final String PORTAL_FORBIDDEN_MESS = getMess(casePfx + "forbidden.mess", "HTTP Status 403 -");
+ */
+
+ protected final String ADR_PORTAL = getProp(casePfx+"adr.portal","/portal");
+ protected final String ADR_EXAMPLE = getProp(casePfx+"adr.example","/TomcatSSOValveExampleApp");
+ protected final String ADR_JMX_CONSOLE = getProp(casePfx+"adr.jmx","/jmx-console/");
+ protected final String EXAMPLE_TITLE_ELEMENT = getProp(casePfx+"ex.title","//h1");
+ protected final String EXAMPLE_INP_USERNAME = getProp(casePfx+"ex.inp.username","j_username");
+ protected final String EXAMPLE_INP_PASSWORD = getProp(casePfx+"ex.inp.password","j_password");
+ protected final String EXAMPLE_LOGIN = getProp(casePfx+"ex.login","//input[@value='Login']");
+ protected final String EXAMPLE_LOGOUT = getProp(casePfx+"ex.logout","//input[@value='Logout']");
+ protected final String EXAMPLE_LOGGED_USER_OUTPUT = getProp(casePfx+"ex.logged.user.label","//tr[1]/td[2]/b");
+ protected final String EXAMPLE_AUTHORIZED_ROLE_OUTPUT = getProp(casePfx+"ex.logged.role.auth.label","//tr[4]/td[2]/b");
+ protected final String JMX_TITLE_ELEMENT = getProp(casePfx+"jmx.title.element", "//h1");
+ protected final String JMX_IMAGE = getProp(casePfx+"jmx.image", "//img[@alt='JBoss']");
+
+ protected final String LNK_LOGIN = getProp(casePfx+"lnk.login","link=Login");
+ protected final String LNK_LOGOUT = getProp(casePfx+"lnk.logout","link=Logout");
+ protected final String LNK_DEFAULT = getProp(casePfx+"lnk.default","link=default");
+ protected final String LNK_ADMIN = getProp(casePfx+"lnk.admin","link=Admin");
+ protected final String LNK_WSRP = getProp(casePfx+"lnk.wsrp","link=WSRP");
+ protected final String LNK_DASHBOARD = getProp(casePfx+"lnk.default.dashboard","link=Dashboard");
+
+ protected final String EXAMPLE_LOGIN_FORM = getProp(casePfx+"example.login.form", "Login form");
+ protected final String EXAMPLE_TITLE_OUTPUT = getProp(casePfx+"example.title.output", "Tomcat SSO valve example servlet");
+ protected final String LOGGED_IN_AS_MESSAGE = getProp(casePfx+"logged.in.mess", "Logged in as: ");
+ protected final String JMX_AGENT_VIEW = getProp(casePfx+"jmx.agnview", "JMX Agent View");
+ protected final String PORTAL_FORBIDDEN_MESS = getProp(casePfx + "forbidden.mess", "HTTP Status 403 -");
+
+ protected final String EXAMPLE_ADMIN_USERNAME = "admin";
+ protected final String EXAMPLE_ADMIN_PASSWORD = "password";
+ protected final String EXAMPLE_ADMIN2_USERNAME = "admin2";
+ protected final String EXAMPLE_ADMIN2_PASSWORD = "password";
+ protected final String EXAMPLE_USER_USERNAME = "user";
+ protected final String EXAMPLE_USER_PASSWORD = "password";
+ protected final String PORTAL_ADMIN_USERNAME = "admin";
+ protected final String PORTAL_ADMIN_PASSWORD = "admin";
+ protected final String JMX_ADMIN_USERNAME = "admin";
+ protected final String JMX_ADMIN_PASSWORD = "admin";
+ protected final String PORTAL_USER_USERNAME = "user";
+ protected final String PORTAL_USER_PASSWORD = "user";
+
+ /**
+ * Login to jmx-console web application with usage of selenium framework.
+ *
+ * @param user
+ * @param password
+ */
+ protected void loginToJMXConsole(String user, String password) {
+ // 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), "User should be logged to JMX console but it seems that he is not logged.");
+ Assert.assertTrue(selenium.getText(JMX_TITLE_ELEMENT).contains(JMX_AGENT_VIEW), "User should be logged to JMX console but it seems that he is not logged.");
+ }
+
+ /**
+ * Login to TomcatSSOValveExampleApp (sample third-party application)
+ *
+ * @param username
+ * @param password
+ */
+ protected void logIntoExampleApp(String username, String password) {
+ openAndWait(ADR_EXAMPLE);
+ selenium.type(EXAMPLE_INP_USERNAME, username);
+ selenium.type(EXAMPLE_INP_PASSWORD, password);
+ clickAndWait(EXAMPLE_LOGIN);
+ Assert.assertTrue(EXAMPLE_TITLE_OUTPUT.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)), "User should be logged to TomcatSSOValveExampleApp but it seems that he is not logged.");
+ Assert.assertTrue(username.equals(selenium.getText(EXAMPLE_LOGGED_USER_OUTPUT)), "User should be logged to TomcatSSOValveExampleApp but it seems that he is not logged.");
+ }
+
+ /**
+ * Logout from TomcatSSOValveExampleApp
+ */
+ protected void logoutFromExampleIfPossible() {
+ selenium.open(ADR_EXAMPLE);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ if (selenium.isElementPresent(EXAMPLE_LOGOUT)) {
+ selenium.click(EXAMPLE_LOGOUT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(EXAMPLE_LOGIN_FORM.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)), "User should be logged out from TomcatSSOValveExampleApp.");
+ }
+ }
+
+}
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithExampleTestCase.java 2009-07-09 15:41:36 UTC (rev 13533)
@@ -0,0 +1,95 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * The Class TomcatSSOValveWithExampleTestCase is reponsible for testing of the Tomcat SSO Valve. This class is responsible for testing
+ * with Tomcat SSO valve enabled and uses JBoss Portal with TomcatSSOValveExampleApp (sample third-party web application)
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+@Test(groups = { "sso_tests" }, enabled = true, description = "Tomcat SSO valve success test case.")
+public class TomcatSSOValveWithExampleTestCase extends TomcatSSOValveTestCase {
+
+
+ @BeforeMethod(groups = { "log" })
+ private void logoutBeforeTest() {
+ logoutIfPossible();
+ }
+
+ /**
+ * Login to TomcatSSOValveExampleApp and then going to JBoss Portal. The user "admin", who loggs in TomcatSSOValveExampleApp is logged
+ * in JBoss Portal too. After logout from JBoss Portal, the user is signed-off also in TomcatSSOValveExampleApp.
+ * This testCase uses "admin" user, who have only role "Admin" but not "Authenticated" in TomcatSSOValveExampleApp and so he is not enable to do everythink
+ * in JBoss Portal (After going to some page, the user should have 'Forbidden' error).
+ */
+ @Test(enabled = true)
+ public void loginInExampleAndCheckPortalUnauthorized() {
+ // going to portal. 'logged in as: admin' page is not shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should not be shown in JBoss Portal. Admin shouldn't be logged in, but it seems that he is logged.");
+
+ // login to example app
+ logIntoExampleApp(EXAMPLE_ADMIN_USERNAME, EXAMPLE_ADMIN_PASSWORD);
+ // user should not be in Authorized role
+ Assert.assertTrue("false".equals(selenium.getText(EXAMPLE_AUTHORIZED_ROLE_OUTPUT)), "User 'admin' shouldn't be in role 'Authorized' but it seems that he is in this role.");
+
+ // going to portal. 'logged in as: admin' page is shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "User 'admin' should be logged in JBoss Portal.");
+
+ // The error 403 - forbidden should be thrown by portal when user clicks to some link on the page
+ clickAndWait(LNK_DASHBOARD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_FORBIDDEN_MESS), "Page 403 - forbidden should be shown but it seems that it isn't.");
+ }
+
+ /**
+ * Login to TomcatSSOValveExampleApp and then going to JBoss Portal. The user "admin2", who loggs in TomcatSSOValveExampleApp is logged
+ * in JBoss Portal too. After logout from JBoss Portal, the user is signed-off also in TomcatSSOValveExampleApp.
+ * This testCase uses "admin2" user, who have both roles "Admin" and "Authenticated" in TomcatSSOValveExampleApp and so he is enable to do everythink
+ * in JBoss Portal (This user has admin privileges in JBoss Portal).
+ */
+ @Test(enabled = true)
+ public void loginInExampleAndCheckPortalAuthorized() {
+ // going to portal. 'logged in as: admin' page is not shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should not be shown in JBoss Portal. Admin shouldn't be logged in, but it seems that he is logged.");
+
+ // login to example app
+ logIntoExampleApp(EXAMPLE_ADMIN2_USERNAME, EXAMPLE_ADMIN2_PASSWORD);
+ // user should be in Authorized role
+ Assert.assertTrue("true".equals(selenium.getText(EXAMPLE_AUTHORIZED_ROLE_OUTPUT)), "User 'admin2' should be in role 'Authorized' but it seems that he isn't.");
+
+ // going to portal. 'logged in as: admin' is shown
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + EXAMPLE_ADMIN2_USERNAME), "User 'admin2' should be logged in JBoss Portal.");
+ clickAndWait(LNK_ADMIN);
+ Assert.assertTrue(selenium.isElementPresent(LNK_WSRP), "Link to 'wsrp' page should be shown on admin portal. But this link is not here.");
+
+ // logout from portal and check if logout from example app
+ clickAndWait(LNK_LOGOUT);
+ openAndWait(ADR_EXAMPLE);
+ Assert.assertTrue(EXAMPLE_LOGIN_FORM.equals(selenium.getText(EXAMPLE_TITLE_ELEMENT)), "User should not be logged in TomcatSSOValveExampleApp, but it seems that he is still logged.");
+ }
+
+ /**
+ * After login in JBoss Portal as "admin", the user should be logged in TomcatSSOValveExampleApp too.
+ */
+ @Test(enabled = true)
+ public void loginInPortalAndCheckExample() {
+ // login to portal as admin
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+
+ // open example app and chek if login and check Authorized role. Then logout
+ selenium.open(ADR_EXAMPLE);
+ Assert.assertTrue("true".equals(selenium.getText(EXAMPLE_AUTHORIZED_ROLE_OUTPUT)), "User 'admin' should be in 'Authorized' role but it seems that he isn't.");
+ clickAndWait(EXAMPLE_LOGOUT);
+
+ // Check if logout from portal
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isElementPresent(LNK_LOGIN), "Nobody should be logged in JBoss Portal but it seems that user is still logged in.");
+ }
+
+}
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/sso/TomcatSSOValveWithJMXConsoleTestCase.java 2009-07-09 15:41:36 UTC (rev 13533)
@@ -0,0 +1,62 @@
+package org.jboss.portal.test.selenium.sso;
+
+import org.testng.Assert;
+import org.testng.annotations.BeforeMethod;
+import org.testng.annotations.Test;
+
+/**
+ * The Class TomcatSSOValveWithJMXConsoleTestCase is reponsible for testing of the Tomcat SSO Valve. This class is responsible for testing
+ * with Tomcat SSO valve enabled and uses JBoss Portal with jmx-console application. Various scenarios of tests are performed.
+ *
+ * JMX Console is configured to roles JBossAdmin and Admin can see it (so authentication in portal enables access to JMX Console)
+ * roles.properties of JMX console looks like: admin=JBossAdmin,HttpInvoker,Admin
+ * Authenticated role is missing, so login to JMX Console doesn't enable full access to JBoss portal (after click to something in JBoss portal, 403 is thrown)
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+@Test(groups = { "sso_tests" }, enabled = true, description = "Tomcat SSO valve success test case.")
+public class TomcatSSOValveWithJMXConsoleTestCase extends TomcatSSOValveTestCase {
+
+ @BeforeMethod(groups = { "log" })
+ private void logoutBeforeTest() {
+ logoutIfPossible();
+ }
+
+ /**
+ * Login to portal as admin and then see jmx-console application. Admin from JBoss Portal is authorized to see jmx-console application.
+ * After logout from portal and login as "user", then access to jmx-console is forbidden.
+ */
+ @Test(enabled = true)
+ public void loginInPortalAndCheckConsole() {
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should not be shown in JBoss Portal. Admin shouldn't be logged in, but it seems that he is logged.");
+ login(PORTAL_ADMIN_USERNAME, PORTAL_ADMIN_PASSWORD);
+
+ openAndWait("http://localhost:8080" + ADR_JMX_CONSOLE);
+ Assert.assertTrue(selenium.isElementPresent(JMX_IMAGE), "User should be logged to JMX console but it seems that he is not logged.");
+ Assert.assertTrue(selenium.getText(JMX_TITLE_ELEMENT).contains(JMX_AGENT_VIEW), "User should be logged to JMX console but it seems that he is not logged.");
+ // 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), "Page 403 - forbidden should be shown but it seems that it isn't.");
+ }
+
+ /**
+ * Login to jmx-console and then user should be logged in JBoss Portal too.
+ */
+ @Test(enabled = true)
+ public void loginInConsoleAndCheckPortal() {
+ openAndWait(ADR_PORTAL);
+ Assert.assertFalse(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should not be shown in JBoss Portal. Admin shouldn't be logged in, but it seems that he is logged.");
+ // TODO: this probably doesn't work in IE. So disable test while working with IE.
+ loginToJMXConsole(JMX_ADMIN_USERNAME, JMX_ADMIN_PASSWORD);
+
+ openAndWait(ADR_PORTAL);
+ Assert.assertTrue(selenium.isTextPresent(LOGGED_IN_AS_MESSAGE + PORTAL_ADMIN_USERNAME), "Message 'Logged in as: admin' should be shown in JBoss Portal. Admin should be logged in, but it seems that he is not logged.");
+ // The error 403 - forbidden should be thrown by portal when user clicks to some link on the page
+ clickAndWait(LNK_DASHBOARD);
+ Assert.assertTrue(selenium.isTextPresent(PORTAL_FORBIDDEN_MESS), "Page 403 - forbidden should be shown but it seems that it isn't.");
+ }
+}
16 years, 10 months
JBoss Portal SVN: r13532 - branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium.
by portal-commits@lists.jboss.org
Author: mposolda(a)redhat.com
Date: 2009-07-09 07:00:44 -0400 (Thu, 09 Jul 2009)
New Revision: 13532
Added:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java
Modified:
branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
Log:
LdapIdentityAdminTestCase added and IdentityAdminTestCase refactored for usage with LdapIdentityAdminTestCase.
Modified: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-07-09 08:00:21 UTC (rev 13531)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/IdentityAdminTestCase.java 2009-07-09 11:00:44 UTC (rev 13532)
@@ -21,7 +21,7 @@
private final String INP_USER_SEARCH_NEXT = getProp(casePfx + "inp.user.search.next", "//input[contains(@id,'search-user-form1:next-page')]");
private final String SEL_SEARCHUSER_LIMIT = getProp(casePfx + "sel.searchuser.limit", "//select[contains(@id,'search-user-form:limit')]");
- private final String SUB_EDIT_PROF = getProp(casePfx + "sub.edit.prof", "//input[contains(@id,'profile-form:submit')]");
+ final String SUB_EDIT_PROF = getProp(casePfx + "sub.edit.prof", "//input[contains(@id,'profile-form:submit')]");
private final String SUB_PAGIN_LEFT = getProp(casePfx + "sub.pagin.left", INP_USER_SEARCH_PREV);
private final String SUB_PAGIN_RIGHT = getProp(casePfx + "sub.pagin.right", INP_USER_SEARCH_NEXT);
@@ -90,7 +90,7 @@
return MessageFormat.format(LNK_T_USRLIST_DEL, r - 1);
}
- private String butUsrRol_id(String userName) {
+ String butUsrRol_id(String userName) {
String table = TBL_USERLIST;
int r = findTableRow(table, userName, 0);
return MessageFormat.format(LNK_T_USRLIST_ROLES, r - 1);
@@ -435,7 +435,16 @@
createUser("user0" + i + "", "useruser", "user0" + i + "" + "@portal.com");
}
}
+
+ void goToEdit(String userName, String userMail) {
+ searchUser(userName, userMail);
+ int r = findTableRow(TBL_USERLIST, userName, 0);
+ selenium.click(MessageFormat.format(LNK_T_USRLIST_EDIT, r - 1));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ }
+
@Test(enabled = true, description = "Altering the number of rows in user search")
public void testSearchUserCount() {
@@ -640,7 +649,7 @@
}
- private void deleteUser(String username, String email) {
+ void deleteUser(String username, String email) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Admin");
@@ -680,7 +689,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
}
- private void createRole(String roleName, String roleDisplayName) {
+ void createRole(String roleName, String roleDisplayName) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Admin");
@@ -707,7 +716,7 @@
Assert.assertTrue(selenium.isTextPresent(roleDisplayName), "Display name of newly created role is missing.");
}
- private void deleteRole(String roleName) {
+ void deleteRole(String roleName) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=Admin");
Added: branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java (rev 0)
+++ branches/Enterprise_Portal_Platform_4_3/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java 2009-07-09 11:00:44 UTC (rev 13532)
@@ -0,0 +1,145 @@
+package org.jboss.portal.test.selenium;
+
+import java.text.MessageFormat;
+
+import org.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * <p>The Class LdapIdentityAdminTestCase is used for testing of admin gui of JBoss Portal, especially the users and roles part.
+ * And this is the reason while it is derived from IdentityAdminTestCase.
+ *
+ * <p>The assumption is that JBoss Portal identity is configured with Ldap and users <i>ldap1</i> and <i>ldap2</i> are stored in Ldap directory with <i>Ldap</i> role too.
+ * The users <i>admin</i>, <i>user</i> and roles <i>Admins</i>, <i>Users</i> should be also in Ldap directory.
+ *
+ * @author <a href="mailto:mposolda@redhat.com">Marek Posolda</a>
+ */
+@Test(groups = { "admin_ui_ldap" }, enabled = true)
+public class LdapIdentityAdminTestCase extends IdentityAdminTestCase {
+
+ private final String LDAP1_USER = "ldap1";
+ private final String LDAP1_USER_PASSWORD = "password";
+ private final String LDAP1_USER_MAIL = "ldap1(a)portal.com";
+ private final String LDAP1_FIRST_NAME = "Joseph";
+ private final String LDAP1_SURNAME = "Berry";
+
+ private final String LDAP2_USER = "ldap2";
+ private final String LDAP2_USER_PASSWORD = "password";
+ private final String LDAP2_USER_MAIL = "ldap2(a)portal.com";
+ private final String LDAP2_FIRST_NAME = "Cyril";
+ private final String LDAP2_SURNAME = "Berry";
+
+ private final String LDAP_ROLE_NAME = "Ldap";
+
+ /**
+ * <p>User (tempUser, tempPassword, tempUser(a)redhat.com) and role (tempRole,
+ * tempRoleDisplay) are created. The role is assigned to the user and it is
+ * asserted by the checked button in user roles.
+ *
+ * <p>First deassignation is not successfull because each role in Ldap should have at least one user. So
+ * another user (tempUser2) is created and assigned to the tempRole. Then user tempUser is deassigned successfully
+ * from tempRole.
+ *
+ * <p>At the end of the test both the user and the role are deleted.
+ */
+ @Test(enabled = true, dependsOnMethods = { "testCreateUser", "testCreateRole" }, description = "Assigning and deassigning of the role to the user.")
+ public void testAssignRole2User() {
+ String user = "tempUser";
+ String userMail = "tempUser(a)redhat.com";
+ String user2 = "tempUser2";
+ String userMail2 = "tempUser2(a)redhat.com";
+ String role = "tempRole";
+ final String roleDisplayName = "tempRoleDisplay";
+ final String userPass = "tempPassword";
+
+ createUser(user, userPass, userMail);
+ createRole(role, roleDisplayName);
+ assignRole(user, userMail, role, roleDisplayName);
+
+ createUser(user2, userPass, userMail2);
+ assignRole(user2, userMail2, role, roleDisplayName);
+
+ deassignRole(user, userMail, role, roleDisplayName);
+ deleteRole(role);
+ deleteUser(user, userMail);
+ deleteUser(user2, userMail2);
+ }
+
+ /**
+ * This method searches for users 'ldap1' and 'ldap2'. Assumption is that these users are stored in Ldap directory
+ * with correct settings of their attributes.
+ */
+ @Test(enabled = true, description = "Searching for users from ldap and testing his roles.")
+ public void testSearchLdapUsers() {
+ // user 'ldap1'
+ searchUser(LDAP1_USER, LDAP1_USER_MAIL);
+ Assert.assertTrue(selenium.isTextPresent(LDAP1_FIRST_NAME), "Name " + LDAP1_FIRST_NAME + " of user " + LDAP1_USER + " was not found on the page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP1_SURNAME), "Surname " + LDAP1_SURNAME + " of user " + LDAP1_USER + " was not found on the page.");
+ final String CHECK_ROLE = MessageFormat.format(CHK_ROLE, LDAP_ROLE_NAME);
+ selenium.click(butUsrRol_id(LDAP1_USER));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isChecked(CHECK_ROLE), "The role LdapRole is not correctly assigned to user " + LDAP1_USER + ".");
+ Assert.assertTrue(selenium.isChecked(MessageFormat.format(CHK_ROLE, "User")), "The role Users is not correctly assigned to user " + LDAP1_USER + ".");
+ Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE, "Admin")), "The role Admins is not correctly assigned to user " + LDAP1_USER + ".");
+
+ // user 'ldap2'
+ searchUser(LDAP2_USER, LDAP2_USER_MAIL);
+ Assert.assertTrue(selenium.isTextPresent(LDAP2_FIRST_NAME), "Name " + LDAP2_FIRST_NAME + " of user " + LDAP2_USER + " was not found on the page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP2_SURNAME), "Surname " + LDAP2_SURNAME + " of user " + LDAP2_USER + " was not found on the page.");
+ selenium.click(butUsrRol_id(LDAP2_USER));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isChecked(CHECK_ROLE), "The role LdapRoleDisplay is not correctly assigned to user " + LDAP2_USER + ".");
+ Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE, "User")), "The role Users is not correctly assigned to user " + LDAP2_USER + ".");
+ Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE, "Admin")), "The role Admins is not correctly assigned to user " + LDAP2_USER + ".");
+ }
+
+ /**
+ * This method searches for users 'ldap1' and 'ldap2'. Then check and edit their user profiles.
+ * Both attributes from Ldap directory and from database are changed. Assumption is that these users are stored in
+ * Ldap directory with correct settings of their attributes.
+ */
+ @Test(enabled = true, description = "Searching for users from Ldap and checking their user profiles.")
+ public void testUserProfilesOfLdapUsers() {
+ // Go to edit page and check user profile
+ goToEdit(LDAP1_USER, LDAP1_USER_MAIL);
+ // TODO: add localizators while they will be added to IdentityAdminTestCase.
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:givenname')]").equals(LDAP1_FIRST_NAME), "First name should be " + LDAP1_FIRST_NAME + " but is " + selenium.getValue("//input[contains(@id,'profile-form:givenname')]"));
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:lastname')]").equals(LDAP1_SURNAME), "Surname should be " + LDAP1_SURNAME + " but is " + selenium.getValue("//input[contains(@id,'profile-form:lastname')]"));
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:location')]").contains("Brno, Czechue Republic"), "Location should contains Brno,Czechue Republic but is " + selenium.getValue("//input[contains(@id,'profile-form:location')]"));
+ Assert.assertTrue(selenium.getValue("//textarea[contains(@id,'profile-form:extra')]").contains("This is content of ldap attribute \"description\""), "Description has value " + selenium.getValue("//textarea[contains(@id,'profile-form:extra')]"));
+
+ // fill some attributes (homepage should be DB attribute and givenname should be LDAP attribute) and check them.
+ selenium.type("//input[contains(@id,'profile-form:givenname')]", "Jack");
+ selenium.type("//input[contains(@id,'profile-form:homepage')]", "http://www.jboss.org/jbossportal");
+ clickAndWait(SUB_EDIT_PROF);
+ goToEdit(LDAP1_USER, LDAP1_USER_MAIL);
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:givenname')]").equals("Jack"), "First name should be Jack but is " + selenium.getValue("//input[contains(@id,'profile-form:givenname')]"));
+ Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:homepage')]").equals("http://www.jboss.org/jbossportal"), "Homepage should be http://www.jboss.org/jbossportal but is " + selenium.getValue("//input[contains(@id,'profile-form:homepage')]"));
+ // Change name to the original value
+ selenium.type("//input[contains(@id,'profile-form:givenname')]", LDAP1_FIRST_NAME);
+ clickAndWait(SUB_EDIT_PROF);
+ }
+
+ /**
+ * This method tries to login as user 'ldap1' and as user 'ldap2'. Assumption is that these users are stored in Ldap directory
+ * with correct settings of their attributes including user passwords.
+ */
+ @Test(enabled = true, description = "Trying to login as user from Ldap.")
+ public void testLoginAsLdapUsers() {
+ logoutIfPossible();
+ // user 'ldap1'
+ login(LDAP1_USER, LDAP1_USER_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(LDAP1_USER_MAIL), "Mail " + LDAP1_USER_MAIL + " of user " + LDAP1_USER + " was not found on the page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP1_FIRST_NAME), "Name " + LDAP1_FIRST_NAME + " of user " + LDAP1_USER + " was not found on the page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP1_SURNAME), "Surname " + LDAP1_SURNAME + " of user " + LDAP1_USER + " was not found on the page.");
+ logoutIfPossible();
+
+ // user 'ldap2'
+ login(LDAP2_USER, LDAP2_USER_PASSWORD);
+ Assert.assertTrue(selenium.isTextPresent(LDAP2_USER_MAIL), "Mail " + LDAP2_USER_MAIL + " of user " + LDAP2_USER + " was not found on the page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP2_FIRST_NAME), "Name " + LDAP2_FIRST_NAME + " of user " + LDAP2_USER + " was not found on the page.");
+ Assert.assertTrue(selenium.isTextPresent(LDAP2_SURNAME), "Surname " + LDAP2_SURNAME + " of user " + LDAP2_USER + " was not found on the page.");
+ logoutIfPossible();
+ }
+
+}
16 years, 10 months
JBoss Portal SVN: r13531 - branches/Enterprise_Portal_Platform_4_3/core/src/resources/portal-core-sar/conf/hibernate/portal.
by portal-commits@lists.jboss.org
Author: mputz
Date: 2009-07-09 04:00:21 -0400 (Thu, 09 Jul 2009)
New Revision: 13531
Modified:
branches/Enterprise_Portal_Platform_4_3/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
Log:
JBPORTAL-2384: Fix hibernate mappings to address N+1 select problem on accessing ObjectNode.children
Modified: branches/Enterprise_Portal_Platform_4_3/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
===================================================================
--- branches/Enterprise_Portal_Platform_4_3/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2009-07-08 10:53:04 UTC (rev 13530)
+++ branches/Enterprise_Portal_Platform_4_3/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2009-07-09 08:00:21 UTC (rev 13531)
@@ -54,7 +54,7 @@
name="children"
inverse="true"
cascade="none"
- fetch="select"
+ fetch="subselect"
lazy="true">
<cache usage="@portal.hibernate.cache.usage@"/>
<key column="PARENT_KEY"/>
@@ -73,7 +73,9 @@
name="object"
class="org.jboss.portal.core.impl.model.portal.PortalObjectImpl"
cascade="none"
- fetch="select">
+ fetch="join"
+ constrained="true"
+ lazy="false">
</one-to-one>
<map
name="securityConstraints"
16 years, 10 months
JBoss Portal SVN: r13500 - in modules/authorization/trunk: http-profile/src/main/java/org/jboss/security/authz/http/component/resource and 1 other directories.
by portal-commits@lists.jboss.org
Author: sohil.shah(a)jboss.com
Date: 2009-07-08 23:49:09 -0400 (Wed, 08 Jul 2009)
New Revision: 13500
Added:
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/MockPolicy.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/NoPermitMeansDeniedAlg.java
Modified:
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/AnnotationProcessor.java
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/RuleComposition.java
modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/TargetComposition.java
modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java
modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java
Log:
Integrating HttpResource component
Modified: modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/AnnotationProcessor.java
===================================================================
--- modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/AnnotationProcessor.java 2009-07-05 11:12:20 UTC (rev 13499)
+++ modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/AnnotationProcessor.java 2009-07-09 03:49:09 UTC (rev 13500)
@@ -23,12 +23,14 @@
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
+import java.lang.reflect.Method;
import java.util.List;
import java.util.ArrayList;
import org.jboss.security.authz.component.Component;
import org.jboss.security.authz.component.ComponentCategory;
import org.jboss.security.authz.component.SecurityContextData;
+import org.jboss.security.authz.component.LogicExpression;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
@@ -72,6 +74,32 @@
return null;
}
+
+ static Method findExpression(Class targetClass, String expressionName)
+ {
+ Method[] declaredMethods = targetClass.getDeclaredMethods();
+ if(declaredMethods != null)
+ {
+ for(Method declaredMethod: declaredMethods)
+ {
+ Annotation logicExpression = declaredMethod.getAnnotation(LogicExpression.class);
+ if(logicExpression != null)
+ {
+ if(declaredMethod.getName().equals(expressionName))
+ {
+ return declaredMethod;
+ }
+ }
+ }
+ }
+
+ if(targetClass.getSuperclass() != null)
+ {
+ return findExpression(targetClass.getSuperclass(), expressionName);
+ }
+
+ return null;
+ }
//---------------------------------------------------------------------------------------------------------------------------------------------------------------------
private static Object[] extractSecurityContextData(Object component, Class targetClass) throws Exception
{
Modified: modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/RuleComposition.java
===================================================================
--- modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/RuleComposition.java 2009-07-05 11:12:20 UTC (rev 13499)
+++ modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/RuleComposition.java 2009-07-09 03:49:09 UTC (rev 13500)
@@ -22,13 +22,11 @@
package org.jboss.security.authz.agent.services;
import java.lang.reflect.Method;
-import java.lang.annotation.Annotation;
import java.util.Set;
import java.util.HashSet;
import org.apache.log4j.Logger;
-import org.jboss.security.authz.component.LogicExpression;
import org.jboss.security.authz.model.Rule;
import org.jboss.security.authz.model.Expression;
import org.jboss.security.authz.model.Effect;
@@ -182,7 +180,7 @@
DroolsRuleExpression expression = new DroolsRuleExpression();
//Read the LogicExpression of the Logic Component
- Method expressionMethod = this.findExpression(this.logicComponent.getClass(), this.expressionName);
+ Method expressionMethod = AnnotationProcessor.findExpression(this.logicComponent.getClass(), this.expressionName);
expressionMethod.setAccessible(true);
String[] expressionMetaData = (String[])expressionMethod.invoke(this.logicComponent, null);
@@ -191,31 +189,5 @@
expression.setRule(expressionMetaData[1]);
return expression;
- }
-
- private Method findExpression(Class targetClass, String expressionName)
- {
- Method[] declaredMethods = targetClass.getDeclaredMethods();
- if(declaredMethods != null)
- {
- for(Method declaredMethod: declaredMethods)
- {
- Annotation logicExpression = declaredMethod.getAnnotation(LogicExpression.class);
- if(logicExpression != null)
- {
- if(declaredMethod.getName().equals(expressionName))
- {
- return declaredMethod;
- }
- }
- }
- }
-
- if(targetClass.getSuperclass() != null)
- {
- return this.findExpression(targetClass.getSuperclass(), expressionName);
- }
-
- return null;
- }
+ }
}
Modified: modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/TargetComposition.java
===================================================================
--- modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/TargetComposition.java 2009-07-05 11:12:20 UTC (rev 13499)
+++ modules/authorization/trunk/agent/src/main/java/org/jboss/security/authz/agent/services/TargetComposition.java 2009-07-09 03:49:09 UTC (rev 13500)
@@ -22,7 +22,11 @@
package org.jboss.security.authz.agent.services;
import java.lang.annotation.Annotation;
-import java.lang.reflect.Field;
+import java.lang.reflect.Array;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
+import java.util.Map;
import java.util.Set;
import java.util.HashSet;
@@ -31,7 +35,6 @@
import org.jboss.security.authz.component.Component;
import org.jboss.security.authz.component.ComponentCategory;
import org.jboss.security.authz.component.ImpliedActions;
-import org.jboss.security.authz.component.SecurityContextData;
import org.jboss.security.authz.model.Target;
import org.jboss.security.authz.model.Attribute;
import org.jboss.security.authz.model.AttributeExpression;
@@ -124,52 +127,22 @@
private Target generateTarget() throws Exception
{
Target target = new Target();
+
+ //use the proper category for the data
+ ComponentCategory category = this.findComponentCategory(this.targetComponent.getClass());
+ String attributeCategory = category.getAttributeCategory();
- //Read the TargetUri
- Field targetField = this.findSecurityContextDataField(this.targetComponent.getClass());
- targetField.setAccessible(true);
- Object targetUriObj = targetField.get(this.targetComponent);
+ //Read the SecurityContext State of the Component being provisioned
+ Object[] securityContextData = AnnotationProcessor.extractSecurityContextData(this.targetComponent);
- //Get a String representation of this URI
- String uriStr = targetUriObj.toString();
+ //Get the Attribute expression based on the Security Context State
+ List<AttributeExpression> urlExpressions = this.generateAttributeExpression(securityContextData, attributeCategory);
- //use the proper category for the data
- ComponentCategory category = this.findComponentCategory(this.targetComponent.getClass());
- String attributeCategory = category.getAttributeCategory();
-
- AttributeExpression urlExpression = new AttributeExpression();
- if (uriStr.charAt(0) == '/' && uriStr.endsWith("/*"))
+ //Depending up the data category add the appropriate match expression
+ for(AttributeExpression urlExpression: urlExpressions)
{
- // If URL starts with '/' and ends with "/*", use a regular
- // expression to match it (In consistency with the servlet spec)
- urlExpression
- .setFunctionId(XACMLConstants.FUNCTION_REGEXP_STRING_MATCH);
-
- String uriexp = uriStr.substring(1, uriStr.length() - 2);
- StringBuilder buffer = new StringBuilder();
- buffer.append("^/" + uriexp + "$|");
- buffer.append("^" + uriexp + "$|");
- buffer.append("^/" + uriexp + "/.*|");
- buffer.append("^" + uriexp + "/.*");
-
- Attribute attribute = new Attribute(
- attributeCategory,
- XMLSchemaConstants.DATATYPE_STRING, buffer.toString());
- urlExpression.setAttribute(attribute);
- }
- else
- {
- // use an exact match
- urlExpression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
-
- Attribute attribute = new Attribute(
- attributeCategory,
- XMLSchemaConstants.DATATYPE_STRING, uriStr);
- urlExpression.setAttribute(attribute);
+ category.setExpression(target, urlExpression);
}
-
- //Depending up the data category add the appropriate match expression
- category.setExpression(target, urlExpression);
return target;
}
@@ -195,28 +168,91 @@
return null;
}
-
- private Field findSecurityContextDataField(Class targetClass)
- {
- Field[] declaredFields = targetClass.getDeclaredFields();
- if(declaredFields != null)
- {
- for(Field declaredField: declaredFields)
+
+ private List<AttributeExpression> generateAttributeExpression(Object[] securityContextState, String attributeCategory)
+ {
+ List<AttributeExpression> expressions = new ArrayList<AttributeExpression>();
+
+ for(Object input: securityContextState)
+ {
+ if(Collection.class.isAssignableFrom(input.getClass()) || input.getClass().isArray())
{
- Annotation targetUri = declaredField.getAnnotation(SecurityContextData.class);
- if(targetUri != null)
+ Set<String> uris = null;
+ if(input.getClass().isArray())
{
- return declaredField;
+ List<Object> local = new ArrayList<Object>();
+ int arrayLength = Array.getLength(input);
+ for(int i=0; i<arrayLength; i++)
+ {
+ local.add(Array.get(input, i));
+ }
+ uris = SecurityContextDataProcessor.processEnforcementState(local);
}
+ else
+ {
+ uris = SecurityContextDataProcessor.processEnforcementState((Collection)input);
+ }
+
+ for(String uri: uris)
+ {
+ AttributeExpression expression = new AttributeExpression();
+ this.setAttribute(expression, attributeCategory, uri);
+ expressions.add(expression);
+ }
}
+ else if(Map.class.isAssignableFrom(input.getClass()))
+ {
+ Map<String, String> mappedUris = SecurityContextDataProcessor.processEnforcementState((Map)input);
+ Set<String> customCategories = mappedUris.keySet();
+ for(String customCategory: customCategories)
+ {
+ AttributeExpression expression = new AttributeExpression();
+ this.setAttribute(expression, customCategory, mappedUris.get(customCategory));
+ expressions.add(expression);
+ }
+ }
+ else
+ {
+ AttributeExpression expression = new AttributeExpression();
+ this.setAttribute(expression, attributeCategory, input.toString());
+ expressions.add(expression);
+ }
}
- //If I get here, query the super class
- if(targetClass.getSuperclass() != null)
+ return expressions;
+ }
+
+ private void setAttribute(AttributeExpression urlExpression, String attributeCategory, String uriStr)
+ {
+ Attribute attribute = null;
+
+ if (uriStr.charAt(0) == '/' && uriStr.endsWith("/*"))
{
- return this.findSecurityContextDataField(targetClass.getSuperclass());
+ // If URL starts with '/' and ends with "/*", use a regular
+ // expression to match it (In consistency with the servlet spec)
+ urlExpression.setFunctionId(XACMLConstants.FUNCTION_REGEXP_STRING_MATCH);
+
+ String uriexp = uriStr.substring(1, uriStr.length() - 2);
+ StringBuilder buffer = new StringBuilder();
+ buffer.append("^/" + uriexp + "$|");
+ buffer.append("^" + uriexp + "$|");
+ buffer.append("^/" + uriexp + "/.*|");
+ buffer.append("^" + uriexp + "/.*");
+
+ attribute = new Attribute(
+ attributeCategory,
+ XMLSchemaConstants.DATATYPE_STRING, buffer.toString());
+ }
+ else
+ {
+ // use an exact match
+ urlExpression.setFunctionId(XACMLConstants.FUNCTION_STRING_EQUAL);
+
+ attribute = new Attribute(
+ attributeCategory,
+ XMLSchemaConstants.DATATYPE_STRING, uriStr);
}
- return null;
+ urlExpression.setAttribute(attribute);
}
}
Modified: modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java
===================================================================
--- modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java 2009-07-05 11:12:20 UTC (rev 13499)
+++ modules/authorization/trunk/http-profile/src/main/java/org/jboss/security/authz/http/component/resource/HttpResource.java 2009-07-09 03:49:09 UTC (rev 13500)
@@ -79,47 +79,5 @@
public void addParameter(String name, String value)
{
this.getParameters().put(name, value);
- }
-
- /*public PolicyMetaData getPolicyMetaData()
- {
- PolicyMetaData metadata = super.getPolicyMetaData();
-
- if(!this.getParameters().isEmpty())
- {
- Set<String> names = this.parameters.keySet();
- for(String name: names)
- {
- String value = this.parameters.get(name);
-
- AttributeExpression paramExpression = ExpressionBuilder.getInstance().createCustomResourceExpression(name, value);
- paramExpression.setDesignatorMustBePresent(false);
- metadata.getTarget().addResourceMatch(paramExpression);
- }
- }
-
- return metadata;
- }*/
-
- /*public Resource getResource()
- {
- Resource urlResource = super.getResource();
-
- if(!this.getParameters().isEmpty())
- {
- Set<String> names = this.parameters.keySet();
- for(String name: names)
- {
- String value = this.parameters.get(name);
-
- Attribute customAttribute = new Attribute();
- customAttribute.setUri(name);
- customAttribute.setDatatType(XMLSchemaConstants.DATATYPE_STRING);
- customAttribute.setValue(value);
- urlResource.addAttribute(customAttribute);
- }
- }
-
- return urlResource;
- }*/
+ }
}
Added: modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/MockPolicy.java
===================================================================
--- modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/MockPolicy.java (rev 0)
+++ modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/MockPolicy.java 2009-07-09 03:49:09 UTC (rev 13500)
@@ -0,0 +1,276 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.security.authz.http.components;
+
+import java.util.List;
+import java.util.Set;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.UUID;
+
+import javax.xml.bind.JAXBElement;
+
+import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.PolicyMetaData;
+import org.jboss.security.authz.model.Rule;
+import org.jboss.security.authz.model.Effect;
+import org.jboss.security.authz.model.PolicyException;
+import org.jboss.security.authz.model.AttributeExpression;
+import org.jboss.security.authz.model.DroolsRuleExpression;
+import org.jboss.security.authz.model.Expression;
+import org.jboss.security.authz.xacml.AttributeDesignatorUtil;
+import org.jboss.security.authz.xacml.PolicyUtil;
+
+import org.jboss.security.xacml.core.model.policy.ActionMatchType;
+import org.jboss.security.xacml.core.model.policy.SubjectMatchType;
+import org.jboss.security.xacml.core.model.policy.ApplyType;
+import org.jboss.security.xacml.core.model.policy.VariableReferenceType;
+import org.jboss.security.xacml.core.model.policy.EffectType;
+import org.jboss.security.xacml.core.model.policy.PolicyType;
+import org.jboss.security.xacml.core.model.policy.ResourceMatchType;
+import org.jboss.security.xacml.core.model.policy.ResourcesType;
+import org.jboss.security.xacml.core.model.policy.ResourceType;
+import org.jboss.security.xacml.core.model.policy.ActionsType;
+import org.jboss.security.xacml.core.model.policy.ActionType;
+import org.jboss.security.xacml.core.model.policy.SubjectsType;
+import org.jboss.security.xacml.core.model.policy.SubjectType;
+import org.jboss.security.xacml.core.model.policy.RuleType;
+import org.jboss.security.xacml.core.model.policy.TargetType;
+import org.jboss.security.xacml.core.model.policy.ConditionType;
+import org.jboss.security.xacml.core.model.policy.ObjectFactory;
+import org.jboss.security.xacml.core.model.policy.AttributeValueType;
+import org.jboss.security.xacml.core.model.policy.SubjectAttributeDesignatorType;
+import org.jboss.security.xacml.factories.PolicyAttributeFactory;
+
+/**
+ * Used for specifying policies for Resources represented by unique URIs, sometimes forming a tree like relationship with other Resources in the system
+ *
+ * An example of such resources would be tree of resources/nodes in a Content Management System
+ *
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class MockPolicy extends Policy
+{
+
+ public MockPolicy(String policyUri, PolicyMetaData metaData) throws PolicyException
+ {
+ super(policyUri, metaData);
+ }
+
+
+ @Override
+ public String generateSystemPolicy() throws PolicyException
+ {
+ ByteArrayOutputStream bos = null;
+ try
+ {
+ String xacmlXml = null;
+
+ //SetUp the Policy Header
+ ObjectFactory objectFactory = new ObjectFactory();
+ PolicyType policyType = new PolicyType();
+ policyType.setPolicyId(this.policyUri);
+ policyType.setVersion("2.0");
+ policyType.setRuleCombiningAlgId(new NoPermitMeansDeniedAlg().getIdentifier().toString());
+
+ TargetType targetType = new TargetType();
+ policyType.setTarget(targetType);
+
+ //Process Resource Matches as Targets for the Policy
+ List<AttributeExpression> resourceMatches = this.metaData.getTarget().getResourceMatches();
+ if(resourceMatches != null && !resourceMatches.isEmpty())
+ {
+ ResourcesType resourcesType = new ResourcesType();
+ targetType.setResources(resourcesType);
+ ResourceType resourceType = new ResourceType();
+
+ for(AttributeExpression resourceMatch: resourceMatches)
+ {
+ ResourceMatchType rmt = new ResourceMatchType();
+
+ rmt.setMatchId(resourceMatch.getFunctionId());
+ rmt.setResourceAttributeDesignator(AttributeDesignatorUtil.getAttributeDesignator(resourceMatch.getAttribute(), true));
+ rmt.setAttributeValue(PolicyAttributeFactory
+ .createStringAttributeType(resourceMatch.getAttribute().getValue()));
+
+ resourceType.getResourceMatch().add(rmt);
+ }
+
+ resourcesType.getResource().add(resourceType);
+ }
+
+ //Process the Policy Rules
+ Set<Rule> rules = this.metaData.getRules();
+ if(rules != null && !rules.isEmpty())
+ {
+ for(Rule rule: rules)
+ {
+ RuleType ruleType = new RuleType();
+ ruleType.setRuleId(rule.getRuleId());
+ if(rule.getEffect() == Effect.PERMIT)
+ {
+ ruleType.setEffect(EffectType.PERMIT);
+ }
+ else
+ {
+ ruleType.setEffect(EffectType.DENY);
+ }
+
+ //Process the Rule Target
+ if(rule.getTarget() != null)
+ {
+ List<AttributeExpression> actionMatches = rule.getTarget().getActionMatches();
+ List<AttributeExpression> subjectMatches = rule.getTarget().getSubjectMatches();
+ TargetType ruleTarget = new TargetType();
+
+ if(actionMatches != null && !actionMatches.isEmpty())
+ {
+ ruleTarget.setActions(this.generateRuleActions(actionMatches));
+ }
+
+ if(subjectMatches != null && !subjectMatches.isEmpty())
+ {
+ ruleTarget.setSubjects(this.generateRuleSubjects(subjectMatches));
+ }
+
+ ruleType.setTarget(ruleTarget);
+ }
+
+ //Process the Rule Expression/Condition
+ ConditionType condition = this.generateCondition(objectFactory, rule.getExpression());
+ ruleType.setCondition(condition);
+
+ policyType.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition().add(ruleType);
+ }
+ }
+
+ bos = new ByteArrayOutputStream();
+ PolicyUtil.marshall(bos, policyType);
+ xacmlXml = new String(bos.toByteArray());
+
+ return xacmlXml;
+ }
+ catch(Exception e)
+ {
+ throw new PolicyException(e);
+ }
+ finally
+ {
+ if(bos != null)
+ {
+ try{bos.close();}catch(IOException ioe){}
+ }
+ }
+ }
+
+ private ActionsType generateRuleActions(List<AttributeExpression> actionMatches)
+ {
+ ActionsType actions = new ActionsType();
+
+ for(AttributeExpression action: actionMatches)
+ {
+ ActionType actionType = new ActionType();
+ ActionMatchType amct = new ActionMatchType();
+ amct.setMatchId(action.getFunctionId());
+ amct.setAttributeValue(PolicyAttributeFactory.createStringAttributeType(action.getAttribute().getValue()));
+ amct.setActionAttributeDesignator(AttributeDesignatorUtil.getAttributeDesignator(action.getAttribute(), true));
+ actionType.getActionMatch().add(amct);
+ actions.getAction().add(actionType);
+ }
+
+ return actions;
+ }
+
+ private SubjectsType generateRuleSubjects(List<AttributeExpression> subjectMatches)
+ {
+ SubjectsType subjects = new SubjectsType();
+
+ for(AttributeExpression subject: subjectMatches)
+ {
+ SubjectType subjectType = new SubjectType();
+ SubjectMatchType match = new SubjectMatchType();
+ match.setMatchId(subject.getFunctionId());
+ match.setAttributeValue(PolicyAttributeFactory.createStringAttributeType(subject.getAttribute().getValue()));
+ match.setSubjectAttributeDesignator((SubjectAttributeDesignatorType)AttributeDesignatorUtil.getAttributeDesignator(subject.getAttribute(), true));
+ subjectType.getSubjectMatch().add(match);
+ subjects.getSubject().add(subjectType);
+ }
+
+ return subjects;
+ }
+
+ /**
+ *
+ * @param expression
+ * @return
+ */
+ private ConditionType generateCondition(ObjectFactory objectFactory, Expression expression)
+ {
+ ConditionType condition = new ConditionType();
+
+ if(expression instanceof AttributeExpression)
+ {
+ AttributeExpression attributeExpression = (AttributeExpression)expression;
+
+ //Function to be applied
+ ApplyType apply = new ApplyType();
+ apply.setFunctionId(attributeExpression.getFunctionId());
+
+ //Value to check against
+ AttributeValueType attrValue = PolicyAttributeFactory.createStringAttributeType(attributeExpression.getAttribute().getValue());
+ JAXBElement<AttributeValueType> jaxbAttrValue = objectFactory.createAttributeValue(attrValue);
+ apply.getExpression().add(jaxbAttrValue);
+
+ //Place within the Context where this Value should exist during an Authorization Request
+ apply.getExpression().add(AttributeDesignatorUtil.getAttributeDesignatorXml(attributeExpression.getAttribute(), true));
+
+
+ condition.setExpression(objectFactory.createApply(apply));
+ }
+ else if(expression instanceof DroolsRuleExpression)
+ {
+ DroolsRuleExpression ruleExpression = (DroolsRuleExpression)expression;
+
+ //Function to be applied
+ ApplyType apply = new ApplyType();
+ apply.setFunctionId(ruleExpression.getFunctionId());
+
+
+ VariableReferenceType ruleReference = new VariableReferenceType();
+ ruleReference.setVariableId(ruleExpression.getRuleReference());
+ JAXBElement<VariableReferenceType> jaxbRuleReference = objectFactory.createVariableReference(ruleReference);
+ apply.getExpression().add(jaxbRuleReference);
+
+
+ condition.setExpression(objectFactory.createApply(apply));
+ }
+
+ return condition;
+ }
+
+ private String generateUniqueId()
+ {
+ return UUID.randomUUID().toString();
+ }
+}
Added: modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/NoPermitMeansDeniedAlg.java
===================================================================
--- modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/NoPermitMeansDeniedAlg.java (rev 0)
+++ modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/NoPermitMeansDeniedAlg.java 2009-07-09 03:49:09 UTC (rev 13500)
@@ -0,0 +1,83 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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. *
+ * *
+ * This is free software; you can redistribute it and/or modify it *
+ * under the terms of the GNU Lesser General Public License as *
+ * published by the Free Software Foundation; either version 2.1 of *
+ * the License, or (at your option) any later version. *
+ * *
+ * This software is distributed in the hope that it will be useful, *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
+ * Lesser General Public License for more details. *
+ * *
+ * You should have received a copy of the GNU Lesser General Public *
+ * License along with this software; if not, write to the Free *
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA *
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org. *
+ ******************************************************************************/
+package org.jboss.security.authz.http.components;
+
+import java.util.List;
+import java.util.Iterator;
+import java.net.URI;
+import java.net.URISyntaxException;
+
+import org.jboss.security.xacml.sunxacml.combine.RuleCombiningAlgorithm;
+import org.jboss.security.xacml.sunxacml.EvaluationCtx;
+import org.jboss.security.xacml.sunxacml.ctx.Result;
+import org.jboss.security.xacml.sunxacml.Rule;
+import org.jboss.security.xacml.sunxacml.combine.RuleCombinerElement;
+
+/**
+ * @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
+ *
+ */
+public class NoPermitMeansDeniedAlg extends RuleCombiningAlgorithm
+{
+ /**
+ *
+ * @throws URISyntaxException
+ */
+ public NoPermitMeansDeniedAlg() throws URISyntaxException
+ {
+ super(new URI("rule-combining-alg:nopermit-means-denied"));
+ }
+
+ /**
+ *
+ * @param context
+ * @param rules
+ * @return
+ */
+ public Result combine(EvaluationCtx context, List parameters, List ruleElements)
+ {
+ Result result = new Result(Result.DECISION_PERMIT);
+
+ Iterator rules = ruleElements.iterator();
+ boolean permitFound = false;
+ while(rules.hasNext())
+ {
+ RuleCombinerElement ruleCombinerElement = (RuleCombinerElement)rules.next();
+ Rule rule = ruleCombinerElement.getRule();
+ Result currentResult = rule.evaluate(context);
+
+ if(currentResult.getDecision() == Result.DECISION_PERMIT)
+ {
+ permitFound = true;
+ break;
+ }
+ }
+
+ if(!permitFound)
+ {
+ result = new Result(Result.DECISION_DENY);
+ }
+
+ return result;
+ }
+}
Modified: modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java
===================================================================
--- modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java 2009-07-05 11:12:20 UTC (rev 13499)
+++ modules/authorization/trunk/http-profile/src/test/java/org/jboss/security/authz/http/components/TestHttpResource.java 2009-07-09 03:49:09 UTC (rev 13500)
@@ -27,9 +27,17 @@
import org.apache.log4j.Logger;
-import org.jboss.security.authz.http.component.resource.HttpResource;
+import org.jboss.security.authz.agent.Agent;
+import org.jboss.security.authz.agent.services.CompositionContext;
+import org.jboss.security.authz.agent.services.PolicyComposer;
+
+import org.jboss.security.authz.components.subject.Identity;
+import org.jboss.security.authz.components.subject.Roles;
import org.jboss.security.authz.model.Policy;
+import org.jboss.security.authz.model.Effect;
+import org.jboss.security.authz.http.component.resource.HttpResource;
+import org.jboss.security.authz.http.component.action.Get;
/**
* @author <a href="mailto:sshah@redhat.com">Sohil Shah</a>
@@ -38,13 +46,29 @@
{
private static Logger log = Logger.getLogger(TestHttpResource.class);
+ private PolicyComposer policyComposer;
+
+ protected void setUp() throws Exception
+ {
+ Agent.bootstrap();
+ this.policyComposer = (PolicyComposer)Agent.lookup("/agent/PolicyComposer");
+ }
+ //------------------------------------------------------------------------------------------------------------------------------------------------------------------
//TODO: migrate to the new developer framework
- /*public void testGetURLTargetNoParameters() throws Exception
+ public void testGetURLTargetNoParameters() throws Exception
{
HttpResource httpResource = new HttpResource();
httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
+
+ Identity identity = new Identity();
+ identity.setName("blahUser");
+
+ //Setup the Context for the Composition with these components
+ CompositionContext context = new CompositionContext();
+ context.setPolicyTarget(httpResource);
+ context.addPolicyRule(Effect.PERMIT, identity, null);
- Policy policy = new MockPolicy("testGetURLTargetNoParameters", httpResource.getPolicyMetaData());
+ Policy policy = new MockPolicy("testGetURLTargetNoParameters", this.policyComposer.compose(context));
log.info("------------------------------------------------------------------");
log.info(policy.generateSystemPolicy());
@@ -56,10 +80,17 @@
httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
httpResource.addParameter("test1", "test1://value");
httpResource.addParameter("test2", "test2://value");
+
+ Identity identity = new Identity();
+ identity.setName("blahUser");
+
+ //Setup the Context for the Composition with these components
+ CompositionContext context = new CompositionContext();
+ context.setPolicyTarget(httpResource);
+ context.addPolicyRule(Effect.PERMIT, identity, null);
+ Policy policy = new MockPolicy("testGetURLTargetWithParameters", this.policyComposer.compose(context));
- Policy policy = new MockPolicy("testGetURLTargetWithParameters", httpResource.getPolicyMetaData());
-
log.info("------------------------------------------------------------------");
log.info(policy.generateSystemPolicy());
}
@@ -70,42 +101,49 @@
httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
httpResource.addParameter("test1", "test1://value");
httpResource.addParameter("test2", "test2://value");
- httpResource.addAllowed("admin");
- httpResource.addDenied("anonymous");
+
+ Roles allowedRoles = new Roles();
+ allowedRoles.addName("admin");
+ allowedRoles.addName("user");
+
+ Roles deniedRoles = new Roles();
+ deniedRoles.addName("anonymous");
+
+ //Setup the Context for the Composition with these components
+ CompositionContext context = new CompositionContext();
+ context.setPolicyTarget(httpResource);
+ context.addPolicyRule(Effect.PERMIT, new Get(), allowedRoles, "allowExpression");
+ context.addPolicyRule(Effect.DENY, new Get(), deniedRoles, "denyExpression");
- Policy policy = new MockPolicy("testRoleRules", httpResource.getPolicyMetaData());
+ Policy policy = new MockPolicy("testRoleRules", this.policyComposer.compose(context));
log.info("------------------------------------------------------------------");
log.info(policy.generateSystemPolicy());
}
-
- public void testIPRules() throws Exception
- {
- HttpResource httpResource = new HttpResource();
- httpResource.setUri(new URI("/portal/admin-tool/modifyLayout"));
- httpResource.addParameter("test1", "test1://value");
- httpResource.addParameter("test2", "test2://value");
- httpResource.addAllowed("admin");
- httpResource.addDenied("anonymous");
-
- Policy policy = new MockPolicy("testIPRules", httpResource.getPolicyMetaData());
- log.info("------------------------------------------------------------------");
- log.info(policy.generateSystemPolicy());
- }
-
public void testURLPattern() throws Exception
{
HttpResource httpResource = new HttpResource();
httpResource.setUri(new URI("/portal/*"));
httpResource.addParameter("test1", "test1://value");
httpResource.addParameter("test2", "test2://value");
- httpResource.addAllowed("admin");
- httpResource.addDenied("anonymous");
+
+ Roles allowedRoles = new Roles();
+ allowedRoles.addName("admin");
+ allowedRoles.addName("user");
+
+ Roles deniedRoles = new Roles();
+ deniedRoles.addName("anonymous");
+
+ //Setup the Context for the Composition with these components
+ CompositionContext context = new CompositionContext();
+ context.setPolicyTarget(httpResource);
+ context.addPolicyRule(Effect.PERMIT, new Get(), allowedRoles, "allowExpression");
+ context.addPolicyRule(Effect.DENY, new Get(), deniedRoles, "denyExpression");
- Policy policy = new MockPolicy("testURLPattern", httpResource.getPolicyMetaData());
+ Policy policy = new MockPolicy("testURLPattern", this.policyComposer.compose(context));
log.info("------------------------------------------------------------------");
log.info(policy.generateSystemPolicy());
- }*/
+ }
}
16 years, 10 months
JBoss Portal SVN: r13530 - branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/hibernate/portal.
by portal-commits@lists.jboss.org
Author: mputz
Date: 2009-07-08 06:53:04 -0400 (Wed, 08 Jul 2009)
New Revision: 13530
Modified:
branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
Log:
JBPORTAL-2384: Fix hibernate mappings to address N+1 select problem on accessing ObjectNode.children
Modified: branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml
===================================================================
--- branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2009-07-07 23:59:53 UTC (rev 13529)
+++ branches/JBoss_Portal_Branch_2_7/core/src/resources/portal-core-sar/conf/hibernate/portal/domain.hbm.xml 2009-07-08 10:53:04 UTC (rev 13530)
@@ -54,7 +54,7 @@
name="children"
inverse="true"
cascade="none"
- fetch="select"
+ fetch="subselect"
lazy="true">
<cache usage="@portal.hibernate.cache.usage@"/>
<key column="PARENT_KEY"/>
@@ -73,7 +73,9 @@
name="object"
class="org.jboss.portal.core.impl.model.portal.PortalObjectImpl"
cascade="none"
- fetch="select">
+ fetch="join"
+ constrained="true"
+ lazy="false">
</one-to-one>
<map
name="securityConstraints"
16 years, 10 months