[MRM-1278] Wrong repository displayed in Archiva browse

o added selenium test that uploads SNAPSHOT artifacts in releases and snapshots repositories and checks artifact info page for correct artifact information
o refactored upload artifact methos in AbstractManagementTest, moved them over to AbstractArchivaTest to avoid repetition in other tests that uses it


git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@882399 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Maria Odea B. Ching 2009-11-20 03:31:19 +00:00
parent caaee4251e
commit 33c8c4c81e
7 changed files with 175 additions and 121 deletions

View File

@ -95,3 +95,7 @@ NETWORKPROXY_HOSTNAME=
NETWORKPROXY_PORT=8080 NETWORKPROXY_PORT=8080
NETWORKPROXY_USERNAME=admin NETWORKPROXY_USERNAME=admin
NETWORKPROXY_PASSWORD=admin123 NETWORKPROXY_PASSWORD=admin123
# Browse - MRM-1278 test
SNAPSHOTS_REPOSITORY=snapshots
RELEASES_REPOSITORY=releases

View File

@ -19,6 +19,8 @@ package org.apache.archiva.web.test;
* under the License. * under the License.
*/ */
import java.io.File;
import org.apache.archiva.web.test.parent.AbstractBrowseTest; import org.apache.archiva.web.test.parent.AbstractBrowseTest;
import org.testng.annotations.Test; import org.testng.annotations.Test;
@ -42,4 +44,72 @@ public class BrowseTest
assertTextPresent( "Artifacts" ); assertTextPresent( "Artifacts" );
} }
// MRM-1278
public void testCorrectRepositoryInBrowse()
{
File artifact =
new File( getBasedir(),
"/src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar" );
//"src/test/it-resources/foo-bar-1.0-20091110.181459-4.jar" );
String releasesRepo = getProperty( "RELEASES_REPOSITORY" );
// create releases repository first
goToRepositoriesPage();
clickLinkWithText( "Add" );
addManagedRepository( getProperty( "RELEASES_REPOSITORY" ), "Releases Repository",
new File( getBasedir(), "target/repository/releases" ).getPath(), "", "Maven 2.x Repository",
"0 0 * * * ?", "", "" );
assertTextPresent( "Releases Repository" );
String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" );
// upload a snapshot artifact to repository 'releases'
addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", artifact.getPath(),
releasesRepo );
assertTextPresent( "Artifact 'archiva:archiva-webapp:1.0-SNAPSHOT' was successfully deployed to repository '" + releasesRepo + "'" );
goToBrowsePage();
assertBrowsePage();
assertGroupsPage( "archiva/" );
assertArtifactsPage( "archiva-webapp/" );
assertArtifactInfoPage( "1.0-SNAPSHOT/", releasesRepo, "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar" );
// upload a snapshot artifact to repository 'snapshots'
addArtifact( "continuum", "continuum-core", "1.0-SNAPSHOT", "jar", artifact.getPath(),
snapshotsRepo );
assertTextPresent( "Artifact 'continuum:continuum-core:1.0-SNAPSHOT' was successfully deployed to repository '" + snapshotsRepo + "'" );
goToBrowsePage();
assertBrowsePage();
assertGroupsPage( "continuum/" );
assertArtifactsPage( "continuum-core/" );
assertArtifactInfoPage( "1.0-SNAPSHOT/", snapshotsRepo, "continuum", "continuum-core", "1.0-SNAPSHOT", "jar" );
}
private void assertArtifactInfoPage( String version, String artifactInfoRepositoryId, String artifactInfoGroupId,
String artifactInfoArtifactId, String artifactInfoVersion, String artifactInfoPackaging )
{
clickLinkWithText( version );
assertPage( "Apache Archiva \\ Browse Repository" );
assertTextPresent( artifactInfoRepositoryId );
assertTextPresent( artifactInfoGroupId );
assertTextPresent( artifactInfoArtifactId );
assertTextPresent( artifactInfoVersion );
assertTextPresent( artifactInfoPackaging );
}
private void assertArtifactsPage( String artifactId )
{
clickLinkWithText( artifactId );
assertPage( "Apache Archiva \\ Browse Repository" );
assertTextPresent( "Versions" );
}
private void assertGroupsPage( String groupId )
{
clickLinkWithText( groupId );
assertPage( "Apache Archiva \\ Browse Repository" );
assertTextPresent( "Artifacts" );
}
} }

View File

