[MRM-1276] Selenium tests need a clean up

- fixed poor formatting in the source code (tabs, etc) following the Maven Code Style



git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@931475 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Marecor M. Baclay 2010-04-07 09:27:05 +00:00
parent 45100a8806
commit ddeaa798b6
24 changed files with 2250 additions and 2253 deletions

View File

@ -23,29 +23,32 @@ import org.apache.archiva.web.test.parent.AbstractArchivaTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Test( groups = { "appearance" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) @Test( groups = { "appearance" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
public class AppearanceTest extends AbstractArchivaTest public class AppearanceTest
extends AbstractArchivaTest
{ {
public void testAddAppearanceNullValues() public void testAddAppearanceNullValues()
{ {
goToAppearancePage(); goToAppearancePage();
clickLinkWithText( "Edit" ); clickLinkWithText( "Edit" );
addEditAppearance( "", "", "" ); addEditAppearance( "", "", "" );
assertTextPresent( "You must enter a name" ); assertTextPresent( "You must enter a name" );
} }
@Test( dependsOnMethods = { "testAddAppearanceNullValues" }) @Test( dependsOnMethods = { "testAddAppearanceNullValues" } )
public void testAddAppearanceValidValues() public void testAddAppearanceValidValues()
{ {
addEditAppearance( "The Apache Software Foundation" , "http://www.apache.org/" , "http://www.apache.org/images/asf_logo_wide.gifs" ); addEditAppearance( "The Apache Software Foundation", "http://www.apache.org/",
assertTextPresent( "The Apache Software Foundation" ); "http://www.apache.org/images/asf_logo_wide.gifs" );
} assertTextPresent( "The Apache Software Foundation" );
}
@Test( dependsOnMethods = { "testAddAppearanceValidValues" })
public void testEditAppearance() @Test( dependsOnMethods = { "testAddAppearanceValidValues" } )
{ public void testEditAppearance()
clickLinkWithText( "Edit" ); {
addEditAppearance( "Apache Software Foundation" , "http://www.apache.org/" , "http://www.apache.org/images/asf_logo_wide.gifs" ); clickLinkWithText( "Edit" );
assertTextPresent( "Apache Software Foundation" ); addEditAppearance( "Apache Software Foundation", "http://www.apache.org/",
} "http://www.apache.org/images/asf_logo_wide.gifs" );
assertTextPresent( "Apache Software Foundation" );
}
} }

View File

@ -28,8 +28,8 @@ 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
{ {
@Override @Override
@ -47,10 +47,12 @@ public class ArchivaAdminTest
{ {
super.open(); super.open();
} }
@BeforeTest @BeforeTest
@Parameters( { "baseUrl", "browser", "seleniumHost", "seleniumPort" } ) @Parameters( { "baseUrl", "browser", "seleniumHost", "seleniumPort" } )
public void initializeArchiva( String baseUrl, String browser, @Optional( "localhost" ) String seleniumHost, @Optional( "4444" ) int seleniumPort ) throws Exception public void initializeArchiva( String baseUrl, String browser, @Optional( "localhost" ) String seleniumHost,
@Optional( "4444" ) int seleniumPort )
throws Exception
{ {
super.open( baseUrl, browser, seleniumHost, seleniumPort ); super.open( baseUrl, browser, seleniumHost, seleniumPort );
getSelenium().open( baseUrl ); getSelenium().open( baseUrl );
@ -66,7 +68,7 @@ public class ArchivaAdminTest
assertUserLoggedIn( username ); assertUserLoggedIn( username );
submit(); submit();
clickLinkWithText( "Logout" ); clickLinkWithText( "Logout" );
} }
} }
} }

View File

@ -24,144 +24,145 @@ import org.testng.annotations.Test;
@Test( groups = { "artifactmanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) @Test( groups = { "artifactmanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public class ArtifactManagementTest public class ArtifactManagementTest
extends AbstractArtifactManagementTest extends AbstractArtifactManagementTest
{ {
public void testAddArtifactNullValues()
public void testAddArtifactNullValues() {
{ goToAddArtifactPage();
goToAddArtifactPage(); clickButtonWithValue( "Submit" );
clickButtonWithValue( "Submit" ); assertTextPresent( "Please add a file to upload." );
assertTextPresent( "Please add a file to upload." ); assertTextPresent( "Invalid version." );
assertTextPresent( "Invalid version." ); assertTextPresent( "You must enter a groupId." );
assertTextPresent( "You must enter a groupId." ); assertTextPresent( "You must enter an artifactId." );
assertTextPresent( "You must enter an artifactId." ); assertTextPresent( "You must enter a version" );
assertTextPresent( "You must enter a version" ); assertTextPresent( "You must enter a packaging" );
assertTextPresent( "You must enter a packaging" ); }
}
@Test( dependsOnMethods = { "testAddArtifactNullValues" } )
@Test(dependsOnMethods = { "testAddArtifactNullValues" } ) 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" } ) public void testAddArtifactNoArtifactId()
public void testAddArtifactNoArtifactId() {
{
addArtifact( getGroupId(), " ", getVersion(), getPackaging(), getArtifactFilePath(), getRepositoryId() );
addArtifact( getGroupId() , " ", getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() ); assertTextPresent( "You must enter an artifactId." );
assertTextPresent( "You must enter an artifactId." ); }
}
@Test( dependsOnMethods = { "testAddArtifactNoGroupId" } )
@Test(dependsOnMethods = { "testAddArtifactNoGroupId" } ) 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" } ) 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" } ) 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" } ) public void testAddArtifactNoFilePath()
public void testAddArtifactNoFilePath() {
{ addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), " ", getRepositoryId() );
addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , " ", getRepositoryId() ); assertTextPresent( "Please add a file to upload." );
assertTextPresent( "Please add a file to upload." ); }
}
@Test( groups = "requiresUpload" )
@Test(groups = "requiresUpload") public void testAddArtifactValidValues()
public void testAddArtifactValidValues() {
{ String groupId = getProperty( "VALIDARTIFACT_GROUPID" );
String groupId = getProperty( "VALIDARTIFACT_GROUPID" ); String artifactId = getProperty( "VALIDARTIFACT_ARTIFACTID" );
String artifactId = getProperty( "VALIDARTIFACT_ARTIFACTID" );
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" )
public void testDotNetTypes() public void testDotNetTypes()
{ {
String groupId = getProperty( "GROUPID_DOTNETARTIFACT" ); String groupId = getProperty( "GROUPID_DOTNETARTIFACT" );
String artifactId = getProperty( "ARTIFACTID_DOTNETARTIFACT" ); String artifactId = getProperty( "ARTIFACTID_DOTNETARTIFACT" );
String packaging = getProperty ( "PACKAGING_DOTNETARTIFACT" ); String packaging = getProperty( "PACKAGING_DOTNETARTIFACT" );
addArtifact( groupId, artifactId, getVersion(), packaging, getArtifactFilePath(), addArtifact( groupId, artifactId, getVersion(), packaging, getArtifactFilePath(), getRepositoryId() );
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();
assertTextPresent( "<type>library</type>" ); assertTextPresent( "<type>library</type>" );
String basePath = String basePath =
"/archiva/repository/internal/" + groupId + "/" + artifactId + "/" + getVersion() + "/" + artifactId + "-" + "/archiva/repository/internal/" + groupId + "/" + artifactId + "/" + getVersion() + "/" + artifactId + "-"
getVersion(); + getVersion();
assertLinkPresent( ".NET Library" ); assertLinkPresent( ".NET Library" );
assertElementPresent( "//a[@href='" + basePath + ".dll']" ); assertElementPresent( "//a[@href='" + basePath + ".dll']" );
assertElementPresent( "//a[@href='" + basePath + ".pom']" ); assertElementPresent( "//a[@href='" + basePath + ".pom']" );
} }
//MRM-747 // MRM-747
@Test(groups = "requiresUpload") @Test( groups = "requiresUpload" )
public void testAddArtifactBlockRedeployments() public void testAddArtifactBlockRedeployments()
{ {
addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() ); addArtifact( getGroupId(), getArtifactId(), getVersion(), getPackaging(), getArtifactFilePath(),
assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." ); getRepositoryId() );
} assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." );
}
@Test(groups = "requiresUpload")
public void testDeleteArtifact()
{
//prep
String groupId = getProperty( "GROUPID1" );
String artifactId = getProperty( "ARTIFACTID1" );
String version = getProperty( "VERSION1" );
String packaging = getProperty( "PACKAGING1" );
String repositoryId = getProperty( "REPOSITORYID1" );
// TODO: do this differently as it only works in Firefox's chrome mode
addArtifact( groupId , artifactId, version, packaging , getArtifactFilePath(), repositoryId );
assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deployed to repository 'internal'" );
deleteArtifact( "delete", "delete", "1.0", "internal"); @Test( groups = "requiresUpload" )
assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" ); public void testDeleteArtifact()
} {
// prep
public void testDeleteArtifactNoGroupId() String groupId = getProperty( "GROUPID1" );
{ String artifactId = getProperty( "ARTIFACTID1" );
deleteArtifact( " ", "delete", "1.0", "internal"); String version = getProperty( "VERSION1" );
assertTextPresent( "You must enter a groupId." ); String packaging = getProperty( "PACKAGING1" );
} String repositoryId = getProperty( "REPOSITORYID1" );
// TODO: do this differently as it only works in Firefox's chrome mode
public void testDeleteArtifactNoArtifactId() addArtifact( groupId, artifactId, version, packaging, getArtifactFilePath(), repositoryId );
{ assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deployed to repository 'internal'" );
deleteArtifact( "delete", " ", "1.0", "internal");
assertTextPresent( "You must enter an artifactId." ); deleteArtifact( "delete", "delete", "1.0", "internal" );
} assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" );
}
public void testDeleteArtifactNoVersion()
{ public void testDeleteArtifactNoGroupId()
deleteArtifact( "delete", "delete", " ", "internal"); {
assertTextPresent( "Invalid version." ); deleteArtifact( " ", "delete", "1.0", "internal" );
assertTextPresent( "You must enter a version." ); assertTextPresent( "You must enter a groupId." );
} }
public void testDeleteArtifactInvalidVersion() public void testDeleteArtifactNoArtifactId()
{ {
deleteArtifact( "delete", "delete", "asdf", "internal"); deleteArtifact( "delete", " ", "1.0", "internal" );
assertTextPresent( "Invalid version." ); assertTextPresent( "You must enter an artifactId." );
} }
}
public void testDeleteArtifactNoVersion()
{
deleteArtifact( "delete", "delete", " ", "internal" );
assertTextPresent( "Invalid version." );
assertTextPresent( "You must enter a version." );
}
public void testDeleteArtifactInvalidVersion()
{
deleteArtifact( "delete", "delete", "asdf", "internal" );
assertTextPresent( "Invalid version." );
}
}

View File

@ -28,14 +28,14 @@ public class AuditLogsReportTest
{ {
private void goToAuditLogReports() private void goToAuditLogReports()
{ {
clickLinkWithText( "Audit Log Report" ); clickLinkWithText( "Audit Log Report" );
} }
private void assertAuditLogsReportPage() private void assertAuditLogsReportPage()
{ {
assertPage( "Apache Archiva \\ Audit Log Report" ); assertPage( "Apache Archiva \\ Audit Log Report" );
assertTextPresent( "Audit Log Report" ); assertTextPresent( "Audit Log Report" );
assertElementPresent( "repository" ); assertElementPresent( "repository" );
assertElementPresent( "groupId" ); assertElementPresent( "groupId" );
assertElementPresent( "artifactId" ); assertElementPresent( "artifactId" );
@ -44,91 +44,91 @@ public class AuditLogsReportTest
assertElementPresent( "rowCount" ); assertElementPresent( "rowCount" );
assertButtonWithValuePresent( "View Audit Log" ); assertButtonWithValuePresent( "View Audit Log" );
} }
@Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } ) @Test( dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public void testAuditLogsReport() public void testAuditLogsReport()
{ {
goToAuditLogReports(); goToAuditLogReports();
assertAuditLogsReportPage(); assertAuditLogsReportPage();
assertTextPresent( "Latest Events" ); assertTextPresent( "Latest Events" );
} }
@Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } ) @Test( dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public void testViewAuditLogsNoDataFound() public void testViewAuditLogsNoDataFound()
{ {
goToAuditLogReports(); goToAuditLogReports();
assertAuditLogsReportPage(); assertAuditLogsReportPage();
setFieldValue( "groupId", "non.existing" ); setFieldValue( "groupId", "non.existing" );
submit(); submit();
assertPage( "Apache Archiva \\ Audit Log Report" ); assertPage( "Apache Archiva \\ Audit Log Report" );
assertTextPresent( "Results" ); assertTextPresent( "Results" );
assertTextPresent( "No audit logs found." ); assertTextPresent( "No audit logs found." );
} }
// TODO: add test for adding via WebDAV // TODO: add test for adding via WebDAV
@Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload") @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
public void testViewAuditLogsDataFound() public void testViewAuditLogsDataFound()
{ {
goToAuditLogReports(); goToAuditLogReports();
assertAuditLogsReportPage(); assertAuditLogsReportPage();
selectValue( "repository", "internal" ); selectValue( "repository", "internal" );
setFieldValue( "groupId", getProperty( "VALIDARTIFACT_GROUPID" ) ); setFieldValue( "groupId", getProperty( "VALIDARTIFACT_GROUPID" ) );
submit(); submit();
assertAuditLogsReportPage(); assertAuditLogsReportPage();
assertTextPresent( "Results" ); assertTextPresent( "Results" );
assertTextNotPresent( "No audit logs found." ); assertTextNotPresent( "No audit logs found." );
assertTextPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + assertTextPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "."
"." + getProperty( "ARTIFACT_PACKAGING" ) ); + getProperty( "ARTIFACT_PACKAGING" ) );
assertTextPresent( "Uploaded File" ); assertTextPresent( "Uploaded File" );
assertTextPresent( "internal" ); assertTextPresent( "internal" );
assertTextPresent( "admin" ); assertTextPresent( "admin" );
} }
// TODO: add test for adding via WebDAV // TODO: add test for adding via WebDAV
@Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload") @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
public void testViewAuditLogsOnlyArtifactIdIsSpecified() public void testViewAuditLogsOnlyArtifactIdIsSpecified()
{ {
goToAuditLogReports(); goToAuditLogReports();
assertAuditLogsReportPage(); assertAuditLogsReportPage();
selectValue( "repository", "internal" ); selectValue( "repository", "internal" );
setFieldValue( "artifactId", getProperty( "AUDITLOGARTIFACT_ARTIFACTID" ) ); setFieldValue( "artifactId", getProperty( "AUDITLOGARTIFACT_ARTIFACTID" ) );
submit(); submit();
assertAuditLogsReportPage(); assertAuditLogsReportPage();
assertTextPresent( "If you specify an artifact ID, you must specify a group ID" ); assertTextPresent( "If you specify an artifact ID, you must specify a group ID" );
assertTextNotPresent( "Results" ); assertTextNotPresent( "Results" );
assertTextNotPresent( "No audit logs found." ); assertTextNotPresent( "No audit logs found." );
assertTextNotPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + assertTextNotPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "."
"." + getProperty( "ARTIFACT_PACKAGING" ) ); + getProperty( "ARTIFACT_PACKAGING" ) );
assertTextNotPresent( "Uploaded File" ); assertTextNotPresent( "Uploaded File" );
} }
// TODO: add test for adding via WebDAV // TODO: add test for adding via WebDAV
@Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload") @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
public void testViewAuditLogsForAllRepositories() public void testViewAuditLogsForAllRepositories()
{ {
goToAuditLogReports(); goToAuditLogReports();
assertAuditLogsReportPage(); assertAuditLogsReportPage();
selectValue( "repository", "all" ); selectValue( "repository", "all" );
submit(); submit();
assertAuditLogsReportPage(); assertAuditLogsReportPage();
assertTextPresent( "Results" ); assertTextPresent( "Results" );
assertTextNotPresent( "No audit logs found." ); assertTextNotPresent( "No audit logs found." );
assertTextPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + assertTextPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "."
"." + getProperty( "ARTIFACT_PACKAGING" ) ); + getProperty( "ARTIFACT_PACKAGING" ) );
assertTextPresent( "Uploaded File" ); assertTextPresent( "Uploaded File" );
assertTextPresent( "internal" ); assertTextPresent( "internal" );
assertTextPresent( "admin" ); assertTextPresent( "admin" );
} }
@Test (dependsOnMethods = { "testAddArtifactValidValues", "testUserWithRepoManagerInternalRole" }, groups = "requiresUpload") @Test( dependsOnMethods = { "testAddArtifactValidValues", "testUserWithRepoManagerInternalRole" }, groups = "requiresUpload" )
public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly() public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly()
{ {
String groupId = getProperty( "SNAPSHOT_GROUPID" ); String groupId = getProperty( "SNAPSHOT_GROUPID" );
@ -136,13 +136,13 @@ public class AuditLogsReportTest
String version = getProperty( "SNAPSHOT_VERSION" ); String version = getProperty( "SNAPSHOT_VERSION" );
String repo = getProperty( "SNAPSHOT_REPOSITORYID" ); String repo = getProperty( "SNAPSHOT_REPOSITORYID" );
String packaging = getProperty( "SNAPSHOT_PACKAGING" ); String packaging = getProperty( "SNAPSHOT_PACKAGING" );
addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repo ); addArtifact( groupId, artifactId, version, packaging, getProperty( "SNAPSHOT_ARTIFACTFILEPATH" ), repo );
assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + version + assertTextPresent( "Artifact '" + groupId + ":" + artifactId + ":" + version
"' was successfully deployed to repository '" + repo + "'" ); + "' was successfully deployed to repository '" + repo + "'" );
clickLinkWithText( "Logout" ); clickLinkWithText( "Logout" );
login( getProperty( "REPOMANAGER_INTERNAL_USERNAME" ), getUserRoleNewPassword() ); login( getProperty( "REPOMANAGER_INTERNAL_USERNAME" ), getUserRoleNewPassword() );
goToAuditLogReports(); goToAuditLogReports();
@ -154,7 +154,8 @@ public class AuditLogsReportTest
assertAuditLogsReportPage(); assertAuditLogsReportPage();
assertTextPresent( "Results" ); assertTextPresent( "Results" );
assertTextNotPresent( "No audit logs found." ); assertTextNotPresent( "No audit logs found." );
assertTextPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "." + packaging ); assertTextPresent( getProperty( "VALIDARTIFACT_ARTIFACTID" ) + "-" + getProperty( "ARTIFACT_VERSION" ) + "."
+ packaging );
assertTextPresent( "Uploaded File" ); assertTextPresent( "Uploaded File" );
assertTextPresent( "internal" ); assertTextPresent( "internal" );
assertTextPresent( "admin" ); assertTextPresent( "admin" );
@ -163,7 +164,7 @@ public class AuditLogsReportTest
clickLinkWithText( "Logout" ); clickLinkWithText( "Logout" );
login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) ); login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
} }
// MRM-1304 // MRM-1304
@Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" ) @Test( dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload" )
public void testViewAuditLogsReportForGroupId() public void testViewAuditLogsReportForGroupId()
@ -187,4 +188,4 @@ public class AuditLogsReportTest
assertTextPresent( expectedArtifact ); assertTextPresent( expectedArtifact );
assertTextPresent( repositoryId ); assertTextPresent( repositoryId );
} }
} }

View File

