You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by br...@apache.org on 2012/10/02 05:53:44 UTC
svn commit: r1392725 - in /continuum/trunk/continuum-webapp-test/src/test:
resources/ testng/config/ testng/org/apache/continuum/web/test/
testng/org/apache/continuum/web/test/parent/
Author: brett
Date: Tue Oct 2 03:53:43 2012
New Revision: 1392725
URL: http://svn.apache.org/viewvc?rev=1392725&view=rev
Log:
refactor release tests to confirm behaviour when not operating in a distributed environment. Move distributed build methods into the generic parent rather than having a specialised one
Added:
continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractReleaseTest.java (with props)
continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedReleaseTest.java
- copied, changed from r1392684, continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ReleaseTest.java
Removed:
continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildAgentsTest.java
Modified:
continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties
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/ReleaseTest.java
continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractAdminTest.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=1392725&r1=1392724&r2=1392725&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties (original)
+++ continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties Tue Oct 2 03:53:43 2012
@@ -176,20 +176,30 @@ DISTRIBUTED_BUILD_ENV_NAME=Distributed B
DISTRIBUTED_BUILD_AGENT_GROUP_NAME=Distributed Build Agent Group
DISTRIBUTED_DUPLICATE_BUILD_ENV=Distributed Duplicate Build Env
+# Distributed Release test properties
+
+DIST_RELEASE_PROJECT_GROUP_NAME=Distributed Release Test Project Group
+DIST_RELEASE_PROJECT_GROUP_ID=com.example.release
+DIST_RELEASE_PROJECT_TAGBASE=${svn.base.url}/tags
+DIST_RELEASE_PROJECT_TAG=simple-example-1.0
+DIST_RELEASE_PROJECT_VERSION=1.0
+DIST_RELEASE_PROJECT_DEVELOPMENT_VERSION=1.1-SNAPSHOT
+DIST_RELEASE_PROJECT_SCM_URL=scm:svn:${svn.base.url}/trunk/simple-example
+
+DIST_RELEASE_BUILD_ENV=RELEASE_BUILD_ENV
+DIST_RELEASE_BUILD_AGENT_GROUP=RELEASE_BUILDAGENT_GROUP
+DIST_RELEASE_NO_AGENT_MESSAGE=Unable to prepare release because build agent
+
# Release test properties
-RELEASE_PROJECT_GROUP_NAME=Distributed Release Test Project Group
-RELEASE_PROJECT_GROUP_ID=com.example.release
+RELEASE_PROJECT_GROUP_NAME=Release Test Project Group
+RELEASE_PROJECT_GROUP_ID=com.example.release.local
RELEASE_PROJECT_TAGBASE=${svn.base.url}/tags
-RELEASE_PROJECT_TAG=simple-example-1.0
-RELEASE_PROJECT_VERSION=1.0
-RELEASE_PROJECT_DEVELOPMENT_VERSION=1.1-SNAPSHOT
+RELEASE_PROJECT_TAG=simple-example-10.0
+RELEASE_PROJECT_VERSION=10.0
+RELEASE_PROJECT_DEVELOPMENT_VERSION=10.1-SNAPSHOT
RELEASE_PROJECT_SCM_URL=scm:svn:${svn.base.url}/trunk/simple-example
-RELEASE_BUILD_ENV=RELEASE_BUILD_ENV
-RELEASE_BUILD_AGENT_GROUP=RELEASE_BUILDAGENT_GROUP
-RELEASE_NO_AGENT_MESSAGE=Unable to prepare release because build agent
-
# Report test properties
REPORT_PROJECT_GROUP_NAME=Report Test Project Group
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=1392725&r1=1392724&r2=1392725&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 Tue Oct 2 03:53:43 2012
@@ -50,6 +50,7 @@
<include name="report"/>
<include name="agent"/>
<include name="release"/>
+ <include name="distributedRelease"/>
<include name="buildDefinition"/>
<include name="notifier"/>
<include name="myAccount"/>
Added: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractReleaseTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractReleaseTest.java?rev=1392725&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractReleaseTest.java (added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractReleaseTest.java Tue Oct 2 03:53:43 2012
@@ -0,0 +1,147 @@
+package org.apache.continuum.web.test;
+
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+import org.apache.continuum.web.test.parent.AbstractAdminTest;
+
+import java.util.Arrays;
+
+public abstract class AbstractReleaseTest
+ extends AbstractAdminTest
+{
+ protected static final String RELEASE_BUTTON_TEXT = "Release";
+
+ protected static final String PROVIDE_RELEASE_PARAMETERS_TEXT = "Provide Release Parameters";
+
+ protected void releasePrepareProject( String username, String password, String tagBase, String tag,
+ String releaseVersion, String developmentVersion, String buildEnv )
+ {
+ 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();
+
+ waitForRelease();
+ }
+
+ protected void releasePerformProjectWithProvideParameters( String username, String password, String tagBase,
+ String tag, String scmUrl, String buildEnv )
+ {
+ goToReleasePerformProvideParametersPage();
+ setFieldValue( "scmUrl", scmUrl );
+ setFieldValue( "scmUsername", username );
+ setFieldValue( "scmPassword", password );
+ setFieldValue( "scmTag", tag );
+ setFieldValue( "scmTagBase", tagBase );
+ setFieldValue( "goals", "clean deploy" );
+ selectValue( "profileId", buildEnv );
+ submit();
+
+ waitForRelease();
+
+ assertReleasePhaseError();
+ }
+
+ private void goToReleasePreparePage()
+ {
+ clickLinkWithLocator( "goal", false );
+ submit();
+ assertReleasePreparePage();
+ }
+
+ private void goToReleasePerformProvideParametersPage()
+ {
+ selectValue( "preparedReleaseId", PROVIDE_RELEASE_PARAMETERS_TEXT );
+ selectPerformAndSubmit();
+ assertReleasePerformProvideParametersPage();
+ }
+
+ protected void selectPerformAndSubmit()
+ {
+ clickLinkWithLocator( "//input[@name='goal' and @value='perform']", false );
+ submit();
+ }
+
+ void assertReleasePreparePage()
+ {
+ assertPage( "Continuum - Release Project" );
+ assertTextPresent( "Prepare Project for Release" );
+ assertTextPresent( "Release Prepare Parameters" );
+ assertTextPresent( "SCM Username" );
+ assertTextPresent( "SCM Password" );
+ assertTextPresent( "SCM Tag" );
+ assertTextPresent( "SCM Tag Base" );
+ assertTextPresent( "SCM Comment Prefix" );
+ assertTextPresent( "Preparation Goals" );
+ assertTextPresent( "Arguments" );
+ assertTextPresent( "Build Environment" );
+ assertTextPresent( "Release Version" );
+ assertTextPresent( "Next Development Version" );
+ assertButtonWithValuePresent( "Submit" );
+ }
+
+ void assertReleasePerformProvideParametersPage()
+ {
+ assertPage( "Continuum - Perform Project Release" );
+ assertTextPresent( "Perform Project Release" );
+ assertTextPresent( "Release Perform Parameters" );
+ assertTextPresent( "SCM Connection URL" );
+ assertTextPresent( "SCM Username" );
+ assertTextPresent( "SCM Password" );
+ assertTextPresent( "SCM Tag" );
+ assertTextPresent( "SCM Tag Base" );
+ assertTextPresent( "Perform Goals" );
+ assertTextPresent( "Arguments" );
+ assertTextPresent( "Build Environment" );
+ assertButtonWithValuePresent( "Submit" );
+ }
+
+ void assertReleaseError()
+ {
+ assertTextPresent( "Release Error" );
+ }
+
+ protected void assertReleasePhaseError()
+ {
+ assertButtonWithValuePresent( "Rollback changes" );
+ assertImgWithAlt( "Error" );
+ }
+
+ protected void assertReleasePhaseSuccess()
+ {
+ assertButtonWithValuePresent( "Rollback changes" );
+ assertElementNotPresent( "//img[@alt='Error']" );
+ }
+
+ protected void waitForRelease()
+ {
+ 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
+ waitForOneOfElementsPresent( Arrays.asList( doneButtonLocator, errorTextLocator ), true );
+ }
+}
Propchange: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractReleaseTest.java
------------------------------------------------------------------------------
svn:eol-style = native
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=1392725&r1=1392724&r2=1392725&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 Tue Oct 2 03:53:43 2012
@@ -19,7 +19,7 @@ package org.apache.continuum.web.test;
* under the License.
*/
-import org.apache.continuum.web.test.parent.AbstractBuildAgentsTest;
+import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
@@ -27,9 +27,9 @@ import org.testng.annotations.Test;
import java.io.UnsupportedEncodingException;
-@Test( groups = { "agent" } )
+@Test( groups = {"agent"} )
public class BuildAgentsTest
- extends AbstractBuildAgentsTest
+ extends AbstractAdminTest
{
private String buildAgentGroup;
@@ -74,8 +74,8 @@ public class BuildAgentsTest
public void testViewBuildAgentInstallationXSS()
{
- String url = baseUrl
- + "/security/viewBuildAgent.action?buildAgent.url=test%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E";
+ String url = baseUrl +
+ "/security/viewBuildAgent.action?buildAgent.url=test%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E";
getSelenium().open( url );
Assert.assertFalse( getSelenium().isAlertPresent() );
assertTextPresent( "<script>alert('xss')</script>" );
@@ -83,8 +83,8 @@ public class BuildAgentsTest
public void testEditBuildAgentXSS()
{
- String url = baseUrl
- + "/security/editBuildAgent.action?buildAgent.url=test%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E";
+ String url = baseUrl +
+ "/security/editBuildAgent.action?buildAgent.url=test%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E";
getSelenium().open( url );
Assert.assertFalse( getSelenium().isAlertPresent() );
}
@@ -137,15 +137,15 @@ public class BuildAgentsTest
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
- addEditBuildAgentGroup( "%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E", new String[]{ }, new String[]{ },
+ addEditBuildAgentGroup( "%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E", new String[]{}, new String[]{},
false );
assertTextPresent( "Build agent group name contains invalid characters" );
}
public void testEditBuildAgentGroupXSS()
{
- String url = baseUrl
- + "/security/editBuildAgentGroup.action?buildAgentGroup.name=test%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E";
+ String url = baseUrl +
+ "/security/editBuildAgentGroup.action?buildAgentGroup.name=test%3Cscript%3Ealert%28%27xss%27%29%3C/script%3E";
getSelenium().open( url );
Assert.assertFalse( getSelenium().isAlertPresent() );
}
@@ -156,7 +156,7 @@ public class BuildAgentsTest
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
- addEditBuildAgentGroup( buildAgentGroup, new String[]{ buildAgentUrl }, new String[]{ }, true );
+ addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, true );
}
public void testEditBuildAgentGroup()
@@ -165,13 +165,13 @@ public class BuildAgentsTest
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
- addEditBuildAgentGroup( buildAgentGroup, new String[]{ buildAgentUrl }, new String[]{ }, true );
+ addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, true );
String newName = "new_agentgroupname";
- goToEditBuildAgentGroup( buildAgentGroup, new String[]{ buildAgentUrl } );
- addEditBuildAgentGroup( newName, new String[]{ }, new String[]{ buildAgentUrl }, true );
- goToEditBuildAgentGroup( newName, new String[]{ } );
- addEditBuildAgentGroup( buildAgentGroup, new String[]{ buildAgentUrl }, new String[]{ }, true );
+ goToEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl} );
+ addEditBuildAgentGroup( newName, new String[]{}, new String[]{buildAgentUrl}, true );
+ goToEditBuildAgentGroup( newName, new String[]{} );
+ addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, true );
}
public void testAddAnExistingBuildAgentGroup()
@@ -180,10 +180,10 @@ public class BuildAgentsTest
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
- addEditBuildAgentGroup( buildAgentGroup, new String[]{ buildAgentUrl }, new String[]{ }, true );
+ addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, true );
goToAddBuildAgentGroup();
- addEditBuildAgentGroup( buildAgentGroup, new String[]{ buildAgentUrl }, new String[]{ }, false );
+ addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, false );
assertTextPresent( "Build agent group already exists." );
}
@@ -193,7 +193,7 @@ public class BuildAgentsTest
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
- addEditBuildAgentGroup( "", new String[]{ }, new String[]{ }, false );
+ addEditBuildAgentGroup( "", new String[]{}, new String[]{}, false );
assertTextPresent( "Build agent group name is required." );
}
@@ -203,7 +203,7 @@ public class BuildAgentsTest
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
- addEditBuildAgentGroup( buildAgentGroup, new String[]{ buildAgentUrl }, new String[]{ }, true );
+ addEditBuildAgentGroup( buildAgentGroup, new String[]{buildAgentUrl}, new String[]{}, true );
removeBuildAgentGroup( buildAgentGroup );
}
@@ -214,6 +214,6 @@ public class BuildAgentsTest
addBuildAgent( buildAgentUrl );
goToAddBuildAgentGroup();
- addEditBuildAgentGroup( buildAgentGroup, new String[]{ }, new String[]{ }, true );
+ addEditBuildAgentGroup( buildAgentGroup, new String[]{}, new String[]{}, true );
}
}
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=1392725&r1=1392724&r2=1392725&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 Tue Oct 2 03:53:43 2012
@@ -19,7 +19,7 @@ package org.apache.continuum.web.test;
* under the License.
*/
-import org.apache.continuum.web.test.parent.AbstractBuildAgentsTest;
+import org.apache.continuum.web.test.parent.AbstractAdminTest;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
@@ -30,9 +30,9 @@ import org.testng.annotations.Test;
* @author José Morales MartÃnez
* @version $Id$
*/
-@Test( groups = { "distributed" } )
+@Test( groups = {"distributed"} )
public class DistributedBuildTest
- extends AbstractBuildAgentsTest
+ extends AbstractAdminTest
{
private String projectGroupName;
@@ -183,13 +183,13 @@ public class DistributedBuildTest
public void testAddBuildEnvironmentWithBuildAgentGroup()
{
- addBuildAgentGroupAndEnvironment( new String[]{ buildAgentUrl } );
+ addBuildAgentGroupAndEnvironment( new String[]{buildAgentUrl} );
}
public void testProjectGroupNoBuildAgentConfiguredInBuildAgentGroup()
throws Exception
{
- addBuildAgentGroupAndEnvironment( new String[]{ } );
+ addBuildAgentGroupAndEnvironment( new String[]{} );
addMavenTwoProject( pomUrl, pomUsername, pomPassword, projectGroupName, true );
@@ -208,13 +208,13 @@ public class DistributedBuildTest
public void testEditDuplicatedBuildEnvironmentDistributedBuilds()
{
- addBuildAgentGroupAndEnvironment( new String[]{ buildAgentUrl } );
+ addBuildAgentGroupAndEnvironment( new String[]{buildAgentUrl} );
goToAddBuildEnvironment();
- addBuildEnvironmentWithBuildAgentGroup( newBuildEnv, new String[]{ }, buildAgentGroupName );
+ addBuildEnvironmentWithBuildAgentGroup( newBuildEnv, new String[]{}, buildAgentGroupName );
goToEditBuildEnvironment( newBuildEnv );
- editBuildEnvironmentWithBuildAgentGroup( buildEnvName, new String[]{ }, buildAgentGroupName, false );
+ editBuildEnvironmentWithBuildAgentGroup( buildEnvName, new String[]{}, buildAgentGroupName, false );
assertTextPresent( "A Build Environment with the same name already exists" );
}
@@ -238,10 +238,10 @@ public class DistributedBuildTest
{
// create build agent group
goToAddBuildAgentGroup();
- addEditBuildAgentGroup( buildAgentGroupName, buildAgents, new String[]{ }, true );
+ addEditBuildAgentGroup( buildAgentGroupName, buildAgents, new String[]{}, true );
goToAddBuildEnvironment();
- addBuildEnvironmentWithBuildAgentGroup( buildEnvName, new String[]{ }, buildAgentGroupName );
+ addBuildEnvironmentWithBuildAgentGroup( buildEnvName, new String[]{}, buildAgentGroupName );
}
private void editBuildDefinitionShellType()
Copied: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedReleaseTest.java (from r1392684, 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/DistributedReleaseTest.java?p2=continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/DistributedReleaseTest.java&p1=continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ReleaseTest.java&r1=1392684&r2=1392725&rev=1392725&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/DistributedReleaseTest.java Tue Oct 2 03:53:43 2012
@@ -20,7 +20,6 @@ package org.apache.continuum.web.test;
*/
import org.apache.commons.io.IOUtils;
-import org.apache.continuum.web.test.parent.AbstractBuildAgentsTest;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
@@ -34,9 +33,9 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
-@Test( groups = {"release"} )
-public class ReleaseTest
- extends AbstractBuildAgentsTest
+@Test( groups = {"distributedRelease"} )
+public class DistributedReleaseTest
+ extends AbstractReleaseTest
{
private static final String RELEASE_BUTTON_TEXT = "Release";
@@ -66,8 +65,8 @@ public class ReleaseTest
@BeforeClass
public void createAndBuildProject()
{
- projectGroupName = getProperty( "RELEASE_PROJECT_GROUP_NAME" );
- projectGroupId = getProperty( "RELEASE_PROJECT_GROUP_ID" );
+ projectGroupName = getProperty( "DIST_RELEASE_PROJECT_GROUP_NAME" );
+ projectGroupId = getProperty( "DIST_RELEASE_PROJECT_GROUP_ID" );
String description = "Distributed Release test projects";
loginAsAdmin();
@@ -96,15 +95,15 @@ public class ReleaseTest
public void setUp()
throws IOException
{
- releaseBuildEnvironment = getProperty( "RELEASE_BUILD_ENV" );
- releaseBuildAgentGroup = getProperty( "RELEASE_BUILD_AGENT_GROUP" );
- errorMessageNoAgent = getProperty( "RELEASE_NO_AGENT_MESSAGE" );
-
- tagBase = getProperty( "RELEASE_PROJECT_TAGBASE" );
- tag = getProperty( "RELEASE_PROJECT_TAG" );
- releaseVersion = getProperty( "RELEASE_PROJECT_VERSION" );
- developmentVersion = getProperty( "RELEASE_PROJECT_DEVELOPMENT_VERSION" );
- releaseProjectScmUrl = getProperty( "RELEASE_PROJECT_SCM_URL" );
+ releaseBuildEnvironment = getProperty( "DIST_RELEASE_BUILD_ENV" );
+ releaseBuildAgentGroup = getProperty( "DIST_RELEASE_BUILD_AGENT_GROUP" );
+ errorMessageNoAgent = getProperty( "DIST_RELEASE_NO_AGENT_MESSAGE" );
+
+ tagBase = getProperty( "DIST_RELEASE_PROJECT_TAGBASE" );
+ tag = getProperty( "DIST_RELEASE_PROJECT_TAG" );
+ releaseVersion = getProperty( "DIST_RELEASE_PROJECT_VERSION" );
+ developmentVersion = getProperty( "DIST_RELEASE_PROJECT_DEVELOPMENT_VERSION" );
+ releaseProjectScmUrl = getProperty( "DIST_RELEASE_PROJECT_SCM_URL" );
File file = new File( "target/conf/prepared-releases.xml" );
@@ -136,7 +135,7 @@ public class ReleaseTest
disableDistributedBuilds();
}
- public void testReleasePrepareWithoutInterveningPerform()
+ public void testDistributedReleasePrepareWithoutInterveningPerform()
throws IOException
{
// CONTINUUM-2687
@@ -156,6 +155,7 @@ public class ReleaseTest
// check prepared releases content (timestamp version)
String str = getPreparedReleasesContent();
+ System.out.println( str );
Assert.assertTrue( str.contains( "<releaseId>org.apache.continuum.examples.simple:simple-example:" ) );
// check that two versions are present
@@ -374,120 +374,6 @@ public class ReleaseTest
}
}
- private void releasePrepareProject( String username, String password, String tagBase, String tag,
- String releaseVersion, String developmentVersion, String buildEnv )
- {
- 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();
-
- waitForRelease();
- }
-
- private void releasePerformProjectWithProvideParameters( String username, String password, String tagBase,
- String tag, String scmUrl, String buildEnv )
- {
- goToReleasePerformProvideParametersPage();
- setFieldValue( "scmUrl", scmUrl );
- setFieldValue( "scmUsername", username );
- setFieldValue( "scmPassword", password );
- setFieldValue( "scmTag", tag );
- setFieldValue( "scmTagBase", tagBase );
- setFieldValue( "goals", "clean deploy" );
- selectValue( "profileId", buildEnv );
- submit();
-
- waitForRelease();
-
- assertReleasePhaseError();
- }
-
- private void goToReleasePreparePage()
- {
- clickLinkWithLocator( "goal", false );
- submit();
- assertReleasePreparePage();
- }
-
- private void goToReleasePerformProvideParametersPage()
- {
- selectPerformAndSubmit();
- assertReleasePerformProvideParametersPage();
- }
-
- private void selectPerformAndSubmit()
- {
- clickLinkWithLocator( "//input[@name='goal' and @value='perform']", false );
- submit();
- }
-
- private void assertReleasePreparePage()
- {
- assertPage( "Continuum - Release Project" );
- assertTextPresent( "Prepare Project for Release" );
- assertTextPresent( "Release Prepare Parameters" );
- assertTextPresent( "SCM Username" );
- assertTextPresent( "SCM Password" );
- assertTextPresent( "SCM Tag" );
- assertTextPresent( "SCM Tag Base" );
- assertTextPresent( "SCM Comment Prefix" );
- assertTextPresent( "Preparation Goals" );
- assertTextPresent( "Arguments" );
- assertTextPresent( "Build Environment" );
- assertTextPresent( "Release Version" );
- assertTextPresent( "Next Development Version" );
- assertButtonWithValuePresent( "Submit" );
- }
-
- private void assertReleasePerformProvideParametersPage()
- {
- assertPage( "Continuum - Perform Project Release" );
- assertTextPresent( "Perform Project Release" );
- assertTextPresent( "Release Perform Parameters" );
- assertTextPresent( "SCM Connection URL" );
- assertTextPresent( "SCM Username" );
- assertTextPresent( "SCM Password" );
- assertTextPresent( "SCM Tag" );
- assertTextPresent( "SCM Tag Base" );
- assertTextPresent( "Perform Goals" );
- assertTextPresent( "Arguments" );
- assertTextPresent( "Build Environment" );
- assertButtonWithValuePresent( "Submit" );
- }
-
- private void assertReleaseError()
- {
- assertTextPresent( "Release Error" );
- }
-
- private void assertReleasePhaseError()
- {
- assertButtonWithValuePresent( "Rollback changes" );
- assertImgWithAlt( "Error" );
- }
-
- private void assertReleasePhaseSuccess()
- {
- assertButtonWithValuePresent( "Rollback changes" );
- assertElementNotPresent( "//img[@alt='Error']" );
- }
-
- private void waitForRelease()
- {
- 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
- waitForOneOfElementsPresent( Arrays.asList( doneButtonLocator, errorTextLocator ), true );
- }
-
private void assertPreparedReleasesFileContainsBuildAgent()
throws Exception
{
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=1392725&r1=1392724&r2=1392725&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 Tue Oct 2 03:53:43 2012
@@ -19,38 +19,23 @@ package org.apache.continuum.web.test;
* under the License.
*/
-import org.apache.commons.io.IOUtils;
-import org.apache.continuum.web.test.parent.AbstractBuildAgentsTest;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStreamReader;
import java.util.Arrays;
@Test( groups = {"release"} )
public class ReleaseTest
- extends AbstractBuildAgentsTest
+ extends AbstractReleaseTest
{
-
- private static final String RELEASE_BUTTON_TEXT = "Release";
-
- private static final String PROVIDE_RELEASE_PARAMETERS_TEXT = "Provide Release Parameters";
-
private String projectGroupName;
private String projectGroupId;
- private String releaseBuildEnvironment;
-
- private String releaseBuildAgentGroup;
-
private String tagBase;
private String tag;
@@ -59,8 +44,6 @@ public class ReleaseTest
private String developmentVersion;
- private String errorMessageNoAgent;
-
private String releaseProjectScmUrl;
@BeforeClass
@@ -68,14 +51,10 @@ public class ReleaseTest
{
projectGroupName = getProperty( "RELEASE_PROJECT_GROUP_NAME" );
projectGroupId = getProperty( "RELEASE_PROJECT_GROUP_ID" );
- String description = "Distributed Release test projects";
+ String description = "Release test projects";
loginAsAdmin();
- enableDistributedBuilds();
-
- addBuildAgent( buildAgentUrl );
-
String pomUrl = getProperty( "MAVEN2_POM_URL" );
String pomUsername = getProperty( "MAVEN2_POM_USERNAME" );
String pomPassword = getProperty( "MAVEN2_POM_PASSWORD" );
@@ -96,119 +75,22 @@ public class ReleaseTest
public void setUp()
throws IOException
{
- releaseBuildEnvironment = getProperty( "RELEASE_BUILD_ENV" );
- releaseBuildAgentGroup = getProperty( "RELEASE_BUILD_AGENT_GROUP" );
- errorMessageNoAgent = getProperty( "RELEASE_NO_AGENT_MESSAGE" );
-
tagBase = getProperty( "RELEASE_PROJECT_TAGBASE" );
tag = getProperty( "RELEASE_PROJECT_TAG" );
releaseVersion = getProperty( "RELEASE_PROJECT_VERSION" );
developmentVersion = getProperty( "RELEASE_PROJECT_DEVELOPMENT_VERSION" );
releaseProjectScmUrl = getProperty( "RELEASE_PROJECT_SCM_URL" );
-
- File file = new File( "target/conf/prepared-releases.xml" );
-
- if ( file.exists() && !file.delete() )
- {
- throw new IOException( "Unable to delete existing prepared-releases.xml file" );
- }
-
- enableDistributedBuilds();
-
- addBuildAgent( buildAgentUrl );
-
- createBuildEnvAndBuildagentGroup( releaseBuildEnvironment, releaseBuildAgentGroup );
}
@AfterMethod
public void tearDown()
throws Exception
{
- removeBuildagentGroupFromBuildEnv( releaseBuildAgentGroup );
-
- removeBuildAgentGroup( releaseBuildAgentGroup );
-
- // enable agent if disabled
- goToBuildAgentPage();
- clickImgWithAlt( "Edit" );
- enableDisableBuildAgent( buildAgentUrl, true );
-
- disableDistributedBuilds();
- }
-
- public void testReleasePrepareWithoutInterveningPerform()
- throws IOException
- {
- // CONTINUUM-2687
- showProjectGroup( projectGroupName, projectGroupId, "" );
- clickButtonWithValue( RELEASE_BUTTON_TEXT );
- assertReleaseChoicePage();
-
- // first attempt
- releasePrepareProject( "", "", tagBase, "simple-example-1.1", "1.1", "1.2-SNAPSHOT", releaseBuildEnvironment );
- assertReleasePhaseSuccess();
- clickButtonWithValue( "Done" );
-
- // second attempt
- releasePrepareProject( "", "", tagBase, "simple-example-1.2", "1.2", "1.3-SNAPSHOT", releaseBuildEnvironment );
- assertReleasePhaseSuccess();
- clickButtonWithValue( "Done" );
-
- // check prepared releases content (timestamp version)
- String str = getPreparedReleasesContent();
- Assert.assertTrue( str.contains( "<releaseId>org.apache.continuum.examples.simple:simple-example:" ) );
-
- // check that two versions are present
- Assert.assertEquals( Arrays.asList( getSelenium().getSelectOptions( "preparedReleaseId" ) ), Arrays.asList(
- "1.1", "1.2", PROVIDE_RELEASE_PARAMETERS_TEXT ) );
-
- // check that 1.2 is selected by default
- Assert.assertEquals( getSelenium().getSelectedLabel( "preparedReleaseId" ), "1.2" );
-
- // test perform on 1.1
- selectPerformAndSubmit();
-
- setFieldValue( "goals", "clean validate" );
- submit();
-
- waitForRelease();
-
- assertReleasePhaseSuccess();
- }
-
- public void testReleasePrepareWhenAgentGoesDown()
- throws IOException
- {
- // CONTINUUM-2686
- showProjectGroup( projectGroupName, projectGroupId, "" );
- clickButtonWithValue( RELEASE_BUTTON_TEXT );
- assertReleaseChoicePage();
-
- releasePrepareProject( "", "", tagBase, "simple-example-2.0", "2.0", "2.1-SNAPSHOT", releaseBuildEnvironment );
- assertReleasePhaseSuccess();
-
- // disable agent
- goToBuildAgentPage();
- clickImgWithAlt( "Edit" );
- enableDisableBuildAgent( buildAgentUrl, false );
-
- // check prepared releases content
- String str = getPreparedReleasesContent();
- Assert.assertTrue( str.contains( "<releaseId>org.apache.continuum.examples.simple:simple-example" ) );
-
- // go back to release page
- showProjectGroup( projectGroupName, projectGroupId, "" );
- clickButtonWithValue( RELEASE_BUTTON_TEXT );
- assertReleaseChoicePage();
-
- // check that the version is present
- Assert.assertEquals( Arrays.asList( getSelenium().getSelectOptions( "preparedReleaseId" ) ), Arrays.asList(
- "2.0", PROVIDE_RELEASE_PARAMETERS_TEXT ) );
}
// can't test u/p locally and don't have a suitable SVN server to test against
@Test( enabled = false )
- public void testReleasePrepareProjectWithInvalidUsernamePasswordInDistributedBuilds()
+ public void testReleasePrepareProjectWithInvalidUsernamePassword()
throws Exception
{
String releaseUsername = "invalid";
@@ -217,54 +99,12 @@ public class ReleaseTest
showProjectGroup( projectGroupName, projectGroupId, "" );
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
- releasePrepareProject( releaseUsername, releasePassword, tagBase, "simple-example-3.0", "3.0", "3.1-SNAPSHOT",
- releaseBuildEnvironment );
+ releasePrepareProject( releaseUsername, releasePassword, tagBase, "simple-example-13.0", "13.0",
+ "13.1-SNAPSHOT", null );
assertReleasePhaseError();
- assertPreparedReleasesFileContainsBuildAgent();
}
- /*
- * Test release prepare with no build agent configured in the selected build environment.
- */
- public void testReleasePrepareProjectWithNoBuildagentInBuildEnvironment()
- throws Exception
- {
- detachBuildagentFromGroup( releaseBuildAgentGroup );
-
- showProjectGroup( projectGroupName, projectGroupId, projectGroupId );
-
- clickButtonWithValue( RELEASE_BUTTON_TEXT );
- assertReleaseChoicePage();
- releasePrepareProject( "", "", tagBase, tag, releaseVersion, developmentVersion, releaseBuildEnvironment );
-
- assertReleaseError();
-
- assertTextPresent( errorMessageNoAgent );
- }
-
- /*
- * Test release prepare with no build agent group in the selected build environment.
- */
- public void testReleasePrepareProjectWithNoBuildagentGroupInBuildEnvironment()
- throws Exception
- {
- removeBuildagentGroupFromBuildEnv( releaseBuildEnvironment );
-
- showProjectGroup( projectGroupName, projectGroupId, projectGroupId );
-
- clickButtonWithValue( RELEASE_BUTTON_TEXT );
- assertReleaseChoicePage();
- releasePrepareProject( "", "", tagBase, tag, releaseVersion, developmentVersion, releaseBuildEnvironment );
-
- assertReleaseError();
-
- assertTextPresent( errorMessageNoAgent );
- }
-
- /*
- * Test release prepare with no build environment selected.
- */
- public void testReleasePrepareProjectWithNoBuildEnvironment()
+ public void testReleasePrepareProject()
throws Exception
{
showProjectGroup( projectGroupName, projectGroupId, projectGroupId );
@@ -274,12 +114,10 @@ public class ReleaseTest
releasePrepareProject( "", "", tagBase, tag, releaseVersion, developmentVersion, "" );
assertReleasePhaseSuccess();
-
- assertPreparedReleasesFileContainsBuildAgent();
}
- @Test( dependsOnMethods = {"testReleasePrepareProjectWithNoBuildEnvironment"} )
- public void testReleasePerformUsingProvidedParametersWithDistributedBuilds()
+ @Test( dependsOnMethods = {"testReleasePrepareProject"} )
+ public void testReleasePerformUsingProvidedParameters()
throws Exception
{
String releaseUsername = "invalid";
@@ -289,240 +127,45 @@ public class ReleaseTest
clickButtonWithValue( RELEASE_BUTTON_TEXT );
assertReleaseChoicePage();
releasePerformProjectWithProvideParameters( releaseUsername, releasePassword, tagBase, tag,
- releaseProjectScmUrl, releaseBuildEnvironment );
- assertPreparedReleasesFileContainsBuildAgent();
+ releaseProjectScmUrl, "" );
}
- private void createBuildEnvAndBuildagentGroup( String projectBuildEnv, String projectAgentGroup )
- {
- // add build agent group no agents
- goToBuildAgentPage();
- if ( !isTextPresent( projectAgentGroup ) )
- {
- clickAndWait( "//input[@id='editBuildAgentGroup_0']" );
- setFieldValue( "saveBuildAgentGroup_buildAgentGroup_name", projectAgentGroup );
- clickButtonWithValue( "Save" );
- }
-
- // add build environment with build agent group
- clickLinkWithText( "Build Environments" );
- if ( !isTextPresent( projectBuildEnv ) )
- {
- clickAndWait( "//input[@id='addBuildEnv_0']" );
- setFieldValue( "saveBuildEnv_profile_name", projectBuildEnv );
- clickButtonWithValue( "Save" );
- }
-
- attachBuildagentGroupToBuildEnv( releaseBuildEnvironment, releaseBuildAgentGroup );
-
- // attach build agent in build agent group created
- attachBuildagentInGroup( releaseBuildAgentGroup );
- }
-
- private void attachBuildagentGroupToBuildEnv( String projectBuildEnv, String projectAgentGroup )
- {
- clickLinkWithText( "Build Environments" );
- String xPath = "//preceding::td[text()='" + projectBuildEnv + "']//following::img[@alt='Edit']";
- clickLinkWithXPath( xPath );
- selectValue( "profile.buildAgentGroup", projectAgentGroup );
- clickButtonWithValue( "Save" );
- }
-
- private void removeBuildagentGroupFromBuildEnv( String projectBuildEnv )
- {
- clickLinkWithText( "Build Environments" );
- String xPath = "//preceding::td[text()='" + projectBuildEnv + "']//following::img[@alt='Edit']";
- if ( isElementPresent( "xpath=" + xPath ) )
- {
- clickLinkWithXPath( xPath );
- selectValue( "profile.buildAgentGroup", "" );
- clickButtonWithValue( "Save" );
- }
- }
-
- private void attachBuildagentInGroup( String projectAgentGroup )
- {
- String buildAgent = buildAgentUrl;
-
- clickLinkWithText( "Build Agents" );
- String xPath = "//preceding::td[text()='" + projectAgentGroup + "']//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( String projectAgentGroup )
- {
- String buildAgent = buildAgentUrl;
-
- clickLinkWithText( "Build Agents" );
- String xPath = "//preceding::td[text()='" + projectAgentGroup + "']//following::img[@alt='Edit']";
- clickLinkWithXPath( xPath );
-
- if ( isElementPresent(
- "xpath=//select[@id='saveBuildAgentGroup_selectedBuildAgentIds']/option[@value='" + buildAgent + "']" ) )
- {
- selectValue( "selectedBuildAgentIds", buildAgent );
- clickLinkWithXPath( "//input[@value='<-']", false );
- submit();
- }
- }
-
- private void releasePrepareProject( String username, String password, String tagBase, String tag,
- String releaseVersion, String developmentVersion, String buildEnv )
+ // avoid the above test running between these so that the list of prepared releases is correct
+ @Test( dependsOnMethods = {"testReleasePrepareProject"} )
+ public void testReleasePrepareWithoutInterveningPerform()
+ throws IOException
{
- 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();
-
- waitForRelease();
- }
+ // CONTINUUM-2687
+ showProjectGroup( projectGroupName, projectGroupId, "" );
+ clickButtonWithValue( RELEASE_BUTTON_TEXT );
+ assertReleaseChoicePage();
- private void releasePerformProjectWithProvideParameters( String username, String password, String tagBase,
- String tag, String scmUrl, String buildEnv )
- {
- goToReleasePerformProvideParametersPage();
- setFieldValue( "scmUrl", scmUrl );
- setFieldValue( "scmUsername", username );
- setFieldValue( "scmPassword", password );
- setFieldValue( "scmTag", tag );
- setFieldValue( "scmTagBase", tagBase );
- setFieldValue( "goals", "clean deploy" );
- selectValue( "profileId", buildEnv );
- submit();
+ // first attempt
+ releasePrepareProject( "", "", tagBase, "simple-example-10.1", "10.1", "10.2-SNAPSHOT", "" );
+ assertReleasePhaseSuccess();
+ clickButtonWithValue( "Done" );
- waitForRelease();
+ // second attempt
+ releasePrepareProject( "", "", tagBase, "simple-example-10.2", "10.2", "10.3-SNAPSHOT", "" );
+ assertReleasePhaseSuccess();
+ clickButtonWithValue( "Done" );
- assertReleasePhaseError();
- }
+ // check that two versions are present
+ Assert.assertEquals( Arrays.asList( getSelenium().getSelectOptions( "preparedReleaseId" ) ), Arrays.asList(
+ "10.0", "10.1", "10.2", PROVIDE_RELEASE_PARAMETERS_TEXT ) );
- private void goToReleasePreparePage()
- {
- clickLinkWithLocator( "goal", false );
- submit();
- assertReleasePreparePage();
- }
+ // check that 1.2 is selected by default
+ Assert.assertEquals( getSelenium().getSelectedLabel( "preparedReleaseId" ), "10.2" );
- private void goToReleasePerformProvideParametersPage()
- {
+ // test perform on 1.1
selectPerformAndSubmit();
- assertReleasePerformProvideParametersPage();
- }
- private void selectPerformAndSubmit()
- {
- clickLinkWithLocator( "//input[@name='goal' and @value='perform']", false );
+ setFieldValue( "goals", "clean validate" );
submit();
- }
-
- private void assertReleasePreparePage()
- {
- assertPage( "Continuum - Release Project" );
- assertTextPresent( "Prepare Project for Release" );
- assertTextPresent( "Release Prepare Parameters" );
- assertTextPresent( "SCM Username" );
- assertTextPresent( "SCM Password" );
- assertTextPresent( "SCM Tag" );
- assertTextPresent( "SCM Tag Base" );
- assertTextPresent( "SCM Comment Prefix" );
- assertTextPresent( "Preparation Goals" );
- assertTextPresent( "Arguments" );
- assertTextPresent( "Build Environment" );
- assertTextPresent( "Release Version" );
- assertTextPresent( "Next Development Version" );
- assertButtonWithValuePresent( "Submit" );
- }
-
- private void assertReleasePerformProvideParametersPage()
- {
- assertPage( "Continuum - Perform Project Release" );
- assertTextPresent( "Perform Project Release" );
- assertTextPresent( "Release Perform Parameters" );
- assertTextPresent( "SCM Connection URL" );
- assertTextPresent( "SCM Username" );
- assertTextPresent( "SCM Password" );
- assertTextPresent( "SCM Tag" );
- assertTextPresent( "SCM Tag Base" );
- assertTextPresent( "Perform Goals" );
- assertTextPresent( "Arguments" );
- assertTextPresent( "Build Environment" );
- assertButtonWithValuePresent( "Submit" );
- }
-
- private void assertReleaseError()
- {
- assertTextPresent( "Release Error" );
- }
- private void assertReleasePhaseError()
- {
- assertButtonWithValuePresent( "Rollback changes" );
- assertImgWithAlt( "Error" );
- }
-
- private void assertReleasePhaseSuccess()
- {
- assertButtonWithValuePresent( "Rollback changes" );
- assertElementNotPresent( "//img[@alt='Error']" );
- }
-
- private void waitForRelease()
- {
- 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
- waitForOneOfElementsPresent( Arrays.asList( doneButtonLocator, errorTextLocator ), true );
- }
-
- private void assertPreparedReleasesFileContainsBuildAgent()
- throws Exception
- {
- String str = getPreparedReleasesContent();
+ waitForRelease();
- Assert.assertTrue( str.contains( "<buildAgentUrl>" + buildAgentUrl + "</buildAgentUrl>" ),
- "prepared-releases.xml was not populated" );
+ assertReleasePhaseSuccess();
}
- private String getPreparedReleasesContent()
- throws IOException
- {
- File file = new File( "target/conf/prepared-releases.xml" );
- Assert.assertTrue( file.exists(), "prepared-releases.xml was not created" );
-
- FileInputStream fis = null;
- BufferedReader reader = null;
-
- try
- {
- fis = new FileInputStream( file );
- reader = new BufferedReader( new InputStreamReader( fis ) );
-
- String strLine;
- StringBuilder str = new StringBuilder();
- while ( ( strLine = reader.readLine() ) != null )
- {
- str.append( strLine );
- }
- return str.toString();
- }
- finally
- {
- IOUtils.closeQuietly( reader );
- IOUtils.closeQuietly( fis );
- }
- }
}
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=1392725&r1=1392724&r2=1392725&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 Tue Oct 2 03:53:43 2012
@@ -19,11 +19,17 @@ package org.apache.continuum.web.test.pa
* under the License.
*/
+import org.testng.annotations.BeforeClass;
import org.testng.annotations.BeforeMethod;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
public abstract class AbstractAdminTest
extends AbstractContinuumTest
{
+ protected String buildAgentUrl;
+
@BeforeMethod( alwaysRun = true )
public void loginAsAdmin()
{
@@ -43,4 +49,297 @@ public abstract class AbstractAdminTest
clickLinkWithText( "Configuration" );
assertEditConfigurationPage();
}
+
+ protected void enableDisableBuildAgent( String agentName, boolean enable )
+ {
+ assertFieldValue( agentName, "saveBuildAgent_buildAgent_url" );
+
+ if ( enable )
+ {
+ checkField( "saveBuildAgent_buildAgent_enabled" );
+ }
+ else
+ {
+ uncheckField( "saveBuildAgent_buildAgent_enabled" );
+ }
+ submit();
+ assertBuildAgentPage();
+ assertTextPresent( Boolean.toString( enable ) );
+ }
+
+ protected void goToAddBuildAgentGroup()
+ {
+ goToBuildAgentPage();
+ clickAndWait( "editBuildAgentGroup_0" ); //add button
+ String[] options = new String[]{"--- Available Build Agents ---"};
+ assertAddEditBuildAgentGroupPage( options, null );
+ }
+
+ protected void addEditBuildAgentGroup( String name, String[] addBuildAgents, String[] removeBuildAgents,
+ boolean success )
+ {
+ setFieldValue( "saveBuildAgentGroup_buildAgentGroup_name", name );
+ if ( addBuildAgents != null && addBuildAgents.length > 0 )
+ {
+ for ( String ba : addBuildAgents )
+ {
+ selectValue( "buildAgentIds", ba );
+ clickButtonWithValue( "->", false );
+ }
+ }
+ if ( removeBuildAgents != null && removeBuildAgents.length > 0 )
+ {
+ for ( String ba : removeBuildAgents )
+ {
+ selectValue( "selectedBuildAgentIds", ba );
+ clickButtonWithValue( "<-", false );
+ }
+ }
+ submit();
+ if ( success )
+ {
+ assertBuildAgentPage();
+ }
+ else
+ {
+ assertAddEditBuildAgentGroupPage( null, null );
+ }
+ }
+
+ void assertAddEditBuildAgentGroupPage( String[] availableBuildAgents, String[] usedBuildAgents )
+ {
+ assertPage( "Continuum - Add/Edit Build Agent Group" );
+ assertTextPresent( "Add/Edit Build Agent Group" );
+ assertTextPresent( "Name*:" );
+ assertTextPresent( "Configure the used Build Agents:" );
+ assertElementPresent( "buildAgentGroup.name" );
+ if ( availableBuildAgents != null && availableBuildAgents.length > 0 )
+ {
+ assertOptionPresent( "buildAgentIds", availableBuildAgents );
+ }
+ if ( usedBuildAgents != null && usedBuildAgents.length > 0 )
+ {
+ assertOptionPresent( "selectedBuildAgentIds", usedBuildAgents );
+ }
+
+ assertButtonWithValuePresent( "Save" );
+ assertButtonWithValuePresent( "Cancel" );
+ }
+
+ protected void goToEditBuildAgentGroup( String name, String[] buildAgents )
+ {
+ goToBuildAgentPage();
+ String xPath = "//preceding::td[text()='" + name + "']//following::img[@alt='Edit']";
+ clickLinkWithXPath( xPath );
+ assertAddEditBuildAgentGroupPage( null, buildAgents );
+ assertFieldValue( name, "buildAgentGroup.name" );
+ }
+
+ protected void removeBuildAgentGroup( String name )
+ throws UnsupportedEncodingException
+ {
+ removeBuildAgentGroup( name, true );
+ }
+
+ protected void removeBuildAgentGroup( String name, boolean failIfMissing )
+ throws UnsupportedEncodingException
+ {
+ goToBuildAgentPage();
+ if ( isTextPresent( name ) || failIfMissing )
+ {
+ clickLinkWithXPath(
+ "(//a[contains(@href,'deleteBuildAgentGroup.action') and contains(@href, '" + URLEncoder.encode( name,
+ "UTF-8" ) +
+ "')])//img" );
+ assertPage( "Continuum - Delete Build Agent Group" );
+ assertTextPresent( "Delete Build Agent" );
+ assertTextPresent( "Are you sure you want to delete build agent group " + name + " ?" );
+ assertButtonWithValuePresent( "Delete" );
+ assertButtonWithValuePresent( "Cancel" );
+ clickButtonWithValue( "Delete" );
+ assertBuildAgentPage();
+ assertTextNotPresent( name );
+ }
+ }
+
+ protected void addBuildAgent( String buildAgentUrl )
+ {
+ addBuildAgent( buildAgentUrl, "Default description" );
+ }
+
+ protected void addBuildAgent( String buildAgentUrl, String description )
+ {
+ goToBuildAgentPage();
+ assertBuildAgentPage();
+
+ if ( !isElementPresent( "link=" + buildAgentUrl ) )
+ {
+
+ clickAndWait( "editBuildAgent_0" ); //add button
+ assertAddEditBuildAgentPage( true );
+
+ setFieldValue( "saveBuildAgent_buildAgent_url", buildAgentUrl );
+ setFieldValue( "saveBuildAgent_buildAgent_description", description );
+ checkField( "saveBuildAgent_buildAgent_enabled" );
+
+ submit();
+
+ assertBuildAgentPage();
+ assertElementPresent( "link=" + buildAgentUrl );
+ }
+ }
+
+ protected void goToAddBuildAgent()
+ {
+ goToBuildAgentPage();
+ assertBuildAgentPage();
+ clickAndWait( "editBuildAgent_0" ); //add button
+ assertAddEditBuildAgentPage( true );
+ }
+
+ void assertAddEditBuildAgentPage( boolean isChecked )
+ {
+ assertPage( "Continuum - Add/Edit Build Agent" );
+ assertTextPresent( "Add/Edit Build Agent" );
+ assertTextPresent( "Build Agent URL*:" );
+ assertTextPresent( "Description:" );
+ assertTextPresent( "Enabled" );
+ assertElementPresent( "saveBuildAgent_buildAgent_url" );
+ assertElementPresent( "saveBuildAgent_buildAgent_description" );
+
+ if ( isChecked )
+ {
+ assertIsChecked();
+ }
+
+ assertButtonWithValuePresent( "Save" );
+ assertButtonWithValuePresent( "Cancel" );
+ }
+
+ @BeforeClass( alwaysRun = true )
+ public void initializeBuildAgent()
+ {
+ buildAgentUrl = baseUrl.substring( 0, baseUrl.indexOf( "/continuum" ) ) + "/continuum-buildagent/xmlrpc";
+ }
+
+ protected void enableDistributedBuilds()
+ {
+ goToConfigurationPage();
+ setFieldValue( "numberOfAllowedBuildsinParallel", "2" );
+ if ( !isChecked( "configuration_distributedBuildEnabled" ) )
+ {
+ // must use click here so the JavaScript enabling the shared secret gets triggered
+ click( "configuration_distributedBuildEnabled" );
+ }
+ setFieldValue( "configuration_sharedSecretPassword", SHARED_SECRET );
+ clickAndWait( "configuration_" );
+ assertTextPresent( "true" );
+ assertTextPresent( "Distributed Builds" );
+ assertElementPresent( "link=Build Agents" );
+ }
+
+ protected void disableDistributedBuilds()
+ {
+ goToConfigurationPage();
+ setFieldValue( "numberOfAllowedBuildsinParallel", "2" );
+ if ( isChecked( "configuration_distributedBuildEnabled" ) )
+ {
+ uncheckField( "configuration_distributedBuildEnabled" );
+ }
+ submit();
+ assertTextPresent( "false" );
+ assertElementNotPresent( "link=Build Agents" );
+ }
+
+ protected void goToBuildAgentPage()
+ {
+ clickAndWait( "link=Build Agents" );
+ assertPage( "Continuum - Build Agents" );
+ }
+
+ void assertBuildAgentPage()
+ {
+ assertPage( "Continuum - Build Agents" );
+ assertTextPresent( "Build Agents" );
+ assertTextPresent( "Build Agent Groups" );
+ assertButtonWithValuePresent( "Add" );
+ }
+
+ protected void removeBuildAgent( String agentName )
+ throws Exception
+ {
+ removeBuildAgent( agentName, true );
+ }
+
+ protected 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();
+ assertElementNotPresent( deleteButton );
+ }
+ }
+
+ protected void addBuildAgent( String agentURL, String description, boolean success, boolean enabled,
+ boolean pingOk )
+ {
+ setFieldValue( "saveBuildAgent_buildAgent_url", agentURL );
+ setFieldValue( "saveBuildAgent_buildAgent_description", description );
+
+ if ( enabled )
+ {
+ checkField( "saveBuildAgent_buildAgent_enabled" );
+ }
+
+ submit();
+
+ if ( success )
+ {
+ if ( pingOk )
+ {
+ assertBuildAgentPage();
+ assertElementPresent( "link=" + agentURL );
+ clickLinkWithText( agentURL );
+
+ assertTextPresent( "true" );
+ }
+ else
+ {
+ assertTextPresent( "Unable to ping" );
+ assertAddEditBuildAgentPage( true );
+ }
+ }
+ else
+ {
+ assertAddEditBuildAgentPage( true );
+ }
+ }
+
+ protected void goToEditBuildAgent( String name, String description )
+ {
+ goToBuildAgentPage();
+ clickImgWithAlt( "Edit" );
+ assertAddEditBuildAgentPage( false );
+ assertFieldValue( name, "saveBuildAgent_buildAgent_url" );
+ assertFieldValue( description, "saveBuildAgent_buildAgent_description" );
+ }
+
+ protected void addEditBuildAgent( String agentName, String newDesc )
+ {
+ assertFieldValue( agentName, "saveBuildAgent_buildAgent_url" );
+ setFieldValue( "saveBuildAgent_buildAgent_description", newDesc );
+ submit();
+ assertBuildAgentPage();
+ assertTextPresent( newDesc );
+ }
}