continuum-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wsm...@apache.org
Subject svn commit: r787531 - in /continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test: BuildAgentsTest.java parent/AbstractBuildAgentsTest.java
Date Tue, 23 Jun 2009 03:54:43 GMT
Author: wsmoak
Date: Tue Jun 23 03:54:43 2009
New Revision: 787531

URL: http://svn.apache.org/viewvc?rev=787531&view=rev
Log:
[CONTINUUM-2271] Selenium tests for build agents. 
Add files that I missed in r786635
Submitted by: Tin Pardo

Added:
    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/parent/AbstractBuildAgentsTest.java

Added: 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=787531&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildAgentsTest.java
(added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildAgentsTest.java
Tue Jun 23 03:54:43 2009
@@ -0,0 +1,153 @@
+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.AbstractBuildQueueTest;
+import org.testng.annotations.Test;
+import org.apache.continuum.web.test.parent.AbstractBuildAgentsTest;
+
+
+@Test( groups = { "agent" }, dependsOnMethods = { "testDeleteBuildDefinitionTemplate" } )
+    public class BuildAgentsTest
+    extends AbstractBuildAgentsTest
+    {
+    
+    public void testAddBuildAgent()
+    {
+		String BUILD_AGENT_NAME = getProperty( "BUILD_AGENT_NAME" );
+		String BUILD_AGENT_DESCRIPTION = getProperty( "BUILD_AGENT_DESCRIPTION" );
+		String BUILD_AGENT_NAME2 = getProperty( "BUILD_AGENT_NAME2" );
+		String BUILD_AGENT_DESCRIPTION2 = getProperty( "BUILD_AGENT_DESCRIPTION2" );
+		String BUILD_AGENT_NAME3 = getProperty( "BUILD_AGENT_NAME3" );
+		String BUILD_AGENT_DESCRIPTION3 = getProperty( "BUILD_AGENT_DESCRIPTION3" );
+		
+		enableDistributedBuilds();
+		goToAddBuildAgent();
+		addBuildAgent( BUILD_AGENT_NAME, BUILD_AGENT_DESCRIPTION, true ) ;
+		goToAddBuildAgent();
+		addBuildAgent( BUILD_AGENT_NAME2, BUILD_AGENT_DESCRIPTION2, true ) ;
+		goToAddBuildAgent();
+		addBuildAgent( BUILD_AGENT_NAME3, BUILD_AGENT_DESCRIPTION3, true ) ;
+	}
+	
+	@Test( dependsOnMethods = { "testEditBuildAgent" } )
+    public void testAddAnExistingBuildAgent()
+    {
+		String BUILD_AGENT_NAME = getProperty( "BUILD_AGENT_NAME" );
+		String BUILD_AGENT_DESCRIPTION = getProperty( "BUILD_AGENT_DESCRIPTION" );
+		
+		goToAddBuildAgent();
+		addBuildAgent( BUILD_AGENT_NAME, BUILD_AGENT_DESCRIPTION, false ) ;
+        assertTextPresent( "Build agent already exists" );
+    }
+	
+	@Test( dependsOnMethods = { "testAddBuildAgent" } )
+	public void testEditBuildAgent()
+	
+    {
+		String BUILD_AGENT_NAME = getProperty( "BUILD_AGENT_NAME" );
+		String BUILD_AGENT_DESCRIPTION = getProperty( "BUILD_AGENT_DESCRIPTION" );
+		String new_agentDescription = "new_agentDescription";
+        
+        goToEditBuildAgent( BUILD_AGENT_NAME, BUILD_AGENT_DESCRIPTION);
+		addEditBuildAgent( BUILD_AGENT_NAME, new_agentDescription );
+		goToEditBuildAgent( BUILD_AGENT_NAME, new_agentDescription);
+		addEditBuildAgent( BUILD_AGENT_NAME, BUILD_AGENT_DESCRIPTION );
+		
+    } 
+	
+	@Test( dependsOnMethods = { "testAddAnExistingBuildAgent" } )
+    public void testDeleteBuildAgent()
+   
+    {
+        goToBuildAgentPage();
+        String BUILD_AGENT_NAME3 = getProperty( "BUILD_AGENT_NAME3" );
+        removeBuildAgent( BUILD_AGENT_NAME3 );
+        assertTextNotPresent( BUILD_AGENT_NAME3 );
+    }
+	
+	@Test( dependsOnMethods = { "testDeleteBuildAgent" } )
+    public void testAddEmptyBuildAgent()
+    {
+    	String BUILD_AGENT_DESCRIPTION = getProperty( "BUILD_AGENT_DESCRIPTION" );
+    	
+    	goToAddBuildAgent();
+		addBuildAgent( "", BUILD_AGENT_DESCRIPTION, false ) ;
+		assertTextPresent( "Build agent url is required." );
+    }
+    
+//TESTS FOR BUILD AGENT GROUPS    
+    
+    @Test( dependsOnMethods = { "testAddBuildAgent" } )
+    public void testAddBuildAgentGroup()
+    throws Exception
+    {
+    	String BUILD_AGENT_GROUPNAME = getProperty( "BUILD_AGENT_GROUPNAME" );
+		
+    	goToAddBuildAgentGroup();
+		addEditBuildAgentGroup( BUILD_AGENT_GROUPNAME, new String[] { "Agent_url_name", "Second_Agent"
}, new String[] {}, true );
+    	
+	}
+	
+	@Test( dependsOnMethods = { "testAddBuildAgentGroup" } )
+    public void testEditBuildAgentGroup()
+        throws Exception
+    {
+    	String BUILD_AGENT_GROUPNAME = getProperty( "BUILD_AGENT_GROUPNAME" );
+        String newName = "new_agentgroupname";
+        goToEditBuildAgentGroup( BUILD_AGENT_GROUPNAME, new String[] { "Agent_url_name",
"Second_Agent" } );
+        addEditBuildAgentGroup( newName, new String[] {},
+                         new String[] { "Second_Agent" }, true );
+        goToEditBuildAgentGroup( newName, new String[] { "Agent_url_name" } );
+        addEditBuildAgentGroup( BUILD_AGENT_GROUPNAME, new String[] { "Second_Agent" },
+                         new String[] {}, true );
+    }
+	
+	@Test( dependsOnMethods = { "testEditBuildAgentGroup" } )
+    public void testAddAnExistingBuildAgentGroup()
+    throws Exception
+    {
+        String BUILD_AGENT_GROUPNAME = getProperty( "BUILD_AGENT_GROUPNAME" );
+		
+    	goToAddBuildAgentGroup();
+	   	addEditBuildAgentGroup( BUILD_AGENT_GROUPNAME, new String[] { "Agent_url_name", "Second_Agent"
}, new String[] {}, false );
+	   	assertTextPresent( "Build agent group already exists." );
+     
+    }   
+    
+    @Test( dependsOnMethods = { "testAddAnExistingBuildAgentGroup" } )
+    public void testAddEmptyBuildAgentGroupName()
+    throws Exception
+    {
+    	
+    	goToAddBuildAgentGroup();
+    	addEditBuildAgentGroup( "", new String[] {}, new String[] {}, false );
+		assertTextPresent( "Build agent group name required." );
+    }
+    
+    @Test( dependsOnMethods = { "testAddEmptyBuildAgentGroupName" } )
+    public void testDeleteBuildAgentGroup()
+    {
+    	String BUILD_AGENT_GROUPNAME = getProperty( "BUILD_AGENT_GROUPNAME" );
+        removeBuildAgentGroup( BUILD_AGENT_GROUPNAME );
+    }
+    
+    
+}

Added: 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=787531&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildAgentsTest.java
(added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/parent/AbstractBuildAgentsTest.java
Tue Jun 23 03:54:43 2009
@@ -0,0 +1,219 @@
+package org.apache.continuum.web.test.parent;
+
+//import org.testng.Assert;
+import org.apache.continuum.web.test.ConfigurationTest;
+
+/*
+ * 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.
+ */
+
+public abstract class AbstractBuildAgentsTest
+    extends AbstractContinuumTest
+{
+    public void enableDistributedBuilds()
+    {
+		ConfigurationTest config = new ConfigurationTest();
+	    config.goToConfigurationPage();
+		setFieldValue( "numberOfAllowedBuildsinParallel", "2" );
+        if (!isChecked("configuration_distributedBuildEnabled"));
+        {
+		checkField("configuration_distributedBuildEnabled");
+        }
+		clickAndWait("configuration_");
+		assertTextPresent("true");
+		assertTextPresent("Distributed Builds");
+		assertElementPresent("link=Build Agents");
+		
+    }
+
+	public void goToBuildAgentPage()
+    {
+		clickAndWait("link=Build Agents");
+		assertPage("Continuum - Build Agents");
+	}
+	
+	public void assertBuildAgentPage()
+    {
+		assertPage("Continuum - Build Agents");
+		assertTextPresent("Build Agents");
+		assertTextPresent("Build Agent Groups");
+		assertButtonWithValuePresent( "Add" );
+		
+    }
+	
+	public void goToAddBuildAgent()
+    {
+		goToBuildAgentPage();
+		assertBuildAgentPage();
+		clickAndWait("editBuildAgent_0"); //add button
+		assertAddEditBuildAgentPage();
+    }
+	
+	public void assertAddEditBuildAgentPage()
+    {
+		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");
+        assertButtonWithValuePresent( "Save" );
+        assertButtonWithValuePresent( "Cancel" );
+    }
+	
+	public void removeBuildAgent( String agentName ) 
+	{
+        clickLinkWithXPath( "(//a[contains(@href,'deleteBuildAgent.action') and contains(@href,
'" + agentName + "')])//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();
+    } 
+
+	public void addBuildAgent( String agentURL, String description, boolean success )
+	{
+		setFieldValue( "saveBuildAgent_buildAgent_url", agentURL );
+	    setFieldValue("saveBuildAgent_buildAgent_description", description );
+	    checkField("saveBuildAgent_buildAgent_enabled");
+		submit();
+	    if ( success )
+	    {
+	        assertBuildAgentPage();
+	        assertElementPresent( "link=" + agentURL );
+	        
+	    }
+	    else
+	    {
+	        assertAddEditBuildAgentPage();
+	    }
+	    
+	}
+	
+	public void goToEditBuildAgent( String name, String description )
+	{
+	   goToBuildAgentPage();
+	   clickImgWithAlt( "Edit" );
+	   assertAddEditBuildAgentPage();
+	   assertFieldValue( name, "saveBuildAgent_buildAgent_url" );
+	   assertFieldValue( description, "saveBuildAgent_buildAgent_description" );
+	    
+	}
+	
+	public void addEditBuildAgent( String agentName, String newDesc )
+	{
+		assertFieldValue( agentName, "saveBuildAgent_buildAgent_url" );
+		setFieldValue( "saveBuildAgent_buildAgent_description", newDesc );
+		submit();
+		assertBuildAgentPage();
+		assertTextPresent( newDesc );
+		
+	}
+	
+	
+	public void goToAddBuildAgentGroup()
+    {
+		goToBuildAgentPage();
+		clickAndWait("editBuildAgentGroup_0"); //add button
+        String[] options =
+            new String[] { "--- Available Build Agents ---", "Agent_url_name", "Second_Agent"
};
+        assertAddEditBuildAgentGroupPage( options, null );
+    }
+	
+	
+	public void addEditBuildAgentGroup( String name, String[] addBuildAgents, String[] removeBuildAgents,
+            boolean success ) throws Exception
+	{
+		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 );
+		}
+		
+		 
+	}
+	
+	public 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" );
+    }
+	
+	public 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" );
+    }
+
+   	
+	public void removeBuildAgentGroup( String name ) 
+	{
+		goToBuildAgentPage();
+		clickLinkWithXPath( "(//a[contains(@href,'deleteBuildAgentGroup.action') and contains(@href,
'" + name + "')])//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();
+    }
+	
+
+}



Mime
View raw message