mirror of https://github.com/apache/archiva.git
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
This commit is contained in:
parent
7b98b75985
commit
fba613f3f2
|
@ -41,9 +41,8 @@
|
|||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>5.8</version>
|
||||
<version>5.14.9</version>
|
||||
<scope>test</scope>
|
||||
<classifier>jdk15</classifier>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-io</groupId>
|
||||
|
@ -114,7 +113,6 @@
|
|||
</dependencies>
|
||||
|
||||
<build>
|
||||
<testSourceDirectory>src/test/testng</testSourceDirectory>
|
||||
<testResources>
|
||||
<testResource>
|
||||
<directory>src/test/resources</directory>
|
||||
|
@ -156,20 +154,15 @@
|
|||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<configuration>
|
||||
<properties>
|
||||
<systemPropertyVariables>
|
||||
<MAX_WAIT_TIME_IN_MS>60000</MAX_WAIT_TIME_IN_MS>
|
||||
<!-- Exclude on all browsers but Firefox, as it is the only one that Selenium supports file uploads on -->
|
||||
<excludegroups>${excluded.groups}</excludegroups>
|
||||
<!--
|
||||
Use this instead of suiteXmlFiles so that we can add the exclusion, as it is only accepted without suiteXmlFiles
|
||||
-->
|
||||
<property>
|
||||
<name>listener</name>
|
||||
<value>org.apache.archiva.web.test.listener.CaptureScreenShotsListener</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>excludegroups</name>
|
||||
<!-- Exclude on all browsers but Firefox, as it is the only one that Selenium supports file uploads on -->
|
||||
<value>${excluded.groups}</value>
|
||||
</property>
|
||||
</properties>
|
||||
<listener>org.apache.archiva.web.test.listener.CaptureScreenShotsListener</listener>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
|
@ -179,16 +172,10 @@
|
|||
<goal>test</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<systemProperties>
|
||||
<property>
|
||||
<name>browser</name>
|
||||
<value>${selenium.browser}</value>
|
||||
</property>
|
||||
<property>
|
||||
<name>baseUrl</name>
|
||||
<value>${baseUrl}</value>
|
||||
</property>
|
||||
</systemProperties>
|
||||
<systemPropertyVariables>
|
||||
<browser>${selenium.browser}</browser>
|
||||
<baseUrl>${baseUrl}</baseUrl>
|
||||
</systemPropertyVariables>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
|
|
|
@ -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" );
|
||||
}
|
||||
|
||||
}
|
|
@ -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
|
||||
{
|
|
@ -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");
|
|
@ -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();
|
|
@ -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
|
||||
{
|
|
@ -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
|
||||
{
|
|
@ -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
|
||||
{
|
|
@ -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
|
||||
{
|
|
@ -36,7 +36,7 @@ import org.testng.annotations.Test;
|
|||
* @version $Id$
|
||||
*/
|
||||
|
||||
@Test ( groups = { "login" } )
|
||||
@Test ( groups = { "login" }, dependsOnGroups = "about")
|
||||
public class LoginTest
|
||||
extends AbstractArchivaTest
|
||||
{
|
|
@ -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();
|
|
@ -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
|
||||
{
|
|
@ -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
|
||||
{
|
|
@ -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
|
||||
{
|
|
@ -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
|
||||
{
|
|
@ -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
|
||||
{
|
|
@ -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" );
|
|
@ -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
|
||||
{
|
|
@ -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--;
|
|
@ -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" );
|
||||
}
|
||||
}
|
|
@ -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 )
|
|
@ -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" );
|
||||
}
|
||||
|
||||
}
|
|
@ -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" );
|
||||
}
|
||||
}
|
31
pom.xml
31
pom.xml
|
@ -64,7 +64,7 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>1.0-alpha-4</version>
|
||||
<version>1.3.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
|
@ -130,10 +130,15 @@
|
|||
</dependency>
|
||||
</dependencies>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-clean-plugin</artifactId>
|
||||
<version>2.5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.2-beta-3</version>
|
||||
<version>2.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
|
@ -147,32 +152,32 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-remote-resources-plugin</artifactId>
|
||||
<version>1.0-beta-2</version>
|
||||
<version>1.5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-deploy-plugin</artifactId>
|
||||
<version>2.3</version>
|
||||
<version>2.7</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-gpg-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
<version>1.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-install-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>2.5</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-jar-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>2.4</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-release-plugin</artifactId>
|
||||
<version>2.0-beta-9</version>
|
||||
<version>2.4.1</version>
|
||||
<configuration>
|
||||
<tagBase>https://svn.apache.org/repos/asf/archiva/tags</tagBase>
|
||||
<useReleaseProfile>false</useReleaseProfile>
|
||||
|
@ -186,22 +191,16 @@
|
|||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<version>2.2</version>
|
||||
<version>2.6</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.4.2</version>
|
||||
<version>2.16</version>
|
||||
<configuration>
|
||||
<redirectTestOutputToFile>true</redirectTestOutputToFile>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-idea-plugin</artifactId>
|
||||
<configuration>
|
||||
<jdkLevel>1.5</jdkLevel>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
|
Loading…
Reference in New Issue