continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jzurb...@apache.org
Subject svn commit: r930249 - in /continuum/trunk/continuum-webapp-test/src/test: resources/ testng/org/apache/continuum/web/test/ testng/org/apache/continuum/web/test/parent/
Date Fri, 02 Apr 2010 11:48:28 GMT
Author: jzurbano
Date: Fri Apr  2 11:48:28 2010
New Revision: 930249

URL: http://svn.apache.org/viewvc?rev=930249&view=rev
Log:
* added test for release prepare with no build agent in selected build environment
* added build environment selection in release prepare and release perform with parameters
tests
* used waitForCondition() so page will have more time to load
* added check if browser is IE in assertRelease() and use the waitForPageToLoad instead of
waitForCondition


Modified:
    continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ReleaseTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractContinuumTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractReleaseTest.java

Modified: continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties?rev=930249&r1=930248&r2=930249&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties (original)
+++ continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties Fri Apr  2
11:48:28 2010
@@ -62,6 +62,21 @@ M2_PROJ_WITH_TAG_POM_URL=http://localhos
 M2_PROJ_WITH_TAG_PROJ_GRP_NAME=Continuum 2437 Example Project
 M2_PROJ_WITH_TAG_PROJ_GRP_ID=org.apache.continuum.examples
 
+# Properties for testReleasePrepareProjectWithNoBuildagentInBuildEnvironment
+M2_RELEASE_POM_URL=http://localhost:9595/example-projects/simple-example/pom.xml
+M2_RELEASE_PROJECT_NAME=Continuum Simple Example Project
+M2_RELEASE_GRP_NAME=Simple Example Project Release
+M2_RELEASE_GRP_ID=org.apache.continuum.examples.simple.release
+M2_RELEASE_GRP_DESCRIPTION=Release test project
+M2_RELEASE_GRP_SCM_ROOT_URL=scm:svn:${svn.base.url}/trunk/simple-example
+M2_RELEASE_TAG=simple-example-1.0-test
+M2_RELEASE_RELEASE_VERSION=1.0-test
+M2_RELEASE_DEVELOPMENT_VERSION=1.0-SNAPSHOT
+M2_RELEASE_TAGBASE_URL=http://localhost:9595/example-projects/tags
+M2_RELEASE_BUILD_ENV=RELEASE_BUILD_ENV
+M2_RELEASE_AGENT_GROUP=RELEASE_BUILDAGENT_GROUP
+M2_RELEASE_NO_AGENT_MESSAGE=Unable to prepare release because build agent 
+
 ########################
 # mavenOneProject group 
 ########################

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ReleaseTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ReleaseTest.java?rev=930249&r1=930248&r2=930249&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ReleaseTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ReleaseTest.java
Fri Apr  2 11:48:28 2010
@@ -46,11 +46,15 @@ public class ReleaseTest
         try
         {
             enableDistributedBuilds();
+        
+            String M2_PROJECT_BUILD_ENV = getProperty( "M2_RELEASE_BUILD_ENV" );
+            createBuildEnvAndBuildagentGroup();
+            
             showProjectGroup( M2_PROJ_GRP_NAME, M2_PROJ_GRP_ID, "" );
             clickButtonWithValue( "Release" );
             assertReleaseSuccess();
             releasePrepareProject( M2_PROJ_USERNAME, M2_PROJ_PASSWORD, M2_PROJ_TAGBASE, M2_PROJ_TAG,
-                                   M2_PROJ_RELEASE_VERSION, M2_PROJ_DEVELOPMENT_VERSION,
false );
+                                   M2_PROJ_RELEASE_VERSION, M2_PROJ_DEVELOPMENT_VERSION,
M2_PROJECT_BUILD_ENV, false );
             assertPreparedReleasesFileCreated();
         }
         finally
@@ -58,8 +62,56 @@ public class ReleaseTest
             disableDistributedBuilds();
         }
     }
