continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1547306 - in /continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test: ./ parent/
Date Tue, 03 Dec 2013 08:01:01 GMT
Author: brett
Date: Tue Dec  3 08:01:01 2013
New Revision: 1547306

URL: http://svn.apache.org/r1547306
Log:
allow re-running tests

Modified:
    continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTemplateTest.java
    continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildEnvironmentTest.java
    continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedReleaseTest.java
    continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/UserRolesManagementTest.java
    continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.java
    continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildDefinitionTemplateTest.java
    continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractUserRolesManagementTest.java

Modified: continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTemplateTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTemplateTest.java?rev=1547306&r1=1547305&r2=1547306&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTemplateTest.java
(original)
+++ continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTemplateTest.java
Tue Dec  3 08:01:01 2013
@@ -20,6 +20,8 @@ package org.apache.continuum.web.test;
  */
 
 import org.apache.continuum.web.test.parent.AbstractBuildDefinitionTemplateTest;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 /**
@@ -30,12 +32,19 @@ import org.testng.annotations.Test;
 public class BuildDefinitionTemplateTest
     extends AbstractBuildDefinitionTemplateTest
 {
+    private String templateName;
+
+    @BeforeClass
+    public void setUp()
+    {
+        templateName = getProperty( "TEMPLATE_NAME" );
+    }
+
     public void testAddTemplate()
         throws Exception
     {
-        String TEMPLATE_NAME = getProperty( "TEMPLATE_NAME" );
         goToAddTemplate();
-        addEditTemplate( TEMPLATE_NAME,
+        addEditTemplate( templateName,
                          new String[]{"Default Maven Build Definition", "Default Maven 1
Build Definition"},
                          new String[]{}, true );
     }
@@ -60,22 +69,20 @@ public class BuildDefinitionTemplateTest
     public void testEditTemplate()
         throws Exception
     {
-        String TEMPLATE_NAME = getProperty( "TEMPLATE_NAME" );
         String newName = "new_name";
-        goToEditTemplate( TEMPLATE_NAME,
+        goToEditTemplate( templateName,
                           new String[]{"Default Maven Build Definition", "Default Maven 1
Build Definition"} );
         addEditTemplate( newName, new String[]{"Default Shell Build Definition"},
                          new String[]{"Default Maven Build Definition"}, true );
         goToEditTemplate( newName, new String[]{"Default Maven 1 Build Definition", "Default
Shell Build Definition"} );
-        addEditTemplate( TEMPLATE_NAME, new String[]{"Default Maven Build Definition"},
+        addEditTemplate( templateName, new String[]{"Default Maven Build Definition"},
                          new String[]{"Default Shell Build Definition"}, true );
     }
 
     @Test( dependsOnMethods = {"testEditTemplate"} )
     public void testDeleteTemplate()
     {
-        String TEMPLATE_NAME = getProperty( "TEMPLATE_NAME" );
-        removeTemplate( TEMPLATE_NAME );
+        removeTemplate( templateName );
     }
 
     public void testAddBuildDefinitionTemplate()
@@ -135,9 +142,13 @@ public class BuildDefinitionTemplateTest
     public void testAddTemplateWithEmptyBuildDefinitions()
         throws Exception
     {
-        String TEMPLATE_NAME = getProperty( "TEMPLATE_NAME" );
         goToAddTemplate();
-        addEditTemplate( TEMPLATE_NAME, new String[] {}, new String[] {}, false );
+        addEditTemplate( templateName, new String[] {}, new String[] {}, false );
     }
 
+    @AfterClass
+    public void tearDown()
+    {
+        removeTemplate( templateName, false );
+    }
 }

Modified: continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildEnvironmentTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildEnvironmentTest.java?rev=1547306&r1=1547305&r2=1547306&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildEnvironmentTest.java
(original)
+++ continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildEnvironmentTest.java
Tue Dec  3 08:01:01 2013
@@ -20,6 +20,8 @@ package org.apache.continuum.web.test;
  */
 
 import org.apache.continuum.web.test.parent.AbstractAdminTest;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.BeforeClass;
 import org.testng.annotations.Test;
 
 /**
@@ -30,11 +32,19 @@ import org.testng.annotations.Test;
 public class BuildEnvironmentTest
     extends AbstractAdminTest
 {
+
+    private String buildEnvName;
+
+    @BeforeClass
+    public void setUp()
+    {
+        buildEnvName = getProperty( "BUILD_ENV_NAME" );
+    }
+
     public void testAddBuildEnvironment()
     {
-        String BUILD_ENV_NAME = getProperty( "BUILD_ENV_NAME" );
         goToAddBuildEnvironment();
-        addBuildEnvironment( BUILD_ENV_NAME, new String[]{ }, true );
+        addBuildEnvironment( buildEnvName, new String[]{ }, true );
     }
 
     public void testAddInvalidBuildEnvironment()
@@ -54,8 +64,7 @@ public class BuildEnvironmentTest
     @Test( dependsOnMethods = { "testAddBuildEnvironment" } )
     public void testEditInvalidBuildEnvironment()
     {
-        String BUILD_ENV_NAME = getProperty( "BUILD_ENV_NAME" );
-        goToEditBuildEnvironment( BUILD_ENV_NAME );
+        goToEditBuildEnvironment( buildEnvName );
         editBuildEnvironment( "", new String[]{ }, false );
         assertTextPresent( "You must define a name" );
     }
@@ -63,41 +72,37 @@ public class BuildEnvironmentTest
     @Test( dependsOnMethods = { "testAddBuildEnvironment" } )
     public void testAddDuplicatedBuildEnvironment()
     {
-        String BUILD_ENV_NAME = getProperty( "BUILD_ENV_NAME" );
         goToAddBuildEnvironment();
-        addBuildEnvironment( BUILD_ENV_NAME, new String[]{ }, false );
+        addBuildEnvironment( buildEnvName, new String[]{ }, false );
         assertTextPresent( "A Build Environment with the same name already exists" );
     }
 
     @Test( dependsOnMethods = { "testAddBuildEnvironment" } )
     public void testEditBuildEnvironment()
     {
-        String BUILD_ENV_NAME = getProperty( "BUILD_ENV_NAME" );
         String newName = "new_name";
-        goToEditBuildEnvironment( BUILD_ENV_NAME );
+        goToEditBuildEnvironment( buildEnvName );
         editBuildEnvironment( newName, new String[]{ }, true );
         // TODO: ADD INSTALLATIONS TO ENVIROTMENT
         goToEditBuildEnvironment( newName );
-        editBuildEnvironment( BUILD_ENV_NAME, new String[]{ }, true );
+        editBuildEnvironment( buildEnvName, new String[]{ }, true );
     }
 
     @Test( dependsOnMethods = { "testEditInvalidBuildEnvironment", "testEditBuildEnvironment",
         "testAddDuplicatedBuildEnvironment", "testEditInvalidBuildEnvironment" } )
     public void testDeleteBuildEnvironment()
     {
-        String BUILD_ENV_NAME = getProperty( "BUILD_ENV_NAME" );
-        removeBuildEnvironment( BUILD_ENV_NAME );
+        removeBuildEnvironment( buildEnvName );
     }
 
     @Test( dependsOnMethods = { "testAddBuildEnvironmentWithBuildAgentGroup" } )
     public void testEditDuplicatedBuildEnvironmentParallelBuilds()
     {
-        String BUILD_ENV_NAME = getProperty( "BUILD_ENV_NAME" );
         String newName = "NEW_BUILD_ENV";
         goToAddBuildEnvironment();
         addBuildEnvironment( newName, new String[]{ }, true );
         goToEditBuildEnvironment( newName );
-        editBuildEnvironment( BUILD_ENV_NAME, new String[]{ }, false );
+        editBuildEnvironment( buildEnvName, new String[]{ }, false );
         assertTextPresent( "A Build Environment with the same name already exists" );
     }
 
@@ -126,4 +131,10 @@ public class BuildEnvironmentTest
             assertAddBuildEnvironmentPage();
         }
     }
+
+    @AfterClass
+    public void tearDown()
+    {
+        removeBuildEnvironment( buildEnvName, false );
+    }
 }

Modified: continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedReleaseTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedReleaseTest.java?rev=1547306&r1=1547305&r2=1547306&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedReleaseTest.java
(original)
+++ continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedReleaseTest.java
Tue Dec  3 08:01:01 2013
@@ -80,7 +80,9 @@ public class DistributedReleaseTest
         String pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
         String projectName = getProperty( "MAVEN2_POM_PROJECT_NAME" );
 
-        addProjectGroup( projectGroupName, projectGroupId, description, true, false );
+        removeProjectGroup( projectGroupName, false );
+
+        addProjectGroup( projectGroupName, projectGroupId, description, true );
         clickLinkWithText( projectGroupName );
 
         if ( !isLinkPresent( projectName ) )

Modified: continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/UserRolesManagementTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/UserRolesManagementTest.java?rev=1547306&r1=1547305&r2=1547306&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/UserRolesManagementTest.java
(original)
+++ continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/UserRolesManagementTest.java
Tue Dec  3 08:01:01 2013
@@ -20,12 +20,22 @@ package org.apache.continuum.web.test;
  */
 
 import org.apache.continuum.web.test.parent.AbstractUserRolesManagementTest;
