start working on fixing issue with selenium tests

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1165351 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Olivier Lamy 2011-09-05 16:34:57 +00:00
parent b2fb3e0465
commit 31ee82d0d9
4 changed files with 67 additions and 44 deletions

View File

@ -210,6 +210,7 @@
<value>${excluded.groups}</value> <value>${excluded.groups}</value>
</property> </property>
</properties> </properties>
<runOrder>alphabetical</runOrder>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
@ -253,7 +254,6 @@
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId> <artifactId>maven-dependency-plugin</artifactId>
<version>2.2</version>
<executions> <executions>
<execution> <execution>
<id>unzip-archiva-webapp</id> <id>unzip-archiva-webapp</id>

View File

@ -142,21 +142,21 @@ public class ArtifactManagementTest
assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" ); assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" );
} }
@Test( alwaysRun = true ) @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
public void testDeleteArtifactNoGroupId() public void testDeleteArtifactNoGroupId()
{ {
deleteArtifact( " ", "delete", "1.0", "internal" ); deleteArtifact( " ", "delete", "1.0", "internal" );
assertTextPresent( "You must enter a groupId." ); assertTextPresent( "You must enter a groupId." );
} }
@Test( alwaysRun = true ) @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
public void testDeleteArtifactNoArtifactId() public void testDeleteArtifactNoArtifactId()
{ {
deleteArtifact( "delete", " ", "1.0", "internal" ); deleteArtifact( "delete", " ", "1.0", "internal" );
assertTextPresent( "You must enter an artifactId." ); assertTextPresent( "You must enter an artifactId." );
} }
@Test( alwaysRun = true) @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
public void testDeleteArtifactNoVersion() public void testDeleteArtifactNoVersion()
{ {
deleteArtifact( "delete", "delete", " ", "internal" ); deleteArtifact( "delete", "delete", " ", "internal" );
@ -164,7 +164,7 @@ public class ArtifactManagementTest
assertTextPresent( "You must enter a version." ); assertTextPresent( "You must enter a version." );
} }
@Test( alwaysRun = true) @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
public void testDeleteArtifactInvalidVersion() public void testDeleteArtifactInvalidVersion()
{ {
deleteArtifact( "delete", "delete", "asdf", "internal" ); deleteArtifact( "delete", "delete", "asdf", "internal" );
@ -172,7 +172,7 @@ public class ArtifactManagementTest
} }
// HTML select should have the proper value, else it will cause a selenium error: Option with label 'customValue' not found // HTML select should have the proper value, else it will cause a selenium error: Option with label 'customValue' not found
@Test( alwaysRun = true) @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
public void testDeleteArtifactInvalidValues() public void testDeleteArtifactInvalidValues()
{ {
deleteArtifact( "<> \\/~+[ ]'\"", "<> \\/~+[ ]'\"", "<>", "internal" ); deleteArtifact( "<> \\/~+[ ]'\"", "<> \\/~+[ ]'\"", "<>", "internal" );
@ -183,7 +183,7 @@ public class ArtifactManagementTest
"Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." ); "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
} }
@Test( alwaysRun = true) @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
public void testDeleteArtifactInvalidGroupId() public void testDeleteArtifactInvalidGroupId()
{ {
deleteArtifact( "<> \\/~+[ ]'\"", "delete", "1.0", "internal" ); deleteArtifact( "<> \\/~+[ ]'\"", "delete", "1.0", "internal" );
@ -191,7 +191,7 @@ public class ArtifactManagementTest
"Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." ); "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
} }
@Test( alwaysRun = true) @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
public void testDeleteArtifactInvalidArtifactId() public void testDeleteArtifactInvalidArtifactId()
{ {
deleteArtifact( "delete", "<> \\/~+[ ]'\"", "1.0", "internal" ); deleteArtifact( "delete", "<> \\/~+[ ]'\"", "1.0", "internal" );

View File

@ -1,10 +1,10 @@
package org.apache.archiva.web.test.parent; package org.apache.archiva.web.test.parent;
import org.apache.archiva.web.test.XPathExpressionUtil;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import org.apache.archiva.web.test.XPathExpressionUtil;
/* /*
* Licensed to the Apache Software Foundation (ASF) under one * Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file * or more contributor license agreements. See the NOTICE file
@ -103,7 +103,17 @@ public abstract class AbstractArchivaTest
public void goToLoginPage() public void goToLoginPage()
{ {
getSelenium().open( baseUrl ); getSelenium().open( baseUrl );
// are we already logged in ?
if ( isElementPresent( "logoutLink" ) )
{
// so logout
clickLinkWithLocator( "logoutLink" );
clickLinkWithLocator( "loginLink" ); clickLinkWithLocator( "loginLink" );
}
else if ( isElementPresent( "loginLink" ) )
{
clickLinkWithLocator( "loginLink" );
}
assertLoginPage(); assertLoginPage();
} }
@ -202,8 +212,10 @@ public abstract class AbstractArchivaTest
"Guest,Registered User,System Administrator,User Administrator,Global Repository Observer,Global Repository Manager,Repository Observer,Repository Manager,internal"; "Guest,Registered User,System Administrator,User Administrator,Global Repository Observer,Global Repository Manager,Repository Observer,Repository Manager,internal";
String[] arrayRole = userRoles.split( "," ); String[] arrayRole = userRoles.split( "," );
for ( String userroles : arrayRole ) for ( String userroles : arrayRole )
{
assertTextPresent( userroles ); assertTextPresent( userroles );
} }
}
public void assertDeleteUserPage( String username ) public void assertDeleteUserPage( String username )
{ {
@ -336,8 +348,8 @@ public abstract class AbstractArchivaTest
public void assertUserRoleCheckBoxPresent( String value ) public void assertUserRoleCheckBoxPresent( String value )
{ {
getSelenium().isElementPresent( getSelenium().isElementPresent(
"xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value
+ value + "']" ); + "']" );
} }
public void assertResourceRolesCheckBoxPresent( String value ) public void assertResourceRolesCheckBoxPresent( String value )
@ -349,8 +361,8 @@ public abstract class AbstractArchivaTest
{ {
assertUserRoleCheckBoxPresent( value ); assertUserRoleCheckBoxPresent( value );
getSelenium().click( getSelenium().click(
"xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value
+ value + "']" ); + "']" );
} }
public void checkResourceRoleWithValue( String value ) public void checkResourceRoleWithValue( String value )
@ -421,9 +433,11 @@ public abstract class AbstractArchivaTest
"Find Artifact,Browse,Reports,User Management,User Roles,Appearance,Upload Artifact,Delete Artifact,Repository Groups,Repositories,Proxy Connectors,Legacy Support,Network Proxies,Repository Scanning"; "Find Artifact,Browse,Reports,User Management,User Roles,Appearance,Upload Artifact,Delete Artifact,Repository Groups,Repositories,Proxy Connectors,Legacy Support,Network Proxies,Repository Scanning";
String[] arrayMenu = navMenu.split( "," ); String[] arrayMenu = navMenu.split( "," );
for ( String navmenu : arrayMenu ) for ( String navmenu : arrayMenu )
{
assertLinkPresent( navmenu ); assertLinkPresent( navmenu );
} }
} }
}
// Find Artifact // Find Artifact
public void goToFindArtifactPage() public void goToFindArtifactPage()
@ -459,7 +473,9 @@ public abstract class AbstractArchivaTest
"Appearance,Organization Details,The logo in the top right of the screen is controlled by the following settings.,Organization Information,Name,URL,Logo URL"; "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( "," ); String[] arrayAppearance = appearance.split( "," );
for ( String appear : arrayAppearance ) for ( String appear : arrayAppearance )
{
assertTextPresent( appear ); assertTextPresent( appear );
}
assertLinkPresent( "Edit" ); assertLinkPresent( "Edit" );
assertLinkPresent( "Change your appearance" ); assertLinkPresent( "Change your appearance" );
} }
@ -474,8 +490,9 @@ public abstract class AbstractArchivaTest
public void goToHomePage() public void goToHomePage()
{ {
getSelenium().open( ""); getSelenium().open( "" );
} }
// Upload Artifact // Upload Artifact
public void goToAddArtifactPage() public void goToAddArtifactPage()
{ {
@ -577,9 +594,9 @@ public abstract class AbstractArchivaTest
setFieldValue( "repository.id", identifier ); setFieldValue( "repository.id", identifier );
setFieldValue( "repository.name", name ); setFieldValue( "repository.name", name );
setFieldValue( "repository.location", directory ); setFieldValue( "repository.location", directory );
setFieldValue( "repository.indexDir", indexDirectory ); setFieldValue( "repository.indexDirectory", indexDirectory );
selectValue( "repository.layout", type ); selectValue( "repository.layout", type );
setFieldValue( "repository.refreshCronExpression", cron ); setFieldValue( "repository.cronExpression", cron );
setFieldValue( "repository.daysOlder", daysOlder ); setFieldValue( "repository.daysOlder", daysOlder );
setFieldValue( "repository.retentionCount", retentionCount ); setFieldValue( "repository.retentionCount", retentionCount );
// TODO // TODO
@ -617,17 +634,18 @@ public abstract class AbstractArchivaTest
assertLinkPresent( "Add Network Proxy" ); assertLinkPresent( "Add Network Proxy" );
} }
public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username, String password ) public void addNetworkProxy( String identifier, String protocol, String hostname, String port, String username,
String password )
{ {
//goToNetworkProxiesPage(); //goToNetworkProxiesPage();
clickLinkWithText( "Add Network Proxy" ); clickLinkWithText( "Add Network Proxy" );
assertAddNetworkProxy(); assertAddNetworkProxy();
setFieldValue( "proxy.id" , identifier ); setFieldValue( "proxy.id", identifier );
setFieldValue( "proxy.protocol" , protocol ); setFieldValue( "proxy.protocol", protocol );
setFieldValue( "proxy.host" , hostname ); setFieldValue( "proxy.host", hostname );
setFieldValue( "proxy.port" , port ); setFieldValue( "proxy.port", port );
setFieldValue( "proxy.username" , username ); setFieldValue( "proxy.username", username );
setFieldValue( "proxy.password" , password ); setFieldValue( "proxy.password", password );
clickButtonWithValue( "Save Network Proxy" ); clickButtonWithValue( "Save Network Proxy" );
} }
@ -660,15 +678,16 @@ public abstract class AbstractArchivaTest
assertLinkPresent( "Add" ); assertLinkPresent( "Add" );
} }
public void addLegacyArtifactPath( String path, String groupId, String artifactId, String version, String classifier, String type) public void addLegacyArtifactPath( String path, String groupId, String artifactId, String version,
String classifier, String type )
{ {
assertAddLegacyArtifactPathPage(); assertAddLegacyArtifactPathPage();
setFieldValue( "legacyArtifactPath.path" , path ); setFieldValue( "legacyArtifactPath.path", path );
setFieldValue( "groupId" , groupId ); setFieldValue( "groupId", groupId );
setFieldValue( "artifactId" , artifactId ); setFieldValue( "artifactId", artifactId );
setFieldValue( "version" , version ); setFieldValue( "version", version );
setFieldValue( "classifier" , classifier ); setFieldValue( "classifier", classifier );
setFieldValue( "type" , type ); setFieldValue( "type", type );
clickButtonWithValue( "Add Legacy Artifact Path" ); clickButtonWithValue( "Add Legacy Artifact Path" );
} }
@ -676,11 +695,15 @@ public abstract class AbstractArchivaTest
{ {
assertPage( "Apache Archiva \\ Admin: Add Legacy Artifact Path" ); assertPage( "Apache Archiva \\ Admin: Add Legacy Artifact Path" );
assertTextPresent( "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." ); assertTextPresent(
String element = "addLegacyArtifactPath_legacyArtifactPath_path,addLegacyArtifactPath_groupId,addLegacyArtifactPath_artifactId,addLegacyArtifactPath_version,addLegacyArtifactPath_classifier,addLegacyArtifactPath_type"; "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( "," ); String[] arrayElement = element.split( "," );
for ( String arrayelement : arrayElement ) for ( String arrayelement : arrayElement )
{
assertElementPresent( arrayelement ); assertElementPresent( arrayelement );
}
assertButtonWithValuePresent( "Add Legacy Artifact Path" ); assertButtonWithValuePresent( "Add Legacy Artifact Path" );
} }
@ -691,9 +714,9 @@ public abstract class AbstractArchivaTest
setFieldValue( "repository.id", identifier ); setFieldValue( "repository.id", identifier );
setFieldValue( "repository.name", name ); setFieldValue( "repository.name", name );
setFieldValue( "repository.location", directory ); setFieldValue( "repository.location", directory );
setFieldValue( "repository.indexDir", indexDirectory ); setFieldValue( "repository.indexDirectory", indexDirectory );
selectValue( "repository.layout", type ); selectValue( "repository.layout", type );
setFieldValue( "repository.refreshCronExpression", cron ); setFieldValue( "repository.cronExpression", cron );
setFieldValue( "repository.daysOlder", daysOlder ); setFieldValue( "repository.daysOlder", daysOlder );
setFieldValue( "repository.retentionCount", retentionCount ); setFieldValue( "repository.retentionCount", retentionCount );
checkField( "stageNeeded" ); checkField( "stageNeeded" );

View File

@ -273,9 +273,9 @@ public abstract class AbstractRepositoryTest
assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" ); assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
setFieldValue( "repository.name" , name ); setFieldValue( "repository.name" , name );
setFieldValue( "repository.location" , directory ); setFieldValue( "repository.location" , directory );
setFieldValue( "repository.indexDir" , indexDirectory ); setFieldValue( "repository.indexDirectory" , indexDirectory );
selectValue( "repository.layout", type ); selectValue( "repository.layout", type );
setFieldValue( "repository.refreshCronExpression" , cron ); setFieldValue( "repository.cronExpression" , cron );
setFieldValue( "repository.daysOlder" , daysOlder ); setFieldValue( "repository.daysOlder" , daysOlder );
setFieldValue( "repository.retentionCount" , retentionCount ); setFieldValue( "repository.retentionCount" , retentionCount );
clickButtonWithValue( "Update Repository" ); clickButtonWithValue( "Update Repository" );