-
+    
+    /*
+     * Test release prepare with no build agent configured in the selected build environment.
+     */
     @Test( dependsOnMethods = { "testReleasePrepareProjectWithInvalidUsernamePasswordInDistributedBuilds"
} )
+    public void testReleasePrepareProjectWithNoBuildagentInBuildEnvironment()
+        throws Exception
+    {
+        String M2_PROJECT_POM_URL = getProperty( "M2_RELEASE_POM_URL" );
+        String M2_PROJECT_NAME = getProperty( "M2_RELEASE_PROJECT_NAME" );
+        String M2_PROJECT_GROUP_NAME = getProperty( "M2_RELEASE_GRP_NAME" );
+        String M2_PROJECT_GROUP_ID = getProperty( "M2_RELEASE_GRP_ID" );
+        String M2_PROJECT_DESCRIPTION = getProperty( "M2_RELEASE_GRP_DESCRIPTION" );
+        String M2_PROJECT_TAGBASE = getProperty( "M2_RELEASE_TAGBASE_URL" );
+        String M2_PROJECT_TAG = getProperty( "M2_RELEASE_TAG" );
+        String M2_PROJECT_RELEASE_VERSION = getProperty( "M2_RELEASE_RELEASE_VERSION" );
+        String M2_PROJECT_DEVELOPMENT_VERSION = getProperty( "M2_RELEASE_DEVELOPMENT_VERSION"
);
+        String ERROR_TEXT = getProperty( "M2_RELEASE_NO_AGENT_MESSAGE" );
+        
+        addProjectGroup( M2_PROJECT_GROUP_NAME, M2_PROJECT_GROUP_ID, M2_PROJECT_DESCRIPTION,
true );
+        addMavenTwoProject( M2_PROJECT_POM_URL, "", "", M2_PROJECT_GROUP_NAME, true );
+
+        init();
+
+        try
+        {
+            enableDistributedBuilds();
+        
+            String M2_PROJECT_BUILD_ENV = getProperty( "M2_RELEASE_BUILD_ENV" );
+            createBuildEnvAndBuildagentGroup();
+            detachBuildagentFromGroup();
+            
+            buildProjectGroup( M2_PROJECT_GROUP_NAME, M2_PROJECT_GROUP_ID, M2_PROJECT_DESCRIPTION,
M2_PROJECT_NAME );
+            
+            clickButtonWithValue( "Release" );
+            assertReleaseSuccess();
+            releasePrepareProjectWithBuildEnvironmentSelection( "", "", M2_PROJECT_TAGBASE,
M2_PROJECT_TAG, M2_PROJECT_RELEASE_VERSION,
+                                                                M2_PROJECT_DEVELOPMENT_VERSION,
M2_PROJECT_BUILD_ENV );
+            
+            assertTextPresent( "Release Error" );
+            assertTextPresent( ERROR_TEXT );
+        }
+        finally
+        {
+            attachBuildagentInGroup();
+            disableDistributedBuilds();
+        }
+    }
+
+    @Test( dependsOnMethods = { "testReleasePrepareProjectWithNoBuildagentInBuildEnvironment"
} )
     public void testReleasePerformUsingProvideParamtersWithDistributedBuilds()
         throws Exception
     {
@@ -77,11 +129,15 @@ public class ReleaseTest
         try
         {
             enableDistributedBuilds();
+        
+            String M2_PROJECT_BUILD_ENV = getProperty( "M2_RELEASE_BUILD_ENV" );
+            createBuildEnvAndBuildagentGroup();
+            
             showProjectGroup( M2_PROJ_GRP_NAME, M2_PROJ_GRP_ID, "" );
             clickButtonWithValue( "Release" );
             assertReleaseSuccess();
             releasePerformProjectWithProvideParameters( M2_PROJ_USERNAME, M2_PROJ_PASSWORD,
M2_PROJ_TAGBASE, M2_PROJ_TAG, 
-                                                        M2_PROJ_SCM_URL, false );
+                                                        M2_PROJ_SCM_URL, M2_PROJECT_BUILD_ENV,
false );
             assertPreparedReleasesFileCreated();
 
             removeProjectGroup( M2_PROJ_GRP_NAME );
@@ -102,4 +158,70 @@ public class ReleaseTest
             file.delete();
         }
     }