+import org.testng.annotations.AfterClass;
+import org.testng.annotations.AfterMethod;
 import org.testng.annotations.Test;
 
+import java.util.ArrayList;
+import java.util.List;
+
 @Test( groups = {"userroles"}, sequential = true )
 public class UserRolesManagementTest
     extends AbstractUserRolesManagementTest
 {
+
+    public static final String TEST_GROUP = "UserRoles Test Group";
+
+    private List<String> usernames = new ArrayList<String>();
+
     public void testBasicAddDeleteUser()
     {
         username = getProperty( "GUEST_USERNAME" );
@@ -269,8 +279,8 @@ public class UserRolesManagementTest
         assertTextNotPresent( "Project Groups list is empty." );
         // test add project group
         clickButtonWithValue( "Add Project Group" );
-        setFieldValue( "name", "Test Group" );
-        setFieldValue( "groupId", "Test Group" );
+        setFieldValue( "name", TEST_GROUP );
+        setFieldValue( "groupId", TEST_GROUP );
         setFieldValue( "description", "testing project group" );
         submit();
     }
@@ -279,7 +289,7 @@ public class UserRolesManagementTest
     public void testContinuumGroupProjectAdmin_AddProjectToProjectGroup()
         throws Exception
     {
-        clickLinkWithText( "Test Group" );
+        clickLinkWithText( TEST_GROUP );
         clickButtonWithValue( "Add" );
         assertAddMavenTwoProjectPage();
         setFieldValue( "m2PomUrl", getProperty( "M2_POM_URL" ) );
@@ -293,7 +303,7 @@ public class UserRolesManagementTest
     public void testContinuumGroupProjectAdmin_BuildProject()
         throws Exception
     {
-        buildProjectGroup( "Test Group", "Test Group", "testing project group", "ContinuumBuildQueueTestData",
true );
+        buildProjectGroup( TEST_GROUP, TEST_GROUP, "testing project group", "ContinuumBuildQueueTestData",
true );
     }
 
     @Test( dependsOnMethods = {"testContinuumGroupProjectAdmin_BuildProject"} )
@@ -303,7 +313,7 @@ public class UserRolesManagementTest
         clickLinkWithText( "guest1" );
         clickLinkWithText( "Edit Roles" );
         checkUserRoleWithValue( "Guest" );
-        checkResourceRoleWithValue( "Project Developer - Test Group" );
+        checkResourceRoleWithValue( "Project Developer - " + TEST_GROUP );
         submit();
         clickLinkWithText( "Logout" );
     }
@@ -619,4 +629,28 @@ public class UserRolesManagementTest
         clickLinkWithText( "Logout" );
     }
 
