Author: vrockai
Date: 2009-05-28 11:27:04 -0400 (Thu, 28 May 2009)
New Revision: 13419
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java
Log:
[selenium] - portal end2end
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java 2009-05-28
11:35:22 UTC (rev 13418)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/portal/EndtoEndPortalAdminTestCase.java 2009-05-28
15:27:04 UTC (rev 13419)
@@ -19,6 +19,45 @@
@Test(groups = { "end2end" }, enabled = true, description = "Creating of
new portal with content.")
public class EndtoEndPortalAdminTestCase extends JBossPortalSeleniumTestCase {
+
+ private static final String SUB_POR_PROPS_UPDATE =
"_AdminPortletWindow:j_id108:common-manage-prop-form:update";
+
+ private static final String SUB_POR_PROPERTY =
"_AdminPortletWindow:j_id108:common-edit-prop-form:add-property";
+
+ private static final String INP_POR_PROPERTY =
"_AdminPortletWindow:j_id108:common-edit-prop-form:property";
+
+ private static final String SUB_POR_LISTENER =
"_AdminPortletWindow:j_id108:edit-prop-form:update";
+
+ private static final String SEL_POR_LISTENER =
"_AdminPortletWindow:j_id108:edit-prop-form:listener";
+
+ private static final String SUB_PAL =
"_AdminPortletWindow:j_id134:common-edit-page-error-form:update";
+
+ private static final String SEL_PAL_PR =
"_AdminPortletWindow:j_id134:common-edit-page-error-form:page-res-select";
+
+ private static final String SEL_PAL_PN =
"_AdminPortletWindow:j_id134:common-edit-page-error-form:page-not-found-select";
+
+ private static final String SEL_PAL_PI =
"_AdminPortletWindow:j_id134:common-edit-page-error-form:page-internal-select";
+
+ private static final String SEL_PAL_PE =
"_AdminPortletWindow:j_id134:common-edit-page-error-form:page-error-select";
+
+ private static final String SEL_PAL_PC =
"_AdminPortletWindow:j_id134:common-edit-page-error-form:page-control-select";
+
+ private static final String SEL_PAL_PA =
"_AdminPortletWindow:j_id134:common-edit-page-error-form:page-access-select";
+
+ private static final String SUB_POL =
"_AdminPortletWindow:j_id134:common-edit-portal-error-form:update";
+
+ private static final String SEL_POL_PR =
"_AdminPortletWindow:j_id134:common-edit-portal-error-form:portal-res-input";
+
+ private static final String SEL_POL_PN =
"_AdminPortletWindow:j_id134:common-edit-portal-error-form:portal-not-found-select";
+
+ private static final String SEL_POL_PI =
"_AdminPortletWindow:j_id134:common-edit-portal-error-form:portal-internal-select";
+
+ private static final String SEL_POL_PE =
"_AdminPortletWindow:j_id134:common-edit-portal-error-form:portal-error-select";
+
+ private static final String SEL_POL_PU =
"_AdminPortletWindow:j_id134:common-edit-portal-error-form:portal-unavail-select";
+
+ private static final String SEL_POL_PA =
"_AdminPortletWindow:j_id134:common-edit-portal-error-form:portal-access-select";
+
/** prefix for locator properties = portal.e2e.*/
public static String casePfx = "portal.e2e.";
@@ -59,7 +98,11 @@
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" })
protected void loginBeforeTest() {
logoutIfPossible();
@@ -72,11 +115,15 @@
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 page1ManName = "firstManPage";
+
final String PORTLET1 = "Cart Portlet";
final String por1str = "Cart Portlet";
final String PORTLET2 = "Band Culinaria";
@@ -137,11 +184,11 @@
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");
@@ -170,11 +217,221 @@
}
- @Test(enabled = true, description = "Usecase for creating small portal with
content.")
+ @Test(enabled = false, description = "Usecase for managing portals - listeners and
properties.")
public void testManagePortalUsecase() {
+ int r = -1;
+
createPortal(portalManName);
+ addPage(portalManName,page1ManName);
+ //- Verify that you can add listener
+ goToProperties();
+
+ selenium.select(SEL_POR_LISTENER, "label=test_listener");
+ selenium.click(SUB_POR_LISTENER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ goToProperties();
+ Assert.assertEquals(selenium.getSelectedLabel(SEL_POR_LISTENER),"test_listener","Previously
selected label not being the current label.");
+
+ selenium.select(SEL_POR_LISTENER, "label=user_listener");
+ selenium.click(SUB_POR_LISTENER);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ goToProperties();
+ Assert.assertEquals(selenium.getSelectedLabel(SEL_POR_LISTENER),"user_listener","Previously
selected label not being the current label.");
+
+ goToProperties();
+ //- assert no property is added
+ //r = countTableRows(TAB_PROPERTIES);
+ //Assert.assertTrue(r==0,"Property table is not empty.");
+ 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 partial refresh prop
+ selenium.type(INP_POR_PROPERTY, "partialRef");
+ selenium.click(SUB_POR_PROPERTY);
+ selenium.waitForPageToLoad("30000");
+
+ 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");
+
+ //- 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==-1,"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
+ r = findTableRow(TAB_PROPERTIES, "partialRef", 0)-1;
+ Assert.assertTrue(r<0,"Deleted property partial refresh was found in property
table.");
+
}
+
+ @Test(enabled = false, 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();
+ selenium.select(SEL_POL_PA, "label="+LAB_RED);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_POL_PU, "label="+LAB_RED);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_POL_PE, "label="+LAB_RED);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_POL_PI, "label="+LAB_RED);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_POL_PN, "label="+LAB_RED);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(SEL_POL_PR, "/WEB-INF/jsp/error/port3al.jsp");
+ selenium.click(SUB_POL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // assert RED handling
+ 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 Portal");
+
+ // select ERR handling
+ goToProperties();
+ selenium.select(SEL_POL_PA, "label="+LAB_ERR);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_POL_PU, "label="+LAB_ERR);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_POL_PE, "label="+LAB_ERR);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_POL_PI, "label="+LAB_ERR);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_POL_PN, "label="+LAB_ERR);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(SEL_POL_PR, "/WEB-INF/jsp/error/port3al.jsp");
+ selenium.click(SUB_POL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // assert ERR handling
+ openAndAssert("/portal/auth/portal/default/Test/Exception+test/ExceptionPortletWindow?op=error&action=1",
"HTTP Status 500");
+
+ // ***
+ // *** Page level
+ // ***
+
+ // select RED handling
+ goToProperties();
+ selenium.select(SEL_PAL_PA, "label="+LAB_RED);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PC, "label="+LAB_RED);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PE, "label="+LAB_RED);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PI, "label="+LAB_RED);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PN, "label="+LAB_RED);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(SEL_PAL_PR, "/WEB-INF/jsp/error/pa9ge.jsp");
+ selenium.click(SUB_PAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // assert RED handling
+ 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 Portal");
+
+ // select ERR handling
+ goToProperties();
+ selenium.select(SEL_PAL_PA, "label="+LAB_ERR);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PC, "label="+LAB_ERR);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PE, "label="+LAB_ERR);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PI, "label="+LAB_ERR);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PN, "label="+LAB_ERR);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(SEL_PAL_PR, "/WEB-INF/jsp/error/pa9ge.jsp");
+ selenium.click(SUB_PAL);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
+ // assert ERR handling
+ 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 Portal");
+
+ // select REM handling
+ goToProperties();
+ selenium.select(SEL_PAL_PA, "label="+LAB_REM);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PC, "label="+LAB_REM);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PE, "label="+LAB_REM);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PI, "label="+LAB_REM);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.select(SEL_PAL_PN, "label="+LAB_REM);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ selenium.type(SEL_PAL_PR, "/WEB-INF/jsp/error/pa9ge.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");
+ openAndAssert("/portal/auth/portal/default/Test/Exception+test/ExceptionPortletWindow?op=error&action=1",
"Powered by JBoss Portal");
+ }
+
+ private void openAndAssert(String add, String ass){
+ selenium.open(add);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertTrue(selenium.isTextPresent(ass),"Text: {\"" + ass +
"\"} not 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);
@@ -210,7 +467,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);