Author: vrockai
Date: 2008-10-20 14:22:26 -0400 (Mon, 20 Oct 2008)
New Revision: 12103
Modified:
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
Log:
wsrp logout fix1
Modified:
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2008-10-20
16:56:58 UTC (rev 12102)
+++
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/JBossPortalSeleniumTestCase.java 2008-10-20
18:22:26 UTC (rev 12103)
@@ -6,6 +6,7 @@
import com.thoughtworks.selenium.DefaultSelenium;
import com.thoughtworks.selenium.Selenium;
+
/**
* @author <a href="mailto:vrockai@redhat.com">Viliam Rockai</a>
*/
@@ -18,11 +19,11 @@
public static final String INPUT_PASSWORD = "j_password";
public static final String INPUT_USERNAME = "j_username";
protected Selenium selenium;
-
- //Generic timeout in miliseconds
+
+ // Generic timeout in miliseconds
protected static final String PAGE_LOAD = "450000";
-
- //Element timeout in seconds
+
+ // Element timeout in seconds
protected static final int ELEM_TIMEOUT = 30;
@BeforeClass
@@ -40,17 +41,17 @@
}
protected void clickIfVisible(String id) {
-
- if (selenium.isElementPresent(id)){
+
+ if (selenium.isElementPresent(id)) {
selenium.click(id);
selenium.waitForPageToLoad(PAGE_LOAD);
}
}
-
+
protected void clickIfVisible(String id, String awaited) {
-
- if (selenium.isElementPresent(id)){
+
+ if (selenium.isElementPresent(id)) {
selenium.click(id);
selenium.waitForPageToLoad(PAGE_LOAD);
}
@@ -69,56 +70,57 @@
return true;
}
}
-
+
return false;
}
protected int findTableRow(String tableLocation, String searchName, int searchCol) {
return Integer.valueOf(selenium.getEval("selenium.findTableRow(\"" +
tableLocation + "\",'" + searchName + "'," + searchCol +
")"));
}
-
- protected int countTableRows(String tableLocation){
+
+ protected int countTableRows(String tableLocation) {
return Integer.valueOf(selenium.getEval("selenium.countTableRows(\"" +
tableLocation + "\")"));
}
// TODO refactor
- protected void safeSelect(String locator, String value){
+ protected void safeSelect(String locator, String value) {
waitForElement(locator);
-
- for (int second = 0; ; second++) {
- if (second >= ELEM_TIMEOUT) {
- Assert.fail("Element "+locator+" not found.");
- }
- try {
- String [] opts = selenium.getSelectOptions(locator);
- boolean isAvailable = false;
-
- for(String opt : opts){
- if (opt.equals(value)){
- isAvailable = true;
- }
- }
-
- if (isAvailable) break;
- } catch (Exception e) {
- }
- waitFor(1000);
- }
-
- selenium.select(locator, "label="+value);
+
+ for (int second = 0;; second++) {
+ if (second >= ELEM_TIMEOUT) {
+ Assert.fail("Element " + locator + " not found.");
+ }
+ try {
+ String[] opts = selenium.getSelectOptions(locator);
+ boolean isAvailable = false;
+
+ for (String opt : opts) {
+ if (opt.equals(value)) {
+ isAvailable = true;
+ }
+ }
+
+ if (isAvailable)
+ break;
+ } catch (Exception e) {
+ }
+ waitFor(1000);
+ }
+
+ selenium.select(locator, "label=" + value);
}
-
- protected void clickAndWait(String locator){
+
+ protected void clickAndWait(String locator) {
waitForElement(locator);
selenium.click(locator);
selenium.waitForPageToLoad(PAGE_LOAD);
}
-
- protected void openAndWait(String locator){
+
+ protected void openAndWait(String locator) {
selenium.open(locator);
selenium.waitForPageToLoad(PAGE_LOAD);
}
-
+
protected void selectIfNotSelected(String selector, String label) {
waitForElement(selector);
if (!selenium.getSelectedLabel(selector).equals(label)) {
@@ -126,52 +128,51 @@
selenium.waitForPageToLoad(PAGE_LOAD);
}
}
-
- protected boolean assertTextOrder(String text){
+
+ protected boolean assertTextOrder(String text) {
return Boolean.valueOf(selenium.getEval("selenium.assertTextOrder(\"" +
text + "\")"));
}
- protected void waitFor(long time){
+ protected void waitFor(long time) {
try {
Thread.sleep(time);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
- }
+ }
}
-
- public void waitForElement(String locator) {
- for (int second = 0; ; second++) {
- if (second >= ELEM_TIMEOUT) {
- Assert.fail("Element "+locator+" not found.");
- }
- try {
- if (selenium.isElementPresent(locator)) break;
- } catch (Exception e) {
- }
- waitFor(1000);
- }
- }
-
-
+
+ public void waitForElement(String locator) {
+ for (int second = 0;; second++) {
+ if (second >= ELEM_TIMEOUT) {
+ Assert.fail("Element " + locator + " not found.");
+ }
+ try {
+ if (selenium.isElementPresent(locator))
+ break;
+ } catch (Exception e) {
+ }
+ waitFor(1000);
+ }
+ }
+
protected void login(String username, String password) {
selenium.open(ADDR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
selenium.click(LINK_LOGIN);
selenium.selectFrame(FRAME_LOGIN_CONTENT);
-
-
+
waitForElement(INPUT_USERNAME);
waitForElement(INPUT_PASSWORD);
waitForElement(SUBMIT_LOGIN);
-
+
selenium.type(INPUT_USERNAME, username);
selenium.type(INPUT_PASSWORD, password);
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.");
+ Assert.assertTrue(selenium.isTextPresent("Logged in as: " + username),
"Not logged in, login message missing.");
}
protected void logout() {
@@ -183,15 +184,15 @@
Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "Not logged
in, login message missing.");
Assert.assertTrue(selenium.isElementPresent("Link=Login"), "Login link
not present.");
}
-
+
protected void logoutIfPossible() {
selenium.open(ADDR_PORTAL);
selenium.waitForPageToLoad(PAGE_LOAD);
- if (selenium.isElementPresent(LINK_LOGOUT)){
- selenium.click(LINK_LOGOUT);
- selenium.waitForPageToLoad(PAGE_LOAD);
- Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "Not logged
in, login message missing.");
- Assert.assertTrue(selenium.isElementPresent("Link=Login"), "Login link
not present.");
+ if (selenium.isElementPresent(LINK_LOGOUT)) {
+ selenium.click(LINK_LOGOUT);
+ selenium.waitForPageToLoad(PAGE_LOAD);
+ Assert.assertFalse(selenium.isTextPresent("Logged in as:"), "Not logged
in, login message missing.");
+ Assert.assertTrue(selenium.isElementPresent("Link=Login"), "Login link
not present.");
}
}
}
Modified:
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2008-10-20
16:56:58 UTC (rev 12102)
+++
branches/JBoss_Portal_Branch_2_6/testsuite/ui-tests/src/org/jboss/portal/test/selenium/WSRPTestCase.java 2008-10-20
18:22:26 UTC (rev 12103)
@@ -6,20 +6,20 @@
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
+
/**
* @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 {
-
private static final String SUBMIT_REFRESH_CANCEL =
"edit-cons-form:list-cons-link_1";
private static final String SUBMIT_PROD_SAVE = "producer-form:save-producer";
private static final String SUBMIT_CONSDEL_CONF =
"confirm-delete-form:destroy-link";
-
+
private static final String SUBMIT_CONS_REGVAL =
"edit-cons-form:refresh-cons-link";
private static final String SUBMIT_REFRESHFINAL =
"edit-cons-form:refresh-cons-link";
-
+
private static final String INPUT_CONS_REGVALUE =
"edit-cons-form:existingProps:{0}:prop-value-input";
private static final String SUBMIT_REFRESHSAVE =
"edit-cons-form:refresh-cons-link";
private static final String INPUT_CONSWSDL = "edit-cons-form:wsdl";
@@ -33,16 +33,17 @@
private static final String INPUT_CREATECONS = "createConsumer:consumerName";
private static final String ID_LINK_PRODCONF =
"cons-temp-form:producer-link";
private static final String ID_LINK_CONSCONF =
"producer-temp-form:consumersTab";
- private static final String LINK_CONSUMER_HOME
="cons-temp-form1:list-cons-link";
-
- private static final String
LINK_T_CONS_CON="consumer-list-form:consumersList:{0}:configure";
- private static final String
LINK_T_CONS_REF="consumer-list-form:consumersList:{0}:refresh";
- private static final String
LINK_T_CONS_ACT="consumer-list-form:consumersList:{0}:activate";
- private static final String
LINK_T_CONS_DEA="consumer-list-form:consumersList:{0}:activate";
- private static final String
LINK_T_CONS_REG="consumer-list-form:consumersList:{0}:register";
- private static final String
LINK_T_CONS_DER="consumer-list-form:consumersList:{0}:register";
- private static final String
LINK_T_CONS_DEL="consumer-list-form:consumersList:{0}:delete";
+ private static final String LINK_CONSUMER_HOME =
"cons-temp-form1:list-cons-link";
+
+ private static final String LINK_T_CONS_CON =
"consumer-list-form:consumersList:{0}:configure";
+ private static final String LINK_T_CONS_REF =
"consumer-list-form:consumersList:{0}:refresh";
+ private static final String LINK_T_CONS_ACT =
"consumer-list-form:consumersList:{0}:activate";
+ private static final String LINK_T_CONS_DEA =
"consumer-list-form:consumersList:{0}:activate";
+ private static final String LINK_T_CONS_REG =
"consumer-list-form:consumersList:{0}:register";
+ private static final String LINK_T_CONS_DER =
"consumer-list-form:consumersList:{0}:register";
+ private static final String LINK_T_CONS_DEL =
"consumer-list-form:consumersList:{0}:delete";
public static String WSRP_CONSUMER_TABLE =
"consumer-list-form:consumersList";
+
@BeforeMethod(groups = { "log" })
public void loginBeforeTest() {
@@ -65,18 +66,18 @@
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("Missing value"));
- selenium.type(MessageFormat.format(INPUT_CONS_REGVALUE,0), "public");
+ selenium.type(MessageFormat.format(INPUT_CONS_REGVALUE, 0), "public");
selenium.click(SUBMIT_CONS_REGVAL);
selenium.waitForPageToLoad(PAGE_LOAD);
Assert.assertTrue(selenium.isTextPresent("Refresh was successful."));
@@ -96,8 +97,8 @@
selenium.waitForPageToLoad(PAGE_LOAD);
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,7 +107,7 @@
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(enabled = true, dependsOnMethods = { "testCreateBeaConsumer" },
description = "Standard BEA consumer deregistering.")
@@ -121,21 +122,21 @@
selenium.waitForPageToLoad(PAGE_LOAD);
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(SUBMIT_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(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);
@@ -143,11 +144,11 @@
selenium.waitForPageToLoad(PAGE_LOAD);
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)"));
@@ -166,12 +167,12 @@
selenium.waitForPageToLoad(PAGE_LOAD);
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)"));
@@ -196,16 +197,16 @@
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?"));
-
+
selenium.click(SUBMIT_CONSDEL_CONF);
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -222,16 +223,16 @@
selenium.waitForPageToLoad(PAGE_LOAD);
clickIfVisible(ID_LINK_PRODCONF);
-
+
selenium.click(SUBMIT_ADDPROP_INIT);
selenium.waitForPageToLoad(PAGE_LOAD);
selenium.type(INPUT_PROPNAME, "testProp");
selenium.type(INPUT_PROPLABEL, "testProp label");
selenium.type(INPUT_PROPHINT, "tetsPropHint");
-
+
selenium.click(SUBMIT_PROD_SAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
-
+
Assert.assertTrue(selenium.isTextPresent("Producer configuration successfully
saved!"));
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(ID_LINK_PRODCONF);
@@ -241,7 +242,7 @@
Assert.assertEquals("tetsPropHint", selenium.getValue(INPUT_PROPHINT));
}
-
+
@Test(enabled = true, description = "Renaming a consumer through the configure
button.")
public void testConfigureConsumer() {
final String name = "renameMe";
@@ -257,38 +258,37 @@
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
- selenium.click(MessageFormat.format(LINK_T_CONS_CON,r-1));
- selenium.waitForPageToLoad(PAGE_LOAD);
-
+ selenium.click(MessageFormat.format(LINK_T_CONS_CON, r - 1));
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
selenium.type("edit-cons-form:id", nameNew);
selenium.click("edit-cons-form:refresh-cons-link");
- selenium.waitForPageToLoad(PAGE_LOAD);
-
+ selenium.waitForPageToLoad(PAGE_LOAD);
+
clickIfVisible(ID_LINK_CONSCONF);
clickIfVisible(LINK_CONSUMER_HOME);
-
+
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) {
selenium.open("/portal/");
selenium.waitForPageToLoad(PAGE_LOAD);
@@ -300,20 +300,16 @@
selenium.type(INPUT_CREATECONS, name);
selenium.click(SUBMIT_CREATECONS);
selenium.waitForPageToLoad(PAGE_LOAD);
-
-
selenium.type(INPUT_CACHEEXP, timeout);
selenium.type(INPUT_CONSWSDL, address);
selenium.click(SUBMIT_REFRESHSAVE);
selenium.waitForPageToLoad(PAGE_LOAD);
- waitForElement(MessageFormat.format(INPUT_CONS_REGVALUE,0));
- selenium.type(MessageFormat.format(INPUT_CONS_REGVALUE,0), "public");
+ waitForElement(MessageFormat.format(INPUT_CONS_REGVALUE, 0));
+ selenium.type(MessageFormat.format(INPUT_CONS_REGVALUE, 0), "public");
selenium.click(SUBMIT_CONS_REGVAL);
selenium.waitForPageToLoad(PAGE_LOAD);
-
-
selenium.click(SUBMIT_REFRESHFINAL);
selenium.waitForPageToLoad(PAGE_LOAD);
}