continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From br...@apache.org
Subject svn commit: r1367862 - in /continuum/trunk/continuum-webapp-test/src/test/testng: config/ org/apache/continuum/web/test/ org/apache/continuum/web/test/parent/
Date Wed, 01 Aug 2012 05:50:36 GMT
Author: brett
Date: Wed Aug  1 05:50:35 2012
New Revision: 1367862

URL: http://svn.apache.org/viewvc?rev=1367862&view=rev
Log:
fix distributed build tests

Modified:
    continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildAgentsTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedBuildTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildAgentsTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractConfigurationTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml?rev=1367862&r1=1367861&r2=1367862&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml (original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml Wed Aug  1 05:50:35
2012
@@ -62,6 +62,7 @@ under the License.
         <include name="buildDefinitionTemplate" />
         <include name="userroles"/>
         <include name="csrf"/>
+        <include name="distributed"/>
       </run>
     </groups>
     <packages>

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildAgentsTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildAgentsTest.java?rev=1367862&r1=1367861&r2=1367862&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildAgentsTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildAgentsTest.java
Wed Aug  1 05:50:35 2012
@@ -89,8 +89,11 @@ public class BuildAgentsTest
     @Test( dependsOnMethods = { "testAddBuildAgent" } )
     public void testEditBuildAgent()
     {
-        String BUILD_AGENT_NAME = getBuildAgentUrl();
         String BUILD_AGENT_DESCRIPTION = getProperty( "BUILD_AGENT_DESCRIPTION" );
+
+        addBuildAgent( getBuildAgentUrl(), BUILD_AGENT_DESCRIPTION );
+
+        String BUILD_AGENT_NAME = getBuildAgentUrl();
         String new_agentDescription = "new_agentDescription";
 
         goToEditBuildAgent( BUILD_AGENT_NAME, BUILD_AGENT_DESCRIPTION );
@@ -99,7 +102,7 @@ public class BuildAgentsTest
         addEditBuildAgent( BUILD_AGENT_NAME, BUILD_AGENT_DESCRIPTION );
     }
 
-    @Test( dependsOnMethods = { "testAddAnExistingBuildAgent" } )
+    @Test( dependsOnMethods = { "testAddAnExistingBuildAgent", "testDeleteBuildAgentGroup"
} )
     public void testDeleteBuildAgent()
         throws Exception
     {
@@ -107,8 +110,6 @@ public class BuildAgentsTest
         String BUILD_AGENT_NAME = getBuildAgentUrl();
         removeBuildAgent( BUILD_AGENT_NAME );
         assertTextNotPresent( BUILD_AGENT_NAME );
-
-        testAddBuildAgent();
     }
 
 	@Test( dependsOnMethods = { "testDeleteBuildAgent" } )
@@ -125,6 +126,8 @@ public class BuildAgentsTest
     public void testBuildSuccessWithDistributedBuildsAfterDisableEnableOfBuildAgent()
         throws Exception
     {
+        addBuildAgent( getBuildAgentUrl() );
+
         String BUILD_AGENT_NAME = getBuildAgentUrl();
         String BUILD_AGENT_DESCRIPTION = getProperty( "BUILD_AGENT_DESCRIPTION" );
         String M2_PROJ_GRP_NAME = getProperty( "M2_DELETE_PROJ_GRP_NAME" );
@@ -159,6 +162,8 @@ public class BuildAgentsTest
     public void testAddBuildAgentGroupXSS()
         throws Exception
     {
+        addBuildAgent( getBuildAgentUrl() );
+
         goToAddBuildAgentGroup();
         addEditBuildAgentGroup( "%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E", new String[]{},
new String[] {}, false );
         assertTextPresent( "Build agent group name contains invalid characters" );
@@ -170,10 +175,11 @@ public class BuildAgentsTest
         Assert.assertFalse( getSelenium().isAlertPresent() );
     }
 
-    @Test( dependsOnMethods = { "testAddBuildAgent", "testDeleteBuildAgent" } )
     public void testAddBuildAgentGroup()
         throws Exception
     {
+        addBuildAgent( getBuildAgentUrl() );
+
         String BUILD_AGENT_NAME = getBuildAgentUrl();
         String BUILD_AGENT_GROUPNAME = getProperty( "BUILD_AGENT_GROUPNAME" );
 

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedBuildTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedBuildTest.java?rev=1367862&r1=1367861&r2=1367862&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedBuildTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedBuildTest.java
Wed Aug  1 05:50:35 2012
@@ -19,7 +19,7 @@ package org.apache.continuum.web.test;
  * under the License.
  */
 
-import org.apache.continuum.web.test.parent.AbstractAdminTest;
+import org.apache.continuum.web.test.parent.AbstractBuildAgentsTest;
 import org.testng.annotations.AfterMethod;
 import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
@@ -32,38 +32,51 @@ import org.testng.annotations.Test;
  */
 @Test( groups = { "distributed" } )
 public class DistributedBuildTest
-    extends AbstractAdminTest
+    extends AbstractBuildAgentsTest
 {
+
+    private String projectGroupName;
+
     @BeforeMethod
     public void setUp()
     {
         enableDistributedBuilds();
+
+        projectGroupName = null;
     }
 
     @AfterMethod
     public void tearDown()
+        throws Exception
     {
+        if ( projectGroupName != null )
+        {
+            removeProjectGroup( projectGroupName, false );
+        }
+
         disableDistributedBuilds();
     }
 
+    @Test( dependsOnMethods = { "testDeleteBuildAgentGroup" } )
     public void testBuildProjectGroupNoBuildAgentConfigured()
         throws Exception
     {
+        goToBuildAgentPage();
+        removeBuildAgent( getBuildAgentUrl(), false );
+
         String M2_PROJ_GRP_NAME = getProperty( "M2_DELETE_PROJ_GRP_NAME" );
         String M2_PROJ_GRP_ID = getProperty( "M2_DELETE_PROJ_GRP_ID" );
+        projectGroupName = M2_PROJ_GRP_NAME;
 
-        addMaven2Project( M2_PROJ_GRP_NAME );
-        clickLinkWithText( M2_PROJ_GRP_NAME );
+        addMaven2Project( projectGroupName );
+        clickLinkWithText( projectGroupName );
 
         assertPage( "Continuum - Project Group" );
 
-        showProjectGroup( M2_PROJ_GRP_NAME, M2_PROJ_GRP_ID, "" );
+        showProjectGroup( projectGroupName, M2_PROJ_GRP_ID, "" );
         clickButtonWithValue( "Build all projects" );
 
         assertTextPresent( "Unable to build projects because no build agent is configured"
);
-
-        removeProjectGroup( M2_PROJ_GRP_NAME );
-        assertLinkNotPresent( M2_PROJ_GRP_NAME );
     }
 
     public void testProjectGroupAllBuildSuccessWithDistributedBuilds()
@@ -71,6 +84,7 @@ public class DistributedBuildTest
     {
         String M2_PROJ_GRP_NAME = getProperty( "M2_DELETE_PROJ_GRP_NAME" );
         String M2_PROJ_GRP_ID = getProperty( "M2_DELETE_PROJ_GRP_ID" );
+        projectGroupName = M2_PROJ_GRP_NAME;
 
         addBuildAgent( getBuildAgentUrl() );
 
@@ -83,6 +97,9 @@ public class DistributedBuildTest
         clickButtonWithValue( "Build all projects" );
 
         buildProjectGroup( M2_PROJ_GRP_NAME, M2_PROJ_GRP_ID, "", M2_PROJ_GRP_NAME, true );
+
+        removeProjectGroup( M2_PROJ_GRP_NAME );
+        assertLinkNotPresent( M2_PROJ_GRP_NAME );
     }
 
     @Test( dependsOnMethods = { "testAddBuildAgentGroupWithEmptyBuildAgent", "testAddBuildEnvironmentWithBuildAgentGroup"
} )
@@ -92,6 +109,7 @@ public class DistributedBuildTest
         String M2_PROJ_GRP_NAME = getProperty( "M2_DELETE_PROJ_GRP_NAME" );
         String M2_PROJ_GRP_ID = getProperty( "M2_DELETE_PROJ_GRP_ID" );
         String BUILD_ENV_NAME = getProperty( "BUILD_ENV_NAME" );
+        projectGroupName = M2_PROJ_GRP_NAME;
 
         addMaven2Project( M2_PROJ_GRP_NAME );
         clickLinkWithText( M2_PROJ_GRP_NAME );
@@ -125,15 +143,14 @@ public class DistributedBuildTest
         String M2_PROJ_GRP_ID = getProperty( "M2_PROJ_WITH_TAG_PROJ_GRP_ID" );
         String M2_PROJ_GRP_DESCRIPTION = "";
 
+        projectGroupName = M2_PROJ_GRP_NAME;
+
         addBuildAgent( getBuildAgentUrl() );
 
         addMavenTwoProject( M2_POM_URL, M2_POM_USERNAME, M2_POM_PASSWORD, null, true );
         assertProjectGroupSummaryPage( M2_PROJ_GRP_NAME, M2_PROJ_GRP_ID, M2_PROJ_GRP_DESCRIPTION
);
 
         buildProjectGroup( M2_PROJ_GRP_NAME, M2_PROJ_GRP_ID, M2_PROJ_GRP_DESCRIPTION, M2_PROJ_GRP_NAME,
true );
-
-        removeProjectGroup( M2_PROJ_GRP_NAME );
-        assertLinkNotPresent( M2_PROJ_GRP_NAME );
     }
 
 }

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.java?rev=1367862&r1=1367861&r2=1367862&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.java
Wed Aug  1 05:50:35 2012
@@ -45,6 +45,11 @@ public abstract class AbstractAdminTest
 
     protected void addBuildAgent( String buildAgentUrl )
     {
+        addBuildAgent( buildAgentUrl, "Default description" );
+    }
+
+    protected void addBuildAgent( String buildAgentUrl, String description )
+    {
         goToBuildAgentPage();
         assertBuildAgentPage();
 
@@ -55,7 +60,7 @@ public abstract class AbstractAdminTest
             assertAddEditBuildAgentPage( true );
 
             setFieldValue( "saveBuildAgent_buildAgent_url", buildAgentUrl );
-            setFieldValue( "saveBuildAgent_buildAgent_description", "Default description"
);
+            setFieldValue( "saveBuildAgent_buildAgent_description", description );
             checkField( "saveBuildAgent_buildAgent_enabled" );
 
             submit();

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildAgentsTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildAgentsTest.java?rev=1367862&r1=1367861&r2=1367862&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildAgentsTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildAgentsTest.java
Wed Aug  1 05:50:35 2012
@@ -1,7 +1,5 @@
 package org.apache.continuum.web.test.parent;
 
-import org.testng.annotations.BeforeClass;
-
 import java.net.URLEncoder;
 
 /*
@@ -29,14 +27,25 @@ public abstract class AbstractBuildAgent
     public void removeBuildAgent( String agentName )
         throws Exception
     {
-        clickLinkWithXPath( "//a[contains(@href,'deleteBuildAgent.action') and contains(@href,
'" + URLEncoder.encode( agentName, "UTF-8" ) + "')]/img" );
-        assertPage("Continuum - Delete Build Agent");
-        assertTextPresent( "Delete Build Agent" );
-        assertTextPresent( "Are you sure you want to delete build agent " + agentName + "
?" );
-        assertButtonWithValuePresent( "Delete" );
-        assertButtonWithValuePresent( "Cancel" );
-        clickButtonWithValue( "Delete" );
-        assertBuildAgentPage();
+        removeBuildAgent( agentName, true );
+    }
+
+    public void removeBuildAgent( String agentName, boolean failIfMissing )
+        throws Exception
+    {
+        String deleteButton = "//a[contains(@href,'deleteBuildAgent.action') and contains(@href,
'" + URLEncoder.encode(
+            agentName, "UTF-8" ) + "')]/img";
+        if ( failIfMissing || isElementPresent( deleteButton ) )
+        {
+            clickLinkWithXPath( deleteButton );
+            assertPage("Continuum - Delete Build Agent");
+            assertTextPresent( "Delete Build Agent" );
+            assertTextPresent( "Are you sure you want to delete build agent " + agentName
+ " ?" );
+            assertButtonWithValuePresent( "Delete" );
+            assertButtonWithValuePresent( "Cancel" );
+            clickButtonWithValue( "Delete" );
+            assertBuildAgentPage();
+        }
     }
 
     public void addBuildAgent( String agentURL, String description, boolean success, boolean
enabled, boolean pingOk )

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractConfigurationTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractConfigurationTest.java?rev=1367862&r1=1367861&r2=1367862&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractConfigurationTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractConfigurationTest.java
Wed Aug  1 05:50:35 2012
@@ -71,6 +71,7 @@ public abstract class AbstractConfigurat
         setFieldValue( "deploymentRepositoryDirectory", deploymentRepository );
         setFieldValue( "baseUrl", baseUrl );
         setFieldValue( "numberOfAllowedBuildsinParallel", numberBuildParallel );
+        setFieldValue( "sharedSecretPassword", SHARED_SECRET );
         if ( distributed )
         {
             checkField( "distributedBuildEnabled" );

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java?rev=1367862&r1=1367861&r2=1367862&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java
Wed Aug  1 05:50:35 2012
@@ -25,6 +25,8 @@ import org.testng.annotations.BeforeSuit
 import org.testng.annotations.Optional;
 import org.testng.annotations.Parameters;
 
+import static org.testng.Assert.assertEquals;
+
 /**
  * Based on AbstractContinuumTestCase of Emmanuel Venisse test.
  *
@@ -35,6 +37,8 @@ public abstract class AbstractContinuumT
     extends AbstractSeleniumTest
 {
 
+    protected static final String SHARED_SECRET = "continuum1234";
+
     // ////////////////////////////////////
     // Create Admin User
     // ////////////////////////////////////
@@ -312,16 +316,25 @@ public abstract class AbstractContinuumT
         clickButtonWithValue( "Save" );
         assertProjectGroupsSummaryPage();
     }
-    
+
     public void removeProjectGroup( String groupName )
         throws Exception
     {
+        removeProjectGroup( groupName, true );
+    }
+
+    public void removeProjectGroup( String groupName, boolean failIfMissing )
+        throws Exception
+    {
         goToProjectGroupsSummaryPage();
-        clickLinkWithText( groupName );
-        clickButtonWithValue( "Delete Group" );
-        assertTextPresent( "Project Group Removal" );
-        clickButtonWithValue( "Delete" );
-        assertProjectGroupsSummaryPage();
+        if ( failIfMissing || isLinkPresent( groupName ) )
+        {
+            clickLinkWithText( groupName );
+            clickButtonWithValue( "Delete Group" );
+            assertTextPresent( "Project Group Removal" );
+            clickButtonWithValue( "Delete" );
+            assertProjectGroupsSummaryPage();
+        }
     }
 
     public void editProjectGroup(String name,String groupId,String description,String newName,String
newDescription )
@@ -383,6 +396,7 @@ public abstract class AbstractContinuumT
         }
 
         clickLinkWithText( projectName );
+        waitForElementPresent( "link=Builds" );
         clickLinkWithText( "Builds" );
         clickLinkWithText( "Result" );
 
@@ -853,7 +867,7 @@ public abstract class AbstractContinuumT
             waitForCondition( condition );
         }
 
-        Assert.assertEquals( getTitle(), title );
+        assertEquals( getTitle(), title );
     }
 
     public void createAndAddUserAsDeveloperToGroup( String username, String name, String
email, String password, String groupName )
@@ -1049,9 +1063,10 @@ public abstract class AbstractContinuumT
         setFieldValue( "numberOfAllowedBuildsinParallel", "2" );
         if ( !isChecked( "configuration_distributedBuildEnabled" ) )
         {
-            checkField( "configuration_distributedBuildEnabled" );
+            // must use click here so the JavaScript enabling the shared secret gets triggered
+            click( "configuration_distributedBuildEnabled" );
         }
-        setFieldValue( "configuration_sharedSecretPassword", "continuum1234" );
+        setFieldValue( "configuration_sharedSecretPassword", SHARED_SECRET );
         clickAndWait( "configuration_" );
         assertTextPresent( "true" );
         assertTextPresent( "Distributed Builds" );



Mime
View raw message