]> source.dussan.org Git - archiva.git/commitdiff
start working on fixing issue with selenium tests
authorOlivier Lamy <olamy@apache.org>
Mon, 5 Sep 2011 16:34:57 +0000 (16:34 +0000)
committerOlivier Lamy <olamy@apache.org>
Mon, 5 Sep 2011 16:34:57 +0000 (16:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1165351 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-test/pom.xml
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArtifactManagementTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java

index 9af478d5daaecc90538a6dfbb25acd3aa8122862..e1d87ccf0ffad1b82873eadad1d711d1d6974d50 100644 (file)
               <value>${excluded.groups}</value>
             </property>
           </properties>
+          <runOrder>alphabetical</runOrder>
         </configuration>
         <executions>
           <execution>
           <plugin>
             <groupId>org.apache.maven.plugins</groupId>
             <artifactId>maven-dependency-plugin</artifactId>
-            <version>2.2</version>
             <executions>
               <execution>
                 <id>unzip-archiva-webapp</id>
index 7de9fcd0916d49b804d024af1d5b1909e96d42c6..7ce6c57bbd16b36cfacd6c93f4e5e468f9f16c37 100644 (file)
@@ -142,21 +142,21 @@ public class ArtifactManagementTest
         assertTextPresent( "Artifact 'delete:delete:1.0' was successfully deleted from repository 'internal'" );
     }
 
-    @Test( alwaysRun = true )
+    @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
     public void testDeleteArtifactNoGroupId()
     {
         deleteArtifact( " ", "delete", "1.0", "internal" );
         assertTextPresent( "You must enter a groupId." );
     }
 
-    @Test( alwaysRun = true )
+    @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
     public void testDeleteArtifactNoArtifactId()
     {
         deleteArtifact( "delete", " ", "1.0", "internal" );
         assertTextPresent( "You must enter an artifactId." );
     }
 
-    @Test( alwaysRun = true)
+    @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
     public void testDeleteArtifactNoVersion()
     {
         deleteArtifact( "delete", "delete", " ", "internal" );
@@ -164,7 +164,7 @@ public class ArtifactManagementTest
         assertTextPresent( "You must enter a version." );
     }
 
-    @Test( alwaysRun = true)
+    @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
     public void testDeleteArtifactInvalidVersion()
     {
         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
-    @Test( alwaysRun = true)
+    @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
     public void testDeleteArtifactInvalidValues()
     {
         deleteArtifact( "<> \\/~+[ ]'\"", "<> \\/~+[ ]'\"", "<>", "internal" );
@@ -183,7 +183,7 @@ public class ArtifactManagementTest
             "Artifact id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
     }
 
-    @Test( alwaysRun = true)
+    @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
     public void testDeleteArtifactInvalidGroupId()
     {
         deleteArtifact( "<> \\/~+[ ]'\"", "delete", "1.0", "internal" );
@@ -191,7 +191,7 @@ public class ArtifactManagementTest
             "Group id must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
     }
 
-    @Test( alwaysRun = true)
+    @Test( alwaysRun = true, dependsOnMethods = { "testAddArtifactNullValues" } )
     public void testDeleteArtifactInvalidArtifactId()
     {
         deleteArtifact( "delete", "<> \\/~+[ ]'\"", "1.0", "internal" );
index dc52ea5572cd363b8b68f055731df9460e76dbd0..ab68025065986c15f96018b8a9e4ddfbb8a575ca 100644 (file)
@@ -1,10 +1,10 @@
 package org.apache.archiva.web.test.parent;
 
+import org.apache.archiva.web.test.XPathExpressionUtil;
+
 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
@@ -103,7 +103,17 @@ public abstract class AbstractArchivaTest
     public void goToLoginPage()
     {
         getSelenium().open( baseUrl );
-        clickLinkWithLocator( "loginLink" );
+        // are we already logged in ?
+        if ( isElementPresent( "logoutLink" ) )
+        {
+            // so logout
+            clickLinkWithLocator( "logoutLink" );
+            clickLinkWithLocator( "loginLink" );
+        }
+        else if ( isElementPresent( "loginLink" ) )
+        {
+            clickLinkWithLocator( "loginLink" );
+        }
         assertLoginPage();
     }
 
@@ -202,7 +212,9 @@ public abstract class AbstractArchivaTest
             "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 )
@@ -336,8 +348,8 @@ public abstract class AbstractArchivaTest
     public void assertUserRoleCheckBoxPresent( String value )
     {
         getSelenium().isElementPresent(
-                                        "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='"
-                                            + value + "']" );
+            "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value
+                + "']" );
     }
 
     public void assertResourceRolesCheckBoxPresent( String value )
@@ -349,8 +361,8 @@ public abstract class AbstractArchivaTest
     {
         assertUserRoleCheckBoxPresent( value );
         getSelenium().click(
-                             "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='"
-                                 + value + "']" );
+            "xpath=//input[@id='addRolesToUser_addNDSelectedRoles' and @name='addNDSelectedRoles' and @value='" + value
+                + "']" );
     }
 
     public void checkResourceRoleWithValue( String value )