@ -25,46 +25,48 @@ import org.apache.archiva.web.test.parent.AbstractBrowseTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Test( groups = { "browse" }, dependsOnMethods = { "testAddArtifactNullValues" } ) @Test( groups = { "browse" }, dependsOnMethods = { "testAddArtifactNullValues" } )
public class BrowseTest public class BrowseTest
extends AbstractBrowseTest extends AbstractBrowseTest
{ {
public void testBrowseArtifact() public void testBrowseArtifact()
{ {
goToBrowsePage(); goToBrowsePage();
assertBrowsePage(); assertBrowsePage();
} }
public void testClickArtifactFromBrowse() public void testClickArtifactFromBrowse()
{ {
goToBrowsePage(); goToBrowsePage();
assertBrowsePage(); assertBrowsePage();
clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" ); clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
assertPage( "Apache Archiva \\ Browse Repository" ); assertPage( "Apache Archiva \\ Browse Repository" );
assertTextPresent( "Artifacts" ); assertTextPresent( "Artifacts" );
} }
// MRM-1278 // MRM-1278
@Test(groups = {"requiresUpload"}) @Test( groups = { "requiresUpload" } )
public void testCorrectRepositoryInBrowse() public void testCorrectRepositoryInBrowse()
{ {
String releasesRepo = getProperty( "RELEASES_REPOSITORY" ); String releasesRepo = getProperty( "RELEASES_REPOSITORY" );
// create releases repository first // create releases repository first
goToRepositoriesPage(); goToRepositoriesPage();
clickLinkWithText( "Add" ); clickLinkWithText( "Add" );
addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository", addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository",
new File( getBasedir(), "target/repository/releases" ).getPath(), "", "Maven 2.x Repository", new File( getBasedir(), "target/repository/releases" ).getPath(), "",
"0 0 * * * ?", "", "" ); "Maven 2.x Repository", "0 0 * * * ?", "", "" );
assertTextPresent( "Releases Repository" ); assertTextPresent( "Releases Repository" );
String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" ); String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
String path = "src/test/resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar"; String path =
"src/test/resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
// TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well) // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well)
// upload a snapshot artifact to repository 'releases' // upload a snapshot artifact to repository 'releases'
addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", path, releasesRepo ); addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", path, releasesRepo );
assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '" + releasesRepo + "'" ); assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '"
+ releasesRepo + "'" );
goToBrowsePage(); goToBrowsePage();
assertBrowsePage(); assertBrowsePage();
@ -72,9 +74,10 @@ public class BrowseTest
assertArtifactsPage( "archiva-webapp/" ); assertArtifactsPage( "archiva-webapp/" );
assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" ); assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
// upload a snapshot artifact to repository 'snapshots' // upload a snapshot artifact to repository 'snapshots'
addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", path, snapshotsRepo ); addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", path, snapshotsRepo );
assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '" + snapshotsRepo + "'" ); assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '"
+ snapshotsRepo + "'" );
goToBrowsePage(); goToBrowsePage();
assertBrowsePage(); assertBrowsePage();
@ -84,7 +87,8 @@ public class BrowseTest
} }
private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId, private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
String artifactInfoArtifactId, String artifactInfoVersion, String artifactInfoPackaging ) String artifactInfoArtifactId, String artifactInfoVersion,
String artifactInfoPackaging )
{ {
clickLinkWithText( version ); clickLinkWithText( version );
assertPage( "Apache Archiva \\ Browse Repository" ); assertPage( "Apache Archiva \\ Browse Repository" );
@ -108,4 +112,4 @@ public class BrowseTest
assertPage( "Apache Archiva \\ Browse Repository" ); assertPage( "Apache Archiva \\ Browse Repository" );
assertTextPresent( "Artifacts" ); assertTextPresent( "Artifacts" );
} }
} }

View File

@ -24,22 +24,22 @@ import org.testng.annotations.Test;
@Test( groups = { "findartifact" }, sequential = true ) @Test( groups = { "findartifact" }, sequential = true )
public class FindArtifactTest public class FindArtifactTest
extends AbstractArchivaTest extends AbstractArchivaTest
{ {
public void testFindArtifactNullValues() public void testFindArtifactNullValues()
{ {
goToFindArtifactPage(); goToFindArtifactPage();
clickButtonWithValue( "Search" ); clickButtonWithValue( "Search" );
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." );
} }
public void testFindArtifactUsingChecksum() public void testFindArtifactUsingChecksum()
{ {
goToFindArtifactPage(); goToFindArtifactPage();
setFieldValue( "checksumSearch_q" , "8e896baea663a45d7bd2737f8e464481" ); setFieldValue( "checksumSearch_q", "8e896baea663a45d7bd2737f8e464481" );
clickButtonWithValue( "Search" ); clickButtonWithValue( "Search" );
assertTextPresent( "No results found" ); assertTextPresent( "No results found" );
} }
// TODO: test using file upload on Firefox versions that support getAsBinary (ie, no applet) // TODO: test using file upload on Firefox versions that support getAsBinary (ie, no applet)
} }

View File

