Author: vrockai
Date: 2009-05-06 06:38:41 -0400 (Wed, 06 May 2009)
New Revision: 13298
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowTestCase.java
Log:
[JBPORTAL-2311] - javadoc for tests
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowTestCase.java 2009-05-05
16:41:12 UTC (rev 13297)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/cms/CMSFileWorkflowTestCase.java 2009-05-06
10:38:41 UTC (rev 13298)
@@ -9,6 +9,8 @@
import org.testng.annotations.Test;
/**
+ * Testing file actions of CMS which require workflow security.
+ *
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
@@ -17,65 +19,72 @@
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 =
getLoc(casePfx+"lab.lang.czech","label=Czech");
- 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");
+ private final String LAB_LANG_CZECH = getLoc(casePfx + "lab.lang.czech",
"label=Czech");
+ 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 =
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");
-
+ 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.waitForPageToLoad(PAGE_LOAD);
@@ -85,32 +94,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,25 +140,29 @@
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.waitForPageToLoad(PAGE_LOAD);
selenium.click(LNK_ADMIN);
@@ -163,18 +181,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);
@@ -184,52 +209,62 @@
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);
@@ -239,7 +274,7 @@
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isElementPresent("link=fileToMove"));
-
+
// really moving file
selenium.open(ADDR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -249,15 +284,15 @@
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);
@@ -269,17 +304,22 @@
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);
@@ -294,33 +334,41 @@
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.waitForPageToLoad(PAGE_LOAD);
@@ -330,32 +378,32 @@
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.click("link=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);
@@ -363,10 +411,9 @@
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.waitForPageToLoad(PAGE_LOAD);
@@ -383,21 +430,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.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 + "')");
}
}