diff options
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webapp-test')
25 files changed, 318 insertions, 97 deletions
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml index d70d16632..060823d68 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml @@ -23,7 +23,7 @@ <parent> <groupId>org.apache.archiva</groupId> <artifactId>archiva-web</artifactId> - <version>1.3-SNAPSHOT</version> + <version>1.4-SNAPSHOT</version> </parent> <artifactId>archiva-webapp-test</artifactId> <packaging>pom</packaging> diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar Binary files differnew file mode 100644 index 000000000..d98bcfb34 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.md5 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.md5 new file mode 100644 index 000000000..7359be6f9 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.md5 @@ -0,0 +1 @@ +ea7dea9244b2a0975cfa117dc34fe18e
\ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.sha1 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.sha1 new file mode 100644 index 000000000..45ec67894 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.jar.sha1 @@ -0,0 +1 @@ +1039566ff5361d07eccd1243c45929b96441c7d6
\ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom new file mode 100644 index 000000000..cbec59866 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom @@ -0,0 +1,24 @@ +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> + <modelVersion>4.0.0</modelVersion> + <groupId>test</groupId> + <artifactId>test</artifactId> + <packaging>jar</packaging> + <version>1.0</version> + <name>test</name> + <url>http://maven.apache.org</url> + <dependencies> + <dependency> + <groupId>junit</groupId> + <artifactId>junit</artifactId> + <version>3.8.1</version> + <scope>test</scope> + </dependency> + </dependencies> +<distributionManagement> +<repository> + <id>test</id> +<url>file://localhost/Users/brett/scm/archiva/archiva/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal</url> +</repository> +</distributionManagement> +</project> diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.md5 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.md5 new file mode 100644 index 000000000..3b20276cd --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.md5 @@ -0,0 +1 @@ +f80c7c493716de649a99db00cd2ff34c
\ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.sha1 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.sha1 new file mode 100644 index 000000000..d7c09225e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/1.0/test-1.0.pom.sha1 @@ -0,0 +1 @@ +4b95c6fa09d1e02efdb69129f53f025e33bc8958
\ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml new file mode 100644 index 000000000..68287fd4e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml @@ -0,0 +1,12 @@ +<?xml version="1.0" encoding="UTF-8"?> +<metadata> + <groupId>test</groupId> + <artifactId>test</artifactId> + <version>1.0</version> + <versioning> + <versions> + <version>1.0</version> + </versions> + <lastUpdated>20100114015837</lastUpdated> + </versioning> +</metadata> diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.md5 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.md5 new file mode 100644 index 000000000..4bb9667e4 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.md5 @@ -0,0 +1 @@ +dab1b8c2475fe839f387ceaef0d82b30
\ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.sha1 b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.sha1 new file mode 100644 index 000000000..f00268387 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/it-resources/appserver-base/data/repositories/internal/test/test/maven-metadata.xml.sha1 @@ -0,0 +1 @@ +4e5b414d5419121ef75131cb52235a9abbf2095a
\ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml index c107bda61..e8607fb3b 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml @@ -33,6 +33,7 @@ under the License. <include name= "reposcan" /> <include name= "artifactmanagement" /> <include name= "search" /> + <include name= "auditlogsreport" /> <include name= "browse" /> <include name= "reports" /> <include name= "virtualrepository" /> 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 ca03471de..1f60076bc 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 @@ -83,34 +83,36 @@ public class ArtifactManagementTest assertTextPresent( "Please add a file to upload." ); } + @Test( enabled = false ) public void testAddArtifactValidValues() { - addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() ); + // TODO: disable test on non *chrome browsers, there is no way to do file uploads (SEL-63) + addArtifact( getGroupId() , "testAddArtifactValidValues", getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() ); assertTextPresent( "Artifact 'test:test:1.0' was successfully deployed to repository 'internal'" ); } //MRM-747 - @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) + @Test( enabled = false ) public void testAddArtifactBlockRedeployments() { - addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() ); - assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." ); + // TODO: disable test on non *chrome browsers, there is no way to do file uploads (SEL-63) + addArtifact( getGroupId() , getArtifactId(), getVersion(), getPackaging() , getArtifactFilePath(), getRepositoryId() ); + assertTextPresent( "Overwriting released artifacts in repository '" + getRepositoryId() + "' is not allowed." ); } - public void testAddArtifactValidValues1() + @Test( enabled = false ) + 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'" ); - } - - @Test(dependsOnMethods = { "testAddArtifactValidValues1" } ) - public void testDeleteArtifact() - { + deleteArtifact( "delete", "delete", "1.0", "internal"); assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" ); } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java new file mode 100644 index 000000000..daedc24a9 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java @@ -0,0 +1,131 @@ +package org.apache.archiva.web.test; + +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +import org.apache.archiva.web.test.parent.AbstractArchivaTest; +import org.testng.annotations.Test; + +@Test( groups = { "auditlogsreport" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) +public class AuditLogsReportTest + extends AbstractArchivaTest +{ + private void goToAuditLogReports() + { + clickLinkWithText( "Audit Log Report" ); + } + + private void assertAuditLogsReportPage() + { + assertPage( "Apache Archiva \\ Audit Log Report" ); + assertTextPresent( "Audit Log Report" ); + + assertElementPresent( "repository" ); + assertElementPresent( "groupId" ); + assertElementPresent( "artifactId" ); + assertElementPresent( "startDate" ); + assertElementPresent( "endDate" ); + assertElementPresent( "rowCount" ); + assertButtonWithValuePresent( "View Audit Log" ); + } + + @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } ) + public void testAuditLogsReport() + { + goToAuditLogReports(); + assertAuditLogsReportPage(); + assertTextPresent( "Latest Events" ); + } + + @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } ) + public void testViewAuditLogsNoDataFound() + { + goToAuditLogReports(); + assertAuditLogsReportPage(); + + setFieldValue( "groupId", "non.existing" ); + submit(); + + assertPage( "Apache Archiva \\ Audit Log Report" ); + assertTextPresent( "Results" ); + assertTextPresent( "No audit logs found." ); + } + + // TODO: add test for adding via WebDAV + // TODO: disable if not running on *chrome + @Test (dependsOnMethods = { "testAddArtifactValidValues" }, enabled = false ) + public void testViewAuditLogsDataFound() + { + goToAuditLogReports(); + assertAuditLogsReportPage(); + + selectValue( "repository", "internal" ); + setFieldValue( "groupId", "test" ); + submit(); + + assertAuditLogsReportPage(); + assertTextPresent( "Results" ); + assertTextNotPresent( "No audit logs found." ); + assertTextPresent( "test-1.0.jar" ); + assertTextPresent( "Uploaded File" ); + assertTextPresent( "internal" ); + assertTextPresent( "admin" ); + } + + // TODO: add test for adding via WebDAV + // TODO: disable if not running on *chrome + @Test (dependsOnMethods = { "testAddArtifactValidValues" }, enabled = false ) + public void testViewAuditLogsOnlyArtifactIdIsSpecified() + { + goToAuditLogReports(); + assertAuditLogsReportPage(); + + selectValue( "repository", "internal" ); + setFieldValue( "artifactId", "test" ); + submit(); + + assertAuditLogsReportPage(); + assertTextPresent( "Results" ); + assertTextNotPresent( "No audit logs found." ); + assertTextPresent( "test-1.0.jar" ); + assertTextPresent( "Uploaded File" ); + assertTextPresent( "internal" ); + assertTextPresent( "admin" ); + } + + // TODO: add test for adding via WebDAV + // TODO: disable if not running on *chrome + @Test (dependsOnMethods = { "testAddArtifactValidValues" }, enabled = false ) + public void testViewAuditLogsForAllRepositories() + { + goToAuditLogReports(); + assertAuditLogsReportPage(); + + selectValue( "repository", "all" ); + submit(); + + assertAuditLogsReportPage(); + assertTextPresent( "Results" ); + assertTextNotPresent( "No audit logs found." ); + assertTextPresent( "test-1.0.jar" ); + assertTextPresent( "Uploaded File" ); + assertTextPresent( "internal" ); + assertTextPresent( "admin" ); + } +} 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 ab6ba818a..c9c60ecce 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 @@ -45,6 +45,7 @@ public class BrowseTest } // MRM-1278 + @Test( enabled = false ) public void testCorrectRepositoryInBrowse() { File artifact = @@ -63,6 +64,7 @@ public class BrowseTest String snapshotsRepo = getProperty( "SNAPSHOTS_REPOSITORY" ); + // TODO: do this differently as uploading doesn't work on browsers other than *chrome (below as well) // upload a snapshot artifact to repository 'releases' addArtifact( "archiva", "archiva-webapp", "1.0-SNAPSHOT", "jar", artifact.getPath(), releasesRepo ); diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/FindArtifactTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/FindArtifactTest.java index 8d1e817e7..3431ebf9e 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/FindArtifactTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/FindArtifactTest.java @@ -22,7 +22,7 @@ package org.apache.archiva.web.test; import org.apache.archiva.web.test.parent.AbstractArchivaTest; import org.testng.annotations.Test; -@Test( groups = { "findartifact" }, dependsOnMethods = { "testAddArtifactValidValues1" }, sequential = true ) +@Test( groups = { "findartifact" }, sequential = true ) public class FindArtifactTest extends AbstractArchivaTest { @@ -33,9 +33,9 @@ public class FindArtifactTest assertTextPresent( "You must select a file, or enter the checksum. If the file was given and you receive this message, there may have been an error generating the checksum." ); } - @Test( dependsOnMethods = { "testFindArtifactNullValues" }) public void testFindArtifactUsingChecksum() { + goToFindArtifactPage(); setFieldValue( "checksumSearch_q" , "8e896baea663a45d7bd2737f8e464481" ); clickButtonWithValue( "Search" ); assertTextPresent( "No results found" ); 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 d46c16907..756763fec 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 @@ -22,13 +22,12 @@ package org.apache.archiva.web.test; import org.apache.archiva.web.test.parent.AbstractArtifactReportsTest; import org.testng.annotations.Test; -@Test( groups = { "reports" }, dependsOnMethods = { "testAddArtifactValidValues" } ) +@Test( groups = { "reports" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) public class ReportsTest extends AbstractArtifactReportsTest { //TODO Tests for repository with defects -// @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) public void testRepoStatisticsWithoutRepoCompared() { goToReportsPage(); @@ -57,7 +56,6 @@ public class ReportsTest assertTextPresent( "Start Date must be earlier than the End Date" ); } - @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) public void testRepositoryStatistics() { String repositoryName = getProperty( "REPOSITORY_NAME" ) ; @@ -78,7 +76,6 @@ public class ReportsTest assertTextPresent( "Statistics Report" ); } - @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) public void testRepositoryHealthWithoutDefect() { goToReportsPage(); @@ -89,7 +86,6 @@ public class ReportsTest assertTextPresent( "The operation generated an empty report." ); } - @Test(dependsOnMethods = { "testAddArtifactValidValues" } ) public void testRepositoryHealthWithoutGroupId() { goToReportsPage(); diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java index c4d5bcad9..6d00d1a32 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java @@ -1,8 +1,5 @@ package org.apache.archiva.web.test; -import org.apache.archiva.web.test.parent.AbstractRepositoryTest; -import org.testng.annotations.Test; - /* * Licensed to the Apache Software Foundation (ASF) under one * or more contributor license agreements. See the NOTICE file @@ -22,6 +19,10 @@ import org.testng.annotations.Test; * under the License. */ +import org.apache.archiva.web.test.parent.AbstractRepositoryTest; +import org.testng.annotations.Test; +import org.testng.Assert; + @Test( groups = { "reposcan" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) public class RepositoryScanningTest extends AbstractRepositoryTest @@ -38,7 +39,7 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_0" , "**/*.dll" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" ); - assertTextPresent( "**/*.dll" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" ); } @Test (dependsOnMethods = { "testAddArtifactFileType" } ) @@ -46,14 +47,15 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_0" , "**/*.zip" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[15]/td[2]/a/img" ); - assertTextPresent( "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() { + 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" ); - assertTextNotPresent( "dll" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "" ); } @Test (dependsOnMethods = { "testDeleteArtifactFileType" } ) @@ -69,7 +71,7 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_1" , "**/*-" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" ); - assertTextPresent( "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." ); + Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." ); } @Test (dependsOnMethods = { "testAddAutoRemove_ExistingValue" } ) @@ -77,14 +79,15 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_1" , "**/*.test" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" ); - assertTextPresent( "**/*.test" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" ); } @Test (dependsOnMethods = { "testAddAutoRemove" } ) public void testDeleteAutoRemove() { + 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" ); - assertTextNotPresent( "test" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "" ); } @Test (dependsOnMethods = { "testDeleteAutoRemove" } ) @@ -92,7 +95,7 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_2" , "" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" ); - assertTextPresent( "Unable to process blank pattern." ); + Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." ); } @Test (dependsOnMethods = { "testAddIgnoredArtifacts_NullValue" } ) @@ -100,7 +103,7 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_2" , "**/*.sh" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" ); - assertTextPresent( "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." ); + Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." ); } @Test (dependsOnMethods = { "testAddIgnoredArtifacts_ExistingValue" } ) @@ -108,14 +111,15 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_2" , "**/*.log" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" ); - assertTextPresent( "**/*.log" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" ); } @Test (dependsOnMethods = { "testAddIgnoredArtifacts" } ) 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" ); - assertTextNotPresent( "log" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "" ); } // @@ -124,7 +128,7 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_3" , "" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" ); - assertTextPresent( "Unable to process blank pattern." ); + Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." ); } @Test (dependsOnMethods = { "testAddIndexableContent_NullValue" } ) @@ -132,7 +136,7 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_3" , "**/*.xml" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" ); - assertTextPresent( "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." ); + Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." ); } @Test (dependsOnMethods = { "testAddIndexableContent_ExistingValue" } ) @@ -140,14 +144,15 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_3" , "**/*.html" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" ); - assertTextPresent( "**/*.html" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" ); } @Test (dependsOnMethods = { "testAddIndexableContent" } ) public void testDeleteIndexableContent() { + 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" ); - assertTextNotPresent( "html" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "" ); } @Test (dependsOnMethods = { "testDeleteIndexableContent" } ) @@ -172,10 +177,6 @@ public class RepositoryScanningTest getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='validate-checksums']" ); clickButtonWithValue( "Update Consumers" ); - // remove the ff. 2 lines if MRM-1238 will be fixed. - getSelenium().goBack(); - waitPage(); - assertPage( "Apache Archiva \\ Administration - Repository Scanning" ); } 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 e23e6bf93..c22e02be7 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 @@ -26,7 +26,6 @@ import org.testng.annotations.Test; public class RepositoryTest extends AbstractRepositoryTest { - @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } ) public void testAddManagedRepoValidValues() { goToRepositoriesPage(); @@ -37,11 +36,9 @@ public class RepositoryTest assertRepositoriesPage(); } - @Test(dependsOnMethods = { "testAddManagedRepoValidValues" } ) public void testAddManagedRepoInvalidValues() - { - goToRepositoriesPage(); - assertRepositoriesPage(); + { + goToRepositoriesPage(); clickLinkWithLocator( "//div[@id='contentArea']/div/div/a[@href='/archiva/admin/addRepository.action']" ); addManagedRepository( "", "" , "" , "", "Maven 2.x Repository", "", "", "" ); assertTextPresent( "You must enter a repository identifier." ); diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java index 08a748a49..d10700985 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.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.AbstractSearchTest; import org.testng.annotations.Test; @@ -34,7 +36,6 @@ public class SearchTest assertTextPresent( "No results found" ); } - @Test (dependsOnMethods = { "testAddArtifactValidValues" } ) public void testSearchExistingArtifact() { searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) ); @@ -43,7 +44,6 @@ public class SearchTest assertLinkPresent( "test" ); } - @Test (dependsOnMethods = { "testAddArtifactValidValues" } ) public void testViewSearchedArtifact() { searchForArtifact( getProperty( "ARTIFACT_ARTIFACTID" ) ); @@ -66,12 +66,29 @@ public class SearchTest assertTextPresent( "Advanced Search - At least one search criteria must be provided." ); } - /* public void testSearchExistingArtifactUsingAdvancedSearchArtifactId() + public void testSearchExistingArtifactUsingAdvancedSearchArtifactId() { - searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, null, null, null ); + searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, getProperty( "REPOSITORYID" ), null, null ); assertTextPresent( "Results" ); assertTextPresent( "Hits: 1 to 1 of 1" ); 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() + { + searchForArtifactAdvancedSearch( null, getProperty( "ARTIFACT_ARTIFACTID" ), null, "snapshots", null, null ); + assertTextPresent( "No results found" ); + assertTextNotPresent( "Results" ); + assertTextNotPresent( "Hits: 1 to 1 of 1" ); + assertLinkNotPresent( "test" ); + } } 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 081320fb8..befbea954 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 @@ -21,6 +21,7 @@ package org.apache.archiva.web.test; import org.apache.archiva.web.test.parent.AbstractRepositoryTest; import org.testng.annotations.Test; +import org.testng.Assert; @Test( groups = { "virtualrepository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) public class VirtualRepositoryTest @@ -37,26 +38,25 @@ public class VirtualRepositoryTest { addRepositoryGroup( "testing" ); //assertAddedRepositoryLink( "testing" ); - assertTextPresent( "testing" ); + Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[1]/p[1]" ), "testing" ); } @Test(dependsOnMethods = { "testAddRepositoryGroupValidValue" } ) public void testAddRepositoryToRepositoryGroup() { addRepositoryToRepositoryGroup( "testing", "internal" ); - assertTextPresent( "internal" ); + Assert.assertEquals( getSelenium().getText( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ), "internal" ); //clickLinkWithXPath( "/html/body/div[4]/div/div/div[2]/div/div/p[2]/a" ); //getSelenium().goBack(); } @Test(dependsOnMethods = { "testAddRepositoryToRepositoryGroup" } ) public void testDeleteRepositoryOfRepositoryGroup() - { - goToRepositoryGroupsPage(); + { deleteRepositoryInRepositoryGroups(); assertTextPresent( "Repository Groups" ); assertTextNotPresent( "No Repository Groups Defined." ); - waitPage(); + Assert.assertFalse( getSelenium().isElementPresent( "//div[@id='contentArea']/div[2]/div/div[3]/div[2]/p[1]" ) ); } @Test(dependsOnMethods = { "testDeleteRepositoryOfRepositoryGroup" } ) diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java index 4e6ed3182..947d7cbf3 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java @@ -20,18 +20,28 @@ package org.apache.archiva.web.test.listener; */ import java.io.File; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.regex.Pattern; import org.apache.archiva.web.test.parent.AbstractSeleniumTest; +import org.apache.commons.io.FileUtils; import org.testng.ITestResult; import org.testng.TestListenerAdapter; +import com.thoughtworks.selenium.Selenium; public class CaptureScreenShotsListener extends TestListenerAdapter { @Override + public void onTestSkipped( ITestResult tr ) + { + System.out.println( "Test " + tr.getName() + " -> Skipped" ); + super.onTestSkipped( tr ); + } + + @Override public void onTestFailure( ITestResult tr ) { captureError( tr ); @@ -48,40 +58,38 @@ public class CaptureScreenShotsListener private void captureError( ITestResult tr ) { - try - { - captureScreenshot( tr ); - } - catch ( RuntimeException e ) - { - System.out.println( "Error when take screenshot for test " + tr.getName() ); - e.printStackTrace(); - } - } - - // captureAssertionError() creates a 'target/screenshots' directory and saves '.png' page screenshot of the - // encountered error - private void captureScreenshot( ITestResult tr ) - { - File f = new File( "" ); - String filePath = f.getAbsolutePath(); - Date d = new Date(); SimpleDateFormat sdf = new SimpleDateFormat( "yyyy.MM.dd-HH_mm_ss" ); - String time = sdf.format( d ); - String fs = File.separator; - File targetPath = new File( filePath + fs + "target" + fs + "screenshots" ); - targetPath.mkdir(); - String cName = tr.getTestClass().getName(); + String time = sdf.format( new Date() ); + File targetPath = new File( "target", "screenshots" ); StackTraceElement stackTrace[] = tr.getThrowable().getStackTrace(); + String cName = tr.getTestClass().getName(); int index = getStackTraceIndexOfCallingClass( cName, stackTrace ); String methodName = stackTrace[index].getMethodName(); int lNumber = stackTrace[index].getLineNumber(); String lineNumber = Integer.toString( lNumber ); String className = cName.substring( cName.lastIndexOf( '.' ) + 1 ); - String fileName = - targetPath.toString() + fs + methodName + "(" + className + ".java_" + lineNumber + ")-" + time + ".png"; - AbstractSeleniumTest.getSelenium().windowMaximize(); - AbstractSeleniumTest.getSelenium().captureEntirePageScreenshot( fileName, "" ); + targetPath.mkdirs(); + Selenium selenium = AbstractSeleniumTest.getSelenium(); + String fileBaseName = methodName + "_" + className + ".java_" + lineNumber + "-" + time; + try + { + selenium.windowMaximize(); + File fileName = new File( targetPath, fileBaseName + ".png" ); + selenium.captureEntirePageScreenshot( fileName.getAbsolutePath(), "" ); + } + catch ( RuntimeException e ) + { + System.out.println( "Error when take screenshot for test " + tr.getName() + ": " + e.getMessage() ); + try + { + File fileName = new File( targetPath, fileBaseName + ".html" ); + FileUtils.writeStringToFile( fileName, selenium.getHtmlSource() ); + } + catch ( IOException ioe ) + { + System.out.println( ioe.getMessage() ); + } + } } private int getStackTraceIndexOfCallingClass( String nameOfClass, StackTraceElement stackTrace[] ) 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 830c39cd7..cf03765b0 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 @@ -14,7 +14,7 @@ public abstract class AbstractArtifactManagementTest public String getArtifactId() { - String artifactId = getProperty( "GROUPID" ) ; + String artifactId = getProperty( "ARTIFACTID" ) ; return artifactId; } 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 b6237b8ef..52f02ef8a 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 @@ -1,6 +1,26 @@ package org.apache.archiva.web.test.parent; +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + import java.io.File; +import org.testng.Assert; public abstract class AbstractRepositoryTest extends AbstractArchivaTest @@ -80,12 +100,13 @@ public abstract class AbstractRepositoryTest public void deleteRepositoryInRepositoryGroups() { + goToRepositoryGroupsPage(); getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[3]/div[1]/a/img" ); + waitPage(); } public void deleteRepositoryGroup( String repositoryName ) { - //goToRepositoryGroupsPage(); getSelenium().click( "xpath=//div[@id='contentArea']/div[2]/div/div[1]/div/a/img" ); waitPage(); assertDeleteRepositoryGroupPage( repositoryName ); @@ -306,23 +327,23 @@ public abstract class AbstractRepositoryTest 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( "," ); - for (String artifacttypes : arrayArtifactTypes ) - assertTextPresent( artifacttypes ); + for (int i = 0; i < arrayArtifactTypes.length; i++) + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table."+i+".0"), arrayArtifactTypes[i]); String autoremove = "**/*.bak,**/*~,**/*-"; String [] arrayAutoremove = autoremove.split( "," ); - for ( String arrayautoremove : arrayAutoremove ) - assertTextPresent( arrayautoremove ); + for (int i = 0; i < arrayAutoremove.length; i++) + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table."+i+".0"), arrayAutoremove[i]); String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**"; String [] arrayIgnored = ignored.split( "," ); - for ( String arrayignored : arrayIgnored ) - assertTextPresent( arrayignored ); + for (int i = 0; i < arrayIgnored.length; i++) + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table."+i+".0"), arrayIgnored[i]); String indexableContent = "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld"; String [] arrayIndexableContent = indexableContent.split( "," ); - for ( String indexablecontent : arrayIndexableContent ) - assertTextPresent( indexablecontent ); + for (int i = 0; i < arrayIndexableContent.length; i++) + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table."+i+".0"), arrayIndexableContent[i]); } ///////////////////////////////////////////// diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java index 410ec14ab..5b787b502 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java @@ -25,7 +25,7 @@ public abstract class AbstractSearchTest //Search public void goToSearchPage() { - if ( !"Apache Archiva \\ Quick Search".equals( getSelenium().getTitle() ) ) + if ( !"Apache Archiva \\ Quick Search".equals( getTitle() ) ) { clickLinkWithText( "Search" ); getSelenium().waitForPageToLoad( maxWaitTimeInMs ); @@ -107,6 +107,10 @@ public abstract class AbstractSearchTest setFieldValue( "rowCount", rowCount ); } + if ( repositoryId != null ) + { + selectValue( "filteredSearch_repositoryId", repositoryId ); + } clickSubmitWithLocator( "filteredSearch_0" ); } -}
\ 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/AbstractSeleniumTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java index 2c697d725..cb4fee208 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java @@ -140,14 +140,13 @@ public abstract class AbstractSeleniumTest { public void assertPage( String title ) { - // Collapse spaces - String actualTitle = getSelenium().getTitle().replaceAll( "[ \n\r]+", " " ); - Assert.assertEquals( actualTitle, title ); + Assert.assertEquals( getTitle(), title ); } public String getTitle() { - return getSelenium().getTitle(); + // Collapse spaces + return getSelenium().getTitle().replaceAll( "[ \n\r]+", " " ); } public String getHtmlContent() |