@ -23,53 +23,53 @@ import org.apache.archiva.web.test.parent.AbstractArtifactManagementTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Test( groups = { "legacysupport" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) @Test( groups = { "legacysupport" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
public class LegacySupportTest public class LegacySupportTest
extends AbstractArtifactManagementTest extends AbstractArtifactManagementTest
{ {
public void testAddLegacyArtifact_NullValues() public void testAddLegacyArtifact_NullValues()
{ {
goToLegacySupportPage(); goToLegacySupportPage();
clickLinkWithText( "Add" ); clickLinkWithText( "Add" );
addLegacyArtifactPath( "" , "" , "" , "" , "" , ""); addLegacyArtifactPath( "", "", "", "", "", "" );
assertTextPresent( "You must enter a legacy path." ); assertTextPresent( "You must enter a legacy path." );
assertTextPresent( "You must enter a groupId." ); assertTextPresent( "You must enter a groupId." );
assertTextPresent( "You must enter an artifactId." ); assertTextPresent( "You must enter an artifactId." );
assertTextPresent( "You must enter a version." ); assertTextPresent( "You must enter a version." );
assertTextPresent( "You must enter a type." ); assertTextPresent( "You must enter a type." );
} }
@Test( dependsOnMethods = { "testAddLegacyArtifact_NullValues" }) @Test( dependsOnMethods = { "testAddLegacyArtifact_NullValues" } )
public void testAddLegacyArtifact_NullLegacyPath() public void testAddLegacyArtifact_NullLegacyPath()
{ {
addLegacyArtifactPath( "" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , "jar"); addLegacyArtifactPath( "", "test", "test", "1.0-SNAPSHOT", "testing", "jar" );
assertTextPresent( "You must enter a legacy path." ); assertTextPresent( "You must enter a legacy path." );
} }
@Test( dependsOnMethods = { "testAddLegacyArtifact_NullLegacyPath" }) @Test( dependsOnMethods = { "testAddLegacyArtifact_NullLegacyPath" } )
public void testAddLegacyArtifact_NullGroupId() public void testAddLegacyArtifact_NullGroupId()
{ {
addLegacyArtifactPath( "test" , "" , "test" , "1.0-SNAPSHOT" , "testing" , "jar"); addLegacyArtifactPath( "test", "", "test", "1.0-SNAPSHOT", "testing", "jar" );
assertTextPresent( "You must enter a groupId." ); assertTextPresent( "You must enter a groupId." );
} }
@Test( dependsOnMethods = { "testAddLegacyArtifact_NullGroupId" }) @Test( dependsOnMethods = { "testAddLegacyArtifact_NullGroupId" } )
public void testAddLegacyArtifact_NullArtifactId() public void testAddLegacyArtifact_NullArtifactId()
{ {
addLegacyArtifactPath( "test" , "test" , "" , "1.0-SNAPSHOT" , "testing" , "jar"); addLegacyArtifactPath( "test", "test", "", "1.0-SNAPSHOT", "testing", "jar" );
assertTextPresent( "You must enter an artifactId." ); assertTextPresent( "You must enter an artifactId." );
} }
@Test( dependsOnMethods = { "testAddLegacyArtifact_NullArtifactId" }) @Test( dependsOnMethods = { "testAddLegacyArtifact_NullArtifactId" } )
public void testAddLegacyArtifact_NullVersion() public void testAddLegacyArtifact_NullVersion()
{ {
addLegacyArtifactPath( "test" , "test" , "test" , "" , "testing" , "jar"); addLegacyArtifactPath( "test", "test", "test", "", "testing", "jar" );
assertTextPresent( "You must enter a version." ); assertTextPresent( "You must enter a version." );
} }
@Test( dependsOnMethods = { "testAddLegacyArtifact_NullVersion" }) @Test( dependsOnMethods = { "testAddLegacyArtifact_NullVersion" } )
public void testAddLegacyArtifact_NullType() public void testAddLegacyArtifact_NullType()
{ {
addLegacyArtifactPath( "test" , "test" , "test" , "1.0-SNAPSHOT" , "testing" , ""); addLegacyArtifactPath( "test", "test", "test", "1.0-SNAPSHOT", "testing", "" );
assertTextPresent( "You must enter a type." ); assertTextPresent( "You must enter a type." );
} }
} }

View File

@ -36,11 +36,11 @@ import org.testng.annotations.Test;
* @version $Id$ * @version $Id$
*/ */
@Test ( groups = { "login" } ) @Test( groups = { "login" } )
public class LoginTest public class LoginTest
extends AbstractArchivaTest extends AbstractArchivaTest
{ {
public void testWithBadUsername() public void testWithBadUsername()
{ {
goToLoginPage(); goToLoginPage();
getSelenium().type( "loginForm_username", "badUsername" ); getSelenium().type( "loginForm_username", "badUsername" );
@ -92,8 +92,8 @@ public class LoginTest
assertTextPresent( "Logout" ); assertTextPresent( "Logout" );
assertTextPresent( getProperty( "ADMIN_USERNAME" ) ); assertTextPresent( getProperty( "ADMIN_USERNAME" ) );
} }
@BeforeTest @BeforeTest
public void open() public void open()
throws Exception throws Exception
{ {
@ -107,4 +107,4 @@ public class LoginTest
{ {
super.close(); super.close();
} }
} }

View File

@ -23,74 +23,74 @@ import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Test( groups = { "networkproxies" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) @Test( groups = { "networkproxies" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public class NetworkProxiesTest public class NetworkProxiesTest
extends AbstractRepositoryTest extends AbstractRepositoryTest
{ {
@Test (dependsOnMethods = { "testDeleteRepositoryGroup" } ) @Test( dependsOnMethods = { "testDeleteRepositoryGroup" } )
public void testAddNetworkProxyNullValues() public void testAddNetworkProxyNullValues()
{ {
goToNetworkProxiesPage(); goToNetworkProxiesPage();
addNetworkProxy( "", "", "", "", "", ""); addNetworkProxy( "", "", "", "", "", "" );
assertTextPresent( "You must enter an identifier." ); assertTextPresent( "You must enter an identifier." );
assertTextPresent( "You must enter a protocol." ); assertTextPresent( "You must enter a protocol." );
assertTextPresent( "You must enter a host." ); assertTextPresent( "You must enter a host." );
} }
@Test (dependsOnMethods = { "testAddNetworkProxyNullValues" } ) @Test( dependsOnMethods = { "testAddNetworkProxyNullValues" } )
public void testAddNetworkProxyNullIdentifier() public void testAddNetworkProxyNullIdentifier()
{ {
goToNetworkProxiesPage(); goToNetworkProxiesPage();
addNetworkProxy( "", "http", "localhost", "8080", "", ""); addNetworkProxy( "", "http", "localhost", "8080", "", "" );
assertTextPresent( "You must enter an identifier." ); assertTextPresent( "You must enter an identifier." );
} }
@Test (dependsOnMethods = { "testAddNetworkProxyNullIdentifier" } ) @Test( dependsOnMethods = { "testAddNetworkProxyNullIdentifier" } )
public void testAddNetworkProxyNullProtocol() public void testAddNetworkProxyNullProtocol()
{ {
goToNetworkProxiesPage(); goToNetworkProxiesPage();
addNetworkProxy( "testing123", "", "localhost", "8080", "", ""); addNetworkProxy( "testing123", "", "localhost", "8080", "", "" );
assertTextPresent( "You must enter a protocol." ); assertTextPresent( "You must enter a protocol." );
} }
@Test (dependsOnMethods = { "testAddNetworkProxyNullProtocol" } ) @Test( dependsOnMethods = { "testAddNetworkProxyNullProtocol" } )
public void testAddNetworkProxiesNullHostname() public void testAddNetworkProxiesNullHostname()
{ {
goToNetworkProxiesPage(); goToNetworkProxiesPage();
addNetworkProxy( "testing123", "http", "", "8080", "", ""); addNetworkProxy( "testing123", "http", "", "8080", "", "" );
assertTextPresent( "You must enter a host." ); assertTextPresent( "You must enter a host." );
} }
@Test (dependsOnMethods = { "testAddNetworkProxiesNullHostname" } ) @Test( dependsOnMethods = { "testAddNetworkProxiesNullHostname" } )
public void testAddNetworkProxiesValidValues() public void testAddNetworkProxiesValidValues()
{ {
goToNetworkProxiesPage(); goToNetworkProxiesPage();
addNetworkProxy( "testing123", "http", "localhost", "8080", "", ""); addNetworkProxy( "testing123", "http", "localhost", "8080", "", "" );
assertPage( "Apache Archiva \\ Administration - Network Proxies" ); assertPage( "Apache Archiva \\ Administration - Network Proxies" );
assertTextPresent( "testing123" ); assertTextPresent( "testing123" );
} }
@Test (dependsOnMethods = { "testAddNetworkProxiesValidValues" } ) @Test( dependsOnMethods = { "testAddNetworkProxiesValidValues" } )
public void testEditNetworkProxy() public void testEditNetworkProxy()
{ {
editNetworkProxies( "proxy.host", "localhost" ); editNetworkProxies( "proxy.host", "localhost" );
assertPage( "Apache Archiva \\ Administration - Network Proxies" ); assertPage( "Apache Archiva \\ Administration - Network Proxies" );
assertTextPresent( "localhost" ); assertTextPresent( "localhost" );
} }
@Test (dependsOnMethods = { "testEditNetworkProxy" } ) @Test( dependsOnMethods = { "testEditNetworkProxy" } )
public void testDeleteNetworkProxy() public void testDeleteNetworkProxy()
{ {
deleteNetworkProxy(); deleteNetworkProxy();
assertPage( "Apache Archiva \\ Administration - Network Proxies" ); assertPage( "Apache Archiva \\ Administration - Network Proxies" );
assertTextPresent( "There are no network proxies configured yet." ); assertTextPresent( "There are no network proxies configured yet." );
} }
@Test (dependsOnMethods = { "testDeleteNetworkProxy" } ) @Test( dependsOnMethods = { "testDeleteNetworkProxy" } )
public void testAddNetworkProxyAfterDelete() public void testAddNetworkProxyAfterDelete()
{ {
addNetworkProxy( "testing123", "http", "localhost", "8080", "", ""); addNetworkProxy( "testing123", "http", "localhost", "8080", "", "" );
assertPage( "Apache Archiva \\ Administration - Network Proxies" ); assertPage( "Apache Archiva \\ Administration - Network Proxies" );
assertTextPresent( "testing123" ); assertTextPresent( "testing123" );
} }
} }

View File

@ -23,79 +23,61 @@ import org.apache.archiva.web.test.parent.AbstractArtifactReportsTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Test( groups = { "reports" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) @Test( groups = { "reports" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public class ReportsTest public class ReportsTest
extends AbstractArtifactReportsTest extends AbstractArtifactReportsTest
{ {
//TODO Tests for repository with defects // TODO Tests for repository with defects
public void testRepoStatisticsWithoutRepoCompared() public void testRepoStatisticsWithoutRepoCompared()
{ {
goToReportsPage(); goToReportsPage();
clickButtonWithValue( "View Statistics" ); clickButtonWithValue( "View Statistics" );
assertTextPresent( "Please select a repository (or repositories) from the list." ); assertTextPresent( "Please select a repository (or repositories) from the list." );
} }
@Test(dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } ) @Test( dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } )
public void testRepositoryStatisticsWithoutDate() public void testRepositoryStatisticsWithoutDate()
{ {
String repositoryName = getProperty( "REPOSITORY_NAME" ) ; String repositoryName = getProperty( "REPOSITORY_NAME" );
compareRepositories( "label=" + repositoryName, "", "" ); compareRepositories( "label=" + repositoryName, "", "" );
//TODO // TODO
//assertTextPresent( "Statistics Report" ); // assertTextPresent( "Statistics Report" );
} }
@Test(dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } ) @Test( dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } )
public void testRepositoryStatisticsEndEarlierThanStart() public void testRepositoryStatisticsEndEarlierThanStart()
{ {
String repositoryName = getProperty( "REPOSITORY_NAME" ) ; String repositoryName = getProperty( "REPOSITORY_NAME" );
String startDate = getProperty( "END_DATE" ); String startDate = getProperty( "END_DATE" );
String endDate = getProperty( "START_DATE" ); String endDate = getProperty( "START_DATE" );
compareRepositories( "label=" + repositoryName, startDate, endDate ); compareRepositories( "label=" + repositoryName, startDate, endDate );
//assertTextPresent( "Statistics for Repository '" + repositoryName + "'" ); // assertTextPresent( "Statistics for Repository '" + repositoryName + "'" );
assertPage( "Apache Archiva \\ Reports" ); assertPage( "Apache Archiva \\ Reports" );
assertTextPresent( "Start Date must be earlier than the End Date" ); assertTextPresent( "Start Date must be earlier than the End Date" );
} }
public void testRepositoryStatistics() public void testRepositoryStatistics()
{ {
String repositoryName = getProperty( "REPOSITORY_NAME" ) ; String repositoryName = getProperty( "REPOSITORY_NAME" );
String startDate = getProperty( "START_DATE" ); String startDate = getProperty( "START_DATE" );
String endDate = getProperty( "END_DATE" ); String endDate = getProperty( "END_DATE" );
compareRepositories( "label=" + repositoryName, startDate, endDate ); compareRepositories( "label=" + repositoryName, startDate, endDate );
//assertTextPresent( "Statistics for Repository '" + repositoryName + "'" ); // assertTextPresent( "Statistics for Repository '" + repositoryName + "'" );
//assertPage( "Apache Archiva \\ Reports" ); // assertPage( "Apache Archiva \\ Reports" );
//assertTextPresent( "Statistics Report" ); // assertTextPresent( "Statistics Report" );
} }
/* @Test( dependsOnMethods = { "testRepositoryStatistics" } ) /*
public void testRepositoriesStatisticComparisonReport() * @Test( dependsOnMethods = { "testRepositoryStatistics" } ) public void
{ * testRepositoriesStatisticComparisonReport() { //goToReportsPage(); clickButtonWithValue( "-->>" , false );
//goToReportsPage(); * clickButtonWithValue( "View Statistics" ); assertTextPresent( "Statistics Report" ); } public void
clickButtonWithValue( "-->>" , false ); * testRepositoryHealthWithoutDefect() { goToReportsPage(); String groupId = getProperty( "ARTIFACT_GROUPID" );
clickButtonWithValue( "View Statistics" ); * getSelenium().type( "generateReport_groupId" , groupId ); clickButtonWithValue( "Show Report" ); assertPage(
assertTextPresent( "Statistics Report" ); * "Apache Archiva \\ Reports" ); assertTextPresent( "The operation generated an empty report." ); } public void
} * testRepositoryHealthWithoutGroupId() { goToReportsPage(); clickButtonWithValue( "Show Report" ); assertPage(
* "Apache Archiva \\ Reports" ); assertTextPresent( "The operation generated an empty report." ); //TODO As of the
public void testRepositoryHealthWithoutDefect() * creation of the tests, GroupId is not a required field in showing the reports of repository health. GroupId
{ * should be required I think. }
goToReportsPage(); */
String groupId = getProperty( "ARTIFACT_GROUPID" );
getSelenium().type( "generateReport_groupId" , groupId ); }
clickButtonWithValue( "Show Report" );
assertPage( "Apache Archiva \\ Reports" );
assertTextPresent( "The operation generated an empty report." );
}
public void testRepositoryHealthWithoutGroupId()
{
goToReportsPage();
clickButtonWithValue( "Show Report" );
assertPage( "Apache Archiva \\ Reports" );
assertTextPresent( "The operation generated an empty report." );
//TODO As of the creation of the tests, GroupId is not a required field in showing the reports of repository health. GroupId should be required I think.
}*/
}

View File

@ -24,159 +24,165 @@ import org.testng.Assert;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Test( groups = { "reposcan" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) @Test( groups = { "reposcan" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
public class RepositoryScanningTest public class RepositoryScanningTest
extends AbstractRepositoryTest extends AbstractRepositoryTest
{ {
public void testAddArtifactFileType_NullValue() public void testAddArtifactFileType_NullValue()
{ {
goToRepositoryScanningPage(); goToRepositoryScanningPage();
clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" );
assertTextPresent( "Unable to process blank pattern." ); assertTextPresent( "Unable to process blank pattern." );
} }
@Test (dependsOnMethods = { "testAddArtifactFileType_NullValue" } ) @Test( dependsOnMethods = { "testAddArtifactFileType_NullValue" } )
public void testAddArtifactFileType() public void testAddArtifactFileType()
{ {
setFieldValue( "newpattern_0" , "**/*.dll" ); setFieldValue( "newpattern_0", "**/*.dll" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" );
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" ); Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[1]/table.13.0" ), "**/*.dll" );
} }
@Test (dependsOnMethods = { "testAddArtifactFileType" } ) @Test( dependsOnMethods = { "testAddArtifactFileType" } )
public void testAddArtifactFileType_ExistingValue() public void testAddArtifactFileType_ExistingValue()
{ {
setFieldValue( "newpattern_0" , "**/*.zip" ); setFieldValue( "newpattern_0", "**/*.zip" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[15]/td[2]/a/img" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[15]/td[2]/a/img" );
Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." ); Assert.assertEquals( getSelenium().getText( "//span[@class='errorMessage']" ),
} "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." );
}
@Test (dependsOnMethods = { "testAddArtifactFileType_ExistingValue" } )
public void testDeleteArtifactFileType() @Test( dependsOnMethods = { "testAddArtifactFileType_ExistingValue" } )
{ public void testDeleteArtifactFileType()
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" ); {
clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" ); Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[1]/table.13.0" ), "**/*.dll" );
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" );
} Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[1]/table.13.0" ), "" );
}
@Test (dependsOnMethods = { "testDeleteArtifactFileType" } )
public void testAddAutoRemove_NullValue() @Test( dependsOnMethods = { "testDeleteArtifactFileType" } )
{ public void testAddAutoRemove_NullValue()
setFieldValue( "newpattern_1" , "" ); {
clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" ); setFieldValue( "newpattern_1", "" );
assertTextPresent( "Unable to process blank pattern." ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
} assertTextPresent( "Unable to process blank pattern." );
}
@Test (dependsOnMethods = { "testAddAutoRemove_NullValue" } )
public void testAddAutoRemove_ExistingValue() @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" } )
{ public void testAddAutoRemove_ExistingValue()
setFieldValue( "newpattern_1" , "**/*-" ); {
clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" ); setFieldValue( "newpattern_1", "**/*-" );
Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
} Assert.assertEquals( getSelenium().getText( "//span[@class='errorMessage']" ),
"Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." );
@Test (dependsOnMethods = { "testAddAutoRemove_ExistingValue" } ) }
public void testAddAutoRemove()
{ @Test( dependsOnMethods = { "testAddAutoRemove_ExistingValue" } )
setFieldValue( "newpattern_1" , "**/*.test" ); public void testAddAutoRemove()
clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" ); {
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" ); setFieldValue( "newpattern_1", "**/*.test" );
} clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[2]/table.3.0" ), "**/*.test" );
@Test (dependsOnMethods = { "testAddAutoRemove" } ) }
public void testDeleteAutoRemove()
{ @Test( dependsOnMethods = { "testAddAutoRemove" } )
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" ); public void testDeleteAutoRemove()
clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" ); {
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "" ); Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[2]/table.3.0" ), "**/*.test" );
} clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[2]/table.3.0" ), "" );
@Test (dependsOnMethods = { "testDeleteAutoRemove" } ) }
public void testAddIgnoredArtifacts_NullValue()
{ @Test( dependsOnMethods = { "testDeleteAutoRemove" } )
setFieldValue( "newpattern_2" , "" ); public void testAddIgnoredArtifacts_NullValue()
clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" ); {
Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." ); setFieldValue( "newpattern_2", "" );
} clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
Assert.assertEquals( getSelenium().getText( "//span[@class='errorMessage']" ),
@Test (dependsOnMethods = { "testAddIgnoredArtifacts_NullValue" } ) "Unable to process blank pattern." );
public void testAddIgnoredArtifacts_ExistingValue() }
{
setFieldValue( "newpattern_2" , "**/*.sh" ); @Test( dependsOnMethods = { "testAddIgnoredArtifacts_NullValue" } )
clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" ); public void testAddIgnoredArtifacts_ExistingValue()
Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." ); {
} setFieldValue( "newpattern_2", "**/*.sh" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
@Test (dependsOnMethods = { "testAddIgnoredArtifacts_ExistingValue" } ) Assert.assertEquals( getSelenium().getText( "//span[@class='errorMessage']" ),
public void testAddIgnoredArtifacts() "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." );
{ }
setFieldValue( "newpattern_2" , "**/*.log" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" ); @Test( dependsOnMethods = { "testAddIgnoredArtifacts_ExistingValue" } )
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" ); public void testAddIgnoredArtifacts()
} {
setFieldValue( "newpattern_2", "**/*.log" );
@Test (dependsOnMethods = { "testAddIgnoredArtifacts" } ) clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
public void testDeleteIgnoredArtifacts() Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[3]/table.6.0" ), "**/*.log" );
{ }
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" ); @Test( dependsOnMethods = { "testAddIgnoredArtifacts" } )
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "" ); public void testDeleteIgnoredArtifacts()
} {
Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[3]/table.6.0" ), "**/*.log" );
// clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
@Test (dependsOnMethods = { "testDeleteIgnoredArtifacts" } ) Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[3]/table.6.0" ), "" );
public void testAddIndexableContent_NullValue() }
{
setFieldValue( "newpattern_3" , "" ); //
clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" ); @Test( dependsOnMethods = { "testDeleteIgnoredArtifacts" } )
Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." ); public void testAddIndexableContent_NullValue()
} {
setFieldValue( "newpattern_3", "" );
@Test (dependsOnMethods = { "testAddIndexableContent_NullValue" } ) clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
public void testAddIndexableContent_ExistingValue() Assert.assertEquals( getSelenium().getText( "//span[@class='errorMessage']" ),
{ "Unable to process blank pattern." );
setFieldValue( "newpattern_3" , "**/*.xml" ); }
clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." ); @Test( dependsOnMethods = { "testAddIndexableContent_NullValue" } )
} public void testAddIndexableContent_ExistingValue()
{
@Test (dependsOnMethods = { "testAddIndexableContent_ExistingValue" } ) setFieldValue( "newpattern_3", "**/*.xml" );
public void testAddIndexableContent() clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
{ Assert.assertEquals( getSelenium().getText( "//span[@class='errorMessage']" ),
setFieldValue( "newpattern_3" , "**/*.html" ); "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" ); }
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" );
} @Test( dependsOnMethods = { "testAddIndexableContent_ExistingValue" } )
public void testAddIndexableContent()
@Test (dependsOnMethods = { "testAddIndexableContent" } ) {
public void testDeleteIndexableContent() setFieldValue( "newpattern_3", "**/*.html" );
{ clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" ); Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[4]/table.9.0" ), "**/*.html" );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" ); }
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "" );
} @Test( dependsOnMethods = { "testAddIndexableContent" } )
public void testDeleteIndexableContent()
@Test (dependsOnMethods = { "testDeleteIndexableContent" } ) {
public void testUpdateConsumers() Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[4]/table.9.0" ), "**/*.html" );
{ clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
checkField( "enabledKnownContentConsumers" ); Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[4]/table.9.0" ), "" );
checkField( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" ); }
clickButtonWithValue( "Update Consumers" );
assertPage( "Apache Archiva \\ Administration - Repository Scanning" ); @Test( dependsOnMethods = { "testDeleteIndexableContent" } )
} public void testUpdateConsumers()
{
@Test (dependsOnMethods = { "testUpdateConsumers" } ) checkField( "enabledKnownContentConsumers" );
public void testUpdateConsumers_UnsetAll() checkField( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
{ clickButtonWithValue( "Update Consumers" );
getSelenium().uncheck( "enabledKnownContentConsumers" ); assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" ); }
getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='create-missing-checksums']" );
getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='index-content']" ); @Test( dependsOnMethods = { "testUpdateConsumers" } )
getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='metadata-updater']" ); public void testUpdateConsumers_UnsetAll()
getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='repository-purge']" ); {
getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='validate-checksums']" ); getSelenium().uncheck( "enabledKnownContentConsumers" );
clickButtonWithValue( "Update Consumers" ); getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='create-missing-checksums']" );
assertPage( "Apache Archiva \\ Administration - Repository Scanning" ); getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='index-content']" );
} getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='metadata-updater']" );
getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='repository-purge']" );
} getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='validate-checksums']" );
clickButtonWithValue( "Update Consumers" );
assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
}
}

View File

@ -24,137 +24,142 @@ import org.testng.annotations.Test;
@Test( groups = { "repository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) @Test( groups = { "repository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
public class RepositoryTest public class RepositoryTest
extends AbstractRepositoryTest extends AbstractRepositoryTest
{ {
public void testAddManagedRepoValidValues() public void testAddManagedRepoValidValues()
{ {
goToRepositoriesPage(); goToRepositoriesPage();
getSelenium().open( "/archiva/admin/addRepository.action" ); getSelenium().open( "/archiva/admin/addRepository.action" );
addManagedRepository( "managedrepo1", "Managed Repository Sample 1" , getRepositoryDir() + "repository/" , "", "Maven 2.x Repository", "0 0 * * * ?", "", "" ); addManagedRepository( "managedrepo1", "Managed Repository Sample 1", getRepositoryDir() + "repository/", "",
clickButtonWithValue( "Save" ); "Maven 2.x Repository", "0 0 * * * ?", "", "" );
assertTextPresent( "Managed Repository Sample 1" ); clickButtonWithValue( "Save" );
assertRepositoriesPage(); assertTextPresent( "Managed Repository Sample 1" );
} assertRepositoriesPage();
}
@Test(dependsOnMethods = { "testAddManagedRepoValidValues" } )
public void testAddManagedRepoInvalidValues()
{
goToRepositoriesPage();
getSelenium().open( "/archiva/admin/addRepository.action" );
addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" );
assertTextPresent( "You must enter a repository identifier." );
assertTextPresent( "You must enter a repository name." );
assertTextPresent( "You must enter a directory." );
assertTextPresent( "Invalid cron expression." );
}
@Test(dependsOnMethods = { "testAddManagedRepoInvalidValues" } )
public void testAddManagedRepoNoIdentifier()
{
addManagedRepository( "", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
assertTextPresent( "You must enter a repository identifier." );
}
@Test(dependsOnMethods = { "testAddManagedRepoNoIdentifier" } )
public void testAddManagedRepoNoRepoName()
{
addManagedRepository( "identifier", "" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
assertTextPresent( "You must enter a repository name." );
}
@Test(dependsOnMethods = { "testAddManagedRepoNoRepoName" } )
public void testAddManagedRepoNoDirectory()
{
addManagedRepository( "identifier", "name" , "" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
assertTextPresent( "You must enter a directory." );
}
@Test(dependsOnMethods = { "testAddManagedRepoNoDirectory" } )
public void testAddManagedRepoNoCron()
{
addManagedRepository( "identifier", "name" , "/home" , "/.index", "Maven 2.x Repository", "", "", "" );
assertTextPresent( "Invalid cron expression." );
}
@Test(dependsOnMethods = { "testAddManagedRepoNoCron" } )
public void testAddManagedRepoForEdit()
{
goToRepositoriesPage();
getSelenium().open( "/archiva/admin/addRepository.action" );
addManagedRepository( "managedrepo", "Managed Repository Sample" , getRepositoryDir() + "local-repo/", "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
clickButtonWithValue( "Save" );
assertTextPresent( "Managed Repository Sample" );
}
//TODO @Test( dependsOnMethods = { "testAddManagedRepoValidValues" } )
@Test(dependsOnMethods = { "testAddManagedRepoForEdit" } ) public void testAddManagedRepoInvalidValues()
public void testEditManagedRepo() {
{ goToRepositoriesPage();
editManagedRepository( "repository.name" , "Managed Repo" ); getSelenium().open( "/archiva/admin/addRepository.action" );
assertTextPresent( "Managed Repository Sample" ); addManagedRepository( "", "", "", "", "Maven 2.x Repository", "", "", "" );
} assertTextPresent( "You must enter a repository identifier." );
assertTextPresent( "You must enter a repository name." );
//TODO assertTextPresent( "You must enter a directory." );
@Test(dependsOnMethods = { "testEditManagedRepo" } ) assertTextPresent( "Invalid cron expression." );
public void testDeleteManageRepo() }
{
deleteManagedRepository(); @Test( dependsOnMethods = { "testAddManagedRepoInvalidValues" } )
//assertTextNotPresent( "managedrepo" ); public void testAddManagedRepoNoIdentifier()
} {
addManagedRepository( "", "name", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
@Test(dependsOnMethods = { "testAddRemoteRepoValidValues" } ) assertTextPresent( "You must enter a repository identifier." );
public void testAddRemoteRepoNullValues() }
{
getSelenium().open( "/archiva/admin/addRemoteRepository.action" ); @Test( dependsOnMethods = { "testAddManagedRepoNoIdentifier" } )
addRemoteRepository( "" , "" , "" , "" , "" , "" , "Maven 2.x Repository" ); public void testAddManagedRepoNoRepoName()
assertTextPresent( "You must enter a repository identifier." ); {
assertTextPresent( "You must enter a repository name." ); addManagedRepository( "identifier", "", "/home", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
assertTextPresent( "You must enter a url." ); assertTextPresent( "You must enter a repository name." );
} }
@Test(dependsOnMethods = { "testAddRemoteRepoNullValues" } ) @Test( dependsOnMethods = { "testAddManagedRepoNoRepoName" } )
public void testAddRemoteRepositoryNullIdentifier() public void testAddManagedRepoNoDirectory()
{ {
addRemoteRepository( "" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" ); addManagedRepository( "identifier", "name", "", "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
assertTextPresent( "You must enter a repository identifier." ); assertTextPresent( "You must enter a directory." );
} }
@Test(dependsOnMethods = { "testAddRemoteRepositoryNullIdentifier" } ) @Test( dependsOnMethods = { "testAddManagedRepoNoDirectory" } )
public void testAddRemoteRepoNullName() public void testAddManagedRepoNoCron()
{ {
addRemoteRepository( "remoterepo" , "" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" ); addManagedRepository( "identifier", "name", "/home", "/.index", "Maven 2.x Repository", "", "", "" );
assertTextPresent( "You must enter a repository name." ); assertTextPresent( "Invalid cron expression." );
} }
@Test(dependsOnMethods = { "testAddRemoteRepoNullName" } ) @Test( dependsOnMethods = { "testAddManagedRepoNoCron" } )
public void testAddRemoteRepoNullURL() public void testAddManagedRepoForEdit()
{ {
addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "" , "" , "" , "" , "Maven 2.x Repository" ); goToRepositoriesPage();
assertTextPresent( "You must enter a url." ); getSelenium().open( "/archiva/admin/addRepository.action" );
} addManagedRepository( "managedrepo", "Managed Repository Sample", getRepositoryDir() + "local-repo/", "",
"Maven 2.x Repository", "0 0 * * * ?", "", "" );
clickButtonWithValue( "Save" );
assertTextPresent( "Managed Repository Sample" );
}
// TODO
@Test( dependsOnMethods = { "testAddManagedRepoForEdit" } )
public void testEditManagedRepo()
{
editManagedRepository( "repository.name", "Managed Repo" );
assertTextPresent( "Managed Repository Sample" );
}
// TODO
@Test( dependsOnMethods = { "testEditManagedRepo" } )
public void testDeleteManageRepo()
{
deleteManagedRepository();
// assertTextNotPresent( "managedrepo" );
}
@Test( dependsOnMethods = { "testAddRemoteRepoValidValues" } )
public void testAddRemoteRepoNullValues()
{
getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
addRemoteRepository( "", "", "", "", "", "", "Maven 2.x Repository" );
assertTextPresent( "You must enter a repository identifier." );
assertTextPresent( "You must enter a repository name." );
assertTextPresent( "You must enter a url." );
}
@Test( dependsOnMethods = { "testAddRemoteRepoNullValues" } )
public void testAddRemoteRepositoryNullIdentifier()
{
addRemoteRepository( "", "Remote Repository Sample", "http://repository.codehaus.org/org/codehaus/mojo/", "",
"", "", "Maven 2.x Repository" );
assertTextPresent( "You must enter a repository identifier." );
}
@Test( dependsOnMethods = { "testAddRemoteRepositoryNullIdentifier" } )
public void testAddRemoteRepoNullName()
{
addRemoteRepository( "remoterepo", "", "http://repository.codehaus.org/org/codehaus/mojo/", "", "", "",
"Maven 2.x Repository" );
assertTextPresent( "You must enter a repository name." );
}
@Test( dependsOnMethods = { "testAddRemoteRepoNullName" } )
public void testAddRemoteRepoNullURL()
{
addRemoteRepository( "remoterepo", "Remote Repository Sample", "", "", "", "", "Maven 2.x Repository" );
assertTextPresent( "You must enter a url." );
}
@Test( dependsOnMethods = { "testDeleteManageRepo" } )
public void testAddRemoteRepoValidValues()
{
getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
addRemoteRepository( "remoterepo", "Remote Repository Sample",
"http://repository.codehaus.org/org/codehaus/mojo/", "", "", "", "Maven 2.x Repository" );
assertTextPresent( "Remote Repository Sample" );
}
@Test(dependsOnMethods = { "testDeleteManageRepo" } )
public void testAddRemoteRepoValidValues()
{
getSelenium().open( "/archiva/admin/addRemoteRepository.action" );
addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
assertTextPresent( "Remote Repository Sample" );
}
// *** BUNDLED REPOSITORY TEST *** // *** BUNDLED REPOSITORY TEST ***
@Test ( dependsOnMethods = { "testWithCorrectUsernamePassword" }, alwaysRun = true ) @Test( dependsOnMethods = { "testWithCorrectUsernamePassword" }, alwaysRun = true )
public void testBundledRepository() public void testBundledRepository()
{ {
String repo1 = baseUrl + "repository/internal/"; String repo1 = baseUrl + "repository/internal/";
String repo2 = baseUrl + "repository/snapshots/"; String repo2 = baseUrl + "repository/snapshots/";
assertRepositoryAccess( repo1 ); assertRepositoryAccess( repo1 );
assertRepositoryAccess( repo2 ); assertRepositoryAccess( repo2 );
getSelenium().open( "/archiva" ); getSelenium().open( "/archiva" );
} }
private void assertRepositoryAccess( String repo ) private void assertRepositoryAccess( String repo )
{ {
getSelenium().open( "/archiva" ); getSelenium().open( "/archiva" );
@ -164,4 +169,4 @@ public class RepositoryTest
assertPage( "Collection: /" ); assertPage( "Collection: /" );
assertTextPresent( "Collection: /" ); assertTextPresent( "Collection: /" );
} }
} }

View File

@ -25,39 +25,39 @@ import org.apache.archiva.web.test.parent.AbstractSearchTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Test( groups = { "search" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) @Test( groups = { "search" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public class SearchTest public class SearchTest
extends AbstractSearchTest extends AbstractSearchTest
{ {
public void testSearchNonExistingArtifact() public void testSearchNonExistingArtifact()
throws Exception throws Exception
{
searchForArtifact( getProperty( "SEARCH_BAD_ARTIFACT" ) );
assertTextPresent( "No results found" );
}
// TODO: make search tests more robust especially when comparing/asserting number of hits
public void testSearchExistingArtifact()
{
searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
assertTextPresent( "Results" );
assertTextPresent( "Hits: 1 to 1 of 1" );
assertLinkPresent( "test" );
}
public void testViewSearchedArtifact()
{ {
searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) ); searchForArtifact( getProperty( "SEARCH_BAD_ARTIFACT" ) );
clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) ); assertTextPresent( "No results found" );
assertPage( "Apache Archiva \\ Browse Repository" );
assertTextPresent( getProperty( "ARTIFACT_ARTIFACTID" ) );
clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
assertPage( "Apache Archiva \\ Browse Repository" );
} }
public void testSearchNonExistingArtifactInAdvancedSearch() // TODO: make search tests more robust especially when comparing/asserting number of hits
public void testSearchExistingArtifact()
{ {
searchForArtifactAdvancedSearch( null, getProperty( "SEARCH_BAD_ARTIFACT"), null, null, null, null ); searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
assertTextPresent( "Results" );
assertTextPresent( "Hits: 1 to 1 of 1" );
assertLinkPresent( "test" );
}
public void testViewSearchedArtifact()
{
searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) );
clickLinkWithText( getProperty( "ARTIFACT_ARTIFACTID" ) );
assertPage( "Apache Archiva \\ Browse Repository" );
assertTextPresent( getProperty( "ARTIFACT_ARTIFACTID" ) );
clickLinkWithText( getProperty( "ARTIFACT_VERSION" ) + "/" );
assertPage( "Apache Archiva \\ Browse Repository" );
}
public void testSearchNonExistingArtifactInAdvancedSearch()
{
searchForArtifactAdvancedSearch( null, getProperty( "SEARCH_BAD_ARTIFACT" ), null, null, null, null );
assertTextPresent( "No results found" ); assertTextPresent( "No results found" );
} }
@ -69,27 +69,28 @@ public class SearchTest
public void testSearchExistingArtifactUsingAdvancedSearchArtifactId() public void testSearchExistingArtifactUsingAdvancedSearchArtifactId()
{ {
searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, getProperty( "REPOSITORYID" ), null, null ); searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null,
assertTextPresent( "Results" ); getProperty( "REPOSITORYID" ), null, null );
assertTextPresent( "Hits: 1 to 1 of 1" );
assertLinkPresent( "test" );
}
public void testSearchExistingArtifactUsingAdvancedSearchGroupId()
{
searchForArtifactAdvancedSearch( getProperty( "GROUPID" ), null, null, getProperty( "REPOSITORYID" ), null, null );
assertTextPresent( "Results" ); assertTextPresent( "Results" );
assertTextPresent( "Hits: 1 to 1 of 1" ); assertTextPresent( "Hits: 1 to 1 of 1" );
assertLinkPresent( "test" ); assertLinkPresent( "test" );
} }
public void testSearchExistingArtifactUsingAdvancedSearchGroupId()
{
searchForArtifactAdvancedSearch( getProperty( "GROUPID" ), null, null, getProperty( "REPOSITORYID" ), null,
null );
assertTextPresent( "Results" );
assertTextPresent( "Hits: 1 to 1 of 1" );
assertLinkPresent( "test" );
}
public void testSearchExistingArtifactUsingAdvancedSearchNotInRepository() public void testSearchExistingArtifactUsingAdvancedSearchNotInRepository()
{ {
searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, "snapshots", null, null ); searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, "snapshots", null, null );
assertTextPresent( "No results found" ); assertTextPresent( "No results found" );
assertTextNotPresent( "Results" ); assertTextNotPresent( "Results" );
assertTextNotPresent( "Hits: 1 to 1 of 1" ); assertTextNotPresent( "Hits: 1 to 1 of 1" );
assertLinkNotPresent( "test" ); assertLinkNotPresent( "test" );
} }
} }

View File

@ -23,288 +23,260 @@ import org.apache.archiva.web.test.parent.AbstractArchivaTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@Test( groups = { "userroles" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) @Test( groups = { "userroles" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public class UserRolesTest public class UserRolesTest
extends AbstractArchivaTest extends AbstractArchivaTest
{ {
public void testBasicAddDeleteUser() public void testBasicAddDeleteUser()
{ {
username = getProperty( "GUEST_USERNAME" ); username = getProperty( "GUEST_USERNAME" );
fullname = getProperty( "GUEST_FULLNAME" ); fullname = getProperty( "GUEST_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword(), true); createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
deleteUser( username, fullname, getUserEmail() ); deleteUser( username, fullname, getUserEmail() );
logout(); logout();
login( getAdminUsername() , getAdminPassword() ); login( getAdminUsername(), getAdminPassword() );
} }
@Test (dependsOnMethods = { "testBasicAddDeleteUser" } ) @Test( dependsOnMethods = { "testBasicAddDeleteUser" } )
public void testUserWithGuestRole() public void testUserWithGuestRole()
{ {
username = getProperty("GUEST_USERNAME"); username = getProperty( "GUEST_USERNAME" );
fullname = getProperty("GUEST_FULLNAME"); fullname = getProperty( "GUEST_FULLNAME" );
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true); createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
clickLinkWithText( username ); clickLinkWithText( username );
clickLinkWithText( "Edit Roles" ); clickLinkWithText( "Edit Roles" );
checkUserRoleWithValue( fullname ); checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" ); clickButtonWithValue( "Submit" );
logout(); logout();
login(username, getUserRolePassword()); login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword() );
// this section will be removed if issue from redback after changing password will be fixed. // this section will be removed if issue from redback after changing password will be fixed.
getSelenium().goBack(); getSelenium().goBack();
logout(); logout();
//assertTextPresent("You are already logged in."); // assertTextPresent("You are already logged in.");
login(username, getUserRoleNewPassword()); login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname ); assertLeftNavMenuWithRole( fullname );
logout(); logout();
login( getAdminUsername() , getAdminPassword() ); login( getAdminUsername(), getAdminPassword() );
} }
@Test (dependsOnMethods = { "testUserWithGuestRole" } ) @Test( dependsOnMethods = { "testUserWithGuestRole" } )
public void testUserWithRegisteredUserRole() public void testUserWithRegisteredUserRole()
{ {
username = getProperty("REGISTERED_USERNAME"); username = getProperty( "REGISTERED_USERNAME" );
fullname = getProperty("REGISTERED_FULLNAME"); fullname = getProperty( "REGISTERED_FULLNAME" );
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true); createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
clickLinkWithText( username ); clickLinkWithText( username );
clickLinkWithText( "Edit Roles" ); clickLinkWithText( "Edit Roles" );
checkUserRoleWithValue( fullname ); checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" ); clickButtonWithValue( "Submit" );
logout(); logout();
login(username, getUserRolePassword()); login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword() );
// this section will be removed if issue from redback after changing password will be fixed. // this section will be removed if issue from redback after changing password will be fixed.
getSelenium().goBack(); getSelenium().goBack();
logout(); logout();
//assertTextPresent("You are already logged in."); // assertTextPresent("You are already logged in.");
login(username, getUserRoleNewPassword()); login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname ); assertLeftNavMenuWithRole( fullname );
logout(); logout();
login( getAdminUsername() , getAdminPassword() ); login( getAdminUsername(), getAdminPassword() );
} }
@Test (dependsOnMethods = { "testUserWithRegisteredUserRole" } ) @Test( dependsOnMethods = { "testUserWithRegisteredUserRole" } )
public void testUserWithSysAdminUserRole() public void testUserWithSysAdminUserRole()
{ {
username = getProperty("SYSAD_USERNAME"); username = getProperty( "SYSAD_USERNAME" );
fullname = getProperty("SYSAD_FULLNAME"); fullname = getProperty( "SYSAD_FULLNAME" );
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true); createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
clickLinkWithText( username ); clickLinkWithText( username );
clickLinkWithText( "Edit Roles" ); clickLinkWithText( "Edit Roles" );
checkUserRoleWithValue( fullname ); checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" ); clickButtonWithValue( "Submit" );
logout(); logout();
login(username, getUserRolePassword()); login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword() );
// this section will be removed if issue from redback after changing password will be fixed. // this section will be removed if issue from redback after changing password will be fixed.
getSelenium().goBack(); getSelenium().goBack();
logout(); logout();
//assertTextPresent("You are already logged in."); // assertTextPresent("You are already logged in.");
login(username, getUserRoleNewPassword()); login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname ); assertLeftNavMenuWithRole( fullname );
logout(); logout();
login( getAdminUsername() , getAdminPassword() ); login( getAdminUsername(), getAdminPassword() );
} }
@Test (dependsOnMethods = { "testUserWithSysAdminUserRole" } ) @Test( dependsOnMethods = { "testUserWithSysAdminUserRole" } )
public void testUserWithUserAdminUserRole() public void testUserWithUserAdminUserRole()
{ {
username = getProperty("USERADMIN_USERNAME"); username = getProperty( "USERADMIN_USERNAME" );
fullname = getProperty("USERADMIN_FULLNAME"); fullname = getProperty( "USERADMIN_FULLNAME" );
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true); createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
clickLinkWithText( username ); clickLinkWithText( username );
clickLinkWithText( "Edit Roles" ); clickLinkWithText( "Edit Roles" );
checkUserRoleWithValue( fullname ); checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" ); clickButtonWithValue( "Submit" );
logout(); logout();
login(username, getUserRolePassword()); login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword() );
// this section will be removed if issue from redback after changing password will be fixed. // this section will be removed if issue from redback after changing password will be fixed.
getSelenium().goBack(); getSelenium().goBack();
logout(); logout();
//assertTextPresent("You are already logged in."); // assertTextPresent("You are already logged in.");
login(username, getUserRoleNewPassword()); login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname ); assertLeftNavMenuWithRole( fullname );
logout(); logout();
login( getAdminUsername() , getAdminPassword() ); login( getAdminUsername(), getAdminPassword() );
} }
@Test (dependsOnMethods = { "testUserWithUserAdminUserRole" } ) @Test( dependsOnMethods = { "testUserWithUserAdminUserRole" } )
public void testUserWithGlobalRepoManagerRole() public void testUserWithGlobalRepoManagerRole()
{ {
username = getProperty("GLOBALREPOMANAGER_USERNAME"); username = getProperty( "GLOBALREPOMANAGER_USERNAME" );
fullname = getProperty("GLOBALREPOMANAGER_FULLNAME"); fullname = getProperty( "GLOBALREPOMANAGER_FULLNAME" );
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true); createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
clickLinkWithText( username ); clickLinkWithText( username );
clickLinkWithText( "Edit Roles" ); clickLinkWithText( "Edit Roles" );
checkUserRoleWithValue( fullname ); checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" ); clickButtonWithValue( "Submit" );
logout(); logout();
login(username, getUserRolePassword()); login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword() );
// this section will be removed if issue from redback after changing password will be fixed.
getSelenium().goBack();
logout();
//assertTextPresent("You are already logged in.");
login(username, getUserRoleNewPassword());
assertLeftNavMenuWithRole( fullname );
logout();
login( getAdminUsername() , getAdminPassword() );
}
@Test (dependsOnMethods = { "testUserWithGlobalRepoManagerRole" } ) // this section will be removed if issue from redback after changing password will be fixed.
public void testUserWithGlobalRepoObserverRole() getSelenium().goBack();
{ logout();
username = getProperty("GLOBALREPOOBSERVER_USERNAME"); // assertTextPresent("You are already logged in.");
fullname = getProperty("GLOBALREPOOBSERVER_FULLNAME");
login( username, getUserRoleNewPassword() );
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true); assertLeftNavMenuWithRole( fullname );
clickLinkWithText( username ); logout();
clickLinkWithText( "Edit Roles" ); login( getAdminUsername(), getAdminPassword() );
checkUserRoleWithValue( fullname ); }
clickButtonWithValue( "Submit" );
@Test( dependsOnMethods = { "testUserWithGlobalRepoManagerRole" } )
public void testUserWithGlobalRepoObserverRole()
{
username = getProperty( "GLOBALREPOOBSERVER_USERNAME" );
fullname = getProperty( "GLOBALREPOOBSERVER_FULLNAME" );
createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
clickLinkWithText( username );
clickLinkWithText( "Edit Roles" );
checkUserRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
logout(); logout();
login(username, getUserRolePassword()); login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword() );
// this section will be removed if issue from redback after changing password will be fixed. // this section will be removed if issue from redback after changing password will be fixed.
getSelenium().goBack(); getSelenium().goBack();
logout(); logout();
//assertTextPresent("You are already logged in."); // assertTextPresent("You are already logged in.");
login(username, getUserRoleNewPassword()); login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname ); assertLeftNavMenuWithRole( fullname );
logout(); logout();
login( getAdminUsername() , getAdminPassword() ); login( getAdminUsername(), getAdminPassword() );
} }
@Test (dependsOnMethods = { "testUserWithGlobalRepoObserverRole" } ) @Test( dependsOnMethods = { "testUserWithGlobalRepoObserverRole" } )
public void testUserWithRepoManagerInternalRole() public void testUserWithRepoManagerInternalRole()
{ {
username = getProperty("REPOMANAGER_INTERNAL_USERNAME"); username = getProperty( "REPOMANAGER_INTERNAL_USERNAME" );
fullname = getProperty("REPOMANAGER_INTERNAL_FULLNAME"); fullname = getProperty( "REPOMANAGER_INTERNAL_FULLNAME" );
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true); createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
clickLinkWithText( username ); clickLinkWithText( username );
clickLinkWithText( "Edit Roles" ); clickLinkWithText( "Edit Roles" );
checkResourceRoleWithValue( fullname ); checkResourceRoleWithValue( fullname );
clickButtonWithValue( "Submit" ); clickButtonWithValue( "Submit" );
logout(); logout();
login(username, getUserRolePassword()); login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword() );
// this section will be removed if issue from redback after changing password will be fixed. // this section will be removed if issue from redback after changing password will be fixed.
getSelenium().goBack(); getSelenium().goBack();
logout(); logout();
//assertTextPresent("You are already logged in."); // assertTextPresent("You are already logged in.");
login(username, getUserRoleNewPassword()); login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname ); assertLeftNavMenuWithRole( fullname );
logout(); logout();
login( getAdminUsername() , getAdminPassword() ); login( getAdminUsername(), getAdminPassword() );
} }
/*@Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } ) /*
public void testUserWithRepoManagerSnapshotsRole() * @Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } ) public void
{ * testUserWithRepoManagerSnapshotsRole() { username = getProperty("REPOMANAGER_SNAPSHOTS_USERNAME"); fullname =
username = getProperty("REPOMANAGER_SNAPSHOTS_USERNAME"); * getProperty("REPOMANAGER_SNAPSHOTS_FULLNAME"); createUser(username, fullname, getUserEmail(),
fullname = getProperty("REPOMANAGER_SNAPSHOTS_FULLNAME"); * getUserRolePassword(), true); clickLinkWithText( username ); clickLinkWithText( "Edit Roles" );
* checkResourceRoleWithValue( fullname ); clickButtonWithValue( "Submit" ); clickLinkWithText("Logout");
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true); * login(username, getUserRolePassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword()); // this
clickLinkWithText( username ); * section will be removed if issue from redback after changing password will be fixed. getSelenium().goBack();
clickLinkWithText( "Edit Roles" ); * clickLinkWithText("Logout"); //assertTextPresent("You are already logged in."); login(username,
checkResourceRoleWithValue( fullname ); * getUserRoleNewPassword()); assertLeftNavMenuWithRole( fullname ); clickLinkWithText("Logout"); login(
clickButtonWithValue( "Submit" ); * getAdminUsername() , getAdminPassword() ); }
*/
clickLinkWithText("Logout");
login(username, getUserRolePassword()); @Test( dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
changePassword( getUserRolePassword(), getUserRoleNewPassword()); public void testUserWithRepoObserverInternalRole()
{
// this section will be removed if issue from redback after changing password will be fixed. username = getProperty( "REPOOBSERVER_INTERNAL_USERNAME" );
getSelenium().goBack(); fullname = getProperty( "REPOOBSERVER_INTERNAL_FULLNAME" );
clickLinkWithText("Logout");
//assertTextPresent("You are already logged in."); createUser( username, fullname, getUserEmail(), getUserRolePassword(), true );
clickLinkWithText( username );
login(username, getUserRoleNewPassword()); clickLinkWithText( "Edit Roles" );
assertLeftNavMenuWithRole( fullname ); checkResourceRoleWithValue( fullname );
clickLinkWithText("Logout"); clickButtonWithValue( "Submit" );
login( getAdminUsername() , getAdminPassword() );
}*/
@Test (dependsOnMethods = { "testUserWithRepoManagerInternalRole" } )
public void testUserWithRepoObserverInternalRole()
{
username = getProperty( "REPOOBSERVER_INTERNAL_USERNAME" );
fullname = getProperty( "REPOOBSERVER_INTERNAL_FULLNAME" );
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true);
clickLinkWithText( username );
clickLinkWithText( "Edit Roles" );
checkResourceRoleWithValue( fullname );
clickButtonWithValue( "Submit" );
logout(); logout();
login(username, getUserRolePassword()); login( username, getUserRolePassword() );
changePassword( getUserRolePassword(), getUserRoleNewPassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword() );
// this section will be removed if issue from redback after changing password will be fixed. // this section will be removed if issue from redback after changing password will be fixed.
getSelenium().goBack(); getSelenium().goBack();
logout(); logout();
//assertTextPresent("You are already logged in."); // assertTextPresent("You are already logged in.");
login(username, getUserRoleNewPassword()); login( username, getUserRoleNewPassword() );
assertLeftNavMenuWithRole( fullname ); assertLeftNavMenuWithRole( fullname );
logout(); logout();
login( getAdminUsername() , getAdminPassword() ); login( getAdminUsername(), getAdminPassword() );
} }
/*@Test (dependsOnMethods = { "testUserWithRepoObserverInternalRole" } ) /*
public void testUserWithRepoObserverSnapshotsRole() * @Test (dependsOnMethods = { "testUserWithRepoObserverInternalRole" } ) public void
{ * testUserWithRepoObserverSnapshotsRole() { username = getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" ); fullname =
username = getProperty( "REPOOBSERVER_SNAPSHOTS_USERNAME" ); * getProperty( "REPOOBSERVER_SNAPSHOTS_FULLNAME" ); createUser(username, fullname, getUserEmail(),
fullname = getProperty( "REPOOBSERVER_SNAPSHOTS_FULLNAME" ); * getUserRolePassword(), true); clickLinkWithText( username ); clickLinkWithText( "Edit Roles" );
* checkResourceRoleWithValue( fullname ); clickButtonWithValue( "Submit" ); clickLinkWithText("Logout");
createUser(username, fullname, getUserEmail(), getUserRolePassword(), true); * login(username, getUserRolePassword()); changePassword( getUserRolePassword(), getUserRoleNewPassword()); // this
clickLinkWithText( username ); * section will be removed if issue from redback after changing password will be fixed. getSelenium().goBack();
clickLinkWithText( "Edit Roles" ); * clickLinkWithText("Logout"); //assertTextPresent("You are already logged in."); login(username,
checkResourceRoleWithValue( fullname ); * getUserRoleNewPassword()); assertLeftNavMenuWithRole( fullname ); clickLinkWithText("Logout"); login(
clickButtonWithValue( "Submit" ); * getAdminUsername() , getAdminPassword() ); }
*/
clickLinkWithText("Logout"); }
login(username, getUserRolePassword());
changePassword( getUserRolePassword(), getUserRoleNewPassword());
// this section will be removed if issue from redback after changing password will be fixed.
getSelenium().goBack();
clickLinkWithText("Logout");
//assertTextPresent("You are already logged in.");
login(username, getUserRoleNewPassword());
assertLeftNavMenuWithRole( fullname );
clickLinkWithText("Logout");
login( getAdminUsername() , getAdminPassword() );
}*/
}

View File

@ -24,53 +24,52 @@ import org.testng.annotations.Test;
import org.testng.Assert; import org.testng.Assert;
@Test( groups = { "virtualrepository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) @Test( groups = { "virtualrepository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public class VirtualRepositoryTest public class VirtualRepositoryTest
extends AbstractRepositoryTest extends AbstractRepositoryTest
{ {
public void testAddRepositoryGroupNullValue() public void testAddRepositoryGroupNullValue()
{ {
addRepositoryGroup( " " ); addRepositoryGroup( " " );
assertTextPresent( "Identifier field is required." ); assertTextPresent( "Identifier field is required." );
} }
@Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } ) @Test( dependsOnMethods = { "testWithCorrectUsernamePassword" } )
public void testAddRepositoryGroupValidValue() public void testAddRepositoryGroupValidValue()
{ {
addRepositoryGroup( "testing" ); addRepositoryGroup( "testing" );
//assertAddedRepositoryLink( "testing" ); // assertAddedRepositoryLink( "testing" );
Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[1]/p[1]" ), "testing" ); Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[1]/p[1]" ), "testing" );
} }
@Test(dependsOnMethods = { "testAddRepositoryGroupValidValue" } ) @Test( dependsOnMethods = { "testAddRepositoryGroupValidValue" } )
public void testAddRepositoryToRepositoryGroup() public void testAddRepositoryToRepositoryGroup()
{ {
addRepositoryToRepositoryGroup( "testing", "internal" ); addRepositoryToRepositoryGroup( "testing", "internal" );
Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ), "internal" ); Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ),
//clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" ); "internal" );
//getSelenium().goBack(); // clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" );
} // getSelenium().goBack();
}
@Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } )
public void testDeleteRepositoryOfRepositoryGroup() @Test( dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } )
{ public void testDeleteRepositoryOfRepositoryGroup()
deleteRepositoryInRepositoryGroups(); {
assertTextPresent( "Repository Groups" ); deleteRepositoryInRepositoryGroups();
assertTextNotPresent( "No Repository Groups Defined." ); assertTextPresent( "Repository Groups" );
Assert.assertFalse( getSelenium().isElementPresent( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ) ); assertTextNotPresent( "No Repository Groups Defined." );
} Assert.assertFalse( getSelenium().isElementPresent( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ) );
}
@Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } )
public void testDeleteRepositoryGroup() @Test( dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } )
{ public void testDeleteRepositoryGroup()
assertRepositoryGroupsPage(); {
deleteRepositoryGroup( "testing" ); assertRepositoryGroupsPage();
assertTextPresent( "No Repository Groups Defined." ); deleteRepositoryGroup( "testing" );
} assertTextPresent( "No Repository Groups Defined." );
}
/*@Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } )
public void testCheckRepositoryGroup() /*
{ * @Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } ) public void testCheckRepositoryGroup() {
clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" ); * clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" ); getSelenium().goBack(); }
getSelenium().goBack(); */
}*/ }
}

