diff options
7 files changed, 175 insertions, 121 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties b/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties index d427a9cbf..3940355ab 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties @@ -95,3 +95,7 @@ NETWORKPROXY_HOSTNAME= NETWORKPROXY_PORT=8080 NETWORKPROXY_USERNAME=admin NETWORKPROXY_PASSWORD=admin123 + +# Browse - MRM-1278 test +SNAPSHOTS_REPOSITORY=snapshots +RELEASES_REPOSITORY=releases diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java index c2cf2186d..5314669b7 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java @@ -19,6 +19,8 @@ package org.apache.archiva.web.test; * under the License. */ +import java.io.File; + import org.apache.archiva.web.test.parent.AbstractBrowseTest; import org.testng.annotations.Test; @@ -42,4 +44,72 @@ public class BrowseTest 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" ); + } } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java index fbeb00cca..a6d2fd122 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java @@ -30,18 +30,18 @@ public class RepositoryTest public void testAddManagedRepoValidValues() { 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 * * * ?", "", "" ); clickButtonWithValue( "Save" ); - assertTextPresent( "Managed Repository Sample 1" ); - + assertTextPresent( "Managed Repository Sample 1" ); + assertRepositoriesPage(); } - + @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } ) public void testAddManagedRepoInvalidValues() - { - //goToRepositoriesPage(); - clickLinkWithText( "Add" ); + { + assertRepositoriesPage(); + clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" ); addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" ); assertTextPresent( "You must enter a repository identifier." ); assertTextPresent( "You must enter a repository name." ); @@ -51,8 +51,7 @@ public class RepositoryTest @Test(dependsOnMethods = { "testAddManagedRepoInvalidValues" } ) public void testAddManagedRepoNoIdentifier() - { - //goToRepositoriesPage(); + { addManagedRepository( "", "name" , "/home" , "/.index", "Maven 2.x Repository", "0 0 * * * ?", "", "" ); assertTextPresent( "You must enter a repository identifier." ); } @@ -104,11 +103,10 @@ public class RepositoryTest //assertTextNotPresent( "managedrepo" ); } - @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } ) + @Test(dependsOnMethods = { "testAddRemoteRepoValidValues" } ) public void testAddRemoteRepoNullValues() - { - //goToRepositoriesPage(); - clickLinkWithLocator( "//div[@id='contentArea']/div/div[5]/a" ); + { + clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" ); addRemoteRepository( "" , "" , "" , "" , "" , "" , "Maven 2.x Repository" ); assertTextPresent( "You must enter a repository identifier." ); assertTextPresent( "You must enter a repository name." ); @@ -136,11 +134,10 @@ public class RepositoryTest assertTextPresent( "You must enter a url." ); } - @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } ) + @Test(dependsOnMethods = { "testDeleteManageRepo" } ) public void testAddRemoteRepoValidValues() - { - goToRepositoriesPage(); - clickLinkWithLocator( "//div[@id='contentArea']/div/div[5]/a" ); + { + clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRemoteRepository.action']" ); addRemoteRepository( "remoterepo" , "Remote Repository Sample" , "http://repository.codehaus.org/org/codehaus/mojo/" , "" , "" , "" , "Maven 2.x Repository" ); assertTextPresent( "Remote Repository Sample" ); } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java index ddd42ec6e..7fc155b8a 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java @@ -40,7 +40,7 @@ public class VirtualRepositoryTest assertTextPresent( "testing" ); } - //@Test(dependsOnMethods = { "testAddRepositoryValidValue" } ) + @Test(dependsOnMethods = { "testAddRepositoryGroupValidValue" } ) public void testAddRepositoryToRepositoryGroup() { addRepositoryToRepositoryGroup( "testing", "internal" ); @@ -51,15 +51,17 @@ public class VirtualRepositoryTest @Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } ) public void testDeleteRepositoryOfRepositoryGroup() - { + { deleteRepositoryInRepositoryGroups(); assertTextPresent( "Repository Groups" ); assertTextNotPresent( "No Repository Groups Defined." ); + waitPage(); } @Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } ) public void testDeleteRepositoryGroup() - { + { + assertRepositoryGroupsPage(); deleteRepositoryGroup( "testing" ); assertTextPresent( "No Repository Groups Defined." ); } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java index 3b622eae9..95e2fa853 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java @@ -449,25 +449,86 @@ public abstract class AbstractArchivaTest setFieldValue( "organisationLogo" , logoUrl ); clickButtonWithValue( "Save" ); } - - //Upload Artifact - public void goToUploadArtifactPage() - { - clickLinkWithText( "Upload Artifact" ); - assertUploadArtifactPage(); - } - - public void assertUploadArtifactPage() - { - //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"; - String[] arrayUploadArtifact = uploadArtifact.split( "," ); - for ( String uploadartifact : arrayUploadArtifact ) - assertTextPresent( uploadartifact ); - String uploadElements = "groupId,artifactId,version,packaging,classifier,generatePom,artifact,pom,repositoryId"; - String[] arrayUploadElements = uploadElements.split( "," ); - for ( String uploadelements : arrayUploadElements ) - assertElementPresent( uploadelements ); - assertButtonWithValuePresent( "Submit" ); - } + + // Upload Artifact + public void goToAddArtifactPage() + { + clickLinkWithText( "Upload Artifact" ); + assertAddArtifactPage(); + } + + 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 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" ); + } } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java index db3bd70b8..830c39cd7 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java @@ -43,42 +43,12 @@ public abstract class AbstractArtifactManagementTest return repositoryId; } - public void goToAddArtifactPage() - { - clickLinkWithText( "Upload Artifact" ); - assertAddArtifactPage(); - } - public void goToDeleteArtifactPage() { clickLinkWithText( "Delete Artifact" ); 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 ) { goToDeleteArtifactPage(); @@ -89,22 +59,6 @@ public abstract class AbstractArtifactManagementTest 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() { assertPage( "Apache Archiva \\ Delete Artifact" ); diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java index 6b0cf721c..cd651e967 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java @@ -212,23 +212,6 @@ public abstract class AbstractRepositoryTest 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 public void assertAddRemoteRepository() { @@ -283,23 +266,6 @@ public abstract class AbstractRepositoryTest 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 ) { //goToRepositoriesPage(); |