+    @AfterMethod
+    public void trackUserToDelete()
+    {
+        // record to delete at end, as some are used across dependent tests
+        // TODO: refactor!
+        usernames.add( username );
+    }
+
+    @AfterClass
+    public void cleanup()
+    {
+        loginAsAdmin();
+        if ( !isTextPresent( "List of Users" ) )
+        {
+            clickLinkWithText( "Users" );
+        }
+
+        for ( String username : usernames )
+        {
+            deleteUser( username, false );
+        }
+
+        removeProjectGroup( TEST_GROUP, false );
+    }
 }

Modified: continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.java?rev=1547306&r1=1547305&r2=1547306&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.java
(original)
+++ continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.java
Tue Dec  3 08:01:01 2013
@@ -41,6 +41,8 @@ public abstract class AbstractAdminTest
         if ( !getSelenium().isElementPresent( "//span[@class='username' and text()='" + username
+ "']" ) )
         {
             login( username, password );
+
+            assertElementPresent( "//span[@class='username' and text()='" + username + "']"
);
         }
     }
 

Modified: continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildDefinitionTemplateTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildDefinitionTemplateTest.java?rev=1547306&r1=1547305&r2=1547306&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildDefinitionTemplateTest.java
(original)
+++ continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildDefinitionTemplateTest.java
Tue Dec  3 08:01:01 2013
@@ -125,16 +125,24 @@ public abstract class AbstractBuildDefin
 
     protected void removeTemplate( String name )
     {
+        removeTemplate( name, true );
+    }
+
+    protected void removeTemplate( String name, boolean failIfMissing )
+    {
         goToBuildDefinitionTemplatePage();
-        clickLinkWithXPath(
-            "(//a[contains(@href,'deleteDefinitionTemplate') and contains(@href, '" + name
+ "')])//img" );
-        assertPage( "Continuum - Delete Build Definition Template" );
-        assertTextPresent( "Delete Build Definition Template" );
-        assertTextPresent( "Are you sure you want to delete build definition template \""
+ name + "\"?" );
-        assertButtonWithValuePresent( "Delete" );
-        assertButtonWithValuePresent( "Cancel" );
-        clickButtonWithValue( "Delete" );
-        assertBuildDefinitionTemplatePage();
+        String xpath = "(//a[contains(@href,'deleteDefinitionTemplate') and contains(@href,
'" + name + "')])//img";
+        if ( failIfMissing || isElementPresent( "xpath=" + xpath ) )
+        {
+            clickLinkWithXPath( xpath );
+            assertPage( "Continuum - Delete Build Definition Template" );
+            assertTextPresent( "Delete Build Definition Template" );
+            assertTextPresent( "Are you sure you want to delete build definition template
\"" + name + "\"?" );
+            assertButtonWithValuePresent( "Delete" );
+            assertButtonWithValuePresent( "Cancel" );
+            clickButtonWithValue( "Delete" );
+            assertBuildDefinitionTemplatePage();
+        }
     }
 
     protected void goToAddBuildDefinitionTemplate()