View File

@ -62,7 +62,7 @@ public class XPathExpressionUtil
xpathExpression += LIST; xpathExpression += LIST;
xpathExpression += START_NODE_TEST; xpathExpression += START_NODE_TEST;
for (int nIndex = 0; nIndex < values.length; nIndex++ ) for ( int nIndex = 0; nIndex < values.length; nIndex++ )
{ {
xpathExpression += ( ( nIndex > 0 ) ? AND : "" ); xpathExpression += ( ( nIndex > 0 ) ? AND : "" );
xpathExpression += contains( LINE + position( nIndex + 1 ), values[nIndex] ); xpathExpression += contains( LINE + position( nIndex + 1 ), values[nIndex] );
@ -76,8 +76,8 @@ public class XPathExpressionUtil
/** /**
* expression for acquiring an element in one of the table columns * expression for acquiring an element in one of the table columns
* *
* @param element the node element * @param element the node element
* @param elementIndex column index of the element, used for skipping * @param elementIndex column index of the element, used for skipping
* @param columnValues the values to be matched in each column, element column is included * @param columnValues the values to be matched in each column, element column is included
* @return * @return
@ -89,38 +89,36 @@ public class XPathExpressionUtil
/** /**
* expression for acquiring an element in one of the table columns * expression for acquiring an element in one of the table columns
* *
* @param element the node element * @param element the node element
* @param elementIndex column index of the element, used for skipping * @param elementIndex column index of the element, used for skipping
* @param elementValue the matched element value * @param elementValue the matched element value
* @param columnValues the values to be matched in each column, element column is included * @param columnValues the values to be matched in each column, element column is included
* @return * @return
*/ */
public static String getColumnElement( String element, int elementIndex, String elementValue, public static String getColumnElement( String element, int elementIndex, String elementValue, String[] columnValues )
String[] columnValues )
{ {
return getColumnElement( element, elementIndex, elementValue, "TEXT", columnValues ); return getColumnElement( element, elementIndex, elementValue, "TEXT", columnValues );
} }
/** /**
* expression for acquiring an element in one of the table columns * expression for acquiring an element in one of the table columns
* *
* @param element the node element * @param element the node element
* @param elementIndex column index of the element, used for skipping * @param elementIndex column index of the element, used for skipping
* @param imageName the matched image name * @param imageName the matched image name
* @param columnValues the values to be matched in each column, element column is included * @param columnValues the values to be matched in each column, element column is included
* @return * @return
*/ */
public static String getImgColumnElement( String element, int elementIndex, String imageName, public static String getImgColumnElement( String element, int elementIndex, String imageName, String[] columnValues )
String[] columnValues )
{ {
return getColumnElement( element, elementIndex, imageName, IMG, columnValues ); return getColumnElement( element, elementIndex, imageName, IMG, columnValues );
} }
/** /**
* expression for acquiring an element in one of the table columns * expression for acquiring an element in one of the table columns
* *
* @param element the node element * @param element the node element
* @param elementIndex column index of the element, used for skipping * @param elementIndex column index of the element, used for skipping
* @param imageName the matched image name * @param imageName the matched image name
* @param columnValues the values to be matched in each column, element column is included * @param columnValues the values to be matched in each column, element column is included
@ -160,9 +158,8 @@ public class XPathExpressionUtil
} }
/** /**
* expression for acquiring the table row that matches all column values with the same order * expression for acquiring the table row that matches all column values with the same order as the list
* as the list *
*
* @param columnValues the matched list of columnValues * @param columnValues the matched list of columnValues
* @return * @return
*/ */

View File

@ -106,4 +106,4 @@ public class CaptureScreenShotsListener
i--; i--;
return i; return i;
} }
} }