+    
+    private void createBuildEnvAndBuildagentGroup()
+        throws Exception
+    {
+        String M2_PROJECT_BUILD_ENV = getProperty( "M2_RELEASE_BUILD_ENV" );
+        String M2_PROJECT_AGENT_GROUP = getProperty( "M2_RELEASE_AGENT_GROUP" );
+        
+        // add build agent group no agents
+        goToBuildAgentPage();
+        if ( !isTextPresent( M2_PROJECT_AGENT_GROUP ) )
+        {
+            clickAndWait( "//input[@id='editBuildAgentGroup_0']" );
+            setFieldValue( "saveBuildAgentGroup_buildAgentGroup_name", M2_PROJECT_AGENT_GROUP
);
+            clickButtonWithValue( "Save" );
+        }
+            
+        // add build environment with build agent group
+        clickLinkWithText( "Build Environments" );
+        if ( !isTextPresent( M2_PROJECT_BUILD_ENV ) )
+        {
+            clickAndWait( "//input[@id='addBuildEnv_0']" );
+            setFieldValue( "saveBuildEnv_profile_name", M2_PROJECT_BUILD_ENV );
+            clickButtonWithValue( "Save" );
+            selectValue( "profile.buildAgentGroup", M2_PROJECT_AGENT_GROUP );
+            clickButtonWithValue( "Save" );
+        }
+        
+        // attach build agent in build agent group created
+        attachBuildagentInGroup();
+    }
+    
+    private void attachBuildagentInGroup()
+        throws Exception
+    {
+        String M2_PROJECT_AGENT_GROUP = getProperty( "M2_RELEASE_AGENT_GROUP" );
+        String buildAgent = getProperty( "BUILD_AGENT_NAME2" );
+        
+        clickLinkWithText( "Build Agents" );
+        String xPath = "//preceding::td[text()='" + M2_PROJECT_AGENT_GROUP + "']//following::img[@alt='Edit']";
+        clickLinkWithXPath( xPath );
+        
+        if ( isElementPresent( "xpath=//select[@id='saveBuildAgentGroup_buildAgentIds']/option[@value='"
+ buildAgent + "']" ) )
+        {
+            selectValue( "buildAgentIds", buildAgent );
+            clickLinkWithXPath( "//input[@value='->']", false );
+            submit();
+        }
+    }
+    
+    private void detachBuildagentFromGroup()
+        throws Exception
+    {
+        String M2_PROJECT_AGENT_GROUP = getProperty( "M2_RELEASE_AGENT_GROUP" );
+        String buildAgent = getProperty( "BUILD_AGENT_NAME2" );
+        
+        clickLinkWithText( "Build Agents" );
+        String xPath = "//preceding::td[text()='" + M2_PROJECT_AGENT_GROUP + "']//following::img[@alt='Edit']";
+        clickLinkWithXPath( xPath );
+        
+        if ( isElementPresent( "xpath=//select[@id='saveBuildAgentGroup_selectedBuildAgentIds']/option[@value='"
+ buildAgent + "']" ) )
+        {
+            selectValue( "selectedBuildAgentIds", buildAgent );
+            clickLinkWithXPath( "//input[@value='<-']", false );
+            submit();
+        }
+    }
 }

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=930249&r1=930248&r2=930249&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
Fri Apr  2 11:48:28 2010
@@ -833,7 +833,7 @@ public abstract class AbstractContinuumT
         else
         {
             String condition = "selenium.browserbot.getCurrentWindow().document.title.replace(/^\\s*/,
\"\").replace(/\\s*$/, \"\") != '' && selenium.browserbot.getCurrentWindow().document.getElementById('footer')
!= null";
-            getSelenium().waitForCondition( condition, maxWaitTimeInMs );
+            waitForCondition( condition );
         }
 
         Assert.assertEquals( getTitle(), title );