Modified: continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractUserRolesManagementTest.java
URL: http://svn.apache.org/viewvc/continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractUserRolesManagementTest.java?rev=1547306&r1=1547305&r2=1547306&view=diff
==============================================================================
--- continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractUserRolesManagementTest.java
(original)
+++ continuum/branches/CONTINUUM-2713/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractUserRolesManagementTest.java
Tue Dec  3 08:01:01 2013
@@ -319,13 +319,20 @@ public abstract class AbstractUserRolesM
         clickButtonWithValue( "Submit" );
     }
 
-
     protected void deleteUser( String userName )
     {
-        //clickLinkWithText( "userlist" );
-        clickLinkWithXPath( "//table[@id='ec_table']/tbody[2]/tr[3]/td[7]/a/img" );
-        assertDeleteUserPage( userName );
-        submit();
-        assertElementNotPresent( userName );
+        deleteUser( userName, true );
+    }
+
+    protected void deleteUser( String userName, boolean failIfMissing )
+    {
+        String xpath = "//tr[.//a[text()='" + userName + "']]/td/a[@title='delete user']";
+        if ( failIfMissing || isElementPresent( "xpath=" + xpath ) )
+        {
+            clickLinkWithXPath( xpath );
+            assertDeleteUserPage( userName );
+            submit();
+            assertElementNotPresent( userName );
+        }
     }
 }



Mime
View raw message