View File

@ -24,31 +24,32 @@ import org.apache.archiva.web.test.XPathExpressionUtil;
* under the License. * under the License.
*/ */
public abstract class AbstractArchivaTest public abstract class AbstractArchivaTest
extends AbstractSeleniumTest extends AbstractSeleniumTest
{ {
protected String username; protected String username;
protected String fullname;
public String getUserEmail()
{
String email = getProperty("USERROLE_EMAIL");
return email;
}
public String getUserRolePassword()
{
String password = getProperty("USERROLE_PASSWORD");
return password;
}
public String getUserRoleNewPassword() protected String fullname;
{
String password_new = getProperty( "NEW_USERROLE_PASSWORD" );
return password_new;
}
public String getBasedir() public String getUserEmail()
{
String email = getProperty( "USERROLE_EMAIL" );
return email;
}
public String getUserRolePassword()
{
String password = getProperty( "USERROLE_PASSWORD" );
return password;
}
public String getUserRoleNewPassword()
{
String password_new = getProperty( "NEW_USERROLE_PASSWORD" );
return password_new;
}
public String getBasedir()
{ {
String basedir = System.getProperty( "basedir" ); String basedir = System.getProperty( "basedir" );
@ -59,208 +60,207 @@ public abstract class AbstractArchivaTest
return basedir; return basedir;
} }
public String getAdminUsername()
{
String adminUsername = getProperty( "ADMIN_USERNAME" );
return adminUsername;
}
public String getAdminPassword()
{
String adminPassword = getProperty( "ADMIN_PASSWORD" );
return adminPassword;
}
public void assertCreateAdmin()
{
assertPage( "Apache Archiva \\ Create Admin User" );
assertTextPresent( "Username" );
assertFieldValue( "admin", "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" );
assertButtonWithValuePresent( "Create Admin" );
}
public void submitAdminData( String fullname, String email, String password )
{
setFieldValue( "user.fullName", fullname );
setFieldValue( "user.email", email );
setFieldValue( "user.password", password );
setFieldValue( "user.confirmPassword", password );
submit();
}
//Go to Login Page
public void goToLoginPage()
{
getSelenium().open( baseUrl );
clickLinkWithText( "Login");
assertLoginPage();
}
public void submitUserData( String username, String password, boolean rememberme, boolean success )
{
setFieldValue( "username", username ); public String getAdminUsername()
setFieldValue( "password", password ); {
if ( rememberme ) String adminUsername = getProperty( "ADMIN_USERNAME" );
{ return adminUsername;
checkField( "rememberMe" ); }
}
submit();
if ( success )
{
assertUserLoggedIn( username );
}
else
{
assertLoginPage();
}
}
public void assertLoginPage()
{
assertPage( "Apache Archiva \\ Login Page" );
assertTextPresent( "Login" );
assertTextPresent( "Register" );
assertTextPresent( "Username" );
assertElementPresent( "username" );
assertTextPresent( "Password" );
assertElementPresent( "password" );
assertTextPresent( "Remember Me" );
assertElementPresent( "rememberMe" );
assertButtonWithValuePresent( "Login" );
assertButtonWithValuePresent( "Cancel" );
assertTextPresent( "Need an Account? Register!" );
assertTextPresent( "Forgot your Password? Request a password reset." );
}
//User Management public String getAdminPassword()
public void goToUserManagementPage() {
{ String adminPassword = getProperty( "ADMIN_PASSWORD" );
clickLinkWithText( "User Management" ); return adminPassword;
assertUserManagementPage(); }
}
public void assertCreateAdmin()
public void assertUserManagementPage() {
{ assertPage( "Apache Archiva \\ Create Admin User" );
assertPage( "Apache Archiva \\ [Admin] User List" ); assertTextPresent( "Username" );
assertTextPresent( "[Admin] List of Users in Role: Any" ); assertFieldValue( "admin", "user.username" );
assertTextPresent( "Navigation" ); assertTextPresent( "Full Name*" );
assertImgWithAlt( "First" ); assertElementPresent( "user.fullName" );
assertImgWithAlt( "Prev" ); assertTextPresent( "Email Address*" );
assertImgWithAlt( "Next" ); assertElementPresent( "user.email" );
assertImgWithAlt( "Last" ); assertTextPresent( "Password*" );
assertTextPresent( "Display Rows" ); assertElementPresent( "user.password" );
assertTextPresent( "Username" ); assertTextPresent( "Confirm Password*" );
assertTextPresent( "Full Name" ); assertElementPresent( "user.confirmPassword" );
assertTextPresent( "Email" ); assertButtonWithValuePresent( "Create Admin" );
assertTextPresent( "Permanent" ); }
assertTextPresent( "Validated" );
assertTextPresent( "Locked" ); public void submitAdminData( String fullname, String email, String password )
assertTextPresent( "Tasks" ); {
assertTextPresent( "Tools" ); setFieldValue( "user.fullName", fullname );
assertTextPresent( "Tasks" ); setFieldValue( "user.email", email );
assertTextPresent( "The following tools are available for administrators to manipulate the user list." ); setFieldValue( "user.password", password );
assertButtonWithValuePresent( "Create New User" ); setFieldValue( "user.confirmPassword", password );
assertButtonWithValuePresent( "Show Users In Role" ); submit();
assertElementPresent( "roleName" ); }
assertTextPresent( "Reports" );
assertTextPresent( "Name" ); // Go to Login Page
assertTextPresent( "Types" ); public void goToLoginPage()
assertTextPresent( "User List" ); {
assertTextPresent( "Roles Matrix" ); getSelenium().open( baseUrl );
} clickLinkWithText( "Login" );
assertLoginPage();
/* //User Role }
public void goToUserRolesPage()
{ public void submitUserData( String username, String password, boolean rememberme, boolean success )
clickLinkWithText( "User Roles" ); {
assertUserRolesPage();
}*/ setFieldValue( "username", username );
setFieldValue( "password", password );
public void assertUserRolesPage() if ( rememberme )
{ {
assertPage( "Apache Archiva \\ [Admin] User Edit" ); checkField( "rememberMe" );
assertTextPresent( "[Admin] User Roles" ); }
assertTextPresent( "Username" );
assertTextPresent( "Full Name" ); submit();
String userRoles = "Guest,Registered User,System Administrator,User Administrator,Global Repository Observer,Global Repository Manager,Repository Observer,Repository Manager,internal"; if ( success )
String[] arrayRole = userRoles.split( "," ); {
for ( String userroles : arrayRole ) assertUserLoggedIn( username );
assertTextPresent( userroles ); }
} else
{
public void assertDeleteUserPage( String username ) assertLoginPage();
{ }
assertPage( "Apache Archiva \\ [Admin] User Delete" ); //TODO }
assertTextPresent( "[Admin] User Delete" );
assertTextPresent( "The following user will be deleted:" ); public void assertLoginPage()
assertTextPresent( "Username: " + username ); {
assertButtonWithValuePresent( "Delete User" ); assertPage( "Apache Archiva \\ Login Page" );
} assertTextPresent( "Login" );
assertTextPresent( "Register" );
public void createUser( String userName, String fullName, String email, String password, boolean valid ) assertTextPresent( "Username" );
{ assertElementPresent( "username" );
createUser( userName, fullName, email, password, password, valid ); assertTextPresent( "Password" );
} assertElementPresent( "password" );
assertTextPresent( "Remember Me" );
private void createUser( String userName, String fullName, String emailAd, String password, String confirmPassword, boolean valid ) assertElementPresent( "rememberMe" );
{ assertButtonWithValuePresent( "Login" );
//login( getAdminUsername() , getAdminPassword() ); assertButtonWithValuePresent( "Cancel" );
clickLinkWithText( "User Management" ); assertTextPresent( "Need an Account? Register!" );
clickButtonWithValue( "Create New User" ); assertTextPresent( "Forgot your Password? Request a password reset." );
assertCreateUserPage(); }
// User Management
public void goToUserManagementPage()
{
clickLinkWithText( "User Management" );
assertUserManagementPage();
}
public void assertUserManagementPage()
{
assertPage( "Apache Archiva \\ [Admin] User List" );
assertTextPresent( "[Admin] List of Users in Role: Any" );
assertTextPresent( "Navigation" );
assertImgWithAlt( "First" );
assertImgWithAlt( "Prev" );
assertImgWithAlt( "Next" );
assertImgWithAlt( "Last" );
assertTextPresent( "Display Rows" );
assertTextPresent( "Username" );
assertTextPresent( "Full Name" );
assertTextPresent( "Email" );
assertTextPresent( "Permanent" );
assertTextPresent( "Validated" );
assertTextPresent( "Locked" );
assertTextPresent( "Tasks" );
assertTextPresent( "Tools" );
assertTextPresent( "Tasks" );
assertTextPresent( "The following tools are available for administrators to manipulate the user list." );
assertButtonWithValuePresent( "Create New User" );
assertButtonWithValuePresent( "Show Users In Role" );
assertElementPresent( "roleName" );
assertTextPresent( "Reports" );
assertTextPresent( "Name" );
assertTextPresent( "Types" );
assertTextPresent( "User List" );
assertTextPresent( "Roles Matrix" );
}
/*
* //User Role public void goToUserRolesPage() { clickLinkWithText( "User Roles" ); assertUserRolesPage(); }
*/
public void assertUserRolesPage()
{
assertPage( "Apache Archiva \\ [Admin] User Edit" );
assertTextPresent( "[Admin] User Roles" );
assertTextPresent( "Username" );
assertTextPresent( "Full Name" );
String userRoles =
"Guest,Registered User,System Administrator,User Administrator,Global Repository Observer,Global Repository Manager,Repository Observer,Repository Manager,internal";
String[] arrayRole = userRoles.split( "," );
for ( String userroles : arrayRole )
assertTextPresent( userroles );
}
public void assertDeleteUserPage( String username )
{
assertPage( "Apache Archiva \\ [Admin] User Delete" ); // TODO
assertTextPresent( "[Admin] User Delete" );
assertTextPresent( "The following user will be deleted:" );
assertTextPresent( "Username: " + username );
assertButtonWithValuePresent( "Delete User" );
}
public void createUser( String userName, String fullName, String email, String password, boolean valid )
{
createUser( userName, fullName, email, password, password, valid );
}
private void createUser( String userName, String fullName, String emailAd, String password, String confirmPassword,
boolean valid )
{
// login( getAdminUsername() , getAdminPassword() );
clickLinkWithText( "User Management" );
clickButtonWithValue( "Create New User" );
assertCreateUserPage();
setFieldValue( "user.username", userName ); setFieldValue( "user.username", userName );
setFieldValue( "user.fullName", fullName ); setFieldValue( "user.fullName", fullName );
setFieldValue( "user.email", emailAd ); setFieldValue( "user.email", emailAd );
setFieldValue( "user.password", password ); setFieldValue( "user.password", password );
setFieldValue( "user.confirmPassword", confirmPassword ); setFieldValue( "user.confirmPassword", confirmPassword );
submit(); submit();
assertUserRolesPage( ); assertUserRolesPage();
clickButtonWithValue( "Submit" ); clickButtonWithValue( "Submit" );
if (valid ) if ( valid )
{ {
String[] columnValues = {userName, fullName, emailAd}; String[] columnValues = { userName, fullName, emailAd };
assertElementPresent( XPathExpressionUtil.getTableRow( columnValues ) ); assertElementPresent( XPathExpressionUtil.getTableRow( columnValues ) );
} }
else else
{ {
assertCreateUserPage(); assertCreateUserPage();
} }
} }
public void deleteUser( String userName, String fullName, String emailAdd ) public void deleteUser( String userName, String fullName, String emailAdd )
{ {
deleteUser( userName, fullName, emailAdd, false, false ); deleteUser( userName, fullName, emailAdd, false, false );
} }
public void deleteUser(String userName, String fullName, String emailAd, boolean validated, boolean locked) public void deleteUser( String userName, String fullName, String emailAd, boolean validated, boolean locked )
{ {
String[] columnValues = {userName, fullName, emailAd}; String[] columnValues = { userName, fullName, emailAd };
//clickLinkWithText( "userlist" ); // clickLinkWithText( "userlist" );
clickLinkWithXPath( "//table[@id='ec_table']/tbody[2]/tr[3]/td[7]/a/img" ); clickLinkWithXPath( "//table[@id='ec_table']/tbody[2]/tr[3]/td[7]/a/img" );
assertDeleteUserPage( userName ); assertDeleteUserPage( userName );
submit(); submit();
assertElementNotPresent( XPathExpressionUtil.getTableRow( columnValues ) ); assertElementNotPresent( XPathExpressionUtil.getTableRow( columnValues ) );
} }
public void login( String username, String password ) public void login( String username, String password )
{ {
login( username, password, true, "Login Page" ); login( username, password, true, "Login Page" );
} }
public void login( String username, String password, boolean valid, String assertReturnPage ) public void login( String username, String password, boolean valid, String assertReturnPage )
{ {
if ( isLinkPresent( "Login" ) ) if ( isLinkPresent( "Login" ) )
{ {
@ -273,7 +273,7 @@ public abstract class AbstractArchivaTest
assertUserLoggedIn( username ); assertUserLoggedIn( username );
} }
} }
public void submitLoginPage( String username, String password ) public void submitLoginPage( String username, String password )
{ {
submitLoginPage( username, password, false, true, "Login Page" ); submitLoginPage( username, password, false, true, "Login Page" );
@ -323,133 +323,143 @@ public abstract class AbstractArchivaTest
} }
// User Roles // User Roles
public void assertUserRoleCheckBoxPresent(String value) public void assertUserRoleCheckBoxPresent( String value )
{ {
getSelenium() .isElementPresent("xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value + "']"); getSelenium().isElementPresent(
} "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='"
+ value + "']" );
}
public void assertResourceRolesCheckBoxPresent(String value) { public void assertResourceRolesCheckBoxPresent( String value )
getSelenium().isElementPresent("xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']"); {
} getSelenium().isElementPresent( "xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']" );
}
public void checkUserRoleWithValue(String value) public void checkUserRoleWithValue( String value )
{ {
assertUserRoleCheckBoxPresent(value); assertUserRoleCheckBoxPresent( value );
getSelenium().click( "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value + "']"); getSelenium().click(
} "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='"
+ value + "']" );
}
public void checkResourceRoleWithValue(String value) public void checkResourceRoleWithValue( String value )
{ {
assertResourceRolesCheckBoxPresent(value); assertResourceRolesCheckBoxPresent( value );
getSelenium().click( "xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']" ); getSelenium().click( "xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']" );
} }
public void changePassword(String oldPassword, String newPassword) {
assertPage("Apache Archiva \\ Change Password");
setFieldValue("existingPassword", oldPassword);
setFieldValue("newPassword", newPassword);
setFieldValue("newPasswordConfirm", newPassword);
clickButtonWithValue("Change Password");
}
public void assertCreateUserPage()
{
assertPage( "Apache Archiva \\ [Admin] User Create" );
assertTextPresent( "[Admin] User Create" );
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" );
assertButtonWithValuePresent( "Create User" );
}
public void assertLeftNavMenuWithRole( String role )
{
if ( role.equals( "Guest" ) || role.equals( "Registered User" ) || role.equals( "Global Repository Observer" ) || role.equals( "Repository Observer - internal" ) || role.equals( "Repository Observer - snapshots" ) )
{
assertTextPresent( "Search" );
assertLinkPresent( "Find Artifact" );
assertLinkPresent( "Browse" );
assertLinkNotPresent( "Repositories" );
}
else if ( role.equals( "User Administrator" ) )
{
assertTextPresent( "Search" );
assertLinkPresent( "Find Artifact" );
assertLinkPresent( "Browse" );
assertLinkPresent( "User Management" );
assertLinkPresent( "User Roles" );
assertLinkNotPresent( "Repositories" );
}
else if ( role.equals( "Global Repository Manager" ) || role.equals( "Repository Manager - internal" ) || role.equals( "Repository Manager - snapshots" ) )
{
assertTextPresent( "Search" );
assertLinkPresent( "Find Artifact" );
assertLinkPresent( "Browse" );
assertLinkPresent( "Upload Artifact" );
assertLinkPresent( "Delete Artifact" );
assertLinkNotPresent( "Repositories" );
}
else
{
assertTextPresent( "Search" );
String navMenu = "Find Artifact,Browse,Reports,User Management,User Roles,Appearance,Upload Artifact,Delete Artifact,Repository Groups,Repositories,Proxy Connectors,Legacy Support,Network Proxies,Repository Scanning";
String[] arrayMenu = navMenu.split( "," );
for (String navmenu : arrayMenu )
assertLinkPresent( navmenu );
}
}
//Find Artifact
public void goToFindArtifactPage()
{
clickLinkWithText( "Find Artifact" );
assertFindArtifactPage();
}
public void assertFindArtifactPage()
{
assertPage( "Apache Archiva \\ Find Artifact" );
assertTextPresent( "Find Artifact" );
assertTextPresent( "Search for:" );
assertTextPresent( "Checksum:" );
assertElementPresent( "q" );
assertButtonWithValuePresent( "Search" );
}
//Appearance
public void goToAppearancePage()
{
clickLinkWithText( "Appearance" );
assertAppearancePage();
}
public void assertAppearancePage()
{
assertPage( "Apache Archiva \\ Configure Appearance" );
String appearance = "Appearance,Organization Details,The logo in the top right of the screen is controlled by the following settings.,Organization Information,Name,URL,Logo URL";
String[] arrayAppearance = appearance.split( "," );
for ( String appear : arrayAppearance )
assertTextPresent( appear );
assertLinkPresent( "Edit" );
assertLinkPresent( "Change your appearance" );
}
public void addEditAppearance( String name, String url, String logoUrl )
{
setFieldValue( "organisationName" , name );
setFieldValue( "organisationUrl" , url );
setFieldValue( "organisationLogo" , logoUrl );
clickButtonWithValue( "Save" );
}
// Upload Artifact public void changePassword( String oldPassword, String newPassword )
{
assertPage( "Apache Archiva \\ Change Password" );
setFieldValue( "existingPassword", oldPassword );
setFieldValue( "newPassword", newPassword );
setFieldValue( "newPasswordConfirm", newPassword );
clickButtonWithValue( "Change Password" );
}
public void assertCreateUserPage()
{
assertPage( "Apache Archiva \\ [Admin] User Create" );
assertTextPresent( "[Admin] User Create" );
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" );
assertButtonWithValuePresent( "Create User" );
}
public void assertLeftNavMenuWithRole( String role )
{
if ( role.equals( "Guest" ) || role.equals( "Registered User" ) || role.equals( "Global Repository Observer" )
|| role.equals( "Repository Observer - internal" ) || role.equals( "Repository Observer - snapshots" ) )
{
assertTextPresent( "Search" );
assertLinkPresent( "Find Artifact" );
assertLinkPresent( "Browse" );
assertLinkNotPresent( "Repositories" );
}
else if ( role.equals( "User Administrator" ) )
{
assertTextPresent( "Search" );
assertLinkPresent( "Find Artifact" );
assertLinkPresent( "Browse" );
assertLinkPresent( "User Management" );
assertLinkPresent( "User Roles" );
assertLinkNotPresent( "Repositories" );
}
else if ( role.equals( "Global Repository Manager" ) || role.equals( "Repository Manager - internal" )
|| role.equals( "Repository Manager - snapshots" ) )
{
assertTextPresent( "Search" );
assertLinkPresent( "Find Artifact" );
assertLinkPresent( "Browse" );
assertLinkPresent( "Upload Artifact" );
assertLinkPresent( "Delete Artifact" );
assertLinkNotPresent( "Repositories" );
}
else
{
assertTextPresent( "Search" );
String navMenu =
"Find Artifact,Browse,Reports,User Management,User Roles,Appearance,Upload Artifact,Delete Artifact,Repository Groups,Repositories,Proxy Connectors,Legacy Support,Network Proxies,Repository Scanning";
String[] arrayMenu = navMenu.split( "," );
for ( String navmenu : arrayMenu )
assertLinkPresent( navmenu );
}
}
// Find Artifact
public void goToFindArtifactPage()
{
clickLinkWithText( "Find Artifact" );
assertFindArtifactPage();
}
public void assertFindArtifactPage()
{
assertPage( "Apache Archiva \\ Find Artifact" );
assertTextPresent( "Find Artifact" );
assertTextPresent( "Search for:" );
assertTextPresent( "Checksum:" );
assertElementPresent( "q" );
assertButtonWithValuePresent( "Search" );
}
// Appearance
public void goToAppearancePage()
{
clickLinkWithText( "Appearance" );
assertAppearancePage();
}
public void assertAppearancePage()
{
assertPage( "Apache Archiva \\ Configure Appearance" );
String appearance =
"Appearance,Organization Details,The logo in the top right of the screen is controlled by the following settings.,Organization Information,Name,URL,Logo URL";
String[] arrayAppearance = appearance.split( "," );
for ( String appear : arrayAppearance )
assertTextPresent( appear );
assertLinkPresent( "Edit" );
assertLinkPresent( "Change your appearance" );
}
public void addEditAppearance( String name, String url, String logoUrl )
{
setFieldValue( "organisationName", name );
setFieldValue( "organisationUrl", url );
setFieldValue( "organisationLogo", logoUrl );
clickButtonWithValue( "Save" );
}
// Upload Artifact
public void goToAddArtifactPage() public void goToAddArtifactPage()
{ {
clickLinkWithText( "Upload Artifact" ); clickLinkWithText( "Upload Artifact" );
@ -520,44 +530,44 @@ public abstract class AbstractArchivaTest
public void goToRepositoriesPage() public void goToRepositoriesPage()
{ {
if( !getTitle().equals( "Apache Archiva \\ Administration - Repositories" ) ) if ( !getTitle().equals( "Apache Archiva \\ Administration - Repositories" ) )
{ {
clickLinkWithText( "Repositories" ); clickLinkWithText( "Repositories" );
} }
assertRepositoriesPage(); assertRepositoriesPage();
} }
public void assertRepositoriesPage() public void assertRepositoriesPage()
{ {
assertPage( "Apache Archiva \\ Administration - Repositories" ); assertPage( "Apache Archiva \\ Administration - Repositories" );
assertTextPresent( "Administration - Repositories" ); assertTextPresent( "Administration - Repositories" );
assertTextPresent( "Managed Repositories" ); assertTextPresent( "Managed Repositories" );
assertTextPresent( "Remote Repositories" ); assertTextPresent( "Remote Repositories" );
} }
public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron, public void addManagedRepository( String identifier, String name, String directory, String indexDirectory,
String daysOlder, String retentionCount ) String type, String cron, String daysOlder, String retentionCount )
{ {
//goToRepositoriesPage(); // goToRepositoriesPage();
//clickLinkWithText( "Add" ); // clickLinkWithText( "Add" );
setFieldValue( "repository.id" , identifier ); setFieldValue( "repository.id", identifier );
setFieldValue( "repository.name" , name ); setFieldValue( "repository.name", name );
setFieldValue( "repository.location" , directory ); setFieldValue( "repository.location", directory );
setFieldValue( "repository.indexDir" , indexDirectory ); setFieldValue( "repository.indexDir", indexDirectory );
selectValue( "repository.layout", type ); selectValue( "repository.layout", type );
setFieldValue( "repository.refreshCronExpression" , cron ); setFieldValue( "repository.refreshCronExpression", cron );
setFieldValue( "repository.daysOlder" , daysOlder ); setFieldValue( "repository.daysOlder", daysOlder );
setFieldValue( "repository.retentionCount" , retentionCount ); setFieldValue( "repository.retentionCount", retentionCount );
//TODO // TODO
clickButtonWithValue( "Add Repository" ); clickButtonWithValue( "Add Repository" );
} }
protected void logout() protected void logout()
{ {
clickLinkWithText("Logout"); clickLinkWithText( "Logout" );
assertTextNotPresent( "Current User:" ); assertTextNotPresent( "Current User:" );
assertLinkNotPresent( "Edit Details" ); assertLinkNotPresent( "Edit Details" );
assertLinkNotPresent( "Logout" ); assertLinkNotPresent( "Logout" );
assertLinkPresent( "Login" ); assertLinkPresent( "Login" );
} }
} }

View File

@ -1,112 +1,114 @@
package org.apache.archiva.web.test.parent; package org.apache.archiva.web.test.parent;
public abstract class AbstractArtifactManagementTest public abstract class AbstractArtifactManagementTest
extends AbstractArchivaTest extends AbstractArchivaTest
{ {
public String getGroupId() public String getGroupId()
{ {
String groupId = getProperty( "GROUPID" ) ; String groupId = getProperty( "GROUPID" );
return groupId; return groupId;
} }
public String getArtifactId() public String getArtifactId()
{ {
String artifactId = getProperty( "ARTIFACTID" ) ; String artifactId = getProperty( "ARTIFACTID" );
return artifactId; return artifactId;
} }
public String getVersion() public String getVersion()
{ {
String version = getProperty( "VERSION" ) ; String version = getProperty( "VERSION" );
return version; return version;
} }
public String getPackaging() public String getPackaging()
{ {
String packaging = getProperty( "PACKAGING" ) ; String packaging = getProperty( "PACKAGING" );
return packaging; return packaging;
} }
public String getArtifactFilePath() public String getArtifactFilePath()
{ {
return "src/test/resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar"; return "src/test/resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar";
} }
public String getRepositoryId() public String getRepositoryId()
{ {
String repositoryId = getProperty( "REPOSITORYID" ) ; String repositoryId = getProperty( "REPOSITORYID" );
return repositoryId; return repositoryId;
} }
public void goToDeleteArtifactPage() public void goToDeleteArtifactPage()
{ {
login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) ); login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) );
clickLinkWithText( "Delete Artifact" ); clickLinkWithText( "Delete Artifact" );
assertDeleteArtifactPage(); assertDeleteArtifactPage();
} }
public void deleteArtifact( String groupId, String artifactId, String version, String repositoryId ) public void deleteArtifact( String groupId, String artifactId, String version, String repositoryId )
{ {
goToDeleteArtifactPage(); goToDeleteArtifactPage();
setFieldValue( "groupId" , groupId ); setFieldValue( "groupId", groupId );
setFieldValue( "artifactId" , artifactId ); setFieldValue( "artifactId", artifactId );
setFieldValue( "version" , version ); setFieldValue( "version", version );
selectValue( "repositoryId" , repositoryId ); selectValue( "repositoryId", repositoryId );
clickButtonWithValue( "Submit" ) ; clickButtonWithValue( "Submit" );
} }
public void assertDeleteArtifactPage() public void assertDeleteArtifactPage()
{ {
assertPage( "Apache Archiva \\ Delete Artifact" ); assertPage( "Apache Archiva \\ Delete Artifact" );
assertTextPresent( "Delete Artifact" ); assertTextPresent( "Delete Artifact" );
assertTextPresent( "Group Id*:" ); assertTextPresent( "Group Id*:" );
assertTextPresent( "Artifact Id*:" ); assertTextPresent( "Artifact Id*:" );
assertTextPresent( "Version*:" ); assertTextPresent( "Version*:" );
assertTextPresent( "Repository Id:" ); assertTextPresent( "Repository Id:" );
assertElementPresent( "groupId" ); assertElementPresent( "groupId" );
assertElementPresent( "artifactId" ); assertElementPresent( "artifactId" );
assertElementPresent( "version" ); assertElementPresent( "version" );
assertElementPresent( "repositoryId" ); assertElementPresent( "repositoryId" );
assertButtonWithValuePresent( "Submit" ); assertButtonWithValuePresent( "Submit" );
} }
// Legacy Support // Legacy Support
public void goToLegacySupportPage() public void goToLegacySupportPage()
{ {
clickLinkWithText( "Legacy Support" ); clickLinkWithText( "Legacy Support" );
assertLegacySupportPage(); assertLegacySupportPage();
} }
public void assertLegacySupportPage() public void assertLegacySupportPage()
{ {
assertPage( "Apache Archiva \\ Administration - Legacy Support" ); assertPage( "Apache Archiva \\ Administration - Legacy Support" );
assertTextPresent( "Administration - Legacy Artifact Path Resolution" ); assertTextPresent( "Administration - Legacy Artifact Path Resolution" );
assertTextPresent( "Path Mappings" ); assertTextPresent( "Path Mappings" );
assertLinkPresent( "Add" ); assertLinkPresent( "Add" );
} }
public void addLegacyArtifactPath( String path, String groupId, String artifactId, String version, String classifier, String type) public void addLegacyArtifactPath( String path, String groupId, String artifactId, String version,
{ String classifier, String type )
assertAddLegacyArtifactPathPage(); {
setFieldValue( "legacyArtifactPath.path" , path ); assertAddLegacyArtifactPathPage();
setFieldValue( "groupId" , groupId ); setFieldValue( "legacyArtifactPath.path", path );
setFieldValue( "artifactId" , artifactId ); setFieldValue( "groupId", groupId );
setFieldValue( "version" , version ); setFieldValue( "artifactId", artifactId );
setFieldValue( "classifier" , classifier ); setFieldValue( "version", version );
setFieldValue( "type" , type ); setFieldValue( "classifier", classifier );
clickButtonWithValue( "Add Legacy Artifact Path" ); setFieldValue( "type", type );
} clickButtonWithValue( "Add Legacy Artifact Path" );
}
public void assertAddLegacyArtifactPathPage()
{ public void assertAddLegacyArtifactPathPage()
assertPage( "Apache Archiva \\ Admin: Add Legacy Artifact Path" ); {
assertTextPresent( "Admin: Add Legacy Artifact Path" ); assertPage( "Apache Archiva \\ Admin: Add Legacy Artifact Path" );
assertTextPresent( "Enter the legacy path to map to a particular artifact reference, then adjust the fields as necessary." ); assertTextPresent( "Admin: Add Legacy Artifact Path" );
String element = "addLegacyArtifactPath_legacyArtifactPath_path,addLegacyArtifactPath_groupId,addLegacyArtifactPath_artifactId,addLegacyArtifactPath_version,addLegacyArtifactPath_classifier,addLegacyArtifactPath_type"; assertTextPresent( "Enter the legacy path to map to a particular artifact reference, then adjust the fields as necessary." );
String[] arrayElement = element.split( "," ); String element =
for ( String arrayelement : arrayElement ) "addLegacyArtifactPath_legacyArtifactPath_path,addLegacyArtifactPath_groupId,addLegacyArtifactPath_artifactId,addLegacyArtifactPath_version,addLegacyArtifactPath_classifier,addLegacyArtifactPath_type";
assertElementPresent( arrayelement ); String[] arrayElement = element.split( "," );
assertButtonWithValuePresent( "Add Legacy Artifact Path" ); for ( String arrayelement : arrayElement )
} assertElementPresent( arrayelement );
assertButtonWithValuePresent( "Add Legacy Artifact Path" );
}
} }