@ -30,18 +30,18 @@ public class RepositoryTest
public void testAddManagedRepoValidValues() public void testAddManagedRepoValidValues()
{ {
goToRepositoriesPage(); goToRepositoriesPage();
clickLinkWithText( "Add" ); clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/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/" , "", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
clickButtonWithValue( "Save" ); clickButtonWithValue( "Save" );
assertTextPresent( "Managed Repository Sample 1" ); assertTextPresent( "Managed Repository Sample 1" );
assertRepositoriesPage();
} }
@Test(dependsOnMethods = { "testAddManagedRepoValidValues" } ) @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } )
public void testAddManagedRepoInvalidValues() public void testAddManagedRepoInvalidValues()
{ {
//goToRepositoriesPage(); assertRepositoriesPage();
clickLinkWithText( "Add" ); clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" );
addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" ); addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" );
assertTextPresent( "You must enter a repository identifier." ); assertTextPresent( "You must enter a repository identifier." );
assertTextPresent( "You must enter a repository name." ); assertTextPresent( "You must enter a repository name." );
@ -51,8 +51,7 @@ public class RepositoryTest
@Test(dependsOnMethods = { "testAddManagedRepoInvalidValues" } ) @Test(dependsOnMethods = { "testAddManagedRepoInvalidValues" } )
public void testAddManagedRepoNoIdentifier() public void testAddManagedRepoNoIdentifier()
{ {
//goToRepositoriesPage();
addManagedRepository( "", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" ); addManagedRepository( "", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" );
assertTextPresent( "You must enter a repository identifier." ); assertTextPresent( "You must enter a repository identifier." );
} }
@ -104,11 +103,10 @@ public class RepositoryTest
//assertTextNotPresent( "managedrepo" ); //assertTextNotPresent( "managedrepo" );
} }
@Test(dependsOnMethods = { "testAddManagedRepoValidValues" } ) @Test(dependsOnMethods = { "testAddRemoteRepoValidValues" } )
public void testAddRemoteRepoNullValues() public void testAddRemoteRepoNullValues()
{ {
//goToRepositoriesPage(); clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" );
clickLinkWithLocator( "//div[@id='contentArea']/div/div[5]/a" );
addRemoteRepository( "" , "" , "" , "" , "" , "" , "Maven 2.x Repository" ); addRemoteRepository( "" , "" , "" , "" , "" , "" , "Maven 2.x Repository" );
assertTextPresent( "You must enter a repository identifier." ); assertTextPresent( "You must enter a repository identifier." );
assertTextPresent( "You must enter a repository name." ); assertTextPresent( "You must enter a repository name." );
@ -136,11 +134,10 @@ public class RepositoryTest
assertTextPresent( "You must enter a url." ); assertTextPresent( "You must enter a url." );
} }
@Test(dependsOnMethods = { "testAddManagedRepoValidValues" } ) @Test(dependsOnMethods = { "testDeleteManageRepo" } )
public void testAddRemoteRepoValidValues() public void testAddRemoteRepoValidValues()
{ {
goToRepositoriesPage(); clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" );
clickLinkWithLocator( "//div[@id='contentArea']/div/div[5]/a" );
addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" ); addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" );
assertTextPresent( "Remote Repository Sample" ); assertTextPresent( "Remote Repository Sample" );
} }

View File

@ -40,7 +40,7 @@ public class VirtualRepositoryTest
assertTextPresent( "testing" ); assertTextPresent( "testing" );
} }
//@Test(dependsOnMethods = { "testAddRepositoryValidValue" } ) @Test(dependsOnMethods = { "testAddRepositoryGroupValidValue" } )
public void testAddRepositoryToRepositoryGroup() public void testAddRepositoryToRepositoryGroup()
{ {
addRepositoryToRepositoryGroup( "testing", "internal" ); addRepositoryToRepositoryGroup( "testing", "internal" );
@ -51,15 +51,17 @@ public class VirtualRepositoryTest
@Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } ) @Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } )
public void testDeleteRepositoryOfRepositoryGroup() public void testDeleteRepositoryOfRepositoryGroup()
{ {
deleteRepositoryInRepositoryGroups(); deleteRepositoryInRepositoryGroups();
assertTextPresent( "Repository Groups" ); assertTextPresent( "Repository Groups" );
assertTextNotPresent( "No Repository Groups Defined." ); assertTextNotPresent( "No Repository Groups Defined." );
waitPage();
} }
@Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } ) @Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } )
public void testDeleteRepositoryGroup() public void testDeleteRepositoryGroup()
{ {
assertRepositoryGroupsPage();
deleteRepositoryGroup( "testing" ); deleteRepositoryGroup( "testing" );
assertTextPresent( "No Repository Groups Defined." ); assertTextPresent( "No Repository Groups Defined." );
} }

