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.Parameters;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Test( groups = {"about"}, alwaysRun = true ) @Test( groups = { "about" }, alwaysRun = true )
public class ArchivaAdminTest public class ArchivaAdminTest
extends AbstractArchivaTest extends AbstractArchivaTest
{ {
@ -49,17 +49,17 @@ public class ArchivaAdminTest
} }
@BeforeTest @BeforeTest
@Parameters( {"baseUrl", "browser", "maxWaitTimeInMs", "seleniumHost", "seleniumPort"} ) @Parameters( { "baseUrl", "browser", "maxWaitTimeInMs", "seleniumHost", "seleniumPort" } )
public void initializeArchiva( String baseUrl, String browser, int maxWaitTimeInMs, public void initializeArchiva( String baseUrl, String browser, int maxWaitTimeInMs,
@Optional( "localhost" ) String seleniumHost, @Optional( "4444" ) int seleniumPort ) @Optional( "localhost" ) String seleniumHost, @Optional( "4444" ) int seleniumPort )
throws Exception throws Exception
{ {
super.open( baseUrl , browser, seleniumHost, seleniumPort, Integer.toString( maxWaitTimeInMs ) ); super.open( baseUrl, browser, seleniumHost, seleniumPort, Integer.toString( maxWaitTimeInMs ) );
getSelenium().open( baseUrl ); getSelenium().open( baseUrl );
String title = getSelenium().getTitle(); String title = getSelenium().getTitle();
// if not admin user created create one // if not admin user created create one
if (isElementPresent( "adminCreateForm" )) if ( isElementPresent( "adminCreateForm" ) )
{ {
assertCreateAdmin(); assertCreateAdmin();
String fullname = getProperty( "ADMIN_FULLNAME" ); String fullname = getProperty( "ADMIN_FULLNAME" );
@ -70,6 +70,10 @@ public class ArchivaAdminTest
assertUserLoggedIn( username ); assertUserLoggedIn( username );
clickLinkWithLocator( "logoutLink" ); clickLinkWithLocator( "logoutLink" );
} }
else
{
login( getAdminUsername(), getAdminPassword() );
}
// take care about repositories : internal // 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.apache.archiva.web.test.parent.AbstractArtifactManagementTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Test( groups = { "artifactmanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) @Test( groups = { "artifactmanagement" }, dependsOnGroups = { "about" } )
public class ArtifactManagementTest public class ArtifactManagementTest
extends AbstractArtifactManagementTest extends AbstractArtifactManagementTest
{ {
@Test( alwaysRun = true )
public void testAddArtifactNullValues() public void testAddArtifactNullValues()
{ {
goToAddArtifactPage(); goToAddArtifactPage();
@ -39,14 +40,14 @@ public class ArtifactManagementTest
assertTextPresent( "You must enter a packaging" ); assertTextPresent( "You must enter a packaging" );
} }
@Test( dependsOnMethods = { "testAddArtifactNullValues" } ) @Test( dependsOnMethods = { "testAddArtifactNullValues" }, alwaysRun = true )
public void testAddArtifactNoGroupId() public void testAddArtifactNoGroupId()
{ {
addArtifact( " ", getArtifactId(), getVersion(), getPackaging(), getArtifactFilePath(), getRepositoryId() ); addArtifact( " ", getArtifactId(), getVersion(), getPackaging(), getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "You must enter a groupId." ); assertTextPresent( "You must enter a groupId." );
} }
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" } ) @Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
public void testAddArtifactNoArtifactId() public void testAddArtifactNoArtifactId()
{ {
@ -54,28 +55,28 @@ public class ArtifactManagementTest
assertTextPresent( "You must enter an artifactId." ); assertTextPresent( "You must enter an artifactId." );
} }
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" } ) @Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
public void testAddArtifactNoVersion() public void testAddArtifactNoVersion()
{ {
addArtifact( getGroupId(), getArtifactId(), " ", getPackaging(), getArtifactFilePath(), getRepositoryId() ); addArtifact( getGroupId(), getArtifactId(), " ", getPackaging(), getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "You must enter a version." ); assertTextPresent( "You must enter a version." );
} }
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" } ) @Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
public void testAddArtifactInvalidVersion() public void testAddArtifactInvalidVersion()
{ {
addArtifact( getGroupId(), getArtifactId(), "asdf", getPackaging(), getArtifactFilePath(), getRepositoryId() ); addArtifact( getGroupId(), getArtifactId(), "asdf", getPackaging(), getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "Invalid version." ); assertTextPresent( "Invalid version." );
} }
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" } ) @Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
public void testAddArtifactNoPackaging() public void testAddArtifactNoPackaging()
{ {
addArtifact( getGroupId(), getArtifactId(), getVersion(), " ", getArtifactFilePath(), getRepositoryId() ); addArtifact( getGroupId(), getArtifactId(), getVersion(), " ", getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "You must enter a packaging." ); assertTextPresent( "You must enter a packaging." );
} }
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" } ) @Test( dependsOnMethods = { "testAddArtifactNoGroupId" }, alwaysRun = true )
public void testAddArtifactNoFilePath() public void testAddArtifactNoFilePath()
{ {
addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), " ", getRepositoryId() ); addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), " ", getRepositoryId() );
@ -90,7 +91,7 @@ public class ArtifactManagementTest
addArtifact( groupId, artifactId, getVersion(), getPackaging(), getArtifactFilePath(), getRepositoryId() ); addArtifact( groupId, artifactId, getVersion(), getPackaging(), getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + getVersion() assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + getVersion()
+ "' was successfully deployed to repository 'internal'" ); + "' was successfully deployed to repository 'internal'" );
} }
@Test( groups = "requiresUpload" ) @Test( groups = "requiresUpload" )
@ -102,7 +103,7 @@ public class ArtifactManagementTest
addArtifact( groupId, artifactId, getVersion(), packaging, getArtifactFilePath(), getRepositoryId() ); addArtifact( groupId, artifactId, getVersion(), packaging, getArtifactFilePath(), getRepositoryId() );
assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + getVersion() assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + getVersion()
+ "' was successfully deployed to repository 'internal'" ); + "' was successfully deployed to repository 'internal'" );
getSelenium().open( baseUrl + "/browse/" + groupId + "/" + artifactId + "/" + getVersion() ); getSelenium().open( baseUrl + "/browse/" + groupId + "/" + artifactId + "/" + getVersion() );
waitPage(); waitPage();
@ -141,18 +142,21 @@ public class ArtifactManagementTest
assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" ); assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" );
} }
@Test( alwaysRun = true )
public void testDeleteArtifactNoGroupId() public void testDeleteArtifactNoGroupId()
{ {
deleteArtifact( " ", "delete", "1.0", "internal" ); deleteArtifact( " ", "delete", "1.0", "internal" );
assertTextPresent( "You must enter a groupId." ); assertTextPresent( "You must enter a groupId." );
} }
@Test( alwaysRun = true )
public void testDeleteArtifactNoArtifactId() public void testDeleteArtifactNoArtifactId()
{ {
deleteArtifact( "delete", " ", "1.0", "internal" ); deleteArtifact( "delete", " ", "1.0", "internal" );
assertTextPresent( "You must enter an artifactId." ); assertTextPresent( "You must enter an artifactId." );
} }
@Test( alwaysRun = true)
public void testDeleteArtifactNoVersion() public void testDeleteArtifactNoVersion()
{ {
deleteArtifact( "delete", "delete", " ", "internal" ); deleteArtifact( "delete", "delete", " ", "internal" );
@ -160,6 +164,7 @@ public class ArtifactManagementTest
assertTextPresent( "You must enter a version." ); assertTextPresent( "You must enter a version." );
} }
@Test( alwaysRun = true)
public void testDeleteArtifactInvalidVersion() public void testDeleteArtifactInvalidVersion()
{ {
deleteArtifact( "delete", "delete", "asdf", "internal" ); 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 // 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() public void testDeleteArtifactInvalidValues()
{ {
deleteArtifact( "<> \\/~+[ ]'\"", "<> \\/~+[ ]'\"", "<>", "internal"); deleteArtifact( "<> \\/~+[ ]'\"", "<> \\/~+[ ]'\"", "<>", "internal" );
assertTextPresent( "Invalid version." ); assertTextPresent( "Invalid version." );
assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." ); assertTextPresent(
assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." ); "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() public void testDeleteArtifactInvalidGroupId()
{ {
deleteArtifact( "<> \\/~+[ ]'\"", "delete", "1.0", "internal"); deleteArtifact( "<> \\/~+[ ]'\"", "delete", "1.0", "internal" );
assertTextPresent( "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." ); assertTextPresent(
} "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
}
@Test( alwaysRun = true)
public void testDeleteArtifactInvalidArtifactId() public void testDeleteArtifactInvalidArtifactId()
{ {
deleteArtifact( "delete", "<> \\/~+[ ]'\"", "1.0", "internal"); deleteArtifact( "delete", "<> \\/~+[ ]'\"", "1.0", "internal" );
assertTextPresent( "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." ); 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 public class FindArtifactTest
extends AbstractArchivaTest extends AbstractArchivaTest
{ {
@Test(alwaysRun = true)
public void testFindArtifactNullValues() public void testFindArtifactNullValues()
{ {
goToFindArtifactPage(); 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." ); 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() public void testFindArtifactUsingChecksum()
{ {
goToFindArtifactPage(); goToFindArtifactPage();