From 9c97bf35bca57b121de1650d5e73c2c0cba68496 Mon Sep 17 00:00:00 2001 From: Wendy Smoak Date: Wed, 20 May 2009 17:26:30 +0000 Subject: [PATCH] [MRM-1164] Improve the Selenium tests so testng.properties no longer needs to be modified (patch #4 Submitted by: Marecor Baclay Also changed the webapp-test profile id to 'it' (integration test). Run with -Pit to include this module. git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@776772 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/resources/testng.properties | 14 +++-- .../web/test/ArtifactManagementTest.java | 52 +++++++++++++++++++ .../apache/archiva/web/test/BrowseTest.java | 2 +- .../apache/archiva/web/test/ReportsTest.java | 26 +++++----- .../AbstractArtifactManagementTest.java | 11 ++-- archiva-modules/archiva-web/pom.xml | 2 +- 6 files changed, 85 insertions(+), 22 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 0b2680028..993e07d5d 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 @@ -21,8 +21,8 @@ ARTIFACT_VERSION=1.0 ARTIFACT_PACKAGING=jar # Reports REPOSITORY_NAME=internal -START_DATE=04/01/2009 -END_DATE=04/30/2009 +START_DATE=05/01/2009 +END_DATE=05/30/2009 # Add Valid Artifact @@ -68,5 +68,13 @@ GROUPID=test ARTIFACTID=test VERSION=1.0 PACKAGING=jar -ARTIFACTFILEPATH=/path/to/artifact/file +ARTIFACTFILEPATH=test REPOSITORYID=internal + +GROUPID1=delete +ARTIFACTID1=delete +VERSION1=1.0 +PACKAGING1=jar +ARTIFACTFILEPATH1=test +# /home/cora/Documents/MAESTRO/installers/maestro-2.1.1/project-server/core/activation-1.1.jar +REPOSITORYID1=internal diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java index 21a42b283..b1781584b 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java @@ -7,6 +7,7 @@ import org.testng.annotations.Test; public class ArtifactManagementTest extends AbstractArtifactManagementTest { + public void testAddArtifactNullValues() { @@ -30,6 +31,7 @@ public class ArtifactManagementTest @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } ) public void testAddArtifactNoArtifactId() { + addArtifact( getGroupId() , " ", getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() ); assertTextPresent( "You must enter an artifactId." ); } @@ -41,6 +43,13 @@ public class ArtifactManagementTest assertTextPresent( "You must enter a version." ); } + @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } ) + public void testAddArtifactInvalidVersion() + { + addArtifact( getGroupId() , getArtifactId(), "asdf", getPackaging() , getArtifactFilePath(), getRepositoryId() ); + assertTextPresent( "Invalid version." ); + } + @Test(dependsOnMethods = { "testAddArtifactNoGroupId" } ) public void testAddArtifactNoPackaging() { @@ -60,4 +69,47 @@ public class ArtifactManagementTest addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() ); assertTextPresent( "Artifact 'test:test:1.0' was successfully deployed to repository 'internal'" ); } + + public void testAddArtifactValidValues1() + { + String groupId = p.getProperty( "GROUPID1" ); + String artifactId = p.getProperty( "ARTIFACTID1" ); + String version = p.getProperty( "VERSION1" ); + String packaging = p.getProperty( "PACKAGING1" ); + String repositoryId = p.getProperty( "REPOSITORYID1" ); + addArtifact( groupId , artifactId, version, packaging , getArtifactFilePath(), repositoryId ); + assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deployed to repository 'internal'" ); + } + + @Test(dependsOnMethods = { "testAddArtifactValidValues1" } ) + public void testDeleteArtifact() + { + deleteArtifact( "delete", "delete", "1.0", "internal"); + assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" ); + } + + public void testDeleteArtifactNoGroupId() + { + deleteArtifact( " ", "delete", "1.0", "internal"); + assertTextPresent( "You must enter a groupId." ); + } + + public void testDeleteArtifactNoArtifactId() + { + deleteArtifact( "delete", " ", "1.0", "internal"); + 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." ); + } } 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 bf27b808e..04018fa48 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 @@ -22,7 +22,7 @@ package org.apache.archiva.web.test; import org.apache.archiva.web.test.parent.AbstractBrowseTest; import org.testng.annotations.Test; -@Test( groups = { "browse" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) +@Test( groups = { "browse" }, dependsOnMethods = { "testAddArtifactNullValues" } ) public class BrowseTest extends AbstractBrowseTest { diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java index e3b34589c..67206b191 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java @@ -36,14 +36,14 @@ public class ReportsTest assertTextPresent( "Please select a repository (or repositories) from the list." ); } -/* @Test(dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } ) + @Test(dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } ) public void testRepositoryStatisticsWithoutDate() { String repositoryName = p.getProperty( "REPOSITORY_NAME" ) ; compareRepositories( "label=" + repositoryName, "", "" ); //TODO - assertTextPresent( "Statistics Report" ); - }*/ + //assertTextPresent( "Statistics Report" ); + } @Test(dependsOnMethods = { "testRepoStatisticsWithoutRepoCompared" } ) public void testRepositoryStatisticsEndEarlierThanStart() @@ -57,7 +57,7 @@ public class ReportsTest assertTextPresent( "Start Date must be earlier than the End Date" ); } -/* @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) + @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) public void testRepositoryStatistics() { String repositoryName = p.getProperty( "REPOSITORY_NAME" ) ; @@ -65,19 +65,19 @@ public class ReportsTest String endDate = p.getProperty( "END_DATE" ); compareRepositories( "label=" + repositoryName, startDate, endDate ); //assertTextPresent( "Statistics for Repository '" + repositoryName + "'" ); - assertPage( "Apache Archiva \\ Reports" ); - assertTextPresent( "Statistics Report" ); - }*/ + //assertPage( "Apache Archiva \\ Reports" ); + //assertTextPresent( "Statistics Report" ); + } -/* @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) + /* @Test( dependsOnMethods = { "testRepositoryStatistics" } ) public void testRepositoriesStatisticComparisonReport() { - goToReportsPage(); + //goToReportsPage(); clickButtonWithValue( "-->>" , false ); clickButtonWithValue( "View Statistics" ); assertTextPresent( "Statistics Report" ); } - */ + @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) public void testRepositoryHealthWithoutDefect() { @@ -89,10 +89,10 @@ public class ReportsTest assertTextPresent( "The operation generated an empty report." ); } -/* @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) + @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) public void testRepositoryHealthWithoutGroupId() { - //goToReportsPage(); + goToReportsPage(); clickButtonWithValue( "Show Report" ); assertPage( "Apache Archiva \\ Reports" ); assertTextPresent( "The operation generated an empty report." ); @@ -102,4 +102,4 @@ public class ReportsTest -} \ No newline at end of file +} 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 64f95ea10..7533a452b 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 @@ -1,5 +1,7 @@ package org.apache.archiva.web.test.parent; +import java.io.File; + public abstract class AbstractArtifactManagementTest extends AbstractArchivaTest { @@ -30,8 +32,9 @@ public abstract class AbstractArtifactManagementTest public String getArtifactFilePath() { - String artifactFilePath = p.getProperty( "ARTIFACTFILEPATH" ) ; - return artifactFilePath; + File f = new File( "" ); + String artifactFilePath = f.getAbsolutePath(); + return artifactFilePath + "/src/test/it-resources/snapshots/org/apache/maven/archiva/web/test/foo-bar/1.0-SNAPSHOT/foo-bar-1.0-SNAPSHOT.jar" ; } public String getRepositoryId() @@ -51,7 +54,7 @@ public abstract class AbstractArtifactManagementTest 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); @@ -78,7 +81,7 @@ public abstract class AbstractArtifactManagementTest public void deleteArtifact( String groupId, String artifactId, String version, String repositoryId ) { - goToAddArtifactPage(); + goToDeleteArtifactPage(); setFieldValue( "groupId" , groupId ); setFieldValue( "artifactId" , artifactId ); setFieldValue( "version" , version ); diff --git a/archiva-modules/archiva-web/pom.xml b/archiva-modules/archiva-web/pom.xml index 1ca576509..7a2e5d7d6 100644 --- a/archiva-modules/archiva-web/pom.xml +++ b/archiva-modules/archiva-web/pom.xml @@ -39,7 +39,7 @@ - webapp-test + it archiva-webapp-test -- 2.39.5