mirror of https://github.com/apache/archiva.git
start to cleanup it test for webapp js
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295309 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
2d4ba8d89c
commit
22a95e9e34
|
@ -233,6 +233,8 @@
|
||||||
<browser>${selenium.browser}</browser>
|
<browser>${selenium.browser}</browser>
|
||||||
<baseUrl>${baseUrl}</baseUrl>
|
<baseUrl>${baseUrl}</baseUrl>
|
||||||
<maxWaitTimeInMs>${maxWaitTimeInMs}</maxWaitTimeInMs>
|
<maxWaitTimeInMs>${maxWaitTimeInMs}</maxWaitTimeInMs>
|
||||||
|
<seleniumHost>${seleniumHost}</seleniumHost>
|
||||||
|
<seleniumPort>${seleniumPort}</seleniumPort>
|
||||||
</systemPropertyVariables>
|
</systemPropertyVariables>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
|
|
|
@ -20,71 +20,12 @@ package org.apache.archiva.web.test;
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import org.apache.archiva.web.test.parent.AbstractArchivaTest;
|
import org.apache.archiva.web.test.parent.AbstractArchivaTest;
|
||||||
import org.testng.Assert;
|
|
||||||
import org.testng.annotations.AfterTest;
|
|
||||||
import org.testng.annotations.BeforeSuite;
|
|
||||||
import org.testng.annotations.BeforeTest;
|
|
||||||
import org.testng.annotations.Optional;
|
|
||||||
import org.testng.annotations.Parameters;
|
|
||||||
import org.testng.annotations.Test;
|
import org.testng.annotations.Test;
|
||||||
|
|
||||||
public class ArchivaAdminTest
|
public class ArchivaAdminTest
|
||||||
extends AbstractArchivaTest
|
extends AbstractArchivaTest
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
|
||||||
@AfterTest
|
|
||||||
public void close()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
super.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@BeforeSuite
|
|
||||||
public void open()
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
super.open();
|
|
||||||
}
|
|
||||||
|
|
||||||
@BeforeTest
|
|
||||||
@Parameters( { "baseUrl", "browser", "maxWaitTimeInMs", "seleniumHost", "seleniumPort" } )
|
|
||||||
public void initializeArchiva( String baseUrl, String browser, int maxWaitTimeInMs,
|
|
||||||
@Optional( "localhost" ) String seleniumHost, @Optional( "4444" ) int seleniumPort )
|
|
||||||
throws Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
super.open( baseUrl, browser, seleniumHost, seleniumPort, Integer.toString( maxWaitTimeInMs ) );
|
|
||||||
|
|
||||||
getSelenium().open( baseUrl );
|
|
||||||
|
|
||||||
waitPage();
|
|
||||||
|
|
||||||
// if not admin user created create one
|
|
||||||
if ( isElementVisible( "create-admin-link" ) )
|
|
||||||
{
|
|
||||||
Assert.assertFalse( getSelenium().isVisible( "login-link-a" ) );
|
|
||||||
Assert.assertFalse( getSelenium().isVisible( "register-link-a" ) );
|
|
||||||
clickLinkWithLocator( "create-admin-link-a", false );
|
|
||||||
assertCreateAdmin();
|
|
||||||
String fullname = getProperty( "ADMIN_FULLNAME" );
|
|
||||||
String username = getProperty( "ADMIN_USERNAME" );
|
|
||||||
String mail = getProperty( "ADMIN_EMAIL" );
|
|
||||||
String password = getProperty( "ADMIN_PASSWORD" );
|
|
||||||
submitAdminData( fullname, mail, password );
|
|
||||||
assertUserLoggedIn( username );
|
|
||||||
clickLinkWithLocator( "logout-link-a" );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Assert.assertTrue( getSelenium().isVisible( "login-link-a" ) );
|
|
||||||
Assert.assertTrue( getSelenium().isVisible( "register-link-a" ) );
|
|
||||||
login( getAdminUsername(), getAdminPassword() );
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test( groups = { "about" }, alwaysRun = true )
|
@Test( groups = { "about" }, alwaysRun = true )
|
||||||
public void testHome()
|
public void testHome()
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.testng.annotations.Test;
|
||||||
public class LoginTest
|
public class LoginTest
|
||||||
extends AbstractArchivaTest
|
extends AbstractArchivaTest
|
||||||
{
|
{
|
||||||
@Test( alwaysRun = true )
|
@Test
|
||||||
public void testWithBadUsername()
|
public void testWithBadUsername()
|
||||||
{
|
{
|
||||||
goToLoginPage();
|
goToLoginPage();
|
||||||
|
@ -45,7 +45,7 @@ public class LoginTest
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
|
@Test
|
||||||
public void testWithBadPassword()
|
public void testWithBadPassword()
|
||||||
{
|
{
|
||||||
goToLoginPage();
|
goToLoginPage();
|
||||||
|
@ -55,27 +55,25 @@ public class LoginTest
|
||||||
assertTextPresent( "You have entered an incorrect username and/or password" );
|
assertTextPresent( "You have entered an incorrect username and/or password" );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
|
@Test
|
||||||
public void testWithEmptyUsername()
|
public void testWithEmptyUsername()
|
||||||
{
|
{
|
||||||
goToLoginPage();
|
goToLoginPage();
|
||||||
setFieldValue( "user-login-form-password", "password" );
|
setFieldValue( "user-login-form-password", "password" );
|
||||||
clickLinkWithLocator( "modal-login-ok", true );
|
clickLinkWithLocator( "modal-login-ok", true );
|
||||||
//assertTextPresent( "User Name is required" );
|
|
||||||
assertTextPresent( "This field is required." );
|
assertTextPresent( "This field is required." );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
|
@Test( alwaysRun = true )
|
||||||
public void testWithEmptyPassword()
|
public void testWithEmptyPassword()
|
||||||
{
|
{
|
||||||
goToLoginPage();
|
goToLoginPage();
|
||||||
setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
|
setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
|
||||||
clickLinkWithLocator( "modal-login-ok", true );
|
clickLinkWithLocator( "modal-login-ok", true );
|
||||||
//assertTextPresent( "You have entered an incorrect username and/or password" );
|
|
||||||
assertTextPresent( "This field is required." );
|
assertTextPresent( "This field is required." );
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
|
@Test
|
||||||
public void testWithCorrectUsernamePassword()
|
public void testWithCorrectUsernamePassword()
|
||||||
{
|
{
|
||||||
goToLoginPage();
|
goToLoginPage();
|
||||||
|
|
|
@ -26,13 +26,15 @@ import org.testng.annotations.Test;
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
*/
|
*/
|
||||||
@Test( groups = { "usermanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
|
@Test( groups = { "usermanagement" }, dependsOnGroups = "about" )
|
||||||
public class RolesManagementTest
|
public class RolesManagementTest
|
||||||
extends AbstractArchivaTest
|
extends AbstractArchivaTest
|
||||||
{
|
{
|
||||||
|
@Test
|
||||||
public void testReadRolesAndUpdateDescription()
|
public void testReadRolesAndUpdateDescription()
|
||||||
throws Exception
|
throws Exception
|
||||||
{
|
{
|
||||||
|
login( getAdminUsername(), getAdminPassword() );
|
||||||
clickLinkWithLocator( "menu-roles-list-a", true );
|
clickLinkWithLocator( "menu-roles-list-a", true );
|
||||||
assertTextPresent( "Archiva System Administrator " );
|
assertTextPresent( "Archiva System Administrator " );
|
||||||
Assert.assertTrue( StringUtils.isEmpty( getText( "role-description-Guest" ) ) );
|
Assert.assertTrue( StringUtils.isEmpty( getText( "role-description-Guest" ) ) );
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.testng.annotations.Test;
|
||||||
/**
|
/**
|
||||||
* @author Olivier Lamy
|
* @author Olivier Lamy
|
||||||
*/
|
*/
|
||||||
@Test( groups = { "usermanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
|
@Test( groups = { "usermanagement" }, dependsOnGroups = { "about" } )
|
||||||
public class UserManagementTest
|
public class UserManagementTest
|
||||||
extends AbstractArchivaTest
|
extends AbstractArchivaTest
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package org.apache.archiva.web.test.parent;
|
package org.apache.archiva.web.test.parent;
|
||||||
|
|
||||||
import org.testng.Assert;
|
import org.testng.Assert;
|
||||||
|
import org.testng.annotations.AfterTest;
|
||||||
|
import org.testng.annotations.BeforeSuite;
|
||||||
|
import org.testng.annotations.BeforeTest;
|
||||||
|
import org.testng.annotations.Optional;
|
||||||
|
import org.testng.annotations.Parameters;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
@ -31,6 +36,67 @@ public abstract class AbstractArchivaTest
|
||||||
|
|
||||||
protected String fullname;
|
protected String fullname;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@AfterTest
|
||||||
|
public void close()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
super.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@BeforeSuite
|
||||||
|
public void open()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
super.open();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void assertAdminCreated()
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
initializeArchiva( System.getProperty( "baseUrl" ), System.getProperty( "browser" ),
|
||||||
|
Integer.getInteger( "maxWaitTimeInMs" ), System.getProperty( "seleniumHost" ),
|
||||||
|
Integer.getInteger( "seleniumPort" ) );
|
||||||
|
}
|
||||||
|
|
||||||
|
@BeforeTest
|
||||||
|
@Parameters( { "baseUrl", "browser", "maxWaitTimeInMs", "seleniumHost", "seleniumPort" } )
|
||||||
|
public void initializeArchiva( String baseUrl, String browser, int maxWaitTimeInMs,
|
||||||
|
@Optional( "localhost" ) String seleniumHost, @Optional( "4444" ) int seleniumPort )
|
||||||
|
throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
super.open( baseUrl, browser, seleniumHost, seleniumPort, Integer.toString( maxWaitTimeInMs ) );
|
||||||
|
|
||||||
|
getSelenium().open( baseUrl );
|
||||||
|
|
||||||
|
waitPage();
|
||||||
|
|
||||||
|
// if not admin user created create one
|
||||||
|
if ( isElementVisible( "create-admin-link" ) )
|
||||||
|
{
|
||||||
|
Assert.assertFalse( getSelenium().isVisible( "login-link-a" ) );
|
||||||
|
Assert.assertFalse( getSelenium().isVisible( "register-link-a" ) );
|
||||||
|
clickLinkWithLocator( "create-admin-link-a", false );
|
||||||
|
assertCreateAdmin();
|
||||||
|
String fullname = getProperty( "ADMIN_FULLNAME" );
|
||||||
|
String username = getAdminUsername();
|
||||||
|
String mail = getProperty( "ADMIN_EMAIL" );
|
||||||
|
String password = getProperty( "ADMIN_PASSWORD" );
|
||||||
|
submitAdminData( fullname, mail, password );
|
||||||
|
assertUserLoggedIn( username );
|
||||||
|
clickLinkWithLocator( "logout-link-a" );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Assert.assertTrue( getSelenium().isVisible( "login-link-a" ) );
|
||||||
|
Assert.assertTrue( getSelenium().isVisible( "register-link-a" ) );
|
||||||
|
login( getAdminUsername(), getAdminPassword() );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
protected static String getErrorMessageText()
|
protected static String getErrorMessageText()
|
||||||
{
|
{
|
||||||
return getSelenium().getText( "//ul[@class='errorMessage']/li/span" );
|
return getSelenium().getText( "//ul[@class='errorMessage']/li/span" );
|
||||||
|
@ -487,7 +553,7 @@ public abstract class AbstractArchivaTest
|
||||||
|
|
||||||
public void goToHomePage()
|
public void goToHomePage()
|
||||||
{
|
{
|
||||||
getSelenium().open( "" );
|
getSelenium().open( baseUrl );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Upload Artifact
|
// Upload Artifact
|
||||||
|
@ -729,4 +795,9 @@ public abstract class AbstractArchivaTest
|
||||||
assertLinkNotVisible( "Logout" );
|
assertLinkNotVisible( "Logout" );
|
||||||
assertLinkVisible( "Login" );
|
assertLinkVisible( "Login" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected String getAdminUserName()
|
||||||
|
{
|
||||||
|
return getProperty( "ADMIN_FULLNAME" );
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -57,7 +57,7 @@
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.testng</groupId>
|
<groupId>org.testng</groupId>
|
||||||
<artifactId>testng</artifactId>
|
<artifactId>testng</artifactId>
|
||||||
<version>6.2.1</version>
|
<version>6.4</version>
|
||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
|
|
Loading…
Reference in New Issue