mirror of https://github.com/apache/archiva.git
Use methods from maven-web-ui-tests
git-svn-id: https://svn.apache.org/repos/asf/maven/archiva/trunk@489879 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a239fca20b
commit
a4f0edf9aa
|
@ -27,34 +27,10 @@ import java.util.Calendar;
|
|||
public abstract class AbstractArchivaTestCase
|
||||
extends AbstractSeleniumTestCase
|
||||
{
|
||||
protected String adminUsername = "admin";
|
||||
|
||||
protected String adminPassword = "admin1";
|
||||
|
||||
protected String adminFullName = "Archiva Admin";
|
||||
|
||||
protected String adminEmail = "admin@localhost.localdomain.com";
|
||||
|
||||
private String baseUrl = "http://localhost:9595/archiva";
|
||||
|
||||
public static final String CREATE_ADMIN_USER_PAGE_TITLE = "Maven Archiva :: Create Admin User";
|
||||
|
||||
protected void initialize()
|
||||
{
|
||||
getSelenium().open( "/archiva" );
|
||||
|
||||
if ( CREATE_ADMIN_USER_PAGE_TITLE.equals( getSelenium().getTitle() ) )
|
||||
{
|
||||
assertCreateAdminUserPage();
|
||||
submitCreateAdminUserPage( adminFullName, adminEmail, adminPassword, adminPassword );
|
||||
assertLoginPage();
|
||||
submitLoginPage( adminUsername, adminPassword );
|
||||
logout();
|
||||
}
|
||||
|
||||
login();
|
||||
}
|
||||
|
||||
protected String getApplicationName()
|
||||
{
|
||||
return "Archiva";
|
||||
|
@ -65,15 +41,6 @@ public abstract class AbstractArchivaTestCase
|
|||
return "2005";
|
||||
}
|
||||
|
||||
public abstract void login();
|
||||
|
||||
public void assertFooter()
|
||||
{
|
||||
int currentYear = Calendar.getInstance().get( Calendar.YEAR );
|
||||
assertTrue( getSelenium().getText( "xpath=//div[@id='footer']/div" ).endsWith(
|
||||
" " + getInceptionYear() + "-" + currentYear + " Apache Software Foundation" ) );
|
||||
}
|
||||
|
||||
public void assertHeader()
|
||||
{
|
||||
assertTrue( "banner is missing" , getSelenium().isElementPresent( "xpath=//div[@id='banner']" ) );
|
||||
|
@ -92,47 +59,4 @@ public abstract class AbstractArchivaTestCase
|
|||
{
|
||||
return baseUrl;
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Create Admin User
|
||||
//////////////////////////////////////
|
||||
public void assertCreateAdminUserPage()
|
||||
{
|
||||
assertPage( CREATE_ADMIN_USER_PAGE_TITLE );
|
||||
assertTextPresent( "Create Admin User" );
|
||||
assertTextPresent( "Username" );
|
||||
assertElementPresent( "user.username" );
|
||||
assertTextPresent( "Full Name" );
|
||||
assertElementPresent( "user.fullName" );
|
||||
assertTextPresent( "Email Address" );
|
||||
assertElementPresent( "user.email" );
|
||||
assertTextPresent( "Password" );
|
||||
assertElementPresent( "user.password" );
|
||||
assertTextPresent( "Confirm Password" );
|
||||
assertElementPresent( "user.confirmPassword" );
|
||||
}
|
||||
|
||||
//////////////////////////////////////
|
||||
// Login
|
||||
//////////////////////////////////////
|
||||
public void assertLoginPage()
|
||||
{
|
||||
assertPage( "Maven Archiva :: Login Page" );
|
||||
assertTextPresent( "Login" );
|
||||
assertTextPresent( "Username" );
|
||||
assertTextPresent( "Password" );
|
||||
assertTextPresent( "Remember Me" );
|
||||
assertFalse( isChecked( "rememberMe" ) );
|
||||
}
|
||||
|
||||
public void submitCreateAdminUserPage( String fullName, String email, String password, String confirmPassword )
|
||||
{
|
||||
Selenium sel = getSelenium();
|
||||
sel.type( "user.fullName", fullName );
|
||||
sel.type( "user.email", email );
|
||||
sel.type( "user.password", password );
|
||||
sel.type( "user.confirmPassword", confirmPassword );
|
||||
sel.click( "//input[@type='submit']" );
|
||||
waitPage();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,29 +26,23 @@ public class LoginTest
|
|||
{
|
||||
public void testBadLogin()
|
||||
{
|
||||
getSelenium().open( "/archiva/login.action" );
|
||||
goToLoginPage();
|
||||
submitLoginPage( "badUsername", "badPassword", false );
|
||||
assertLoginPage();
|
||||
assertTextPresent( "Authentication failed" );
|
||||
}
|
||||
|
||||
public void testUserLogin()
|
||||
{
|
||||
createUser( "user", "user01" );
|
||||
getSelenium().open( "/archiva/login.action" );
|
||||
assertLoginPage();
|
||||
goToLoginPage();
|
||||
submitLoginPage( "user", "user01" );
|
||||
}
|
||||
|
||||
public void login()
|
||||
{
|
||||
}
|
||||
|
||||
private void createUser( String username, String password )
|
||||
{
|
||||
Selenium sel = getSelenium();
|
||||
|
||||
sel.open( "/archiva/security/login.action" );
|
||||
goToLoginPage();
|
||||
submitLoginPage( adminUsername, adminPassword );
|
||||
|
||||
sel.open( "/archiva/security/userlist.action" );
|
||||
|
|
Loading…
Reference in New Issue