@@ -421,7 +433,9 @@ 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";
             String[] arrayMenu = navMenu.split( "," );
             for ( String navmenu : arrayMenu )
+            {
                 assertLinkPresent( navmenu );
+            }
         }
     }
 
@@ -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";
         String[] arrayAppearance = appearance.split( "," );
         for ( String appear : arrayAppearance )
+        {
             assertTextPresent( appear );
+        }
         assertLinkPresent( "Edit" );
         assertLinkPresent( "Change your appearance" );
     }
@@ -474,8 +490,9 @@ public abstract class AbstractArchivaTest
 
     public void goToHomePage()
     {
-         getSelenium().open( "");
+        getSelenium().open( "" );
     }
+
     // Upload Artifact
     public void goToAddArtifactPage()
     {
@@ -577,9 +594,9 @@ public abstract class AbstractArchivaTest
         setFieldValue( "repository.id", identifier );
         setFieldValue( "repository.name", name );
         setFieldValue( "repository.location", directory );
-        setFieldValue( "repository.indexDir", indexDirectory );
+        setFieldValue( "repository.indexDirectory", indexDirectory );
         selectValue( "repository.layout", type );
-        setFieldValue( "repository.refreshCronExpression", cron );
+        setFieldValue( "repository.cronExpression", cron );
         setFieldValue( "repository.daysOlder", daysOlder );
         setFieldValue( "repository.retentionCount", retentionCount );
         // TODO
@@ -611,23 +628,24 @@ public abstract class AbstractArchivaTest
 
     public void assertNetworkProxiesPage()
     {
-       assertPage( "Apache Archiva \\ Administration - Network Proxies" );
+        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 )
+    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 );
+        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" );
     }
 
@@ -654,21 +672,22 @@ public abstract class AbstractArchivaTest
 
     public void assertLegacySupportPage()
     {
-       assertPage( "Apache Archiva \\ Administration - Legacy Support" );
-       assertTextPresent( "Administration - Legacy Artifact Path Resolution" );
-       assertTextPresent( "Path Mappings" );
-       assertLinkPresent( "Add" );
+        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)
+    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 );
+        setFieldValue( "legacyArtifactPath.path", path );
+        setFieldValue( "groupId", groupId );
+        setFieldValue( "artifactId", artifactId );
+        setFieldValue( "version", version );
+        setFieldValue( "classifier", classifier );
+        setFieldValue( "type", type );
         clickButtonWithValue( "Add Legacy Artifact Path" );
     }
 
@@ -676,11 +695,15 @@ public abstract class AbstractArchivaTest
     {
         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";
+        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 );
+        {
+            assertElementPresent( arrayelement );
+        }
         assertButtonWithValuePresent( "Add Legacy Artifact Path" );
     }
 
@@ -691,9 +714,9 @@ public abstract class AbstractArchivaTest
         setFieldValue( "repository.id", identifier );
         setFieldValue( "repository.name", name );
         setFieldValue( "repository.location", directory );
-        setFieldValue( "repository.indexDir", indexDirectory );
+        setFieldValue( "repository.indexDirectory", indexDirectory );
         selectValue( "repository.layout", type );
-        setFieldValue( "repository.refreshCronExpression", cron );
+        setFieldValue( "repository.cronExpression", cron );
         setFieldValue( "repository.daysOlder", daysOlder );
         setFieldValue( "repository.retentionCount", retentionCount );
         checkField( "stageNeeded" );
index 13b48f43d6d179ab5584cfb376162018d58affae..65f31d4b5f3a452e33ef4054ea03c703cf7eccee 100644 (file)
@@ -273,9 +273,9 @@ public abstract class AbstractRepositoryTest
         assertPage( "Apache Archiva \\ Admin: Edit Managed Repository" );
         setFieldValue( "repository.name" , name );
         setFieldValue( "repository.location" , directory );
-        setFieldValue( "repository.indexDir" , indexDirectory );
+        setFieldValue( "repository.indexDirectory" , indexDirectory );
         selectValue( "repository.layout", type );
-        setFieldValue( "repository.refreshCronExpression" , cron );
+        setFieldValue( "repository.cronExpression" , cron );
         setFieldValue( "repository.daysOlder" , daysOlder );
         setFieldValue( "repository.retentionCount" , retentionCount );
         clickButtonWithValue( "Update Repository" );