View File

@ -19,62 +19,62 @@ package org.apache.archiva.web.test.parent;
* under the License. * under the License.
*/ */
public abstract class AbstractArtifactReportsTest public abstract class AbstractArtifactReportsTest
extends AbstractArchivaTest extends AbstractArchivaTest
{ {
//Reports // Reports
public void goToReportsPage() public void goToReportsPage()
{ {
clickLinkWithText( "Reports" ); clickLinkWithText( "Reports" );
assertReportsPage(); assertReportsPage();
} }
public void assertReportsPage() public void assertReportsPage()
{ {
assertPage( "Apache Archiva \\ Reports" ); assertPage( "Apache Archiva \\ Reports" );
assertTextPresent( "Reports" ); assertTextPresent( "Reports" );
assertTextPresent( "Repository Statistics" ); assertTextPresent( "Repository Statistics" );
assertTextPresent( "Repositories To Be Compared" ); assertTextPresent( "Repositories To Be Compared" );
assertElementPresent( "availableRepositories" ); assertElementPresent( "availableRepositories" );
assertButtonWithValuePresent( "v" ); assertButtonWithValuePresent( "v" );
assertButtonWithValuePresent( "^" ); assertButtonWithValuePresent( "^" );
assertButtonWithValuePresent( "<-" ); assertButtonWithValuePresent( "<-" );
assertButtonWithValuePresent( "->" ); assertButtonWithValuePresent( "->" );
assertButtonWithValuePresent( "<<--" ); assertButtonWithValuePresent( "<<--" );
assertButtonWithValuePresent( "-->>" ); assertButtonWithValuePresent( "-->>" );
assertButtonWithValuePresent( "<*>" ); assertButtonWithValuePresent( "<*>" );
assertElementPresent( "selectedRepositories" ); assertElementPresent( "selectedRepositories" );
assertButtonWithValuePresent( "v" ); assertButtonWithValuePresent( "v" );
assertButtonWithValuePresent( "^" ); assertButtonWithValuePresent( "^" );
assertTextPresent( "Row Count" ); assertTextPresent( "Row Count" );
assertElementPresent( "rowCount" ); assertElementPresent( "rowCount" );
assertTextPresent( "Start Date" ); assertTextPresent( "Start Date" );
assertElementPresent( "startDate" ); assertElementPresent( "startDate" );
assertTextPresent( "End Date" ); assertTextPresent( "End Date" );
assertElementPresent( "endDate" ); assertElementPresent( "endDate" );
assertButtonWithValuePresent( "View Statistics" ); assertButtonWithValuePresent( "View Statistics" );
assertTextPresent( "Repository Health" ); assertTextPresent( "Repository Health" );
assertTextPresent( "Row Count" ); assertTextPresent( "Row Count" );
assertElementPresent( "rowCount" ); assertElementPresent( "rowCount" );
assertTextPresent( "Group ID" ); assertTextPresent( "Group ID" );
assertElementPresent( "groupId" ); assertElementPresent( "groupId" );
assertTextPresent( "Repository ID" ); assertTextPresent( "Repository ID" );
assertElementPresent( "repositoryId" ); assertElementPresent( "repositoryId" );
assertButtonWithValuePresent( "Show Report" ); assertButtonWithValuePresent( "Show Report" );
} }
public void compareRepositories( String labelSelected, String startDate, String endDate ) public void compareRepositories( String labelSelected, String startDate, String endDate )
{ {
goToReportsPage(); goToReportsPage();
getSelenium().removeSelection( "generateStatisticsReport_availableRepositories" , labelSelected ); getSelenium().removeSelection( "generateStatisticsReport_availableRepositories", labelSelected );
clickButtonWithValue( "->" , false ); clickButtonWithValue( "->", false );
getSelenium().type( "startDate", startDate ); getSelenium().type( "startDate", startDate );
//clickLinkWithLocator( "1" , false ); // clickLinkWithLocator( "1" , false );
//getSelenium().click( "endDate" ); // getSelenium().click( "endDate" );
getSelenium().type( "endDate", endDate ); getSelenium().type( "endDate", endDate );
//clickLinkWithLocator( "30" , false ); // clickLinkWithLocator( "30" , false );
clickButtonWithValue( "View Statistics" ); clickButtonWithValue( "View Statistics" );
} }
} }

View File

@ -19,22 +19,22 @@ package org.apache.archiva.web.test.parent;
* under the License. * under the License.
*/ */
public abstract class AbstractBrowseTest public abstract class AbstractBrowseTest
extends AbstractArchivaTest extends AbstractArchivaTest
{ {
//Browse
public void goToBrowsePage()
{
clickLinkWithText( "Browse" );
assertBrowsePage();
}
public void assertBrowsePage() // Browse
{ public void goToBrowsePage()
assertPage( "Apache Archiva \\ Browse Repository" ); {
assertTextPresent( "Browse Repository" ); clickLinkWithText( "Browse" );
assertTextPresent( "Groups" ); assertBrowsePage();
} }
public void assertBrowsePage()
{
assertPage( "Apache Archiva \\ Browse Repository" );
assertTextPresent( "Browse Repository" );
assertTextPresent( "Groups" );
}
} }