Modified: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractReleaseTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractReleaseTest.java?rev=930249&r1=930248&r2=930249&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractReleaseTest.java
(original)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractReleaseTest.java
Fri Apr  2 11:48:28 2010
@@ -29,7 +29,7 @@ import org.testng.Assert;
 public abstract class AbstractReleaseTest
     extends AbstractContinuumTest
 {
-    public void releasePrepareProject( String username, String password, String tagBase,
String tag, String releaseVersion, String developmentVersion, boolean success )
+    public void releasePrepareProject( String username, String password, String tagBase,
String tag, String releaseVersion, String developmentVersion, String buildEnv, boolean success
)
         throws Exception
     {
         goToReleasePreparePage();
@@ -38,6 +38,7 @@ public abstract class AbstractReleaseTes
         setFieldValue( "scmTag", tag );
         setFieldValue( "scmTagBase", tagBase );
         setFieldValue( "prepareGoals", "clean" );
+        selectValue( "profileId", buildEnv );
         setFieldValue( "relVersions", releaseVersion );
         setFieldValue( "devVersions", developmentVersion );
         submit();
@@ -45,7 +46,7 @@ public abstract class AbstractReleaseTes
         assertRelease( success );
     }
 
-    public void releasePerformProjectWithProvideParameters( String username, String password,
String tagBase, String tag, String scmUrl, boolean success )
+    public void releasePerformProjectWithProvideParameters( String username, String password,
String tagBase, String tag, String scmUrl, String buildEnv, boolean success )
         throws Exception
     {
         goToReleasePerformProvideParametersPage();
@@ -55,10 +56,27 @@ public abstract class AbstractReleaseTes
         setFieldValue( "scmTag", tag );
         setFieldValue( "scmTagBase", tagBase );
         setFieldValue( "goals", "clean deploy" );
+        selectValue( "profileId", buildEnv );
         submit();
 
         assertRelease( success );
     }
+    
+    public void releasePrepareProjectWithBuildEnvironmentSelection( String username, String
password, String tagBase, String tag,
+                                                                    String releaseVersion,
String developmentVersion, String buildEnv )
+        throws Exception
+    {
+        goToReleasePreparePage();
+        setFieldValue( "scmUsername", username );
+        setFieldValue( "scmPassword", password );
+        setFieldValue( "scmTag", tag );
+        setFieldValue( "scmTagBase", tagBase );
+        setFieldValue( "prepareGoals", "clean" );
+        selectValue( "profileId", buildEnv );
+        setFieldValue( "relVersions", releaseVersion );
+        setFieldValue( "devVersions", developmentVersion );
+        submit();
+    }
 
     public void goToReleasePreparePage()
     {
@@ -111,10 +129,28 @@ public abstract class AbstractReleaseTes
     public void assertRelease( boolean success )
         throws Exception
     {
+        String doneButtonLocator = "//input[@id='releaseCleanup_0']";
+        String errorTextLocator = "//h3[text()='Release Error']";
+        
         // condition for release is complete; "Done" button or "Release Error" in page is
present
-        String condition = "( selenium.browserbot.getCurrentWindow().document.getElementById(
'releaseCleanup_0' ) != null )";
-
-        waitForCondition( condition );
+        if ( browser.equals( "*iexplore" ) )
+        {
+            int currentIt = 0;
+            int maxIt = Integer.valueOf( getProperty( "WAIT_TRIES" ) );
+            String pageLoadTimeInMs = getProperty( "PAGE_LOAD_TIME_IN_MS" );
+            
+            while ( ( isElementPresent( doneButtonLocator ) || isElementPresent( errorTextLocator
) ) && currentIt < maxIt )
+            {
+                getSelenium().waitForPageToLoad( pageLoadTimeInMs );
+                currentIt++;
+            }
+        }
+        else
+        {
+            String condition = "( selenium.isElementPresent(\"" + doneButtonLocator + "\")
|| " +
+                               "selenium.isElementPresent(\"" + errorTextLocator + "\") )";
+            waitForCondition( condition );
+        }
 
         assertButtonWithValuePresent( "Rollback changes" );
     



Mime
View raw message