be able to try selenium tests by group

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1140310 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-06-27 20:48:32 +00:00
parent c4234aa1bf
commit c03b07252e
3 changed files with 45 additions and 27 deletions

View File

@ -27,7 +27,7 @@ import org.testng.annotations.Optional;
import org.testng.annotations.Parameters;
import org.testng.annotations.Test;
@Test( groups = {"about"}, alwaysRun = true )
@Test( groups = { "about" }, alwaysRun = true )
public class ArchivaAdminTest
extends AbstractArchivaTest
{
@ -49,17 +49,17 @@ public class ArchivaAdminTest
}
@BeforeTest
@Parameters( {"baseUrl", "browser", "maxWaitTimeInMs", "seleniumHost", "seleniumPort"} )
@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 ) );
super.open( baseUrl, browser, seleniumHost, seleniumPort, Integer.toString( maxWaitTimeInMs ) );
getSelenium().open( baseUrl );
String title = getSelenium().getTitle();
// if not admin user created create one
if (isElementPresent( "adminCreateForm" ))
if ( isElementPresent( "adminCreateForm" ) )
{
assertCreateAdmin();
String fullname = getProperty( "ADMIN_FULLNAME" );
@ -70,6 +70,10 @@ public class ArchivaAdminTest
assertUserLoggedIn( username );
clickLinkWithLocator( "logoutLink" );
}
else
{
login( getAdminUsername(), getAdminPassword() );
}
// take care about repositories : internal
}

View File

@ -22,11 +22,12 @@ package org.apache.archiva.web.test;
import org.apache.archiva.web.test.parent.AbstractArtifactManagementTest;
import org.testng.annotations.Test;
@Test( groups = { "artifactmanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
@Test( groups = { "artifactmanagement" }, dependsOnGroups = { "about" } )
public class ArtifactManagementTest
extends AbstractArtifactManagementTest
{
@Test( alwaysRun = true )
public void testAddArtifactNullValues()
{
goToAddArtifactPage();
@ -39,14 +40,14 @@ public class ArtifactManagementTest
assertTextPresent( "You must enter a packaging" );
}
@Test( dependsOnMethods = { "testAddArtifactNullValues" } )
@Test( dependsOnMethods = { "testAddArtifactNullValues" }, alwaysRun = true )
public void testAddArtifactNoGroupId()
{
addArtifact( " ", getArtifactId(), getVersion(), getPackaging(), getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "You must enter a groupId." );
}
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" } )
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
public void testAddArtifactNoArtifactId()
{
@ -54,28 +55,28 @@ public class ArtifactManagementTest
assertTextPresent( "You must enter an artifactId." );
}
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" } )
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
public void testAddArtifactNoVersion()
{
addArtifact( getGroupId(), getArtifactId(), " ", getPackaging(), getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "You must enter a version." );
}
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" } )
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
public void testAddArtifactInvalidVersion()
{
addArtifact( getGroupId(), getArtifactId(), "asdf", getPackaging(), getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "Invalid version." );
}
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" } )
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
public void testAddArtifactNoPackaging()
{
addArtifact( getGroupId(), getArtifactId(), getVersion(), " ", getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "You must enter a packaging." );
}
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" } )
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
public void testAddArtifactNoFilePath()
{
addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), " ", getRepositoryId() );
@ -90,7 +91,7 @@ public class ArtifactManagementTest
addArtifact( groupId, artifactId, getVersion(), getPackaging(), getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + getVersion()
+ "' was successfully deployed to repository 'internal'" );
+ "' was successfully deployed to repository 'internal'" );
}
@Test( groups = "requiresUpload" )
@ -102,7 +103,7 @@ public class ArtifactManagementTest
addArtifact( groupId, artifactId, getVersion(), packaging, getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + getVersion()
+ "' was successfully deployed to repository 'internal'" );
+ "' was successfully deployed to repository 'internal'" );
getSelenium().open( baseUrl + "/browse/" + groupId + "/" + artifactId + "/" + getVersion() );
waitPage();
@ -141,18 +142,21 @@ public class ArtifactManagementTest
assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" );
}
@Test( alwaysRun = true )
public void testDeleteArtifactNoGroupId()
{
deleteArtifact( " ", "delete", "1.0", "internal" );
assertTextPresent( "You must enter a groupId." );
}
@Test( alwaysRun = true )
public void testDeleteArtifactNoArtifactId()
{
deleteArtifact( "delete", " ", "1.0", "internal" );
assertTextPresent( "You must enter an artifactId." );
}
@Test( alwaysRun = true)
public void testDeleteArtifactNoVersion()
{
deleteArtifact( "delete", "delete", " ", "internal" );
@ -160,6 +164,7 @@ public class ArtifactManagementTest
assertTextPresent( "You must enter a version." );
}
@Test( alwaysRun = true)
public void testDeleteArtifactInvalidVersion()
{
deleteArtifact( "delete", "delete", "asdf", "internal" );
@ -167,23 +172,30 @@ public class ArtifactManagementTest
}
// HTML select should have the proper value, else it will cause a selenium error: Option with label 'customValue' not found
@Test( alwaysRun = true)
public void testDeleteArtifactInvalidValues()
{
deleteArtifact( "<> \\/~+[ ]'\"", "<> \\/~+[ ]'\"", "<>", "internal");
assertTextPresent( "Invalid version." );
assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
}
{
deleteArtifact( "<> \\/~+[ ]'\"", "<> \\/~+[ ]'\"", "<>", "internal" );
assertTextPresent( "Invalid version." );
assertTextPresent(
"Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
assertTextPresent(
"Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
}
@Test( alwaysRun = true)
public void testDeleteArtifactInvalidGroupId()
{
deleteArtifact( "<> \\/~+[ ]'\"", "delete", "1.0", "internal");
assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
}
{
deleteArtifact( "<> \\/~+[ ]'\"", "delete", "1.0", "internal" );
assertTextPresent(
"Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
}
@Test( alwaysRun = true)
public void testDeleteArtifactInvalidArtifactId()
{
deleteArtifact( "delete", "<> \\/~+[ ]'\"", "1.0", "internal");
assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
}
{
deleteArtifact( "delete", "<> \\/~+[ ]'\"", "1.0", "internal" );
assertTextPresent(
"Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
}
}

View File

@ -26,6 +26,7 @@ import org.testng.annotations.Test;
public class FindArtifactTest
extends AbstractArchivaTest
{
@Test(alwaysRun = true)
public void testFindArtifactNullValues()
{
goToFindArtifactPage();
@ -33,6 +34,7 @@ public class FindArtifactTest
assertTextPresent( "You must select a file, or enter the checksum. If the file was given and you receive this message, there may have been an error generating the checksum." );
}
@Test(alwaysRun = true)
public void testFindArtifactUsingChecksum()
{
goToFindArtifactPage();