View File

@ -22,353 +22,365 @@ package org.apache.archiva.web.test.parent;
import java.io.File; import java.io.File;
import org.testng.Assert; import org.testng.Assert;
public abstract class AbstractRepositoryTest public abstract class AbstractRepositoryTest
extends AbstractArchivaTest extends AbstractArchivaTest
{ {
// Repository Groups // Repository Groups
public void goToRepositoryGroupsPage() public void goToRepositoryGroupsPage()
{ {
if( !getTitle().equals( "Apache Archiva \\ Administration - Repository Groups" ) ) if ( !getTitle().equals( "Apache Archiva \\ Administration - Repository Groups" ) )
{ {
clickLinkWithText( "Repository Groups" ); clickLinkWithText( "Repository Groups" );
} }
assertRepositoryGroupsPage(); assertRepositoryGroupsPage();
} }
public void assertRepositoryGroupsPage() public void assertRepositoryGroupsPage()
{ {
assertPage( "Apache Archiva \\ Administration - Repository Groups" ); assertPage( "Apache Archiva \\ Administration - Repository Groups" );
assertTextPresent( "Administration - Repository Groups" ); assertTextPresent( "Administration - Repository Groups" );
assertTextPresent( "Identifier*:" ); assertTextPresent( "Identifier*:" );
assertElementPresent( "repositoryGroup.id" ); assertElementPresent( "repositoryGroup.id" );
assertButtonWithValuePresent( "Add Group" ); assertButtonWithValuePresent( "Add Group" );
assertTextPresent( "Repository Groups" ); assertTextPresent( "Repository Groups" );
} }
public void assertAddedRepositoryLink( String repositoryGroupName) public void assertAddedRepositoryLink( String repositoryGroupName )
{ {
assertPage( "Apache Archiva \\ Administration - Repository Groups" ); assertPage( "Apache Archiva \\ Administration - Repository Groups" );
String repositoryGroupUrlValue = "repository/" + repositoryGroupName + "/"; String repositoryGroupUrlValue = "repository/" + repositoryGroupName + "/";
String baseUrlValue = "archiva"; String baseUrlValue = "archiva";
String repositoryGroupLink = baseUrl.replaceFirst( baseUrlValue, repositoryGroupUrlValue); String repositoryGroupLink = baseUrl.replaceFirst( baseUrlValue, repositoryGroupUrlValue );
assertTextPresent( repositoryGroupLink ); assertTextPresent( repositoryGroupLink );
} }
public void assertAddedRepositoryToRepositoryGroups( String repositoryName) public void assertAddedRepositoryToRepositoryGroups( String repositoryName )
{ {
assertPage( "Apache Archiva \\ Administration - Repository Groups" ); assertPage( "Apache Archiva \\ Administration - Repository Groups" );
assertTextPresent( repositoryName ); assertTextPresent( repositoryName );
assertTextPresent( "Archiva Managed Internal Repository" ); assertTextPresent( "Archiva Managed Internal Repository" );
assertAddedRepositoryLink( repositoryName ); assertAddedRepositoryLink( repositoryName );
} }
public void assertDeleteRepositoryGroupPage( String repositoryName) public void assertDeleteRepositoryGroupPage( String repositoryName )
{ {
assertPage( "Apache Archiva \\ Admin: Delete Repository Group" ); assertPage( "Apache Archiva \\ Admin: Delete Repository Group" );
assertTextPresent( "WARNING: This operation can not be undone." ); assertTextPresent( "WARNING: This operation can not be undone." );
assertTextPresent( "Are you sure you want to delete the following repository group?" ); assertTextPresent( "Are you sure you want to delete the following repository group?" );
assertTextPresent( "ID:" ); assertTextPresent( "ID:" );
assertTextPresent( repositoryName ); assertTextPresent( repositoryName );
assertButtonWithValuePresent( "Confirm" ); assertButtonWithValuePresent( "Confirm" );
assertButtonWithValuePresent( "Cancel" ); assertButtonWithValuePresent( "Cancel" );
} }
public void addRepositoryGroup( String repoGroupName ) public void addRepositoryGroup( String repoGroupName )
{ {
goToRepositoryGroupsPage(); goToRepositoryGroupsPage();
setFieldValue( "repositoryGroup.id", repoGroupName ); setFieldValue( "repositoryGroup.id", repoGroupName );
clickButtonWithValue( "Add Group" ); clickButtonWithValue( "Add Group" );
} }
public void addRepositoryToRepositoryGroup( String repositoryGroupName, String repositoryName ) public void addRepositoryToRepositoryGroup( String repositoryGroupName, String repositoryName )
{ {
goToRepositoryGroupsPage(); goToRepositoryGroupsPage();
String s = getSelenium().getBodyText(); String s = getSelenium().getBodyText();
if ( s.contains( "No Repository Groups Defined." ) ) if ( s.contains( "No Repository Groups Defined." ) )
{ {
setFieldValue( "repositoryGroup.id" , repositoryGroupName ); setFieldValue( "repositoryGroup.id", repositoryGroupName );
clickButtonWithValue( "Add Group" ); clickButtonWithValue( "Add Group" );
//assertAddedRepositoryLink( repositoryGroupName ); // assertAddedRepositoryLink( repositoryGroupName );
selectValue( "addRepositoryToGroup_repoId" , repositoryName ); selectValue( "addRepositoryToGroup_repoId", repositoryName );
clickButtonWithValue( "Add Repository" ); clickButtonWithValue( "Add Repository" );
assertAddedRepositoryToRepositoryGroups( repositoryName ); assertAddedRepositoryToRepositoryGroups( repositoryName );
} }
else else
{ {
//assertAddedRepositoryLink( repositoryGroupName ); // assertAddedRepositoryLink( repositoryGroupName );
selectValue( "addRepositoryToGroup_repoId" , repositoryName ); selectValue( "addRepositoryToGroup_repoId", repositoryName );
clickButtonWithValue( "Add Repository" ); clickButtonWithValue( "Add Repository" );
} }
} }
public void deleteRepositoryInRepositoryGroups() public void deleteRepositoryInRepositoryGroups()
{ {
goToRepositoryGroupsPage(); goToRepositoryGroupsPage();
getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" ); getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" );
waitPage(); waitPage();
} }
public void deleteRepositoryGroup( String repositoryName ) public void deleteRepositoryGroup( String repositoryName )
{ {
getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" ); getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" );
waitPage(); waitPage();
assertDeleteRepositoryGroupPage( repositoryName ); assertDeleteRepositoryGroupPage( repositoryName );
clickButtonWithValue( "Confirm" ); clickButtonWithValue( "Confirm" );
} }
/////////////////////////////// // /////////////////////////////
// proxy connectors // proxy connectors
/////////////////////////////// // /////////////////////////////
public void goToProxyConnectorsPage() public void goToProxyConnectorsPage()
{ {
clickLinkWithText( "Proxy Connectors" ); clickLinkWithText( "Proxy Connectors" );
assertProxyConnectorsPage(); assertProxyConnectorsPage();
} }
public void assertProxyConnectorsPage() public void assertProxyConnectorsPage()
{ {
assertPage( "Apache Archiva \\ Administration - Proxy Connectors" ); assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
assertTextPresent( "Administration - Proxy Connectors" ); assertTextPresent( "Administration - Proxy Connectors" );
assertTextPresent( "Repository Proxy Connectors" ); assertTextPresent( "Repository Proxy Connectors" );
assertTextPresent( "internal" ); assertTextPresent( "internal" );
assertTextPresent( "Archiva Managed Internal Repository" ); assertTextPresent( "Archiva Managed Internal Repository" );
assertTextPresent( "Proxy Connector" ); assertTextPresent( "Proxy Connector" );
assertTextPresent( "Central Repository" ); assertTextPresent( "Central Repository" );
assertTextPresent( "Java.net Repository for Maven 2" ); assertTextPresent( "Java.net Repository for Maven 2" );
} }
public void assertAddProxyConnectorPage() public void assertAddProxyConnectorPage()
{ {
assertPage( "Apache Archiva \\ Admin: Add Proxy Connector" ); assertPage( "Apache Archiva \\ Admin: Add Proxy Connector" );
assertTextPresent( "Admin: Add Proxy Connector" ); assertTextPresent( "Admin: Add Proxy Connector" );
String proxy = "Network Proxy*:,Managed Repository*:,Remote Repository*:,Policies:,Return error when:,On remote error:,Releases:,Snapshots:,Checksum:,Cache failures:,Properties:,No properties have been set.,Black List:,No black list patterns have been set.,White List:,No white list patterns have been set."; String proxy =
String[] arrayProxy = proxy.split( "," ); "Network Proxy*:,Managed Repository*:,Remote Repository*:,Policies:,Return error when:,On remote error:,Releases:,Snapshots:,Checksum:,Cache failures:,Properties:,No properties have been set.,Black List:,No black list patterns have been set.,White List:,No white list patterns have been set.";
for ( String arrayproxy : arrayProxy ) String[] arrayProxy = proxy.split( "," );
assertTextPresent( arrayproxy ); for ( String arrayproxy : arrayProxy )
/*String proxyElements = "addProxyConnector_connector_proxyId,addProxyConnector_connector_sourceRepoId,addProxyConnector_connector_targetRepoId,policy_propagate-errors-on-update,policy_propagate-errors,policy_releases,policy_snapshots,policy_checksum,policy_cache-failures,propertiesEntry,propertiesValue,blackListEntry,whiteListEntry"; assertTextPresent( arrayproxy );
String[] arrayProxyElements = proxyElements.split( "," ); /*
for ( String arrayproxyelements : arrayProxyElements ) * String proxyElements =
assertTextPresent( arrayproxyelements );*/ * "addProxyConnector_connector_proxyId,addProxyConnector_connector_sourceRepoId,addProxyConnector_connector_targetRepoId,policy_propagate-errors-on-update,policy_propagate-errors,policy_releases,policy_snapshots,policy_checksum,policy_cache-failures,propertiesEntry,propertiesValue,blackListEntry,whiteListEntry"
assertButtonWithValuePresent( "Add Property" ); * ; String[] arrayProxyElements = proxyElements.split( "," ); for ( String arrayproxyelements :
assertButtonWithValuePresent( "Add Pattern" ); * arrayProxyElements ) assertTextPresent( arrayproxyelements );
assertButtonWithValuePresent( "Add Proxy Connector" ); */
} assertButtonWithValuePresent( "Add Property" );
assertButtonWithValuePresent( "Add Pattern" );
// this only fills in the values of required fields in adding Proxy Connectors assertButtonWithValuePresent( "Add Proxy Connector" );
public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo ) }
{
goToProxyConnectorsPage(); // this only fills in the values of required fields in adding Proxy Connectors
clickLinkWithText( "Add" ); public void addProxyConnector( String networkProxy, String managedRepo, String remoteRepo )
assertAddProxyConnectorPage(); {
selectValue( "connector.proxyId" , networkProxy ); goToProxyConnectorsPage();
selectValue( "connector.sourceRepoId" , managedRepo ); clickLinkWithText( "Add" );
selectValue( "connector.targetRepoId" , remoteRepo ); assertAddProxyConnectorPage();
} selectValue( "connector.proxyId", networkProxy );
selectValue( "connector.sourceRepoId", managedRepo );
public void deleteProxyConnector() selectValue( "connector.targetRepoId", remoteRepo );
{ }
goToProxyConnectorsPage();
clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" ); public void deleteProxyConnector()
assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" ); {
clickButtonWithValue( "Delete" ); goToProxyConnectorsPage();
assertPage( "Apache Archiva \\ Administration - Proxy Connectors" ); clickLinkWithXPath( "//div[@id='contentArea']/div[2]/div[1]/div[2]/div[1]/a[3]/img" );
} assertPage( "Apache Archiva \\ Admin: Delete Proxy Connectors" );
clickButtonWithValue( "Delete" );
/////////////////////////////// assertPage( "Apache Archiva \\ Administration - Proxy Connectors" );
// network proxies }
///////////////////////////////
public void goToNetworkProxiesPage() // /////////////////////////////
{ // network proxies
clickLinkWithText( "Network Proxies" ); // /////////////////////////////
assertNetworkProxiesPage(); public void goToNetworkProxiesPage()
} {
clickLinkWithText( "Network Proxies" );
public void assertNetworkProxiesPage() assertNetworkProxiesPage();
{ }
assertPage( "Apache Archiva \\ Administration - Network Proxies" );
assertTextPresent( "Administration - Network Proxies" ); public void assertNetworkProxiesPage()
assertTextPresent( "Network Proxies" ); {
assertLinkPresent( "Add Network Proxy" ); assertPage( "Apache Archiva \\ Administration - Network Proxies" );
} assertTextPresent( "Administration - Network Proxies" );
assertTextPresent( "Network Proxies" );
public void assertAddNetworkProxy() assertLinkPresent( "Add Network Proxy" );
{ }
assertPage( "Apache Archiva \\ Admin: Add Network Proxy" );
assertTextPresent( "Admin: Add Network Proxy" ); public void assertAddNetworkProxy()
assertTextPresent( "Add network proxy:" ); {
assertTextPresent( "Identifier*:" ); assertPage( "Apache Archiva \\ Admin: Add Network Proxy" );
assertTextPresent( "Protocol*:" ); assertTextPresent( "Admin: Add Network Proxy" );
assertTextPresent( "Hostname*:" ); assertTextPresent( "Add network proxy:" );
assertTextPresent( "Port*:" ); assertTextPresent( "Identifier*:" );
assertTextPresent( "Username:" ); assertTextPresent( "Protocol*:" );
assertTextPresent( "Password:" ); assertTextPresent( "Hostname*:" );
assertButtonWithValuePresent( "Save Network Proxy" ); assertTextPresent( "Port*:" );
} assertTextPresent( "Username:" );
assertTextPresent( "Password:" );
public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username, String password ) assertButtonWithValuePresent( "Save Network Proxy" );
{ }
//goToNetworkProxiesPage();
clickLinkWithText( "Add Network Proxy" ); public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username,
assertAddNetworkProxy(); String password )
setFieldValue( "proxy.id" , identifier ); {
setFieldValue( "proxy.protocol" , protocol ); // goToNetworkProxiesPage();
setFieldValue( "proxy.host" , hostname ); clickLinkWithText( "Add Network Proxy" );
setFieldValue( "proxy.port" , port ); assertAddNetworkProxy();
setFieldValue( "proxy.username" , username ); setFieldValue( "proxy.id", identifier );
setFieldValue( "proxy.password" , password ); setFieldValue( "proxy.protocol", protocol );
clickButtonWithValue( "Save Network Proxy" ); setFieldValue( "proxy.host", hostname );
} setFieldValue( "proxy.port", port );
setFieldValue( "proxy.username", username );
public void editNetworkProxies( String fieldName, String value) setFieldValue( "proxy.password", password );
{ clickButtonWithValue( "Save Network Proxy" );
//goToNetworkProxiesPage(); }
clickLinkWithText( "Edit Network Proxy" );
setFieldValue( fieldName, value); public void editNetworkProxies( String fieldName, String value )
clickButtonWithValue( "Save Network Proxy" ); {
} // goToNetworkProxiesPage();
clickLinkWithText( "Edit Network Proxy" );
public void deleteNetworkProxy() setFieldValue( fieldName, value );
{ clickButtonWithValue( "Save Network Proxy" );
//goToNetworkProxiesPage(); }
clickLinkWithText( "Delete Network Proxy" );
assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" ); public void deleteNetworkProxy()
assertTextPresent( "WARNING: This operation can not be undone." ); {
clickButtonWithValue( "Delete" ); // goToNetworkProxiesPage();
} clickLinkWithText( "Delete Network Proxy" );
assertPage( "Apache Archiva \\ Admin: Delete Network Proxy" );
// remote repositories assertTextPresent( "WARNING: This operation can not be undone." );
public void assertAddRemoteRepository() clickButtonWithValue( "Delete" );
{ }
assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:"; // remote repositories
String[] arrayRemote = remote.split( "," ); public void assertAddRemoteRepository()
for ( String arrayremote : arrayRemote ) {
assertTextPresent( arrayremote ); assertPage( "Apache Archiva \\ Admin: Add Remote Repository" );
String remoteElements = "addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_username,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout"; String remote = "Identifier*:,Name*:,URL*:,Username:,Password:,Timeout in seconds:,Type:";
String[] arrayRemoteElements = remoteElements.split( "," ); String[] arrayRemote = remote.split( "," );
for ( String arrayremotelement : arrayRemoteElements ) for ( String arrayremote : arrayRemote )
assertElementPresent( arrayremotelement ); assertTextPresent( arrayremote );
} String remoteElements =
"addRemoteRepository_repository_id,addRemoteRepository_repository_name,addRemoteRepository_repository_url,addRemoteRepository_repository_username,addRemoteRepository_repository_password,addRemoteRepository_repository_timeout,addRemoteRepository_repository_layout";
public void assertDeleteRemoteRepositoryPage() String[] arrayRemoteElements = remoteElements.split( "," );
{ for ( String arrayremotelement : arrayRemoteElements )
assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" ); assertElementPresent( arrayremotelement );
assertTextPresent( "Admin: Delete Remote Repository" ); }
assertTextPresent( "WARNING: This operation can not be undone." );
assertTextPresent( "Are you sure you want to delete the following remote repository?" ); public void assertDeleteRemoteRepositoryPage()
assertButtonWithValuePresent( "Confirm" ); {
assertButtonWithValuePresent( "Cancel" ); assertPage( "Apache Archiva \\ Admin: Delete Remote Repository" );
} assertTextPresent( "Admin: Delete Remote Repository" );
assertTextPresent( "WARNING: This operation can not be undone." );
public void addRemoteRepository( String identifier, String name, String url, String username, String password, String timeout, String type ) assertTextPresent( "Are you sure you want to delete the following remote repository?" );
{ assertButtonWithValuePresent( "Confirm" );
//goToRepositoriesPage(); assertButtonWithValuePresent( "Cancel" );
assertAddRemoteRepository(); }
setFieldValue( "addRemoteRepository_repository_id" , identifier );
setFieldValue( "addRemoteRepository_repository_name" , name ); public void addRemoteRepository( String identifier, String name, String url, String username, String password,
setFieldValue( "addRemoteRepository_repository_url" , url ); String timeout, String type )
setFieldValue( "addRemoteRepository_repository_username" , username ); {
setFieldValue( "addRemoteRepository_repository_password" , password ); // goToRepositoriesPage();
setFieldValue( "addRemoteRepository_repository_timeout" , timeout ); assertAddRemoteRepository();
selectValue( "addRemoteRepository_repository_layout" , type ); setFieldValue( "addRemoteRepository_repository_id", identifier );
clickButtonWithValue( "Add Repository" ); setFieldValue( "addRemoteRepository_repository_name", name );
} setFieldValue( "addRemoteRepository_repository_url", url );
setFieldValue( "addRemoteRepository_repository_username", username );
public void deleteRemoteRepository() setFieldValue( "addRemoteRepository_repository_password", password );
{ setFieldValue( "addRemoteRepository_repository_timeout", timeout );
goToRepositoriesPage(); selectValue( "addRemoteRepository_repository_layout", type );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" ); clickButtonWithValue( "Add Repository" );
assertDeleteRemoteRepositoryPage(); }
clickButtonWithValue( "Confirm" );
} public void deleteRemoteRepository()
{
public void editRemoteRepository( String fieldName, String value) goToRepositoriesPage();
{ clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[2]" );
goToRepositoriesPage(); assertDeleteRemoteRepositoryPage();
clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" ); clickButtonWithValue( "Confirm" );
setFieldValue( fieldName, value ); }
clickButtonWithValue( "Update Repository" );
} public void editRemoteRepository( String fieldName, String value )
{
public void editManagedRepository( String fieldName, String value ) goToRepositoriesPage();
{ clickLinkWithXPath( "//div[@id='contentArea']/div/div[8]/div[1]/a[1]" );
goToRepositoriesPage(); setFieldValue( fieldName, value );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" ); clickButtonWithValue( "Update Repository" );
assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" ); }
setFieldValue(fieldName, value);
//TODO public void editManagedRepository( String fieldName, String value )
clickButtonWithValue( "Update Repository" ); {
} goToRepositoriesPage();
clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[1]/img" );
public void deleteManagedRepository() assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
{ setFieldValue( fieldName, value );
clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[2]" ); // TODO
assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" ); clickButtonWithValue( "Update Repository" );
clickButtonWithValue( "Delete Configuration Only" ); }
}
public void deleteManagedRepository()
public String getRepositoryDir() {
{ clickLinkWithXPath( "//div[@id='contentArea']/div/div[5]/div[1]/a[2]" );
File f = new File( "" ); assertPage( "Apache Archiva \\ Admin: Delete Managed Repository" );
String artifactFilePath = f.getAbsolutePath(); clickButtonWithValue( "Delete Configuration Only" );
return artifactFilePath + "/target/"; }
}
public String getRepositoryDir()
///////////////////////////////////////////// {
// Repository Scanning File f = new File( "" );
///////////////////////////////////////////// String artifactFilePath = f.getAbsolutePath();
public void goToRepositoryScanningPage() return artifactFilePath + "/target/";
{ }
clickLinkWithText( "Repository Scanning" );
assertRepositoryScanningPage(); // ///////////////////////////////////////////
} // Repository Scanning
// ///////////////////////////////////////////
public void assertRepositoryScanningPage() public void goToRepositoryScanningPage()
{ {
assertPage( "Apache Archiva \\ Administration - Repository Scanning" ); clickLinkWithText( "Repository Scanning" );
assertTextPresent( "Administration - Repository Scanning" ); assertRepositoryScanningPage();
assertTextPresent( "Repository Scanning - File Types" ); }
String artifactsTypes = "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
String [] arrayArtifactTypes = artifactsTypes.split( "," ); public void assertRepositoryScanningPage()
for (int i = 0; i < arrayArtifactTypes.length; i++) {
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table."+i+".0"), arrayArtifactTypes[i]); assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
assertTextPresent( "Administration - Repository Scanning" );
String autoremove = "**/*.bak,**/*~,**/*-"; assertTextPresent( "Repository Scanning - File Types" );
String [] arrayAutoremove = autoremove.split( "," ); String artifactsTypes =
for (int i = 0; i < arrayAutoremove.length; i++) "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table."+i+".0"), arrayAutoremove[i]); String[] arrayArtifactTypes = artifactsTypes.split( "," );
for ( int i = 0; i < arrayArtifactTypes.length; i++ )
String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**"; Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[1]/table." + i + ".0" ),
String [] arrayIgnored = ignored.split( "," ); arrayArtifactTypes[i] );
for (int i = 0; i < arrayIgnored.length; i++)
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table."+i+".0"), arrayIgnored[i]); String autoremove = "**/*.bak,**/*~,**/*-";
String[] arrayAutoremove = autoremove.split( "," );
String indexableContent = "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld"; for ( int i = 0; i < arrayAutoremove.length; i++ )
String [] arrayIndexableContent = indexableContent.split( "," ); Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[2]/table." + i + ".0" ),
for (int i = 0; i < arrayIndexableContent.length; i++) arrayAutoremove[i] );
Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table."+i+".0"), arrayIndexableContent[i]);
} String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
String[] arrayIgnored = ignored.split( "," );
///////////////////////////////////////////// for ( int i = 0; i < arrayIgnored.length; i++ )
// Database Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[3]/table." + i + ".0" ),
///////////////////////////////////////////// arrayIgnored[i] );
public void goToDatabasePage()
{ String indexableContent =
clickLinkWithText( "Database" ); "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld";
assertDatabasePage(); String[] arrayIndexableContent = indexableContent.split( "," );
} for ( int i = 0; i < arrayIndexableContent.length; i++ )
Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[4]/table." + i + ".0" ),
public void assertDatabasePage() arrayIndexableContent[i] );
{ }
assertPage( "Apache Archiva \\ Administration - Database" );
assertTextPresent( "Administration - Database" ); // ///////////////////////////////////////////
assertTextPresent( "Database - Unprocessed Artifacts Scanning" ); // Database
assertTextPresent( "Cron:" ); // ///////////////////////////////////////////
assertElementPresent( "database_cron" ); public void goToDatabasePage()
assertButtonWithValuePresent( "Update Cron" ); {
assertButtonWithValuePresent( "Update Database Now" ); clickLinkWithText( "Database" );
assertTextPresent( "Database - Unprocessed Artifacts Scanning" ); assertDatabasePage();
assertTextPresent( "Database - Artifact Cleanup Scanning" ); }
}
} public void assertDatabasePage()
{
assertPage( "Apache Archiva \\ Administration - Database" );
assertTextPresent( "Administration - Database" );
assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
assertTextPresent( "Cron:" );
assertElementPresent( "database_cron" );
assertButtonWithValuePresent( "Update Cron" );
assertButtonWithValuePresent( "Update Database Now" );
assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
assertTextPresent( "Database - Artifact Cleanup Scanning" );
}
}

View File

@ -19,12 +19,12 @@ package org.apache.archiva.web.test.parent;
* under the License. * under the License.
*/ */
public abstract class AbstractSearchTest public abstract class AbstractSearchTest
extends AbstractArchivaTest extends AbstractArchivaTest
{ {
//Search // Search
public void goToSearchPage() public void goToSearchPage()
{ {
if ( !"Apache Archiva \\ Quick Search".equals( getTitle() ) ) if ( !"Apache Archiva \\ Quick Search".equals( getTitle() ) )
{ {
clickLinkWithText( "Search" ); clickLinkWithText( "Search" );
@ -32,20 +32,20 @@ public abstract class AbstractSearchTest
assertPage( "Apache Archiva \\ Quick Search" ); assertPage( "Apache Archiva \\ Quick Search" );
} }
} }
public void assertSearchPage() public void assertSearchPage()
{ {
assertPage( "Apache Archiva \\ Quick Search" ); assertPage( "Apache Archiva \\ Quick Search" );
assertTextPresent( "Search for" ); assertTextPresent( "Search for" );
assertElementPresent( "quickSearch_q" ); assertElementPresent( "quickSearch_q" );
assertButtonWithValuePresent( "Search" ); assertButtonWithValuePresent( "Search" );
//assertLinkPresent( "Advanced Search" ); // assertLinkPresent( "Advanced Search" );
assertTextPresent( "Enter your search terms. A variety of data will be searched for your keywords." ); assertTextPresent( "Enter your search terms. A variety of data will be searched for your keywords." );
//assertButtonWithDivIdPresent( "searchHint" ); // assertButtonWithDivIdPresent( "searchHint" );
} }
public void searchForArtifact( String artifactId ) public void searchForArtifact( String artifactId )
{ {
goToSearchPage(); goToSearchPage();
@ -53,8 +53,8 @@ public abstract class AbstractSearchTest
clickButtonWithValue( "Search" ); clickButtonWithValue( "Search" );
} }
public void searchForArtifactAdvancedSearch( String groupId, String artifactId, String version, String repositoryId, public void searchForArtifactAdvancedSearch( String groupId, String artifactId, String version,
String className, String rowCount ) String repositoryId, String className, String rowCount )
{ {
goToSearchPage(); goToSearchPage();
@ -113,4 +113,4 @@ public abstract class AbstractSearchTest
} }
clickSubmitWithLocator( "filteredSearch_0" ); clickSubmitWithLocator( "filteredSearch_0" );
} }
} }