View File

@ -449,25 +449,86 @@ public abstract class AbstractArchivaTest
setFieldValue( "organisationLogo" , logoUrl ); setFieldValue( "organisationLogo" , logoUrl );
clickButtonWithValue( "Save" ); clickButtonWithValue( "Save" );
} }
//Upload Artifact // Upload Artifact
public void goToUploadArtifactPage() public void goToAddArtifactPage()
{ {
clickLinkWithText( "Upload Artifact" ); clickLinkWithText( "Upload Artifact" );
assertUploadArtifactPage(); assertAddArtifactPage();
} }
public void assertUploadArtifactPage() public void assertAddArtifactPage()
{ {
//assertPage( "Apache Archiva \\ Upload Artifact" ); assertPage( "Apache Archiva \\ Upload Artifact" );
String uploadArtifact = "Upload Artifact,Group Id*,Artifact Id*,Version*,Packaging*,Classifier,Generate Maven 2 POM,Artifact File*,POM File,Repository Id"; assertTextPresent( "Upload Artifact" );
String[] arrayUploadArtifact = uploadArtifact.split( "," );
for ( String uploadartifact : arrayUploadArtifact ) String artifact =
assertTextPresent( uploadartifact ); "Upload Artifact,Group Id*:,Artifact Id*:,Version*:,Packaging*:,Classifier:,Generate Maven 2 POM,Artifact File*:,POM File:,Repository Id:";
String uploadElements = "groupId,artifactId,version,packaging,classifier,generatePom,artifact,pom,repositoryId"; String[] arrayArtifact = artifact.split( "," );
String[] arrayUploadElements = uploadElements.split( "," ); for ( String arrayartifact : arrayArtifact )
for ( String uploadelements : arrayUploadElements ) assertTextPresent( arrayartifact );
assertElementPresent( uploadelements );
assertButtonWithValuePresent( "Submit" ); String artifactElements =
} "upload_groupId,upload_artifactId,upload_version,upload_packaging,upload_classifier,upload_generatePom,upload_artifact,upload_pom,upload_repositoryId,upload_0";
String[] arrayArtifactElements = artifactElements.split( "," );
for ( String artifactelements : arrayArtifactElements )
assertElementPresent( artifactelements );
}
public void addArtifact( String groupId, String artifactId, String version, String packaging,
String artifactFilePath, String repositoryId )
{
addArtifact( groupId, artifactId, version, packaging, true, artifactFilePath, repositoryId );
}
public void addArtifact( String groupId, String artifactId, String version, String packaging, boolean generatePom,
String artifactFilePath, String repositoryId )
{
goToAddArtifactPage();
setFieldValue( "groupId", groupId );
setFieldValue( "artifactId", artifactId );
setFieldValue( "version", version );
setFieldValue( "packaging", packaging );
if ( generatePom )
{
checkField( "generatePom" );
}
setFieldValue( "artifact", artifactFilePath );
setFieldValue( "repositoryId", repositoryId );
clickButtonWithValue( "Submit" );
}
public void goToRepositoriesPage()
{
clickLinkWithText( "Repositories" );
assertRepositoriesPage();
}
public void assertRepositoriesPage()
{
assertPage( "Apache Archiva \\ Administration - Repositories" );
assertTextPresent( "Administration - Repositories" );
assertTextPresent( "Managed Repositories" );
assertTextPresent( "Remote Repositories" );
}
public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron,
String daysOlder, String retentionCount )
{
//goToRepositoriesPage();
//clickLinkWithText( "Add" );
setFieldValue( "repository.id" , identifier );
setFieldValue( "repository.name" , name );
setFieldValue( "repository.location" , directory );
setFieldValue( "repository.indexDir" , indexDirectory );
selectValue( "repository.layout", type );
setFieldValue( "repository.refreshCronExpression" , cron );
setFieldValue( "repository.daysOlder" , daysOlder );
setFieldValue( "repository.retentionCount" , retentionCount );
//TODO
clickButtonWithValue( "Add Repository" );
}
} }

View File

