Author: mposolda(a)redhat.com
Date: 2009-07-07 18:28:02 -0400 (Tue, 07 Jul 2009)
New Revision: 13528
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java
Log:
Refactor LdapIdentityAdminTestCase to fix test failures.
Modified:
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java 2009-07-07
14:33:27 UTC (rev 13527)
+++
branches/JBoss_Portal_Branch_2_7/testsuite/ui-tests/src/org/jboss/portal/test/selenium/LdapIdentityAdminTestCase.java 2009-07-07
22:28:02 UTC (rev 13528)
@@ -17,19 +17,19 @@
@Test(groups = { "admin_ui_ldap" }, enabled = true)
public class LdapIdentityAdminTestCase extends IdentityAdminTestCase {
- private final String ldap1User = "ldap1";
- private final String ldap1UserPassword = "password";
- private final String ldap1UserMail = "ldap1(a)portal.com";
- private final String ldap1Firstname = "Joseph";
- private final String ldap1Surname = "Berry";
+ 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 ldap2User = "ldap2";
- private final String ldap2UserPassword = "password";
- private final String ldap2UserMail = "ldap2(a)portal.com";
- private final String ldap2Firstname = "Cyril";
- private final String ldap2Surname = "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 ldapRoleName = "Ldap";
+ private final String LDAP_ROLE_NAME = "Ldap";
/**
* <p>User (tempUser, tempPassword, tempUser(a)redhat.com) and role (tempRole,
@@ -72,25 +72,25 @@
@Test(enabled = true, description = "Searching for users from ldap and testing his
roles.")
public void testSearchLdapUsers() {
// user 'ldap1'
- searchUser(ldap1User, ldap1UserMail);
- Assert.assertTrue(selenium.isTextPresent(ldap1Firstname), "Name " +
ldap1Firstname + " of user " + ldap1User + " was not found on the
page.");
- Assert.assertTrue(selenium.isTextPresent(ldap1Surname), "Surname " +
ldap1Surname + " of user " + ldap1User + " was not found on the
page.");
- final String CHECK_ROLE = MessageFormat.format(CHK_ROLE, ldapRoleName);
- selenium.click(butUsrRol_id(ldap1User));
+ 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 " + ldap1User + ".");
- Assert.assertTrue(selenium.isChecked(MessageFormat.format(CHK_ROLE, "User")),
"The role Users is not correctly assigned to user " + ldap1User +
".");
- Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE,
"Admin")), "The role Admins is not correctly assigned to user " +
ldap1User + ".");
+ 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(ldap2User, ldap2UserMail);
- Assert.assertTrue(selenium.isTextPresent(ldap2Firstname), "Name " +
ldap2Firstname + " of user " + ldap2User + " was not found on the
page.");
- Assert.assertTrue(selenium.isTextPresent(ldap2Surname), "Surname " +
ldap2Surname + " of user " + ldap2User + " was not found on the
page.");
- selenium.click(butUsrRol_id(ldap2User));
+ 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 " + ldap2User + ".");
- Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE,
"User")), "The role Users is not correctly assigned to user " +
ldap2User + ".");
- Assert.assertFalse(selenium.isChecked(MessageFormat.format(CHK_ROLE,
"Admin")), "The role Admins is not correctly assigned to user " +
ldap2User + ".");
+ 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 + ".");
}
/**
@@ -101,23 +101,22 @@
@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(ldap1User, ldap1UserMail);
+ 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(ldap1Firstname));
- Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:familyname')]").equals(ldap1Surname));
- Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:location')]").contains("Brno,
Czechue Republic"));
- Assert.assertTrue(selenium.getValue("//textarea[contains(@id,'profile-form:signature')]").equals("This
is signature"));
- Assert.assertTrue(selenium.getValue("//textarea[contains(@id,'profile-form:extra')]").contains("This
is content of ldap attribute \"description\""));
+ 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:familyname')]").equals(LDAP1_SURNAME),
"Surname should be " + LDAP1_SURNAME + " but is " +
selenium.getValue("//input[contains(@id,'profile-form:familyname')]"));
+ 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 signature should be LDAP
attribute) and check them.
- selenium.type("//input[contains(@id,'profile-form:homepage')]",
"http://www.jboss.org/jbossportal");
- selenium.type("//textarea[contains(@id,'profile-form:signature')]",
"This is updated signature");
+ selenium.type("//input[contains(@id,'profile-form:givenname')]",
"Jack");
+ selenium.type("//textarea[contains(@id,'profile-form:signature')]",
"This is signature");
clickAndWait(SUB_EDIT_PROF);
- goToEdit(ldap1User, ldap1UserMail);
- Assert.assertTrue(selenium.getValue("//input[contains(@id,'profile-form:homepage')]").equals("http://www.jboss.org/jbossportal"));
- Assert.assertTrue(selenium.getValue("//textarea[contains(@id,'profile-form:signature')]").equals("This
is updated signature"));
+ 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("//textarea[contains(@id,'profile-form:signature')]").equals("This
is signature"), "Signature should be 'This is signature' but is " +
selenium.getValue("//input[contains(@id,'profile-form:signature')]"));
// Change signature to the original value
- selenium.type("//textarea[contains(@id,'profile-form:signature')]",
"This is signature");
+ selenium.type("//textarea[contains(@id,'profile-form:givenname')]",
LDAP1_FIRST_NAME);
clickAndWait(SUB_EDIT_PROF);
}
@@ -129,17 +128,17 @@
public void testLoginAsLdapUsers() {
logoutIfPossible();
// user 'ldap1'
- login(ldap1User, ldap1UserPassword);
- Assert.assertTrue(selenium.isTextPresent(ldap1UserMail), "Mail " +
ldap1UserMail + " of user " + ldap1User + " was not found on the
page.");
- Assert.assertTrue(selenium.isTextPresent(ldap1Firstname), "Name " +
ldap1Firstname + " of user " + ldap1User + " was not found on the
page.");
- Assert.assertTrue(selenium.isTextPresent(ldap1Surname), "Surname " +
ldap1Surname + " of user " + ldap1User + " was not found on the
page.");
+ 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(ldap2User, ldap2UserPassword);
- Assert.assertTrue(selenium.isTextPresent(ldap2UserMail), "Mail " +
ldap2UserMail + " of user " + ldap2User + " was not found on the
page.");
- Assert.assertTrue(selenium.isTextPresent(ldap2Firstname), "Name " +
ldap2Firstname + " of user " + ldap2User + " was not found on the
page.");
- Assert.assertTrue(selenium.isTextPresent(ldap2Surname), "Surname " +
ldap2Surname + " of user " + ldap2User + " was not found on the
page.");
+ 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();
}