View File

@ -39,7 +39,8 @@ import org.testng.Assert;
* @version $Id: AbstractSeleniumTestCase.java 761154 2009-04-02 03:31:19Z wsmoak $ * @version $Id: AbstractSeleniumTestCase.java 761154 2009-04-02 03:31:19Z wsmoak $
*/ */
public abstract class AbstractSeleniumTest { public abstract class AbstractSeleniumTest
{
public static String baseUrl; public static String baseUrl;
@ -49,19 +50,19 @@ public abstract class AbstractSeleniumTest {
public static Properties p; public static Properties p;
private final static String PROPERTIES_SEPARATOR = "="; private final static String PROPERTIES_SEPARATOR = "=";
public void open() public void open()
throws Exception throws Exception
{ {
p = new Properties(); p = new Properties();
p.load( this.getClass().getClassLoader().getResourceAsStream( "testng.properties" ) ); p.load( this.getClass().getClassLoader().getResourceAsStream( "testng.properties" ) );
//baseUrl = getProperty( "BASE_URL" ); // baseUrl = getProperty( "BASE_URL" );
maxWaitTimeInMs = getProperty( "MAX_WAIT_TIME_IN_MS" ); maxWaitTimeInMs = getProperty( "MAX_WAIT_TIME_IN_MS" );
} }
/** /**
* Initialize selenium * Initialize selenium
*/ */
public void open( String baseUrl, String browser, String seleniumHost, int seleniumPort ) public void open( String baseUrl, String browser, String seleniumHost, int seleniumPort )
@ -113,8 +114,7 @@ public abstract class AbstractSeleniumTest {
return value; return value;
} }
/**
/**
* Close selenium session. Called from AfterSuite method of sub-class * Close selenium session. Called from AfterSuite method of sub-class
*/ */
public void close() public void close()
@ -126,273 +126,273 @@ public abstract class AbstractSeleniumTest {
selenium.set( null ); selenium.set( null );
} }
} }
// ******************************************************* // *******************************************************
// Auxiliar methods. This method help us and simplify test. // Auxiliar methods. This method help us and simplify test.
// ******************************************************* // *******************************************************
public void assertFieldValue( String fieldValue, String fieldName ) public void assertFieldValue( String fieldValue, String fieldName )
{ {
assertElementPresent( fieldName ); assertElementPresent( fieldName );
Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) ); Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) );
} }
public void assertPage( String title ) public void assertPage( String title )
{ {
Assert.assertEquals( getTitle(), title ); Assert.assertEquals( getTitle(), title );
} }
public String getTitle() public String getTitle()
{ {
// Collapse spaces // Collapse spaces
return getSelenium().getTitle().replaceAll( "[ \n\r]+", " " ); return getSelenium().getTitle().replaceAll( "[ \n\r]+", " " );
} }
public String getHtmlContent() public String getHtmlContent()
{ {
return getSelenium().getHtmlSource(); return getSelenium().getHtmlSource();
} }
public void assertTextPresent( String text ) public void assertTextPresent( String text )
{ {
Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." ); Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." );
} }
public void assertTextNotPresent( String text ) public void assertTextNotPresent( String text )
{ {
Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." ); Assert.assertFalse( getSelenium().isTextPresent( text ), "'" + text + "' is present." );
} }
public void assertElementPresent( String elementLocator ) public void assertElementPresent( String elementLocator )
{ {
Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." ); Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." );
} }
public void assertElementNotPresent( String elementLocator ) public void assertElementNotPresent( String elementLocator )
{ {
Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." ); Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." );
} }
public void assertLinkPresent( String text ) public void assertLinkPresent( String text )
{ {
Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isn't present." ); Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isn't present." );
} }
public void assertLinkNotPresent( String text ) public void assertLinkNotPresent( String text )
{ {
Assert.assertFalse( isElementPresent( "link=" + text ), "The link('" + text + "' is present." ); Assert.assertFalse( isElementPresent( "link=" + text ), "The link('" + text + "' is present." );
} }
public void assertImgWithAlt( String alt ) public void assertImgWithAlt( String alt )
{ {
assertElementPresent( "/¯img[@alt='" + alt + "']" ); assertElementPresent( "/¯img[@alt='" + alt + "']" );
} }
public void assertImgWithAltAtRowCol( boolean isALink, String alt, int row, int column ) public void assertImgWithAltAtRowCol( boolean isALink, String alt, int row, int column )
{ {
String locator = "//tr[" + row + "]/td[" + column + "]/"; String locator = "//tr[" + row + "]/td[" + column + "]/";
locator += isALink ? "a/" : ""; locator += isALink ? "a/" : "";
locator += "img[@alt='" + alt + "']"; locator += "img[@alt='" + alt + "']";
assertElementPresent( locator ); assertElementPresent( locator );
} }
public void assertCellValueFromTable( String expected, String tableElement, int row, int column ) public void assertCellValueFromTable( String expected, String tableElement, int row, int column )
{ {
Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) ); Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) );
} }
public boolean isTextPresent( String text ) public boolean isTextPresent( String text )
{ {
return getSelenium().isTextPresent( text ); return getSelenium().isTextPresent( text );
} }
public boolean isLinkPresent( String text ) public boolean isLinkPresent( String text )
{ {
return isElementPresent( "link=" + text ); return isElementPresent( "link=" + text );
} }
public boolean isElementPresent( String locator ) public boolean isElementPresent( String locator )
{ {
return getSelenium().isElementPresent( locator ); return getSelenium().isElementPresent( locator );
} }
public void waitPage() public void waitPage()
{ {
getSelenium().waitForPageToLoad( maxWaitTimeInMs ); getSelenium().waitForPageToLoad( maxWaitTimeInMs );
} }
public String getFieldValue( String fieldName ) public String getFieldValue( String fieldName )
{ {
return getSelenium().getValue( fieldName ); return getSelenium().getValue( fieldName );
} }
public String getCellValueFromTable( String tableElement, int row, int column ) public String getCellValueFromTable( String tableElement, int row, int column )
{ {
return getSelenium().getTable( tableElement + "." + row + "." + column ); return getSelenium().getTable( tableElement + "." + row + "." + column );
} }
public void selectValue( String locator, String value ) public void selectValue( String locator, String value )
{ {
getSelenium().select( locator, "label=" + value ); getSelenium().select( locator, "label=" + value );
} }
public void assertOptionPresent( String selectField, String[] options ) public void assertOptionPresent( String selectField, String[] options )
{ {
assertElementPresent( selectField ); assertElementPresent( selectField );
String[] optionsPresent = getSelenium().getSelectOptions( selectField ); String[] optionsPresent = getSelenium().getSelectOptions( selectField );
List<String> expected = Arrays.asList( options ); List<String> expected = Arrays.asList( options );
List<String> present = Arrays.asList( optionsPresent ); List<String> present = Arrays.asList( optionsPresent );
Assert.assertTrue( present.containsAll( expected ), "Options expected are not included in present options" ); Assert.assertTrue( present.containsAll( expected ), "Options expected are not included in present options" );
} }
public void assertSelectedValue( String value, String fieldName ) public void assertSelectedValue( String value, String fieldName )
{ {
assertElementPresent( fieldName ); assertElementPresent( fieldName );
String optionsPresent = getSelenium().getSelectedLabel( value ); String optionsPresent = getSelenium().getSelectedLabel( value );
Assert.assertEquals( optionsPresent, value ); Assert.assertEquals( optionsPresent, value );
} }
public void submit() public void submit()
{ {
clickLinkWithXPath( "//input[@type='submit']" ); clickLinkWithXPath( "//input[@type='submit']" );
} }
public void assertButtonWithValuePresent( String text ) public void assertButtonWithValuePresent( String text )
{ {
Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" ); Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" );
} }
public void assertButtonWithIdPresent( String id ) public void assertButtonWithIdPresent( String id )
{ {
Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' isn't present" ); Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' isn't present" );
} }
public void assertButtonWithValueNotPresent( String text ) public void assertButtonWithValueNotPresent( String text )
{ {
Assert.assertFalse( isButtonWithValuePresent( text ), "'" + text + "' button is present" ); Assert.assertFalse( isButtonWithValuePresent( text ), "'" + text + "' button is present" );
} }
public boolean isButtonWithValuePresent( String text ) public boolean isButtonWithValuePresent( String text )
{ {
return isElementPresent( "//button[@value='" + text + "']" ) return isElementPresent( "//button[@value='" + text + "']" )
|| isElementPresent( "//input[@value='" + text + "']" ); || isElementPresent( "//input[@value='" + text + "']" );
} }
public boolean isButtonWithIdPresent( String text ) public boolean isButtonWithIdPresent( String text )
{ {
return isElementPresent( "//button[@id='" + text + "']" ) || isElementPresent( "//input[@id='" + text + "']" ); return isElementPresent( "//button[@id='" + text + "']" ) || isElementPresent( "//input[@id='" + text + "']" );
} }
public void clickButtonWithValue( String text ) public void clickButtonWithValue( String text )
{ {
clickButtonWithValue( text, true ); clickButtonWithValue( text, true );
} }
public void clickButtonWithValue( String text, boolean wait ) public void clickButtonWithValue( String text, boolean wait )
{ {
assertButtonWithValuePresent( text ); assertButtonWithValuePresent( text );
if ( isElementPresent( "//button[@value='" + text + "']" ) ) if ( isElementPresent( "//button[@value='" + text + "']" ) )
{ {
clickLinkWithXPath( "//button[@value='" + text + "']", wait ); clickLinkWithXPath( "//button[@value='" + text + "']", wait );
} }
else else
{ {
clickLinkWithXPath( "//input[@value='" + text + "']", wait ); clickLinkWithXPath( "//input[@value='" + text + "']", wait );
} }
} }
public void clickSubmitWithLocator( String locator ) public void clickSubmitWithLocator( String locator )
{ {
clickLinkWithLocator( locator ); clickLinkWithLocator( locator );
} }
public void clickSubmitWithLocator( String locator, boolean wait ) public void clickSubmitWithLocator( String locator, boolean wait )
{ {
clickLinkWithLocator( locator, wait ); clickLinkWithLocator( locator, wait );
} }
public void clickImgWithAlt( String alt ) public void clickImgWithAlt( String alt )
{ {
clickLinkWithLocator( "//img[@alt='" + alt + "']" ); clickLinkWithLocator( "//img[@alt='" + alt + "']" );
} }
public void clickLinkWithText( String text ) public void clickLinkWithText( String text )
{ {
clickLinkWithText( text, true ); clickLinkWithText( text, true );
} }
public void clickLinkWithText( String text, boolean wait ) public void clickLinkWithText( String text, boolean wait )
{ {
clickLinkWithLocator( "link=" + text, wait ); clickLinkWithLocator( "link=" + text, wait );
} }
public void clickLinkWithXPath( String xpath ) public void clickLinkWithXPath( String xpath )
{ {
clickLinkWithXPath( xpath, true ); clickLinkWithXPath( xpath, true );
} }
public void clickLinkWithXPath( String xpath, boolean wait ) public void clickLinkWithXPath( String xpath, boolean wait )
{ {
clickLinkWithLocator( "xpath=" + xpath, wait ); clickLinkWithLocator( "xpath=" + xpath, wait );
} }
public void clickLinkWithLocator( String locator ) public void clickLinkWithLocator( String locator )
{ {
clickLinkWithLocator( locator, true ); clickLinkWithLocator( locator, true );
} }
public void clickLinkWithLocator( String locator, boolean wait ) public void clickLinkWithLocator( String locator, boolean wait )
{ {
assertElementPresent( locator ); assertElementPresent( locator );
getSelenium().click( locator ); getSelenium().click( locator );
if ( wait ) if ( wait )
{ {
waitPage(); waitPage();
} }
} }
public void setFieldValues( Map<String, String> fieldMap ) public void setFieldValues( Map<String, String> fieldMap )
{ {
Map.Entry<String, String> entry; Map.Entry<String, String> entry;
for ( Iterator<Entry<String, String>> entries = fieldMap.entrySet().iterator(); entries.hasNext(); ) for ( Iterator<Entry<String, String>> entries = fieldMap.entrySet().iterator(); entries.hasNext(); )
{ {
entry = entries.next(); entry = entries.next();
getSelenium().type( entry.getKey(), entry.getValue() ); getSelenium().type( entry.getKey(), entry.getValue() );
} }
} }
public void setFieldValue( String fieldName, String value ) public void setFieldValue( String fieldName, String value )
{ {
getSelenium().type( fieldName, value ); getSelenium().type( fieldName, value );
} }
public void checkField( String locator ) public void checkField( String locator )
{ {
getSelenium().check( locator ); getSelenium().check( locator );
} }
public void uncheckField( String locator ) public void uncheckField( String locator )
{ {
getSelenium().uncheck( locator ); getSelenium().uncheck( locator );
} }
public boolean isChecked( String locator ) public boolean isChecked( String locator )
{ {
return getSelenium().isChecked( locator ); return getSelenium().isChecked( locator );
} }
public void assertIsChecked( String locator ) public void assertIsChecked( String locator )
{ {
Assert.assertTrue( getSelenium().isChecked( locator ) ); Assert.assertTrue( getSelenium().isChecked( locator ) );
} }
public void assertIsNotChecked( String locator ) public void assertIsNotChecked( String locator )
{ {
Assert.assertFalse( getSelenium().isChecked( locator ) ); Assert.assertFalse( getSelenium().isChecked( locator ) );
} }
} }