From fba613f3f219a98053148cbf55eac8c4a92f8017 Mon Sep 17 00:00:00 2001 From: Olivier Lamy Date: Tue, 17 Sep 2013 11:55:52 +0000 Subject: [PATCH] upgrade some plugins versions, move selenium tests sources to a standard directory git-svn-id: https://svn.apache.org/repos/asf/archiva/branches/archiva-1.3.x@1523993 13f79535-47bb-0310-9956-ffa450edef68 --- .../archiva-web/archiva-webapp-test/pom.xml | 35 +- .../archiva/web/test/AppearanceTest.java | 91 +++ .../archiva/web/test/ArchivaAdminTest.java | 0 .../web/test/ArtifactManagementTest.java | 2 +- .../archiva/web/test/AuditLogsReportTest.java | 16 +- .../apache/archiva/web/test/BrowseTest.java | 4 +- .../archiva/web/test/CSRFSecurityTest.java | 2 +- .../apache/archiva/web/test/DatabaseTest.java | 2 +- .../archiva/web/test/FindArtifactTest.java | 2 +- .../archiva/web/test/LegacySupportTest.java | 2 +- .../apache/archiva/web/test/LoginTest.java | 2 +- .../archiva/web/test/NetworkProxiesTest.java | 4 +- .../apache/archiva/web/test/ReportsTest.java | 2 +- .../web/test/RepositoryScanningTest.java | 2 +- .../archiva/web/test/RepositoryTest.java | 2 +- .../apache/archiva/web/test/SearchTest.java | 2 +- .../archiva/web/test/UserRolesTest.java | 2 +- .../web/test/VirtualRepositoryTest.java | 4 +- .../archiva/web/test/XPathExpressionUtil.java | 0 .../archiva/web/test/XSSSecurityTest.java | 2 +- .../listener/CaptureScreenShotsListener.java | 9 +- .../web/test/parent/AbstractArchivaTest.java | 691 ++++++++++++++++++ .../AbstractArtifactManagementTest.java | 0 .../parent/AbstractArtifactReportsTest.java | 0 .../web/test/parent/AbstractBrowseTest.java | 0 .../test/parent/AbstractRepositoryTest.java | 0 .../web/test/parent/AbstractSearchTest.java | 0 .../web/test/parent/AbstractSeleniumTest.java | 13 +- .../archiva/web/test/AppearanceTest.java | 83 --- .../web/test/parent/AbstractArchivaTest.java | 661 ----------------- pom.xml | 31 +- 31 files changed, 852 insertions(+), 814 deletions(-) create mode 100644 archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/AppearanceTest.java rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/ArchivaAdminTest.java (100%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/ArtifactManagementTest.java (98%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/AuditLogsReportTest.java (89%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/BrowseTest.java (97%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/CSRFSecurityTest.java (98%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/DatabaseTest.java (97%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/FindArtifactTest.java (95%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/LegacySupportTest.java (98%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/LoginTest.java (98%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/NetworkProxiesTest.java (97%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/ReportsTest.java (97%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/RepositoryScanningTest.java (98%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/RepositoryTest.java (99%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/SearchTest.java (97%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/UserRolesTest.java (99%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/VirtualRepositoryTest.java (94%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/XPathExpressionUtil.java (100%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/XSSSecurityTest.java (99%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java (93%) create mode 100644 archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java (100%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java (100%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/parent/AbstractBrowseTest.java (100%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java (100%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/parent/AbstractSearchTest.java (100%) rename archiva-modules/archiva-web/archiva-webapp-test/src/test/{testng => java}/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java (95%) delete mode 100644 archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AppearanceTest.java delete mode 100644 archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java diff --git a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml index 7ea361392..1951fafea 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/pom.xml +++ b/archiva-modules/archiva-web/archiva-webapp-test/pom.xml @@ -41,9 +41,8 @@ org.testng testng - 5.8 + 5.14.9 test - jdk15 commons-io @@ -114,7 +113,6 @@ - src/test/testng src/test/resources @@ -156,20 +154,15 @@ org.apache.maven.plugins maven-surefire-plugin - + + 60000 + + ${excluded.groups} - - listener - org.apache.archiva.web.test.listener.CaptureScreenShotsListener - - - excludegroups - - ${excluded.groups} - - + org.apache.archiva.web.test.listener.CaptureScreenShotsListener + @@ -179,16 +172,10 @@ test - - - browser - ${selenium.browser} - - - baseUrl - ${baseUrl} - - + + ${selenium.browser} + ${baseUrl} + diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/AppearanceTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/AppearanceTest.java new file mode 100644 index 000000000..0a400e8b3 --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/AppearanceTest.java @@ -0,0 +1,91 @@ +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 = { "appearance" }, dependsOnGroups = "login", sequential = true) +public class AppearanceTest + extends AbstractArchivaTest +{ + public void testAddAppearanceEmptyValues() + { + goToAppearancePage(); + clickLinkWithText( "Edit" ); + addEditAppearance( "", "", "" ); + assertTextPresent( "You must enter a name" ); + } + + @Test(dependsOnMethods = { "testAddAppearanceEmptyValues" }) + public void testAddAppearanceInvalidValues() + { + addEditAppearance( "<>~+[ ]'\"", "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"", + "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" ); + assertTextPresent( + "Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." ); + assertTextPresent( "You must enter a URL" ); + assertXpathCount( "//span[@class='errorMessage' and text()='You must enter a URL']", 2 ); + } + + @Test(dependsOnMethods = { "testAddAppearanceInvalidValues" }) + public void testAddAppearanceInvalidOrganisationName() + { + addEditAppearance( "<>~+[ ]'\"", "http://www.apache.org/", "http://www.apache.org/images/asf_logo_wide.gifs" ); + assertTextPresent( + "Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." ); + } + + @Test(dependsOnMethods = { "testAddAppearanceInvalidOrganisationName" }) + public void testAddAppearanceInvalidOrganisationUrl() + { + addEditAppearance( "The Apache Software Foundation", "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"", + "http://www.apache.org/images/asf_logo_wide.gifs" ); + assertTextPresent( "You must enter a URL" ); + assertXpathCount( "//span[@class='errorMessage' and text()='You must enter a URL']", 1 ); + } + + @Test(dependsOnMethods = { "testAddAppearanceInvalidOrganisationUrl" }) + public void testAddAppearanceInvalidOrganisationLogo() + { + addEditAppearance( "The Apache Software Foundation", "http://www.apache.org/", + "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" ); + assertTextPresent( "You must enter a URL" ); + assertXpathCount( "//span[@class='errorMessage' and text()='You must enter a URL']", 1 ); + } + + @Test(dependsOnMethods = { "testAddAppearanceInvalidOrganisationLogo" }) + public void testAddAppearanceValidValues() + { + addEditAppearance( "The Apache Software Foundation", "http://www.apache.org/", + "http://www.apache.org/images/asf_logo_wide.gifs" ); + assertTextPresent( "The Apache Software Foundation" ); + } + + @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" ); + assertTextPresent( "Apache Software Foundation" ); + } + +} \ No newline at end of file diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/ArchivaAdminTest.java similarity index 100% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/ArchivaAdminTest.java 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/java/org/apache/archiva/web/test/ArtifactManagementTest.java similarity index 98% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/ArtifactManagementTest.java index d3f2836c3..93ac71c14 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/java/org/apache/archiva/web/test/ArtifactManagementTest.java @@ -22,7 +22,7 @@ package org.apache.archiva.web.test; import org.apache.archiva.web.test.parent.AbstractArtifactManagementTest; import org.testng.annotations.Test; -@Test( groups = { "artifactmanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) +@Test( groups = { "artifactmanagement" }, dependsOnGroups = "login" ) public class ArtifactManagementTest extends AbstractArtifactManagementTest { 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/java/org/apache/archiva/web/test/AuditLogsReportTest.java similarity index 89% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AuditLogsReportTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/AuditLogsReportTest.java index 8199ef224..c97b33545 100644 --- 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/java/org/apache/archiva/web/test/AuditLogsReportTest.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 = { "auditlogsreport" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) +@Test( groups = { "auditlogsreport" }, dependsOnGroups = {"login", "artifactmanagement", "userroles"} ) public class AuditLogsReportTest extends AbstractArchivaTest { @@ -45,7 +45,7 @@ public class AuditLogsReportTest assertButtonWithValuePresent( "View Audit Log" ); } - @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } ) + @Test public void testAuditLogsReport() { goToAuditLogReports(); @@ -53,7 +53,7 @@ public class AuditLogsReportTest assertTextPresent( "Latest Events" ); } - @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } ) + @Test public void testViewAuditLogsNoDataFound() { goToAuditLogReports(); @@ -68,7 +68,7 @@ public class AuditLogsReportTest } // TODO: add test for adding via WebDAV - @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload") + @Test (groups = "requiresUpload") public void testViewAuditLogsDataFound() { goToAuditLogReports(); @@ -88,7 +88,7 @@ public class AuditLogsReportTest } // TODO: add test for adding via WebDAV - @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload") + @Test ( groups = "requiresUpload") public void testViewAuditLogsOnlyArtifactIdIsSpecified() { goToAuditLogReports(); @@ -108,7 +108,7 @@ public class AuditLogsReportTest } // TODO: add test for adding via WebDAV - @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload") + @Test (groups = "requiresUpload") public void testViewAuditLogsForAllRepositories() { goToAuditLogReports(); @@ -126,7 +126,7 @@ public class AuditLogsReportTest assertTextPresent( "admin" ); } - @Test (dependsOnMethods = { "testAddArtifactValidValues", "testUserWithRepoManagerInternalRole" }, groups = "requiresUpload") + @Test (groups = "requiresUpload") public void testViewAuditLogsViewAuditEventsForManageableRepositoriesOnly() { String groupId = getProperty( "SNAPSHOT_GROUPID" ); @@ -162,7 +162,7 @@ public class AuditLogsReportTest login( getProperty( "ADMIN_USERNAME" ), getProperty( "ADMIN_PASSWORD" ) ); } - @Test (dependsOnMethods = { "testAddArtifactValidValues" }, groups = "requiresUpload") + @Test ( groups = "requiresUpload") public void testViewAuditLogsReportForGroupId() { String groupId = getProperty("AUDITLOG_GROUPID"); 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/java/org/apache/archiva/web/test/BrowseTest.java similarity index 97% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/BrowseTest.java index 2f73cecb8..76841fb2d 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/java/org/apache/archiva/web/test/BrowseTest.java @@ -25,7 +25,7 @@ import org.apache.archiva.web.test.parent.AbstractBrowseTest; import org.testng.Assert; import org.testng.annotations.Test; -@Test( groups = { "browse" }, dependsOnMethods = { "testAddArtifactNullValues" } ) +@Test( groups = { "browse" }, dependsOnGroups = {"login","artifactmanagement"} ) public class BrowseTest extends AbstractBrowseTest { @@ -36,7 +36,7 @@ public class BrowseTest assertBrowsePage(); } - @Test( dependsOnMethods = { "testAddArtifactValidValues" } ) + @Test public void testClickArtifactFromBrowse() { goToBrowsePage(); diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/CSRFSecurityTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/CSRFSecurityTest.java similarity index 98% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/CSRFSecurityTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/CSRFSecurityTest.java index 3883605a8..8aa7ff5db 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/CSRFSecurityTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/CSRFSecurityTest.java @@ -25,7 +25,7 @@ import org.testng.annotations.Test; /** * Test all actions affected with CSRF security issue. */ -@Test( groups = { "csrf" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) +@Test( groups = { "csrf" }, dependsOnGroups = "login", sequential = true ) public class CSRFSecurityTest extends AbstractArchivaTest { diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/DatabaseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/DatabaseTest.java similarity index 97% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/DatabaseTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/DatabaseTest.java index 1734ad477..ffa78e994 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/DatabaseTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/DatabaseTest.java @@ -22,7 +22,7 @@ package org.apache.archiva.web.test; import org.apache.archiva.web.test.parent.AbstractRepositoryTest; import org.testng.annotations.Test; -@Test( groups = { "database" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) +@Test( groups = { "database" }, dependsOnGroups = "login", sequential = true ) public class DatabaseTest extends AbstractRepositoryTest { 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/java/org/apache/archiva/web/test/FindArtifactTest.java similarity index 95% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/FindArtifactTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/FindArtifactTest.java index f0db8bea3..17d426e6c 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/java/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" }, sequential = true ) +@Test( groups = { "findartifact" }, dependsOnGroups = "login", sequential = true ) public class FindArtifactTest extends AbstractArchivaTest { diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/LegacySupportTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/LegacySupportTest.java similarity index 98% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/LegacySupportTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/LegacySupportTest.java index 183c15f46..ba8b78f5d 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/LegacySupportTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/LegacySupportTest.java @@ -22,7 +22,7 @@ package org.apache.archiva.web.test; import org.apache.archiva.web.test.parent.AbstractArtifactManagementTest; import org.testng.annotations.Test; -@Test( groups = { "legacysupport" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) +@Test( groups = { "legacysupport" }, dependsOnGroups = "login", sequential = true ) public class LegacySupportTest extends AbstractArtifactManagementTest { diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/LoginTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/LoginTest.java similarity index 98% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/LoginTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/LoginTest.java index 6cc1f68ad..ccbeceb3d 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/LoginTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/LoginTest.java @@ -36,7 +36,7 @@ import org.testng.annotations.Test; * @version $Id$ */ -@Test ( groups = { "login" } ) +@Test ( groups = { "login" }, dependsOnGroups = "about") public class LoginTest extends AbstractArchivaTest { diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/NetworkProxiesTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/NetworkProxiesTest.java similarity index 97% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/NetworkProxiesTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/NetworkProxiesTest.java index 8224353d2..846417dec 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/NetworkProxiesTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/NetworkProxiesTest.java @@ -22,11 +22,11 @@ package org.apache.archiva.web.test; import org.apache.archiva.web.test.parent.AbstractRepositoryTest; import org.testng.annotations.Test; -@Test( groups = { "networkproxies" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) +@Test( groups = { "networkproxies" }, dependsOnGroups = {"login","virtualrepository"}) public class NetworkProxiesTest extends AbstractRepositoryTest { - @Test (dependsOnMethods = { "testDeleteRepositoryGroup" } ) + @Test public void testAddNetworkProxyNullValues() { goToNetworkProxiesPage(); 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/java/org/apache/archiva/web/test/ReportsTest.java similarity index 97% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/ReportsTest.java index 756763fec..496cc34ed 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/java/org/apache/archiva/web/test/ReportsTest.java @@ -22,7 +22,7 @@ package org.apache.archiva.web.test; import org.apache.archiva.web.test.parent.AbstractArtifactReportsTest; import org.testng.annotations.Test; -@Test( groups = { "reports" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) +@Test( groups = { "reports" }, dependsOnGroups = "login") public class ReportsTest extends AbstractArtifactReportsTest { 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/java/org/apache/archiva/web/test/RepositoryScanningTest.java similarity index 98% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/RepositoryScanningTest.java index d5b369b2d..aa4e90285 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/java/org/apache/archiva/web/test/RepositoryScanningTest.java @@ -23,7 +23,7 @@ import org.apache.archiva.web.test.parent.AbstractRepositoryTest; import org.testng.annotations.Test; import org.testng.Assert; -@Test( groups = { "reposcan" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) +@Test( groups = { "reposcan" }, dependsOnGroups = "login", sequential = true ) public class RepositoryScanningTest extends AbstractRepositoryTest { 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/java/org/apache/archiva/web/test/RepositoryTest.java similarity index 99% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/RepositoryTest.java index 8b7743253..c1c744efe 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/java/org/apache/archiva/web/test/RepositoryTest.java @@ -22,7 +22,7 @@ package org.apache.archiva.web.test; import org.apache.archiva.web.test.parent.AbstractRepositoryTest; import org.testng.annotations.Test; -@Test( groups = { "repository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) +@Test( groups = { "repository" }, dependsOnGroups = "login", sequential = true ) public class RepositoryTest extends AbstractRepositoryTest { 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/java/org/apache/archiva/web/test/SearchTest.java similarity index 97% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/SearchTest.java index d10700985..7a0ac36b1 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/java/org/apache/archiva/web/test/SearchTest.java @@ -24,7 +24,7 @@ import java.io.File; import org.apache.archiva.web.test.parent.AbstractSearchTest; import org.testng.annotations.Test; -@Test( groups = { "search" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) +@Test( groups = { "search" }, dependsOnGroups = "login" ) public class SearchTest extends AbstractSearchTest { diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/UserRolesTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/UserRolesTest.java similarity index 99% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/UserRolesTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/UserRolesTest.java index 1f984fbc7..db82aeb0e 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/UserRolesTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/UserRolesTest.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 = { "userroles" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) +@Test( groups = { "userroles" }, dependsOnGroups = "login") public class UserRolesTest extends AbstractArchivaTest { 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/java/org/apache/archiva/web/test/VirtualRepositoryTest.java similarity index 94% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/VirtualRepositoryTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/VirtualRepositoryTest.java index 158baf134..5d17bed90 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/java/org/apache/archiva/web/test/VirtualRepositoryTest.java @@ -23,7 +23,7 @@ import org.apache.archiva.web.test.parent.AbstractRepositoryTest; import org.testng.annotations.Test; import org.testng.Assert; -@Test( groups = { "virtualrepository" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } ) +@Test( groups = { "virtualrepository" }, dependsOnGroups = "login") public class VirtualRepositoryTest extends AbstractRepositoryTest { @@ -33,7 +33,7 @@ public class VirtualRepositoryTest assertTextPresent( "Identifier field is required." ); } - @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } ) + @Test public void testAddRepositoryGroupValidValue() { addRepositoryGroup( "testing" ); diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/XPathExpressionUtil.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/XPathExpressionUtil.java similarity index 100% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/XPathExpressionUtil.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/XPathExpressionUtil.java diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/XSSSecurityTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/XSSSecurityTest.java similarity index 99% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/XSSSecurityTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/XSSSecurityTest.java index 1b9cfa1d1..c4ebb47de 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/XSSSecurityTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/XSSSecurityTest.java @@ -25,7 +25,7 @@ import org.apache.archiva.web.test.parent.AbstractArchivaTest; /** * Test all actions affected with XSS security issue. */ -@Test( groups = { "xss" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) +@Test( groups = { "xss" }, dependsOnGroups = "login", sequential = true ) public class XSSSecurityTest extends AbstractArchivaTest { 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/java/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java similarity index 93% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java index 8ee826394..0a7c9be71 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/java/org/apache/archiva/web/test/listener/CaptureScreenShotsListener.java @@ -83,7 +83,7 @@ public class CaptureScreenShotsListener try { File fileName = new File( targetPath, fileBaseName + ".html" ); - FileUtils.writeStringToFile( fileName, selenium.getHtmlSource() ); + FileUtils.writeStringToFile( fileName, selenium ==null? "nothing" : selenium.getHtmlSource() ); } catch ( IOException ioe ) { @@ -92,7 +92,7 @@ public class CaptureScreenShotsListener } } - private int getStackTraceIndexOfCallingClass( String nameOfClass, StackTraceElement stackTrace[] ) + private int getStackTraceIndexOfCallingClass( String nameOfClass, StackTraceElement[] stackTrace ) { boolean match = false; int i = 0; @@ -101,6 +101,11 @@ public class CaptureScreenShotsListener String className = stackTrace[i].getClassName(); match = Pattern.matches( nameOfClass, className ); i++; + // avoid AIOOBE + if ( i >= stackTrace.length ) + { + return 0; + } } while ( match == false ); i--; diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java new file mode 100644 index 000000000..265c3807e --- /dev/null +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArchivaTest.java @@ -0,0 +1,691 @@ +package org.apache.archiva.web.test.parent; + +import java.io.File; +import java.io.IOException; + +import org.apache.archiva.web.test.XPathExpressionUtil; + +/* + * 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. + */ + +public abstract class AbstractArchivaTest + extends AbstractSeleniumTest +{ + 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() + { + String password_new = getProperty( "NEW_USERROLE_PASSWORD" ); + return password_new; + } + + public String getBasedir() + { + String basedir = System.getProperty( "basedir" ); + + if ( basedir == null ) + { + basedir = new File( "" ).getAbsolutePath(); + } + + 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 ); + setFieldValue( "password", password ); + if ( rememberme ) + { + 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 void goToUserManagementPage() + { + getSelenium().open( "/archiva/security/userlist.action" ); + 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() ); + getSelenium().open( "/archiva/security/userlist.action" ); + clickButtonWithValue( "Create New User" ); + assertCreateUserPage(); + setFieldValue( "user.username", userName ); + setFieldValue( "user.fullName", fullName ); + setFieldValue( "user.email", emailAd ); + setFieldValue( "user.password", password ); + setFieldValue( "user.confirmPassword", confirmPassword ); + submit(); + + assertUserRolesPage(); + clickButtonWithValue( "Submit" ); + + if ( valid ) + { + String[] columnValues = { userName, fullName, emailAd }; + assertElementPresent( XPathExpressionUtil.getTableRow( columnValues ) ); + } + else + { + assertCreateUserPage(); + } + } + + public void deleteUser( String userName, String fullName, String emailAdd ) + { + deleteUser( userName, fullName, emailAdd, false, false ); + } + + public void deleteUser( String userName, String fullName, String emailAd, boolean validated, boolean locked ) + { + String[] columnValues = { userName, fullName, emailAd }; + //clickLinkWithText( "userlist" ); + clickLinkWithXPath( "//table[@id='ec_table']/tbody[2]/tr[3]/td[7]/a/img" ); + assertDeleteUserPage( userName ); + submit(); + assertElementNotPresent( XPathExpressionUtil.getTableRow( columnValues ) ); + } + + public void login( String username, String password ) + { + login( username, password, true, "Login Page" ); + } + + public void login( String username, String password, boolean valid, String assertReturnPage ) + { + if ( isLinkPresent( "Login" ) ) + { + goToLoginPage(); + + submitLoginPage( username, password, false, valid, assertReturnPage ); + } + if ( valid ) + { + assertUserLoggedIn( username ); + } + } + + public void submitLoginPage( String username, String password ) + { + submitLoginPage( username, password, false, true, "Login Page" ); + } + + public void submitLoginPage( String username, String password, boolean validUsernamePassword ) + { + submitLoginPage( username, password, false, validUsernamePassword, "Login Page" ); + } + + public void submitLoginPage( String username, String password, boolean rememberMe, boolean validUsernamePassword, + String assertReturnPage ) + { + assertLoginPage(); + setFieldValue( "username", username ); + setFieldValue( "password", password ); + if ( rememberMe ) + { + checkField( "rememberMe" ); + } + clickButtonWithValue( "Login" ); + + if ( validUsernamePassword ) + { + assertUserLoggedIn( username ); + } + else + { + if ( "Login Page".equals( assertReturnPage ) ) + { + assertLoginPage(); + } + else + { + assertPage( assertReturnPage ); + } + } + } + + protected void assertUserLoggedIn( String username ) + { + assertTextPresent( "Current User:" ); + assertTextPresent( username ); + assertLinkPresent( "Edit Details" ); + assertLinkPresent( "Logout" ); + assertTextNotPresent( "Login" ); + } + + // User Roles + public void assertUserRoleCheckBoxPresent( String value ) + { + getSelenium().isElementPresent( + "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value + + "']" ); + } + + public void assertResourceRolesCheckBoxPresent( String value ) + { + getSelenium().isElementPresent( "xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']" ); + } + + public void checkUserRoleWithValue( String value ) + { + assertUserRoleCheckBoxPresent( value ); + getSelenium().click( + "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value + + "']" ); + } + + public void checkResourceRoleWithValue( String value ) + { + assertResourceRolesCheckBoxPresent( 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,Database"; + String[] arrayMenu = navMenu.split( "," ); + for ( String navmenu : arrayMenu ) + { + assertLinkPresent( navmenu ); + } + } + } + + //Find Artifact + public void goToFindArtifactPage() + { + getSelenium().open( "/archiva/findArtifact.action" ); + 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() + { + getSelenium().open( "/archiva/admin/configureAppearance.action" ); + 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() + { + getSelenium().open( "/archiva/upload.action" ); + 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" ); + } + + String path; + if ( artifactFilePath != null && artifactFilePath.trim().length() > 0 ) + { + File f = new File( artifactFilePath ); + try + { + path = f.getCanonicalPath(); + } + catch ( IOException e ) + { + path = f.getAbsolutePath(); + } + } + else + { + path = artifactFilePath; + } + + setFieldValue( "artifact", path ); + setFieldValue( "repositoryId", repositoryId ); + + clickButtonWithValue( "Submit" ); + } + + public void goToRepositoriesPage() + { + if ( !getTitle().equals( "Apache Archiva \\ Administration - Repositories" ) ) + { + getSelenium().open( "/archiva/admin/repositories.action" ); + } + 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" ); + } + + // artifact management + public void assertDeleteArtifactPage() + { + assertPage( "Apache Archiva \\ Delete Artifact" ); + assertTextPresent( "Delete Artifact" ); + assertTextPresent( "Group Id*:" ); + assertTextPresent( "Artifact Id*:" ); + assertTextPresent( "Version*:" ); + assertTextPresent( "Repository Id:" ); + assertElementPresent( "groupId" ); + assertElementPresent( "artifactId" ); + assertElementPresent( "version" ); + assertElementPresent( "repositoryId" ); + assertButtonWithValuePresent( "Submit" ); + } + + // network proxies + public void goToNetworkProxiesPage() + { + clickLinkWithText( "Network Proxies" ); + assertNetworkProxiesPage(); + } + + public void assertNetworkProxiesPage() + { + assertPage( "Apache Archiva \\ Administration - Network Proxies" ); + assertTextPresent( "Administration - Network Proxies" ); + assertTextPresent( "Network Proxies" ); + assertLinkPresent( "Add Network Proxy" ); + } + + public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username, + String password ) + { + //goToNetworkProxiesPage(); + clickLinkWithText( "Add Network Proxy" ); + assertAddNetworkProxy(); + setFieldValue( "proxy.id", identifier ); + setFieldValue( "proxy.protocol", protocol ); + setFieldValue( "proxy.host", hostname ); + setFieldValue( "proxy.port", port ); + setFieldValue( "proxy.username", username ); + setFieldValue( "proxy.password", password ); + clickButtonWithValue( "Save Network Proxy" ); + } + + public void assertAddNetworkProxy() + { + assertPage( "Apache Archiva \\ Admin: Add Network Proxy" ); + assertTextPresent( "Admin: Add Network Proxy" ); + assertTextPresent( "Add network proxy:" ); + assertTextPresent( "Identifier*:" ); + assertTextPresent( "Protocol*:" ); + assertTextPresent( "Hostname*:" ); + assertTextPresent( "Port*:" ); + assertTextPresent( "Username:" ); + assertTextPresent( "Password:" ); + assertButtonWithValuePresent( "Save Network Proxy" ); + } + + // Legacy Support + public void goToLegacySupportPage() + { + getSelenium().open( "/archiva/admin/legacyArtifactPath.action" ); + assertLegacySupportPage(); + } + + public void assertLegacySupportPage() + { + assertPage( "Apache Archiva \\ Administration - Legacy Support" ); + assertTextPresent( "Administration - Legacy Artifact Path Resolution" ); + assertTextPresent( "Path Mappings" ); + assertLinkPresent( "Add" ); + } + + public void addLegacyArtifactPath( String path, String groupId, String artifactId, String version, + String classifier, String type ) + { + assertAddLegacyArtifactPathPage(); + setFieldValue( "legacyArtifactPath.path", path ); + setFieldValue( "groupId", groupId ); + setFieldValue( "artifactId", artifactId ); + setFieldValue( "version", version ); + setFieldValue( "classifier", classifier ); + setFieldValue( "type", type ); + clickButtonWithValue( "Add Legacy Artifact Path" ); + } + + public void assertAddLegacyArtifactPathPage() + { + assertPage( "Apache Archiva \\ Admin: Add Legacy Artifact Path" ); + assertTextPresent( "Admin: Add Legacy Artifact Path" ); + assertTextPresent( + "Enter the legacy path to map to a particular artifact reference, then adjust the fields as necessary." ); + String element = + "addLegacyArtifactPath_legacyArtifactPath_path,addLegacyArtifactPath_groupId,addLegacyArtifactPath_artifactId,addLegacyArtifactPath_version,addLegacyArtifactPath_classifier,addLegacyArtifactPath_type"; + String[] arrayElement = element.split( "," ); + for ( String arrayelement : arrayElement ) + { + assertElementPresent( arrayelement ); + } + assertButtonWithValuePresent( "Add Legacy Artifact Path" ); + } + + protected void logout() + { + clickLinkWithText( "Logout" ); + assertTextNotPresent( "Current User:" ); + assertLinkNotPresent( "Edit Details" ); + assertLinkNotPresent( "Logout" ); + assertLinkPresent( "Login" ); + } +} 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/java/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java similarity index 100% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArtifactManagementTest.java diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java similarity index 100% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractBrowseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractBrowseTest.java similarity index 100% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractBrowseTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractBrowseTest.java 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/java/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java similarity index 100% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java 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/java/org/apache/archiva/web/test/parent/AbstractSearchTest.java similarity index 100% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSearchTest.java 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/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java similarity index 95% rename from archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java rename to archiva-modules/archiva-web/archiva-webapp-test/src/test/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java index 98d4b6f8d..884a6efbc 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/java/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java @@ -58,7 +58,7 @@ public abstract class AbstractSeleniumTest { p.load( this.getClass().getClassLoader().getResourceAsStream( "testng.properties" ) ); //baseUrl = getProperty( "BASE_URL" ); - maxWaitTimeInMs = getProperty( "MAX_WAIT_TIME_IN_MS" ); + maxWaitTimeInMs = System.getProperty( "MAX_WAIT_TIME_IN_MS" ); } /** @@ -80,7 +80,16 @@ public abstract class AbstractSeleniumTest { public static Selenium getSelenium() { - return selenium == null ? null : selenium.get(); + if (selenium.get() != null) + { + return selenium.get(); + } + DefaultSelenium s = + new DefaultSelenium( System.getProperty("seleniumHost","localhost"), Integer.getInteger( "seleniumPort",4444), System.getProperty("browser"), baseUrl ); + s.start(); + s.setTimeout( maxWaitTimeInMs ); + selenium.set( s ); + return selenium.get(); } protected String getProperty( String key ) diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AppearanceTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AppearanceTest.java deleted file mode 100644 index dbd140ab2..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/AppearanceTest.java +++ /dev/null @@ -1,83 +0,0 @@ -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 = { "appearance" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) -public class AppearanceTest extends AbstractArchivaTest -{ - public void testAddAppearanceEmptyValues() - { - goToAppearancePage(); - clickLinkWithText( "Edit" ); - addEditAppearance( "", "", "" ); - assertTextPresent( "You must enter a name" ); - } - - @Test( dependsOnMethods = { "testAddAppearanceEmptyValues" }) - public void testAddAppearanceInvalidValues() - { - addEditAppearance( "<>~+[ ]'\"" , "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" , "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" ); - assertTextPresent( "Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." ); - assertTextPresent( "You must enter a URL" ); - assertXpathCount("//span[@class='errorMessage' and text()='You must enter a URL']", 2); - } - - @Test( dependsOnMethods = { "testAddAppearanceInvalidValues" }) - public void testAddAppearanceInvalidOrganisationName() - { - addEditAppearance( "<>~+[ ]'\"" , "http://www.apache.org/" , "http://www.apache.org/images/asf_logo_wide.gifs" ); - assertTextPresent( "Organisation name must only contain alphanumeric characters, white-spaces(' '), equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." ); - } - - @Test( dependsOnMethods = { "testAddAppearanceInvalidOrganisationName" }) - public void testAddAppearanceInvalidOrganisationUrl() - { - addEditAppearance( "The Apache Software Foundation" , "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" , "http://www.apache.org/images/asf_logo_wide.gifs" ); - assertTextPresent( "You must enter a URL" ); - assertXpathCount("//span[@class='errorMessage' and text()='You must enter a URL']", 1); - } - - @Test( dependsOnMethods = { "testAddAppearanceInvalidOrganisationUrl" }) - public void testAddAppearanceInvalidOrganisationLogo() - { - addEditAppearance( "The Apache Software Foundation" , "http://www.apache.org/" , "/home/user/abcXYZ0129._/\\~:?!&=-<> ~+[ ]'\"" ); - assertTextPresent( "You must enter a URL" ); - assertXpathCount("//span[@class='errorMessage' and text()='You must enter a URL']", 1); - } - - @Test( dependsOnMethods = { "testAddAppearanceInvalidOrganisationLogo" }) - public void testAddAppearanceValidValues() - { - addEditAppearance( "The Apache Software Foundation" , "http://www.apache.org/" , "http://www.apache.org/images/asf_logo_wide.gifs" ); - assertTextPresent( "The Apache Software Foundation" ); - } - - @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" ); - assertTextPresent( "Apache Software Foundation" ); - } - -} \ 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/AbstractArchivaTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java deleted file mode 100644 index f6b9fb373..000000000 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java +++ /dev/null @@ -1,661 +0,0 @@ -package org.apache.archiva.web.test.parent; - -import java.io.File; -import java.io.IOException; - -import org.apache.archiva.web.test.XPathExpressionUtil; - -/* - * 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. - */ - -public abstract class AbstractArchivaTest - extends AbstractSeleniumTest -{ - 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() - { - String password_new = getProperty( "NEW_USERROLE_PASSWORD" ); - return password_new; - } - - public String getBasedir() - { - String basedir = System.getProperty( "basedir" ); - - if ( basedir == null ) - { - basedir = new File( "" ).getAbsolutePath(); - } - - 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 ); - setFieldValue( "password", password ); - if ( rememberme ) - { - 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 void goToUserManagementPage() - { - getSelenium().open( "/archiva/security/userlist.action" ); - 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() ); - getSelenium().open( "/archiva/security/userlist.action" ); - clickButtonWithValue( "Create New User" ); - assertCreateUserPage(); - setFieldValue( "user.username", userName ); - setFieldValue( "user.fullName", fullName ); - setFieldValue( "user.email", emailAd ); - setFieldValue( "user.password", password ); - setFieldValue( "user.confirmPassword", confirmPassword ); - submit(); - - assertUserRolesPage( ); - clickButtonWithValue( "Submit" ); - - if (valid ) - { - String[] columnValues = {userName, fullName, emailAd}; - assertElementPresent( XPathExpressionUtil.getTableRow( columnValues ) ); - } - else - { - assertCreateUserPage(); - } - } - - public void deleteUser( String userName, String fullName, String emailAdd ) - { - deleteUser( userName, fullName, emailAdd, false, false ); - } - - public void deleteUser(String userName, String fullName, String emailAd, boolean validated, boolean locked) - { - String[] columnValues = {userName, fullName, emailAd}; - //clickLinkWithText( "userlist" ); - clickLinkWithXPath( "//table[@id='ec_table']/tbody[2]/tr[3]/td[7]/a/img" ); - assertDeleteUserPage( userName ); - submit(); - assertElementNotPresent( XPathExpressionUtil.getTableRow( columnValues ) ); - } - - public void login( String username, String password ) - { - login( username, password, true, "Login Page" ); - } - - public void login( String username, String password, boolean valid, String assertReturnPage ) - { - if ( isLinkPresent( "Login" ) ) - { - goToLoginPage(); - - submitLoginPage( username, password, false, valid, assertReturnPage ); - } - if ( valid ) - { - assertUserLoggedIn( username ); - } - } - - public void submitLoginPage( String username, String password ) - { - submitLoginPage( username, password, false, true, "Login Page" ); - } - - public void submitLoginPage( String username, String password, boolean validUsernamePassword ) - { - submitLoginPage( username, password, false, validUsernamePassword, "Login Page" ); - } - - public void submitLoginPage( String username, String password, boolean rememberMe, boolean validUsernamePassword, - String assertReturnPage ) - { - assertLoginPage(); - setFieldValue( "username", username ); - setFieldValue( "password", password ); - if ( rememberMe ) - { - checkField( "rememberMe" ); - } - clickButtonWithValue( "Login" ); - - if ( validUsernamePassword ) - { - assertUserLoggedIn( username ); - } - else - { - if ( "Login Page".equals( assertReturnPage ) ) - { - assertLoginPage(); - } - else - { - assertPage( assertReturnPage ); - } - } - } - - protected void assertUserLoggedIn( String username ) - { - assertTextPresent( "Current User:" ); - assertTextPresent( username ); - assertLinkPresent( "Edit Details" ); - assertLinkPresent( "Logout" ); - assertTextNotPresent( "Login" ); - } - - // User Roles - public void assertUserRoleCheckBoxPresent(String value) - { - getSelenium() .isElementPresent("xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value + "']"); - } - - public void assertResourceRolesCheckBoxPresent(String value) { - getSelenium().isElementPresent("xpath=//input[@name='addDSelectedRoles' and @value='" + value + "']"); - } - - public void checkUserRoleWithValue(String value) - { - assertUserRoleCheckBoxPresent(value); - getSelenium().click( "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value + "']"); - } - - public void checkResourceRoleWithValue(String value) - { - assertResourceRolesCheckBoxPresent(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,Database"; - String[] arrayMenu = navMenu.split( "," ); - for (String navmenu : arrayMenu ) - assertLinkPresent( navmenu ); - } - } - //Find Artifact - public void goToFindArtifactPage() - { - getSelenium().open( "/archiva/findArtifact.action" ); - 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() - { - getSelenium().open( "/archiva/admin/configureAppearance.action" ); - 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() - { - getSelenium().open( "/archiva/upload.action" ); - 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" ); - } - - String path; - if ( artifactFilePath != null && artifactFilePath.trim().length() > 0 ) - { - File f = new File( artifactFilePath ); - try - { - path = f.getCanonicalPath(); - } - catch ( IOException e ) - { - path = f.getAbsolutePath(); - } - } - else - { - path = artifactFilePath; - } - - setFieldValue( "artifact", path ); - setFieldValue( "repositoryId", repositoryId ); - - clickButtonWithValue( "Submit" ); - } - - public void goToRepositoriesPage() - { - if( !getTitle().equals( "Apache Archiva \\ Administration - Repositories" ) ) - { - getSelenium().open( "/archiva/admin/repositories.action" ); - } - 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" ); - } - - // artifact management - public void assertDeleteArtifactPage() - { - assertPage( "Apache Archiva \\ Delete Artifact" ); - assertTextPresent( "Delete Artifact" ); - assertTextPresent( "Group Id*:" ); - assertTextPresent( "Artifact Id*:" ); - assertTextPresent( "Version*:" ); - assertTextPresent( "Repository Id:" ); - assertElementPresent( "groupId" ); - assertElementPresent( "artifactId" ); - assertElementPresent( "version" ); - assertElementPresent( "repositoryId" ); - assertButtonWithValuePresent( "Submit" ); - } - - // network proxies - public void goToNetworkProxiesPage() - { - clickLinkWithText( "Network Proxies" ); - assertNetworkProxiesPage(); - } - - public void assertNetworkProxiesPage() - { - assertPage( "Apache Archiva \\ Administration - Network Proxies" ); - assertTextPresent( "Administration - Network Proxies" ); - assertTextPresent( "Network Proxies" ); - assertLinkPresent( "Add Network Proxy" ); - } - - public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username, String password ) - { - //goToNetworkProxiesPage(); - clickLinkWithText( "Add Network Proxy" ); - assertAddNetworkProxy(); - setFieldValue( "proxy.id" , identifier ); - setFieldValue( "proxy.protocol" , protocol ); - setFieldValue( "proxy.host" , hostname ); - setFieldValue( "proxy.port" , port ); - setFieldValue( "proxy.username" , username ); - setFieldValue( "proxy.password" , password ); - clickButtonWithValue( "Save Network Proxy" ); - } - - public void assertAddNetworkProxy() - { - assertPage( "Apache Archiva \\ Admin: Add Network Proxy" ); - assertTextPresent( "Admin: Add Network Proxy" ); - assertTextPresent( "Add network proxy:" ); - assertTextPresent( "Identifier*:" ); - assertTextPresent( "Protocol*:" ); - assertTextPresent( "Hostname*:" ); - assertTextPresent( "Port*:" ); - assertTextPresent( "Username:" ); - assertTextPresent( "Password:" ); - assertButtonWithValuePresent( "Save Network Proxy" ); - } - - // Legacy Support - public void goToLegacySupportPage() - { - getSelenium().open( "/archiva/admin/legacyArtifactPath.action" ); - assertLegacySupportPage(); - } - - public void assertLegacySupportPage() - { - assertPage( "Apache Archiva \\ Administration - Legacy Support" ); - assertTextPresent( "Administration - Legacy Artifact Path Resolution" ); - assertTextPresent( "Path Mappings" ); - assertLinkPresent( "Add" ); - } - - public void addLegacyArtifactPath( String path, String groupId, String artifactId, String version, String classifier, String type) - { - assertAddLegacyArtifactPathPage(); - setFieldValue( "legacyArtifactPath.path" , path ); - setFieldValue( "groupId" , groupId ); - setFieldValue( "artifactId" , artifactId ); - setFieldValue( "version" , version ); - setFieldValue( "classifier" , classifier ); - setFieldValue( "type" , type ); - clickButtonWithValue( "Add Legacy Artifact Path" ); - } - - public void assertAddLegacyArtifactPathPage() - { - assertPage( "Apache Archiva \\ Admin: Add Legacy Artifact Path" ); - assertTextPresent( "Admin: Add Legacy Artifact Path" ); - assertTextPresent( "Enter the legacy path to map to a particular artifact reference, then adjust the fields as necessary." ); - String element = "addLegacyArtifactPath_legacyArtifactPath_path,addLegacyArtifactPath_groupId,addLegacyArtifactPath_artifactId,addLegacyArtifactPath_version,addLegacyArtifactPath_classifier,addLegacyArtifactPath_type"; - String[] arrayElement = element.split( "," ); - for ( String arrayelement : arrayElement ) - assertElementPresent( arrayelement ); - assertButtonWithValuePresent( "Add Legacy Artifact Path" ); - } - - protected void logout() - { - clickLinkWithText("Logout"); - assertTextNotPresent( "Current User:" ); - assertLinkNotPresent( "Edit Details" ); - assertLinkNotPresent( "Logout" ); - assertLinkPresent( "Login" ); - } -} diff --git a/pom.xml b/pom.xml index 40de35950..09d96a911 100644 --- a/pom.xml +++ b/pom.xml @@ -64,7 +64,7 @@ org.apache.maven.plugins maven-enforcer-plugin - 1.0-alpha-4 + 1.3.1 @@ -130,10 +130,15 @@ + + org.apache.maven.plugins + maven-clean-plugin + 2.5 + org.apache.maven.plugins maven-assembly-plugin - 2.2-beta-3 + 2.4 org.apache.maven.plugins @@ -147,32 +152,32 @@ org.apache.maven.plugins maven-remote-resources-plugin - 1.0-beta-2 + 1.5 org.apache.maven.plugins maven-deploy-plugin - 2.3 + 2.7 org.apache.maven.plugins maven-gpg-plugin - 1.1 + 1.4 org.apache.maven.plugins maven-install-plugin - 2.2 + 2.5 org.apache.maven.plugins maven-jar-plugin - 2.2 + 2.4 org.apache.maven.plugins maven-release-plugin - 2.0-beta-9 + 2.4.1 https://svn.apache.org/repos/asf/archiva/tags false @@ -186,22 +191,16 @@ org.apache.maven.plugins maven-resources-plugin - 2.2 + 2.6 org.apache.maven.plugins maven-surefire-plugin - 2.4.2 + 2.16 true - - maven-idea-plugin - - 1.5 - -