@ -43,42 +43,12 @@ public abstract class AbstractArtifactManagementTest
return repositoryId; return repositoryId;
} }
public void goToAddArtifactPage()
{
clickLinkWithText( "Upload Artifact" );
assertAddArtifactPage();
}
public void goToDeleteArtifactPage() public void goToDeleteArtifactPage()
{ {
clickLinkWithText( "Delete Artifact" ); clickLinkWithText( "Delete Artifact" );
assertDeleteArtifactPage(); assertDeleteArtifactPage();
} }
public void addArtifact( String groupId, String artifactId, String version, String packaging, String artifactFilePath, String repositoryId )
{
addArtifact(groupId, artifactId, version, packaging, true, artifactFilePath, repositoryId);
}
public void addArtifact( String groupId, String artifactId, String version, String packaging, boolean generatePom, String artifactFilePath, String repositoryId)
{
goToAddArtifactPage();
setFieldValue( "groupId" , groupId );
setFieldValue( "artifactId" , artifactId );
setFieldValue( "version" , version );
setFieldValue( "packaging" , packaging );
if ( generatePom )
{
checkField( "generatePom" );
}
setFieldValue( "artifact" , artifactFilePath );
setFieldValue( "repositoryId" , repositoryId );
clickButtonWithValue( "Submit" );
}
public void deleteArtifact( String groupId, String artifactId, String version, String repositoryId ) public void deleteArtifact( String groupId, String artifactId, String version, String repositoryId )
{ {
goToDeleteArtifactPage(); goToDeleteArtifactPage();
@ -89,22 +59,6 @@ public abstract class AbstractArtifactManagementTest
clickButtonWithValue( "Submit" ) ; clickButtonWithValue( "Submit" ) ;
} }
public void assertAddArtifactPage()
{
assertPage( "Apache Archiva \\ Upload Artifact" );
assertTextPresent( "Upload Artifact" );
String artifact = "Upload Artifact,Group Id*:,Artifact Id*:,Version*:,Packaging*:,Classifier:,Generate Maven 2 POM,Artifact File*:,POM File:,Repository Id:";
String[] arrayArtifact = artifact.split( "," );
for ( String arrayartifact : arrayArtifact )
assertTextPresent( arrayartifact );
String artifactElements = "upload_groupId,upload_artifactId,upload_version,upload_packaging,upload_classifier,upload_generatePom,upload_artifact,upload_pom,upload_repositoryId,upload_0";
String[] arrayArtifactElements = artifactElements.split( "," );
for ( String artifactelements : arrayArtifactElements )
assertElementPresent( artifactelements );
}
public void assertDeleteArtifactPage() public void assertDeleteArtifactPage()
{ {
assertPage( "Apache Archiva \\ Delete Artifact" ); assertPage( "Apache Archiva \\ Delete Artifact" );

View File

@ -212,23 +212,6 @@ public abstract class AbstractRepositoryTest
clickButtonWithValue( "Delete" ); clickButtonWithValue( "Delete" );
} }
///////////////////////////////
// repositories
///////////////////////////////
public void goToRepositoriesPage()
{
clickLinkWithText( "Repositories" );
assertRepositoriesPage();
}
public void assertRepositoriesPage()
{
assertPage( "Apache Archiva \\ Administration - Repositories" );
assertTextPresent( "Administration - Repositories" );
assertTextPresent( "Managed Repositories" );
assertTextPresent( "Remote Repositories" );
}
// remote repositories // remote repositories
public void assertAddRemoteRepository() public void assertAddRemoteRepository()
{ {
@ -283,23 +266,6 @@ public abstract class AbstractRepositoryTest
clickButtonWithValue( "Update Repository" ); clickButtonWithValue( "Update Repository" );
} }
// managed repositories
public void addManagedRepository( String identifier, String name, String directory, String indexDirectory, String type, String cron, String daysOlder, String retentionCount )
{
//goToRepositoriesPage();
//clickLinkWithText( "Add" );
setFieldValue( "repository.id" , identifier );
setFieldValue( "repository.name" , name );
setFieldValue( "repository.location" , directory );
setFieldValue( "repository.indexDir" , indexDirectory );
selectValue( "repository.layout", type );
setFieldValue( "repository.refreshCronExpression" , cron );
setFieldValue( "repository.daysOlder" , daysOlder );
setFieldValue( "repository.retentionCount" , retentionCount );
//TODO
clickButtonWithValue( "Add Repository" );
}
public void editManagedRepository( String fieldName, String value ) public void editManagedRepository( String fieldName, String value )
{ {
//goToRepositoriesPage(); //goToRepositoriesPage();