]> source.dussan.org Git - archiva.git/commitdiff
start to cleanup it test for webapp js
authorOlivier Lamy <olamy@apache.org>
Wed, 29 Feb 2012 22:06:12 +0000 (22:06 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 29 Feb 2012 22:06:12 +0000 (22:06 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1295309 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp-test-js/pom.xml
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/LoginTest.java
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/RolesManagementTest.java
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/UserManagementTest.java
archiva-modules/archiva-web/archiva-webapp-test-js/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
archiva-modules/archiva-web/pom.xml

index ea5783216eba8e4136c316643a154d5f6da53f0d..d774fe92bfb629385b69fa533c8ec7510981c160 100644 (file)
                 <browser>${selenium.browser}</browser>
                 <baseUrl>${baseUrl}</baseUrl>
                 <maxWaitTimeInMs>${maxWaitTimeInMs}</maxWaitTimeInMs>
+                <seleniumHost>${seleniumHost}</seleniumHost>
+                <seleniumPort>${seleniumPort}</seleniumPort>
               </systemPropertyVariables>
             </configuration>
           </execution>
index 49387032f0d55b290b3b433a7460a043c680b85f..721d8ba3994978d19ec12aa29ab4d90b4ccf2f7d 100644 (file)
@@ -20,71 +20,12 @@ package org.apache.archiva.web.test;
  */
 
 import org.apache.archiva.web.test.parent.AbstractArchivaTest;
-import org.testng.Assert;
-import org.testng.annotations.AfterTest;
-import org.testng.annotations.BeforeSuite;
-import org.testng.annotations.BeforeTest;
-import org.testng.annotations.Optional;
-import org.testng.annotations.Parameters;
 import org.testng.annotations.Test;
 
 public class ArchivaAdminTest
     extends AbstractArchivaTest
 {
 
-    @Override
-    @AfterTest
-    public void close()
-        throws Exception
-    {
-        super.close();
-    }
-
-    @Override
-    @BeforeSuite
-    public void open()
-        throws Exception
-    {
-        super.open();
-    }
-
-    @BeforeTest
-    @Parameters( { "baseUrl", "browser", "maxWaitTimeInMs", "seleniumHost", "seleniumPort" } )
-    public void initializeArchiva( String baseUrl, String browser, int maxWaitTimeInMs,
-                                   @Optional( "localhost" ) String seleniumHost, @Optional( "4444" ) int seleniumPort )
-        throws Exception
-    {
-
-        super.open( baseUrl, browser, seleniumHost, seleniumPort, Integer.toString( maxWaitTimeInMs ) );
-
-        getSelenium().open( baseUrl );
-
-        waitPage();
-
-        // if not admin user created create one
-        if ( isElementVisible( "create-admin-link" ) )
-        {
-            Assert.assertFalse( getSelenium().isVisible( "login-link-a" ) );
-            Assert.assertFalse( getSelenium().isVisible( "register-link-a" ) );
-            clickLinkWithLocator( "create-admin-link-a", false );
-            assertCreateAdmin();
-            String fullname = getProperty( "ADMIN_FULLNAME" );
-            String username = getProperty( "ADMIN_USERNAME" );
-            String mail = getProperty( "ADMIN_EMAIL" );
-            String password = getProperty( "ADMIN_PASSWORD" );
-            submitAdminData( fullname, mail, password );
-            assertUserLoggedIn( username );
-            clickLinkWithLocator( "logout-link-a" );
-        }
-        else
-        {
-            Assert.assertTrue( getSelenium().isVisible( "login-link-a" ) );
-            Assert.assertTrue( getSelenium().isVisible( "register-link-a" ) );
-            login( getAdminUsername(), getAdminPassword() );
-        }
-
-    }
-
     @Test( groups = { "about" }, alwaysRun = true )
     public void testHome()
     {
index e0df61b07bf8f3313ed77592bdc988ac88f041af..29ba5ef0c0e26ba3091de3c4be7fc5e33f67b164 100644 (file)
@@ -35,7 +35,7 @@ import org.testng.annotations.Test;
 public class LoginTest
     extends AbstractArchivaTest
 {
-    @Test( alwaysRun = true )
+    @Test
     public void testWithBadUsername()
     {
         goToLoginPage();
@@ -45,7 +45,7 @@ public class LoginTest
 
     }
 
-    @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
+    @Test
     public void testWithBadPassword()
     {
         goToLoginPage();
@@ -55,27 +55,25 @@ public class LoginTest
         assertTextPresent( "You have entered an incorrect username and/or password" );
     }
 
-    @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
+    @Test
     public void testWithEmptyUsername()
     {
         goToLoginPage();
         setFieldValue( "user-login-form-password", "password" );
         clickLinkWithLocator( "modal-login-ok", true );
-        //assertTextPresent( "User Name is required" );
         assertTextPresent( "This field is required." );
     }
 
-    @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
+    @Test( alwaysRun = true )
     public void testWithEmptyPassword()
     {
         goToLoginPage();
         setFieldValue( "user-login-form-username", getProperty( "ADMIN_USERNAME" ) );
         clickLinkWithLocator( "modal-login-ok", true );
-        //assertTextPresent( "You have entered an incorrect username and/or password" );
         assertTextPresent( "This field is required." );
     }
 
-    @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
+    @Test
     public void testWithCorrectUsernamePassword()
     {
         goToLoginPage();
index e4b948f24d79ee2d6c3e5aabdfd61e9c388c91c4..388eb5f375085b31271ab4fe5338528650545e1c 100644 (file)
@@ -26,13 +26,15 @@ import org.testng.annotations.Test;
 /**
  * @author Olivier Lamy
  */
-@Test( groups = { "usermanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+@Test( groups = { "usermanagement" }, dependsOnGroups = "about" )
 public class RolesManagementTest
     extends AbstractArchivaTest
 {
+    @Test
     public void testReadRolesAndUpdateDescription()
         throws Exception
     {
+        login( getAdminUsername(), getAdminPassword() );
         clickLinkWithLocator( "menu-roles-list-a", true );
         assertTextPresent( "Archiva System Administrator " );
         Assert.assertTrue( StringUtils.isEmpty( getText( "role-description-Guest" ) ) );
index 61136caa380857e0cdbc5d6873d669093e8e2a0d..3478c13654c0dbd4a1a8965d6d54e7e35b1de7b0 100644 (file)
@@ -24,7 +24,7 @@ import org.testng.annotations.Test;
 /**
  * @author Olivier Lamy
  */
-@Test( groups = { "usermanagement" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+@Test( groups = { "usermanagement" }, dependsOnGroups = { "about" } )
 public class UserManagementTest
     extends AbstractArchivaTest
 {
index fa75900259d9d41dd19a24821059cf65c5e9a70f..5cfc89a127382db9ba0253a4a6ac64a1f95c3627 100644 (file)
@@ -1,6 +1,11 @@
 package org.apache.archiva.web.test.parent;
 
 import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Optional;
+import org.testng.annotations.Parameters;
 
 import java.io.File;
 import java.io.IOException;
@@ -31,6 +36,67 @@ public abstract class AbstractArchivaTest
 
     protected String fullname;
 
+    @Override
+    @AfterTest
+    public void close()
+        throws Exception
+    {
+        super.close();
+    }
+
+    @Override
+    @BeforeSuite
+    public void open()
+        throws Exception
+    {
+        super.open();
+    }
+
+    public void assertAdminCreated()
+        throws Exception
+    {
+        initializeArchiva( System.getProperty( "baseUrl" ), System.getProperty( "browser" ),
+                           Integer.getInteger( "maxWaitTimeInMs" ), System.getProperty( "seleniumHost" ),
+                           Integer.getInteger( "seleniumPort" ) );
+    }
+
+    @BeforeTest
+    @Parameters( { "baseUrl", "browser", "maxWaitTimeInMs", "seleniumHost", "seleniumPort" } )
+    public void initializeArchiva( String baseUrl, String browser, int maxWaitTimeInMs,
+                                   @Optional( "localhost" ) String seleniumHost, @Optional( "4444" ) int seleniumPort )
+        throws Exception
+    {
+
+        super.open( baseUrl, browser, seleniumHost, seleniumPort, Integer.toString( maxWaitTimeInMs ) );
+
+        getSelenium().open( baseUrl );
+
+        waitPage();
+
+        // if not admin user created create one
+        if ( isElementVisible( "create-admin-link" ) )
+        {
+            Assert.assertFalse( getSelenium().isVisible( "login-link-a" ) );
+            Assert.assertFalse( getSelenium().isVisible( "register-link-a" ) );
+            clickLinkWithLocator( "create-admin-link-a", false );
+            assertCreateAdmin();
+            String fullname = getProperty( "ADMIN_FULLNAME" );
+            String username = getAdminUsername();
+            String mail = getProperty( "ADMIN_EMAIL" );
+            String password = getProperty( "ADMIN_PASSWORD" );
+            submitAdminData( fullname, mail, password );
+            assertUserLoggedIn( username );
+            clickLinkWithLocator( "logout-link-a" );
+        }
+        else
+        {
+            Assert.assertTrue( getSelenium().isVisible( "login-link-a" ) );
+            Assert.assertTrue( getSelenium().isVisible( "register-link-a" ) );
+            login( getAdminUsername(), getAdminPassword() );
+        }
+
+    }
+
     protected static String getErrorMessageText()
     {
         return getSelenium().getText( "//ul[@class='errorMessage']/li/span" );
@@ -487,7 +553,7 @@ public abstract class AbstractArchivaTest
 
     public void goToHomePage()
     {
-        getSelenium().open( "" );
+        getSelenium().open( baseUrl );
     }
 
     // Upload Artifact
@@ -729,4 +795,9 @@ public abstract class AbstractArchivaTest
         assertLinkNotVisible( "Logout" );
         assertLinkVisible( "Login" );
     }
+
+    protected String getAdminUserName()
+    {
+        return getProperty( "ADMIN_FULLNAME" );
+    }
 }
\ No newline at end of file
index 174ad67776061a592d440d1061f95b3559afb9fb..4b2cbeb7ad2c64abf142d9eeb2244e839347d568 100644 (file)
@@ -57,7 +57,7 @@
       <dependency>
         <groupId>org.testng</groupId>
         <artifactId>testng</artifactId>
-        <version>6.2.1</version>
+        <version>6.4</version>
         <scope>test</scope>
       </dependency>
       <dependency>