You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@continuum.apache.org by ws...@apache.org on 2009/03/11 18:12:07 UTC

svn commit: r752530 [1/2] - in /continuum/trunk/continuum-webapp-test: ./ src/test/resources/ src/test/testng/ src/test/testng/config/ src/test/testng/org/ src/test/testng/org/apache/ src/test/testng/org/apache/continuum/ src/test/testng/org/apache/con...

Author: wsmoak
Date: Wed Mar 11 17:12:06 2009
New Revision: 752530

URL: http://svn.apache.org/viewvc?rev=752530&view=rev
Log:
[CONTINUUM-2073] Added TestNG version of Selenium tests
Submitted by: Jose Morales Martinez

Added:
    continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties
    continuum/trunk/continuum-webapp-test/src/test/testng/
    continuum/trunk/continuum-webapp-test/src/test/testng/config/
    continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml
    continuum/trunk/continuum-webapp-test/src/test/testng/org/
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AboutTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractContinuumTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractSeleniumTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LoginTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenTwoProjectTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MyAccountTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/NotifierTest.java
    continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/ProjectGroupTest.java
    continuum/trunk/continuum-webapp-test/testng-pom.xml
Modified:
    continuum/trunk/continuum-webapp-test/Readme.txt

Modified: continuum/trunk/continuum-webapp-test/Readme.txt
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/Readme.txt?rev=752530&r1=752529&r2=752530&view=diff
==============================================================================
--- continuum/trunk/continuum-webapp-test/Readme.txt (original)
+++ continuum/trunk/continuum-webapp-test/Readme.txt Wed Mar 11 17:12:06 2009
@@ -13,6 +13,12 @@
 Run Selenium tests in src/test/it with Maven and Cargo with alternate configuration
  * modify src/test/resources/it.properties as needed
  * mvn clean install -f it-pom.xml
+ 
+Run Selenium tests in src/test/testNG with Maven and testNG
+ * Start Continuum
+ * Config admin user for continuum application
+ * modify src/test/resources/testng.properties as needed
+ * mvn clean install -f testng-pom.xml
 
  Note that this does not install anything, it simply runs through the lifecycle including the integration test phases.
  More properly it would be 'mvn clean post-integration-test', but install is much shorter to type. :)

Added: 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=752530&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties (added)
+++ continuum/trunk/continuum-webapp-test/src/test/resources/testng.properties Wed Mar 11 17:12:06 2009
@@ -0,0 +1,71 @@
+#properties for integration tests
+
+#######################
+# General properties
+#######################
+
+BASE_URL=http://localhost:9090
+MAX_WAIT_TIME_IN_MS=60000
+
+ADMIN_USERNAME=admin
+ADMIN_PASSWORD=admin123
+
+SELENIUM_HOST=localhost
+SELENIUM_PORT=4444
+SELENIUM_BROWSER=*firefox
+
+DEFAULT_PROJ_GRP_NAME =Default Project Group
+DEFAULT_PROJ_GRP_ID =default
+DEFAULT_PROJ_GRP_DESCRIPTION =Contains all projects that do not have a group of their own
+
+########################
+# mavenTwoProject group 
+########################
+
+# Properties for testAddMavenTwoProject
+M2_POM_URL =http://svn.apache.org/repos/asf/maven/pom/trunk/maven/pom.xml
+M2_PROJ_GRP_NAME=Apache Maven
+M2_PROJ_GRP_ID=org.apache.maven
+M2_PROJ_GRP_DESCRIPTION=Maven is a software project management and comprehension tool. Based on the concept of a project object model (POM), Maven can manage a project's build, reporting and documentation from a central piece of information.
+M2_POM_USERNAME =dummy
+M2_POM_PASSWORD =dummy
+# SCM element is missing from pom
+NOT_SCM_POM_URL =http://svn.apache.org/repos/asf/continuum/trunk/continuum-webapp-test/src/test/resources/unit/maven-two-projects/missing-scm-element-pom.xml
+MISS_CONECT_POM_URL =http://svn.apache.org/repos/asf/continuum/trunk/continuum-webapp-test/src/test/resources/unit/maven-two-projects/missing-connection-element-pom.xml
+MISS_PARENT_POM_URL =http://svn.apache.org/repos/asf/continuum/trunk/continuum-webapp-test/src/test/resources/unit/maven-two-projects/missing-parent-pom.xml
+MISS_SUBPRO_POM_URL =http://svn.apache.org/repos/asf/continuum/trunk/continuum-webapp-test/src/test/resources/unit/maven-two-projects/missing-modules-pom.xml
+
+########################
+# projectGroup group 
+########################
+TEST_PROJ_GRP_NAME =Test Project Group Name
+TEST_PROJ_GRP_ID =Test Project Group Id
+TEST_PROJ_GRP_DESCRIPTION =Test Project Group Description
+## Second project group without projects
+TEST2_PROJ_GRP_NAME =Test Project Group 2 Name
+TEST2_PROJ_GRP_ID =Test Project Group 2 Id
+TEST2_PROJ_GRP_DESCRIPTION =Test Project Group 2 Description
+
+########################
+# notifier group 
+########################
+WAGON_NOTIFIER_URL =http://svn.apache.org/repos/asf/maven/pom/trunk/maven/pom.xml
+WAGON_SERVER_ID =wagoId
+MAIL_NOTIFIER_ADDRESS =test@test.com
+IRC_NOTIFIER_HOST =test.com
+IRC_NOTIFIER_CHANNEL =test_channel
+JABBER_NOTIFIER_HOST =test
+JABBER_NOTIFIER_LOGIN =test_login
+JABBER_NOTIFIER_PASSWORD =hello
+JABBER_NOTIFIER_ADDRESS =test@address.com
+MSN_NOTIFIER_ADDRESS =test@address.com
+MSN_NOTIFIER_LOGIN =test
+MSN_NOTIFIER_PASSWORD =hello
+
+########################
+# buildDefinition group 
+########################
+BUILD_POM_NAME =pom.xml
+BUILD_GOALS =test
+BUILD_ARGUMENTS =--batch-mode --non-recursive
+BUILD_DESCRIPTION =Maven 2 Build Definition Description

Added: 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=752530&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml (added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/config/testng.xml Wed Mar 11 17:12:06 2009
@@ -0,0 +1,55 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
+<!--
+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.
+-->
+
+<suite name="ContinuumTest" verbose="1">
+	<test name="BasicTest">
+		<!--
+			Groups are divided into the unit tests. The order will be described
+			in the annotations of each type of test.
+		-->
+		<groups>
+			<run>
+				<include name="about" />
+			</run>
+		</groups>
+
+		<packages>
+			<package name="org.apache.continuum.web.test" />
+		</packages>
+	</test>
+	<test name="AdminTest">
+
+		<groups>
+			<run>
+				<include name="login" />
+				<include name="myAccount" />
+				<include name="mavenTwoProject"/>
+				<include name="projectGroup" />
+				<include name="notifier" />
+				<include name="buildDefinition" />
+			</run>
+		</groups>
+
+		<packages>
+			<package name="org.apache.continuum.web.test" />
+		</packages>
+	</test>
+</suite>

Added: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AboutTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AboutTest.java?rev=752530&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AboutTest.java (added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AboutTest.java Wed Mar 11 17:12:06 2009
@@ -0,0 +1,59 @@
+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.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/**
+ * Based on AboutTest of Wendy Smoak test.
+ *
+ * @author José Morales Martínez
+ * @version $Id$
+ */
+@Test( groups = { "about" }, alwaysRun = true )
+public class AboutTest
+    extends AbstractSeleniumTest
+{
+
+    @BeforeTest(groups = { "about" })
+    public void open()
+        throws Exception
+    {
+        super.open(1);
+    }
+
+    public void displayAboutPage()
+    {
+        geSelenium().open( baseUrl + "/about.action" );
+        geSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        Assert.assertEquals( "Continuum - About", geSelenium().getTitle() );
+    }
+
+    @Override
+    @AfterTest(groups = { "about" })
+    public void close()
+        throws Exception
+    {
+        super.close();
+    }
+}
\ No newline at end of file

Added: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractContinuumTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractContinuumTest.java?rev=752530&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractContinuumTest.java (added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractContinuumTest.java Wed Mar 11 17:12:06 2009
@@ -0,0 +1,1101 @@
+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.testng.Assert;
+
+/**
+ * Based on AbstractContinuumTestCase of Emmanuel Venisse test.
+ *
+ * @author José Morales Martínez
+ * @version $Id$
+ */
+public abstract class AbstractContinuumTest
+    extends AbstractSeleniumTest
+{
+
+    // ////////////////////////////////////
+    // About
+    // ////////////////////////////////////
+    public void goToAboutPage()
+    {
+        clickLinkWithText( "About" );
+
+        assertAboutPage();
+    }
+
+    public void assertAboutPage()
+    {
+        assertPage( "Continuum - About" );
+        assertTextPresent( "About Continuum" );
+        assertTextPresent( "Version:" );
+    }
+
+    // ////////////////////////////////////
+    // Configuration
+    // ////////////////////////////////////
+    public void assertEditConfigurationPage()
+    {
+        assertPage( "Continuum - Configuration" );
+        assertTextPresent( "Working Directory" );
+        assertElementPresent( "workingDirectory" );
+        assertTextPresent( "Build Output Directory" );
+        assertElementPresent( "buildOutputDirectory" );
+        assertTextPresent( "Deployment Repository Directory" );
+        assertElementPresent( "deploymentRepositoryDirectory" );
+        assertTextPresent( "Base URL" );
+        assertElementPresent( "baseUrl" );
+    }
+
+    public void submitConfigurationPage( String baseUrl, String companyName, String companyLogo, String companyUrl )
+    {
+        setFieldValue( "baseUrl", baseUrl );
+        if ( companyName != null )
+        {
+            setFieldValue( "companyName", companyName );
+        }
+        if ( companyLogo != null )
+        {
+            setFieldValue( "companyLogo", companyLogo );
+        }
+        if ( companyUrl != null )
+        {
+            setFieldValue( "companyUrl", companyUrl );
+        }
+        submit();
+        waitPage();
+    }
+
+    // ////////////////////////////////////
+    // ANT/SHELL Projects
+    // ////////////////////////////////////
+    public void assertAddProjectPage( String type )
+    {
+        String title = type.substring( 0, 1 ).toUpperCase() + type.substring( 1 ).toLowerCase();
+        assertPage( "Continuum - Add " + title + " Project" );
+        assertTextPresent( "Add " + title + " Project" );
+        assertTextPresent( "Project Name" );
+        assertElementPresent( "projectName" );
+        assertTextPresent( "Version" );
+        assertElementPresent( "projectVersion" );
+        assertTextPresent( "Scm Url" );
+        assertElementPresent( "projectScmUrl" );
+        assertTextPresent( "Scm Username" );
+        assertElementPresent( "projectScmUsername" );
+        assertTextPresent( "Scm Password" );
+        assertElementPresent( "projectScmPassword" );
+        assertTextPresent( "Scm Branch/Tag" );
+        assertElementPresent( "projectScmTag" );
+        assertLinkPresent( "Maven SCM URL" );
+    }
+
+    public void assertAddAntProjectPage()
+    {
+        assertAddProjectPage( "ant" );
+    }
+
+    public void assertAddShellProjectPage()
+    {
+        assertAddProjectPage( "shell" );
+    }
+
+    // ////////////////////////////////////
+    // Project Groups
+    // ////////////////////////////////////
+    public void goToProjectGroupsSummaryPage()
+        throws Exception
+    {
+        clickLinkWithText( "Show Project Groups" );
+
+        assertProjectGroupsSummaryPage();
+    }
+
+    public void assertProjectGroupsSummaryPage()
+    {
+        assertPage( "Continuum - Group Summary" );
+        assertTextPresent( "Project Groups" );
+
+        if ( isTextPresent( "Project Groups list is empty." ) )
+        {
+            assertTextNotPresent( "Name" );
+            assertTextNotPresent( "Group Id" );
+        }
+        else
+        {
+            assertTextPresent( "Name" );
+            assertTextPresent( "Group Id" );
+        }
+    }
+
+    // ////////////////////////////////////
+    // Project Group
+    // ////////////////////////////////////
+    public void showProjectGroup( String name, String groupId, String description )
+        throws Exception
+    {
+        goToProjectGroupsSummaryPage();
+
+        // Checks the link to the created Project Group
+        assertLinkPresent( name );
+        clickLinkWithText( name );
+
+        assertProjectGroupSummaryPage( name, groupId, description );
+    }
+
+    public void assertProjectGroupSummaryPage( String name, String groupId, String description )
+    {
+        assertPage( "Continuum - Project Group" );
+        assertTextPresent( "Project Group Name" );
+        assertTextPresent( name );
+        assertTextPresent( "Project Group Id" );
+        assertTextPresent( groupId );
+        assertTextPresent( "Description" );
+        assertTextPresent( description );
+
+        // Assert the available Project Group Actions
+        assertTextPresent( "Group Actions" );
+        assertElementPresent( "build" );
+        assertElementPresent( "edit" );
+        assertElementPresent( "remove" );
+
+        assertTextPresent( "Project Group Scm Root" );
+
+        if ( isTextPresent( "Member Projects" ) )
+        {
+            assertTextPresent( "Project Name" );
+            assertTextPresent( "Version" );
+            assertTextPresent( "Build" );
+        }
+        else
+        {
+            assertTextNotPresent( "Project Name" );
+        }
+    }
+
+    public void addProjectGroup( String name, String groupId, String description, boolean success )
+        throws Exception
+    {
+        goToProjectGroupsSummaryPage();
+
+        // Go to Add Project Group Page
+        clickButtonWithValue( "Add Project Group" );
+        assertAddProjectGroupPage();
+
+        // Enter values into Add Project Group fields, and submit
+        setFieldValue( "name", name );
+        setFieldValue( "groupId", groupId );
+        setFieldValue( "description", description );
+
+        submit();
+        if ( success )
+        {
+            assertProjectGroupsSummaryPage();
+        }
+        else
+        {
+            assertAddProjectGroupPage();
+        }
+    }
+
+    public void assertAddProjectGroupPage()
+    {
+        assertPage( "Continuum - Add Project Group" );
+
+        assertTextPresent( "Add Project Group" );
+        assertTextPresent( "Project Group Name" );
+        assertElementPresent( "name" );
+        assertTextPresent( "Project Group Id" );
+        assertElementPresent( "groupId" );
+        assertTextPresent( "Description" );
+        assertElementPresent( "description" );
+    }
+
+    public void removeProjectGroup( String name, String groupId, String description )
+        throws Exception
+    {
+        showProjectGroup( name, groupId, description );
+
+        // Remove
+        clickLinkWithLocator( "remove" );
+
+        // Assert Confirmation
+        assertElementPresent( "removeProjectGroup_" );
+        assertElementPresent( "Cancel" );
+
+        // Confirm Project Group deletion
+        clickButtonWithValue( "Save" );
+        assertProjectGroupsSummaryPage();
+    }
+
+    public void editProjectGroup( String name, String groupId, String description, String newName, String newDescription )
+        throws Exception
+    {
+        showProjectGroup( name, groupId, description );
+        clickButtonWithValue( "Edit" );
+        assertEditGroupPage( groupId );
+        setFieldValue( "saveProjectGroup_name", newName );
+        setFieldValue( "saveProjectGroup_description", newDescription );
+        clickButtonWithValue( "Save" );
+    }
+
+    public void assertEditGroupPage( String groupId )
+        throws Exception
+    {
+        assertPage( "Continuum - Update Project Group" );
+        assertTextPresent( "Update Project Group" );
+        assertTextPresent( "Project Group Name" );
+        assertTextPresent( "Project Group Id" );
+        assertTextPresent( groupId );
+        assertTextPresent( "Description" );
+        assertTextPresent( "Homepage Url" );
+        assertTextPresent( "Local Repository" );
+        assertElementPresent( "saveProjectGroup_" );
+        assertElementPresent( "Cancel" );
+    }
+
+    public void buildProjectGroup( String projectGroupName, String groupId, String description )
+        throws Exception
+    {
+        int currentIt = 1;
+        int maxIt = 20;
+        showProjectGroup( projectGroupName, groupId, description );
+        clickButtonWithValue( "Build all projects" );
+
+        while ( isElementPresent( "//img[@alt='Building']" ) || isElementPresent( "//img[@alt='Updating']" ) )
+        {
+            Thread.sleep( 10000 );
+            geSelenium().refresh();
+            waitPage();
+            if ( currentIt > maxIt )
+            {
+                Assert.fail("Timeout, Can't build project group");
+            }
+            currentIt++;
+        }
+        clickLinkWithText( p.getProperty( "M2_PROJ_GRP_NAME" ) );
+        clickLinkWithText( "Builds" );
+        clickLinkWithText( "Result" );
+        assertTextPresent( "BUILD SUCCESSFUL" );
+        clickLinkWithText( "Project Group Summary" );
+    }
+
+    public void assertReleaseSuccess()
+    {
+        assertTextPresent( "Choose Release Goal for Apache Maven" );
+    }
+
+    public void addValidM2ProjectFromProjectGroup( String projectGroupName, String groupId, String description,
+                                                   String m2PomUrl )
+        throws Exception
+    {
+        showProjectGroup( projectGroupName, groupId, description );
+        selectValue( "projectTypes", "Add M2 Project" );
+        clickButtonWithValue( "Add" );
+        assertAddMavenTwoProjectPage();
+
+        setFieldValue( "m2PomUrl", m2PomUrl );
+        clickButtonWithValue( "Add" );
+
+        // if success redirect to summary page
+        assertProjectGroupsSummaryPage();
+    }
+
+    public void goToGroupBuildDefinitionPage( String projectGroupName, String groupId, String description )
+        throws Exception
+    {
+        showProjectGroup( projectGroupName, groupId, description );
+        clickLinkWithText( "Build Definitions" );
+        assertTextPresent( "Project Group Build Definitions of " + projectGroupName + " group" );
+
+        assertGroupBuildDefinitionPage( projectGroupName );
+
+    }
+
+    public void assertGroupBuildDefinitionPage( String projectGroupName )
+    {
+
+        assertTextPresent( "Project Group Build Definitions of " + projectGroupName + " group" );
+    }
+
+    public void assertDeleteBuildDefinitionPage( String description, String goals)
+    {
+        assertTextPresent( "Are you sure you want to delete the build definition with description \""+description+"\", goals \""+ goals + "\" and id" );
+        isButtonWithValuePresent( "Cancel" );
+        isButtonWithValuePresent( "Delete" );
+    }
+
+
+
+    public void assertAddEditBuildDefinitionPage()
+    {
+        assertTextPresent( "Add/Edit Build Definition" );
+        assertTextPresent( "POM filename*:" );
+        assertElementPresent( "buildFile" );
+        assertTextPresent( "Goals:" );
+        assertElementPresent( "goals" );
+        assertTextPresent( "Arguments:" );
+        assertElementPresent( "arguments" );
+        assertTextPresent( "Build Fresh" );
+        assertElementPresent( "buildFresh" );
+        assertTextPresent( "Always Build" );
+        assertElementPresent( "alwaysBuild" );
+        assertTextPresent( "Is it default?" );
+        assertTextPresent( "Schedule:" );
+        assertElementPresent( "scheduleId" );
+        assertTextPresent( "Description" );
+        assertElementPresent( "description" );
+        assertTextPresent( "Type" );
+        assertElementPresent( "buildDefinitionType" );
+        assertTextPresent( "Build Environment" );
+        assertElementPresent( "profileId" );
+    }
+
+    public void addEditGroupBuildDefinition( String groupName, String buildFile, String goals, String arguments, String description,
+                                             boolean buildFresh, boolean alwaysBuild, boolean isDefault )
+    {
+        assertAddEditBuildDefinitionPage();
+        // Enter values into Add Build Definition fields, and submit
+        setFieldValue( "buildFile", buildFile );
+        setFieldValue( "goals", goals );
+        setFieldValue( "arguments", arguments );
+        setFieldValue( "description", description );
+
+        if ( buildFresh )
+        {
+            checkField( "buildFresh" );
+        }
+        else
+        {
+            uncheckField( "buildFresh" );
+        }
+        if ( isElementPresent( "defaultBuildDefinition" ) )
+        {
+            if ( isDefault )
+            {
+                checkField( "defaultBuildDefinition" );
+            }
+            else
+            {
+                uncheckField( "defaultBuildDefinition" );
+            }
+        }
+        if ( alwaysBuild )
+        {
+            checkField( "alwaysBuild" );
+        }
+        else
+        {
+            uncheckField( "alwaysBuild" );
+        }
+
+        submit();
+        if(groupName != null){
+            assertGroupBuildDefinitionPage( groupName );
+        } else {
+            assertProjectInformationPage();
+        }
+    }
+
+    public void assertGroupNotifierPage( String projectGroupName )
+    {
+        assertTextPresent( "Project Group Notifiers of group " + projectGroupName );
+    }
+
+    public void assertProjectNotifierPage()
+    {
+        assertTextPresent( "Add Notifier" );
+    }
+
+    public void assertAddNotifierPage()
+    {
+        assertPage( "Continuum - Add Notifier" );
+        assertTextPresent( "Add Notifier" );
+        assertTextPresent( "Type" );
+        assertElementPresent( "notifierType" );
+        assertElementPresent( "Cancel" );
+    }
+
+    public void assertAddEditMailNotifierPage()
+    {
+        assertPage( "Continuum - Add/Edit Mail Notifier" );
+        assertTextPresent( "Add/Edit Mail Notifier" );
+        assertTextPresent( "Mail Recipient Address" );
+        assertTextPresent( "Send a mail to latest committers" );
+        assertTextPresent( "Send on Success" );
+        assertTextPresent( "Send on Failure" );
+        assertTextPresent( "Send on Error" );
+        assertTextPresent( "Send on Warning" );
+        // TODO: Replace On for on
+        assertTextPresent( "Send On SCM Failure" );
+        assertElementPresent( "address" );
+        assertElementPresent( "Cancel" );
+    }
+
+    public void assertAddEditIrcNotifierPage()
+    {
+        assertPage( "Continuum - Add/Edit IRC Notifier" );
+
+        assertTextPresent( "IRC Host" );
+        assertElementPresent( "host" );
+
+        assertTextPresent( "IRC port" );
+        assertElementPresent( "port" );
+
+        assertTextPresent( "IRC channel" );
+        assertElementPresent( "channel" );
+
+        assertTextPresent( "Nick Name" );
+        assertElementPresent( "nick" );
+
+        assertTextPresent( "Alternate Nick Name" );
+        assertElementPresent( "alternateNick" );
+
+        assertTextPresent( "User Name" );
+        assertElementPresent( "username" );
+
+        assertTextPresent( "Full Name" );
+        assertElementPresent( "fullName" );
+
+        assertTextPresent( "Password" );
+        assertElementPresent( "password" );
+
+        assertTextPresent( "SSL" );
+        assertTextPresent( "Send on Success" );
+        assertTextPresent( "Send on Failure" );
+        assertTextPresent( "Send on Error" );
+        assertTextPresent( "Send on Warning" );
+        assertTextPresent( "Send On SCM Failure" );
+    }
+
+    public void assertAddEditJabberPage()
+    {
+        assertPage( "Continuum - Add/Edit Jabber Notifier" );
+
+        assertTextPresent( "Jabber Host" );
+        assertElementPresent( "host" );
+        assertTextPresent( "Jabber port" );
+        assertElementPresent( "port" );
+        assertTextPresent( "Jabber login" );
+        assertElementPresent( "login" );
+        assertTextPresent( "Jabber Password" );
+        assertElementPresent( "password" );
+        assertTextPresent( "Jabber Domain Name" );
+        assertElementPresent( "domainName" );
+        assertTextPresent( "Jabber Recipient Address" );
+        assertElementPresent( "address" );
+
+        assertTextPresent( "Is it a SSL connection?" );
+        assertTextPresent( "Is it a Jabber group?" );
+        assertTextPresent( "Send on Success" );
+        assertTextPresent( "Send on Failure" );
+        assertTextPresent( "Send on Error" );
+        assertTextPresent( "Send on Warning" );
+        // TODO: Change On for on
+        assertTextPresent( "Send On SCM Failure" );
+    }
+
+    public void assertAddEditMsnPage()
+    {
+        assertPage( "Continuum - Add/Edit MSN Notifier" );
+
+        assertTextPresent( "MSN login" );
+        assertElementPresent( "login" );
+        assertTextPresent( "MSN Password" );
+        assertElementPresent( "password" );
+        assertTextPresent( "MSN Recipient Address" );
+        assertElementPresent( "address" );
+
+        assertTextPresent( "Send on Success" );
+        assertTextPresent( "Send on Failure" );
+        assertTextPresent( "Send on Error" );
+        assertTextPresent( "Send on Warning" );
+        assertTextPresent( "Send On SCM Failure" );
+    }
+
+    public void assertAddEditWagonPage()
+    {
+        assertPage( "Continuum - Add/Edit Wagon Notifier" );
+
+        assertTextPresent( "Project Site URL" );
+        assertTextPresent( "Server Id (defined in your settings.xml for authentication)" );
+        assertElementPresent( "url" );
+        assertElementPresent( "id" );
+        assertTextPresent( "Send on Success" );
+        assertTextPresent( "Send on Failure" );
+        assertTextPresent( "Send on Error" );
+        assertTextPresent( "Send on Warning" );
+    }
+
+    public void goToGroupNotifier( String projectGroupName, String projectGroupId, String projectGroupDescription )
+        throws Exception
+    {
+        showProjectGroup( projectGroupName, projectGroupId, projectGroupDescription );
+        clickLinkWithText( "Notifiers" );
+        assertGroupNotifierPage( projectGroupName );
+        clickButtonWithValue( "Add" );
+        assertAddNotifierPage();
+    }
+
+    public void goToProjectNotifier( String projectGroupName, String projectName )
+        throws Exception
+    {
+        goToProjectInformationPage( projectGroupName, projectName );
+        clickLinkWithXPath( "//input[contains(@id,'addProjectNotifier') and @type='submit']" );
+        assertAddNotifierPage();
+    }
+
+    public void addMailNotifier( String projectGroupName, String projectName, String email, boolean isValid )
+        throws Exception
+    {
+        selectValue( "//select", "Mail" );
+        clickButtonWithValue( "Submit" );
+        assertAddEditMailNotifierPage();
+        setFieldValue( "address", email );
+        clickButtonWithValue( "Save" );
+
+        if ( !isValid )
+        {
+            assertTextPresent( "Address is invalid" );
+        }
+        else if ( projectName != null )
+        {
+            assertProjectInformationPage();
+        }
+        else
+        {
+            assertGroupNotifierPage( projectGroupName );
+        }
+    }
+
+    public void editMailNotifier( String projectGroupName, String projectName, String oldMail, String newMail,
+                                  boolean isValid )
+        throws Exception
+    {
+        if ( projectName == null )
+        {
+            clickLinkWithXPath( "(//a[contains(@href,'editProjectGroupNotifier') and contains(@href,'mail')])//img" );
+        }
+        else
+        {
+            clickLinkWithXPath( "(//a[contains(@href,'editProjectNotifier') and contains(@href,'mail')])//img" );
+        }
+        assertAddEditMailNotifierPage();
+        assertFieldValue( oldMail, "address" );
+        setFieldValue( "address", newMail );
+        clickButtonWithValue( "Save" );
+
+        if ( !isValid )
+        {
+            assertTextPresent( "Address is invalid" );
+        }
+        else if ( projectName != null )
+        {
+            assertProjectInformationPage();
+        }
+        else
+        {
+            assertGroupNotifierPage( projectGroupName );
+        }
+    }
+
+    public void addIrcNotifier( String projectGroupName, String projectName, String host, String channel,
+                                boolean isValid )
+        throws Exception
+    {
+        selectValue( "//select", "IRC" );
+        clickButtonWithValue( "Submit" );
+        assertAddEditIrcNotifierPage();
+        setFieldValue( "host", host );
+        setFieldValue( "channel", channel );
+
+        clickButtonWithValue( "Save" );
+        if ( !isValid )
+        {
+            assertTextPresent( "Host is required" );
+            assertTextPresent( "Channel is required" );
+        }
+        else if ( projectName != null )
+        {
+            assertProjectInformationPage();
+        }
+        else
+        {
+            assertGroupNotifierPage( projectGroupName );
+        }
+    }
+
+    public void editIrcNotifier( String projectGroupName, String projectName, String oldHost, String oldChannel,
+                                 String newHost, String newChannel, boolean isValid )
+        throws Exception
+    {
+        if ( projectName == null )
+        {
+            clickLinkWithXPath( "(//a[contains(@href,'editProjectGroupNotifier') and contains(@href,'irc')])//img" );
+        }
+        else
+        {
+            clickLinkWithXPath( "(//a[contains(@href,'editProjectNotifier') and contains(@href,'irc')])//img" );
+        }
+        assertAddEditIrcNotifierPage();
+        assertFieldValue( oldHost, "host" );
+        assertFieldValue( oldChannel, "channel" );
+        setFieldValue( "host", newHost );
+        setFieldValue( "channel", newChannel );
+        clickButtonWithValue( "Save" );
+
+        if ( !isValid )
+        {
+            assertTextPresent( "Host is required" );
+            assertTextPresent( "Channel is required" );
+        }
+        else if ( projectName != null )
+        {
+            assertProjectInformationPage();
+        }
+        else
+        {
+            assertGroupNotifierPage( projectGroupName );
+        }
+    }
+
+    public void addJabberNotifier( String projectGroupName, String projectName, String host, String login,
+                                   String password, String address, boolean isValid )
+        throws Exception
+    {
+        selectValue( "//select", "Jabber" );
+        clickButtonWithValue( "Submit" );
+        assertAddEditJabberPage();
+        setFieldValue( "host", host );
+        setFieldValue( "login", login );
+        setFieldValue( "password", password );
+        setFieldValue( "address", address );
+        clickButtonWithValue( "Save" );
+
+        if ( !isValid )
+        {
+            assertTextPresent( "Host is required" );
+            assertTextPresent( "Login is required" );
+            assertTextPresent( "Password is required" );
+            assertTextPresent( "Address is required" );
+        }
+        else if ( projectName != null )
+        {
+            assertProjectInformationPage();
+        }
+        else
+        {
+            assertGroupNotifierPage( projectGroupName );
+        }
+    }
+
+    public void editJabberNotifier( String projectGroupName, String projectName, String oldHost, String oldLogin,
+                                    String oldAddress, String newHost, String newLogin, String newPassword,
+                                    String newAddress, boolean isValid )
+        throws Exception
+    {
+        if ( projectName == null )
+        {
+            clickLinkWithXPath( "(//a[contains(@href,'editProjectGroupNotifier') and contains(@href,'jabber')])//img" );
+        }
+        else
+        {
+            clickLinkWithXPath( "(//a[contains(@href,'editProjectNotifier') and contains(@href,'jabber')])//img" );
+        }
+        assertAddEditJabberPage();
+        assertFieldValue( oldHost, "host" );
+        assertFieldValue( oldLogin, "login" );
+        assertFieldValue( oldAddress, "address" );
+        setFieldValue( "host", newHost );
+        setFieldValue( "login", newLogin );
+        setFieldValue( "password", newPassword );
+        setFieldValue( "address", newAddress );
+        clickButtonWithValue( "Save" );
+
+        if ( !isValid )
+        {
+            assertTextPresent( "Host is required" );
+            assertTextPresent( "Login is required" );
+            assertTextPresent( "Password is required" );
+            assertTextPresent( "Address is required" );
+        }
+        else if ( projectName != null )
+        {
+            assertProjectInformationPage();
+        }
+        else
+        {
+            assertGroupNotifierPage( projectGroupName );
+        }
+    }
+
+    public void addMsnNotifier( String projectGroupName, String projectName, String login, String password,
+                                String recipientAddress, boolean isValid )
+        throws Exception
+    {
+        selectValue( "//select", "MSN" );
+        clickButtonWithValue( "Submit" );
+        assertAddEditMsnPage();
+        setFieldValue( "login", login );
+        setFieldValue( "password", password );
+        setFieldValue( "address", recipientAddress );
+        clickButtonWithValue( "Save" );
+
+        if ( !isValid )
+        {
+            assertTextPresent( "Login is required" );
+            assertTextPresent( "Password is required" );
+            assertTextPresent( "Address is required" );
+        }
+        else if ( projectName != null )
+        {
+            assertProjectInformationPage();
+        }
+        else
+        {
+            assertGroupNotifierPage( projectGroupName );
+        }
+    }
+
+    public void editMsnNotifier( String projectGroupName, String projectName, String oldLogin, String oldAddress,
+                                 String newLogin, String newPassword, String newAddress, boolean isValid )
+        throws Exception
+    {
+        if ( projectName == null )
+        {
+            clickLinkWithXPath( "(//a[contains(@href,'editProjectGroupNotifier') and contains(@href,'msn')])//img" );
+        }
+        else
+        {
+            clickLinkWithXPath( "(//a[contains(@href,'editProjectNotifier') and contains(@href,'msn')])//img" );
+        }
+        assertAddEditMsnPage();
+        assertFieldValue( oldLogin, "login" );
+        assertFieldValue( oldAddress, "address" );
+        setFieldValue( "login", newLogin );
+        setFieldValue( "password", newPassword );
+        setFieldValue( "address", newAddress );
+        clickButtonWithValue( "Save" );
+
+        if ( !isValid )
+        {
+            assertTextPresent( "Login is required" );
+            assertTextPresent( "Password is required" );
+            assertTextPresent( "Address is required" );
+        }
+        else if ( projectName != null )
+        {
+            assertProjectInformationPage();
+        }
+        else
+        {
+            assertGroupNotifierPage( projectGroupName );
+        }
+    }
+
+    public void addWagonNotifierPage( String projectGroupName, String projectName, String siteUrl, String serverId,
+                                      boolean isValid )
+        throws Exception
+    {
+        selectValue( "//select", "Wagon" );
+        clickButtonWithValue( "Submit" );
+        assertAddEditWagonPage();
+        setFieldValue( "url", siteUrl );
+        setFieldValue( "id", serverId );
+        clickButtonWithValue( "Save" );
+
+        if ( !isValid )
+        {
+            assertTextPresent( "Destination URL is required" );
+            assertTextPresent( "Server Id is required" );
+        }
+        else if ( projectName != null )
+        {
+            assertProjectInformationPage();
+        }
+        else
+        {
+            assertGroupNotifierPage( projectGroupName );
+        }
+    }
+
+    public void editWagonNotifier( String projectGroupName, String projectName, String oldUrl, String oldId,
+                                   String newUrl, String newId, boolean isValid )
+        throws Exception
+    {
+        if ( projectName == null )
+        {
+            clickLinkWithXPath( "(//a[contains(@href,'editProjectGroupNotifier') and contains(@href,'wagon')])//img" );
+        }
+        else
+        {
+            clickLinkWithXPath( "(//a[contains(@href,'editProjectNotifier') and contains(@href,'wagon')])//img" );
+        }
+        assertAddEditWagonPage();
+        assertFieldValue( oldUrl, "url" );
+        // TODO: BUG: ServerId is not loader
+        // assertFieldValue( oldId, "id" );
+        setFieldValue( "url", newUrl );
+        setFieldValue( "id", newId );
+        clickButtonWithValue( "Save" );
+
+        if ( !isValid )
+        {
+            assertTextPresent( "Destination URL is required" );
+            assertTextPresent( "Server Id is required" );
+        }
+        else if ( projectName != null )
+        {
+            assertProjectInformationPage();
+        }
+        else
+        {
+            assertGroupNotifierPage( projectGroupName );
+        }
+    }
+
+    // ////////////////////////////////////
+    // General Project Pages
+    // ////////////////////////////////////
+    public void goToEditProjectPage( String projectGroupName, String projectName )
+    {
+        clickLinkWithText( "Show Project Groups" );
+        clickLinkWithText( projectGroupName );
+        clickLinkWithText( projectName );
+        clickButtonWithValue( "Edit" );
+
+        assertEditProjectPage();
+    }
+
+    public void assertEditProjectPage()
+    {
+        assertTextPresent( "Update Continuum Project" );
+        assertTextPresent( "Project Name*:" );
+        assertElementPresent( "name" );
+        assertTextPresent( "Version*:" );
+        assertElementPresent( "version" );
+        assertTextPresent( "SCM Url*:" );
+        assertElementPresent( "scmUrl" );
+        assertTextPresent( "Use SCM Credentials Cache, if available" );
+        assertElementPresent( "scmUseCache" );
+        assertTextPresent( "SCM Username:" );
+        assertElementPresent( "scmUsername" );
+        assertTextPresent( "SCM Password:" );
+        assertElementPresent( "scmPassword" );
+        assertTextPresent( "SCM Branch/Tag:" );
+        assertElementPresent( "scmTag" );
+    }
+
+    public void goToAddNotifierPage( String projectGroupName, String projectName )
+    {
+        clickLinkWithText( "Show Project Groups" );
+        clickLinkWithText( projectGroupName );
+        clickLinkWithText( projectName );
+        geSelenium().click( "addProjectNotifier" );
+        clickLinkWithXPath( "//input[@id='addProjectNotifier_0']" );
+
+        assertNotifierPage();
+    }
+
+    public void assertNotifierPage()
+    {
+        assertPage( "Continuum - Add Notifier" );
+        assertTextPresent( "Add Notifier" );
+        assertTextPresent( "Type:" );
+        assertElementPresent( "notifierType" );
+    }
+
+    public void addMailNotifier( String projectGroupName, String projectName, String email, boolean success,
+                                 boolean failure, boolean error, boolean warning )
+    {
+        goToAddNotifierPage( projectGroupName, projectName );
+        clickButtonWithValue( "Submit" );
+
+        // Enter values into Add Notifier fields, and submit
+        setFieldValue( "address", email );
+        if ( success )
+        {
+            checkField( "sendOnSuccess" );
+        }
+        if ( failure )
+        {
+            checkField( "sendOnFailure" );
+        }
+        if ( error )
+        {
+            checkField( "sendOnError" );
+        }
+        if ( warning )
+        {
+            checkField( "sendOnWarning" );
+        }
+
+        submit();
+        assertProjectInformationPage();
+    }
+
+    public void goToProjectInformationPage( String projectGroupName, String projectName )
+    {
+        clickLinkWithText( "Show Project Groups" );
+        clickLinkWithText( projectGroupName );
+        clickLinkWithText( projectName );
+
+        assertProjectInformationPage();
+    }
+
+    public void assertProjectInformationPage()
+    {
+        assertTextPresent( "Project Group Summary" );
+        assertTextPresent( "Project Information" );
+        assertTextPresent( "Builds" );
+        assertTextPresent( "Working Copy" );
+        assertTextPresent( "Build Definitions" );
+        assertTextPresent( "Notifiers" );
+        assertTextPresent( "Dependencies" );
+        assertTextPresent( "Developers" );
+    }
+
+    public void moveProjectToProjectGroup( String name, String groupId, String description, String newProjectGroup )
+        throws Exception
+    {
+        showProjectGroup( name, groupId, description );
+        clickButtonWithValue( "Edit" );
+
+        assertTextPresent( "Move to Group" );
+        selectValue( "//select[contains(@name,'project')]", newProjectGroup );
+        clickButtonWithValue( "Save" );
+    }
+
+    // ////////////////////////////////////
+    // Maven 2.0.x Project
+    // ////////////////////////////////////
+    public void goToAddMavenTwoProjectPage()
+    {
+        clickLinkWithText( "Maven 2.0.x Project" );
+
+        assertAddMavenTwoProjectPage();
+    }
+
+    public void assertAddMavenTwoProjectPage()
+    {
+        assertTextPresent( "POM Url" );
+        assertElementPresent( "m2PomUrl" );
+        assertTextPresent( "Username" );
+        assertElementPresent( "scmUsername" );
+        assertTextPresent( "Password" );
+        assertElementPresent( "scmPassword" );
+        assertTextPresent( "Upload POM" );
+        assertElementPresent( "m2PomFile" );
+        assertTextPresent( "Project Group" );
+        assertElementPresent( "selectedProjectGroup" );
+    }
+
+    public void addMavenTwoProject( String pomUrl, String username, String password, String projectGroup,
+                                    boolean success )
+        throws Exception
+    {
+        goToAddMavenTwoProjectPage();
+
+        // Enter values into Add Maven Two Project fields, and submit
+        setFieldValue( "m2PomUrl", pomUrl );
+        setFieldValue( "scmUsername", username );
+        setFieldValue( "scmPassword", password );
+
+        if ( projectGroup != null )
+        {
+            selectValue( "addMavenTwoProject_selectedProjectGroup", projectGroup );
+        }
+        submit();
+        String ident;
+        if ( success )
+        {
+            ident = "projectGroupSummary";
+        }
+        else
+        {
+            ident = "addMavenTwoProject";
+        }
+        // TODO: Improve the condition
+        String condition = "selenium.browserbot.getCurrentWindow().document.getElementById('" + ident + "')";
+        // 'Continuum - Project Group'
+        geSelenium().waitForCondition( condition, maxWaitTimeInMs );
+    }
+
+    /**
+     * submit the page
+     *
+     * @param m2PomUrl
+     * @param validPom
+     */
+    public void submitAddMavenTwoProjectPage( String m2PomUrl, boolean validPom )
+        throws Exception
+    {
+        addMavenTwoProject( m2PomUrl, "", "", null, validPom );
+
+        if ( validPom )
+        {
+            assertTextPresent( "Default Project Group" );
+            // TODO: Add more tests
+        }
+    }
+
+    // ////////////////////////////////////
+    // Maven 1.x Project
+    // ////////////////////////////////////
+    public void goToAddMavenOneProjectPage()
+    {
+        clickLinkWithText( "Maven 1.x Project" );
+
+        assertAddMavenOneProjectPage();
+    }
+
+    public void assertAddMavenOneProjectPage()
+    {
+        assertTextPresent( "POM Url" );
+        assertElementPresent( "m1PomUrl" );
+        assertTextPresent( "Username" );
+        assertElementPresent( "scmUsername" );
+        assertTextPresent( "Password" );
+        assertElementPresent( "scmPassword" );
+        assertTextPresent( "Upload POM" );
+        assertElementPresent( "m1PomFile" );
+        assertTextPresent( "Project Group" );
+        assertElementPresent( "selectedProjectGroup" );
+    }
+
+    public void addMavenOneProject( String pomUrl, String username, String password, String projectGroup,
+                                    boolean validProject )
+    {
+        goToAddMavenOneProjectPage();
+
+        // Enter values into Add Maven One Project fields, and submit
+        setFieldValue( "m1PomUrl", pomUrl );
+        setFieldValue( "scmUsername", username );
+        setFieldValue( "scmPassword", password );
+
+        if ( projectGroup != null )
+        {
+            selectValue( "addMavenOneProject_selectedProjectGroup", projectGroup );
+        }
+
+        submit();
+
+        geSelenium().waitForCondition( "'' == document.title", maxWaitTimeInMs );
+    }
+}

Added: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractSeleniumTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractSeleniumTest.java?rev=752530&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractSeleniumTest.java (added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/AbstractSeleniumTest.java Wed Mar 11 17:12:06 2009
@@ -0,0 +1,316 @@
+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 java.util.Iterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Map.Entry;
+
+import org.testng.Assert;
+
+import com.thoughtworks.selenium.DefaultSelenium;
+import com.thoughtworks.selenium.Selenium;
+
+/**
+ * Based on AbstractSeleniumTestCase of Emmanuel Venisse test.
+ *
+ * @author José Morales Martínez
+ * @version $Id$
+ */
+public abstract class AbstractSeleniumTest
+{
+    public static String baseUrl;
+
+    public static String maxWaitTimeInMs;
+
+    private static ThreadLocal<Selenium> selenium;
+
+    public static Properties p;
+
+    /**
+     * Initialize selenium an others properties. This method is called from BeforeSuite method of sub-class.
+     */
+    public void open(int number)
+        throws Exception
+    {
+        p = new Properties();
+        p.load( this.getClass().getClassLoader().getResourceAsStream( "testng.properties" ) );
+
+        baseUrl = p.getProperty( "BASE_URL" );
+        maxWaitTimeInMs = p.getProperty( "MAX_WAIT_TIME_IN_MS" );
+
+        String seleniumHost = p.getProperty( "SELENIUM_HOST" );
+        int seleniumPort = Integer.parseInt( ( p.getProperty( "SELENIUM_PORT" ) ) );
+        String seleniumBrowser = p.getProperty( "SELENIUM_BROWSER" );
+        final Selenium s = new DefaultSelenium( seleniumHost, seleniumPort, seleniumBrowser, baseUrl );
+        selenium = new ThreadLocal<Selenium>() {
+            protected Selenium initialValue() {
+                return s;
+            }
+        };
+        geSelenium().start();
+    }
+
+    protected static Selenium geSelenium()
+    {
+        return selenium.get();
+    }
+
+    /**
+     * Close selenium session. Called from AfterSuite method of sub-class
+     */
+    public void close()
+        throws Exception
+    {
+        geSelenium().stop();
+    }
+
+    // *******************************************************
+    // Auxiliar methods. This method help us and simplify test.
+    // *******************************************************
+
+    public void assertFieldValue( String fieldValue, String fieldName )
+    {
+        assertElementPresent( fieldName );
+        Assert.assertEquals( fieldValue, geSelenium().getValue( fieldName ) );
+    }
+
+    public void assertPage( String title )
+    {
+        Assert.assertEquals( getTitle(), title );
+    }
+
+    public String getTitle()
+    {
+        return geSelenium().getTitle();
+    }
+
+    public String getHtmlContent()
+    {
+        return geSelenium().getHtmlSource();
+    }
+
+    public void assertTextPresent( String text )
+    {
+        Assert.assertTrue( geSelenium().isTextPresent( text ), "'" + text + "' isn't present." );
+    }
+
+    public void assertTextNotPresent( String text )
+    {
+        Assert.assertFalse( geSelenium().isTextPresent( text ), "'" + text + "' is present." );
+    }
+
+    public void assertElementPresent( String elementLocator )
+    {
+        Assert.assertTrue( isElementPresent( elementLocator ), "'" + elementLocator + "' isn't present." );
+    }
+
+    public void assertElementNotPresent( String elementLocator )
+    {
+        Assert.assertFalse( isElementPresent( elementLocator ), "'" + elementLocator + "' is present." );
+    }
+
+    public void assertLinkPresent( String text )
+    {
+        Assert.assertTrue( isElementPresent( "link=" + text ), "The link '" + text + "' isn't present." );
+    }
+
+    public void assertLinkNotPresent( String text )
+    {
+        Assert.assertFalse( isElementPresent( "link=" + text ), "The link '" + text + "' is present." );
+    }
+
+    public void assertImgWithAlt( String alt )
+    {
+        assertElementPresent( "//img[@alt='" + alt + "']" );
+    }
+
+    public void assertImgWithAltAtRowCol( boolean isALink, String alt, int row, int column )
+    {
+        String locator = "//tr[" + row + "]/td[" + column + "]/";
+        locator += isALink ? "a/" : "";
+        locator += "img[@alt='" + alt + "']";
+
+        assertElementPresent( locator );
+    }
+
+    public void assertCellValueFromTable( String expected, String tableElement, int row, int column )
+    {
+        Assert.assertEquals( expected, getCellValueFromTable( tableElement, row, column ) );
+    }
+
+    public boolean isTextPresent( String text )
+    {
+        return geSelenium().isTextPresent( text );
+    }
+
+    public boolean isLinkPresent( String text )
+    {
+        return isElementPresent( "link=" + text );
+    }
+
+    public boolean isElementPresent( String locator )
+    {
+        return geSelenium().isElementPresent( locator );
+    }
+
+    public void waitPage()
+    {
+        geSelenium().waitForPageToLoad( maxWaitTimeInMs );
+    }
+
+    public String getFieldValue( String fieldName )
+    {
+        return geSelenium().getValue( fieldName );
+    }
+
+    public String getCellValueFromTable( String tableElement, int row, int column )
+    {
+        return geSelenium().getTable( tableElement + "." + row + "." + column );
+    }
+
+    public void selectValue( String locator, String value )
+    {
+        geSelenium().select( locator, "label=" + value );
+    }
+
+    public void submit()
+    {
+        clickLinkWithXPath( "//input[@type='submit']" );
+    }
+
+    public void assertButtonWithValuePresent( String text )
+    {
+        Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" );
+    }
+
+    public void assertButtonWithValueNotPresent( String text )
+    {
+        Assert.assertFalse( isButtonWithValuePresent( text ), "'" + text + "' button is present" );
+    }
+
+    public boolean isButtonWithValuePresent( String text )
+    {
+        return isElementPresent( "//button[@value='" + text + "']" )
+            || isElementPresent( "//input[@value='" + text + "']" );
+    }
+
+    public void clickButtonWithValue( String text )
+    {
+        clickButtonWithValue( text, true );
+    }
+
+    public void clickButtonWithValue( String text, boolean wait )
+    {
+        assertButtonWithValuePresent( text );
+
+        if ( isElementPresent( "//button[@value='" + text + "']" ) )
+        {
+            clickLinkWithXPath( "//button[@value='" + text + "']", wait );
+        }
+        else
+        {
+            clickLinkWithXPath( "//input[@value='" + text + "']", wait );
+        }
+    }
+
+    public void clickSubmitWithLocator( String locator )
+    {
+        clickLinkWithLocator( locator );
+    }
+
+    public void clickSubmitWithLocator( String locator, boolean wait )
+    {
+        clickLinkWithLocator( locator, wait );
+    }
+
+    public void clickImgWithAlt( String alt )
+    {
+        clickLinkWithLocator( "//img[@alt='" + alt + "']" );
+    }
+
+    public void clickLinkWithText( String text )
+    {
+        clickLinkWithText( text, true );
+    }
+
+    public void clickLinkWithText( String text, boolean wait )
+    {
+        clickLinkWithLocator( "link=" + text, wait );
+    }
+
+    public void clickLinkWithXPath( String xpath )
+    {
+        clickLinkWithXPath( xpath, true );
+    }
+
+    public void clickLinkWithXPath( String xpath, boolean wait )
+    {
+        clickLinkWithLocator( "xpath=" + xpath, wait );
+    }
+
+    public void clickLinkWithLocator( String locator )
+    {
+        clickLinkWithLocator( locator, true );
+    }
+
+    public void clickLinkWithLocator( String locator, boolean wait )
+    {
+        assertElementPresent( locator );
+        geSelenium().click( locator );
+        if ( wait )
+        {
+            waitPage();
+        }
+    }
+
+    public void setFieldValues( Map<String, String> fieldMap )
+    {
+        Map.Entry<String, String> entry;
+
+        for ( Iterator<Entry<String, String>> entries = fieldMap.entrySet().iterator(); entries.hasNext(); )
+        {
+            entry = entries.next();
+
+            geSelenium().type( entry.getKey(), entry.getValue() );
+        }
+    }
+
+    public void setFieldValue( String fieldName, String value )
+    {
+        geSelenium().type( fieldName, value );
+    }
+
+    public void checkField( String locator )
+    {
+        geSelenium().check( locator );
+    }
+
+    public void uncheckField( String locator )
+    {
+        geSelenium().uncheck( locator );
+    }
+
+    public boolean isChecked( String locator )
+    {
+        return geSelenium().isChecked( locator );
+    }
+}

Added: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTest.java?rev=752530&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTest.java (added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/BuildDefinitionTest.java Wed Mar 11 17:12:06 2009
@@ -0,0 +1,200 @@
+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.testng.annotations.Test;
+
+/**
+ * @author José Morales Martínez
+ * @version $Id$
+ */
+@Test( groups = { "buildDefinition" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+public class BuildDefinitionTest
+    extends AbstractContinuumTest
+{
+    public void testDefaultGroupBuildDefinition()
+        throws Exception
+    {
+        String DEFAULT_PROJ_GRP_NAME = p.getProperty( "DEFAULT_PROJ_GRP_NAME" );
+        String DEFAULT_PROJ_GRP_ID = p.getProperty( "DEFAULT_PROJ_GRP_ID" );
+        String DEFAULT_PROJ_GRP_DESCRIPTION = p.getProperty( "DEFAULT_PROJ_GRP_DESCRIPTION" );
+
+        goToGroupBuildDefinitionPage( DEFAULT_PROJ_GRP_NAME, DEFAULT_PROJ_GRP_ID, DEFAULT_PROJ_GRP_DESCRIPTION );
+        String tableElement = "ec_table";
+        assertCellValueFromTable( "Goals", tableElement, 0, 0 );
+        assertCellValueFromTable( "Arguments", tableElement, 0, 1 );
+        assertCellValueFromTable( "Build File", tableElement, 0, 2 );
+        assertCellValueFromTable( "Schedule", tableElement, 0, 3 );
+        assertCellValueFromTable( "Build Environment", tableElement, 0, 4 );
+        assertCellValueFromTable( "From", tableElement, 0, 5 );
+        assertCellValueFromTable( "Build Fresh", tableElement, 0, 6 );
+        assertCellValueFromTable( "Default", tableElement, 0, 7 );
+        assertCellValueFromTable( "Description", tableElement, 0, 8 );
+        assertCellValueFromTable( "Type", tableElement, 0, 9 );
+        assertCellValueFromTable( "Always Build", tableElement, 0, 10 );
+
+        assertCellValueFromTable( "clean install", tableElement, 1, 0 );
+        assertCellValueFromTable( "--batch-mode --non-recursive", tableElement, 1, 1 );
+        assertCellValueFromTable( "pom.xml", tableElement, 1, 2 );
+        assertCellValueFromTable( "DEFAULT_SCHEDULE", tableElement, 1, 3 );
+        assertCellValueFromTable( "GROUP", tableElement, 1, 5 );
+        assertCellValueFromTable( "false", tableElement, 1, 6 );
+        assertCellValueFromTable( "true", tableElement, 1, 7 );
+        assertCellValueFromTable( "Default Maven 2 Build Definition", tableElement, 1, 8 );
+        assertCellValueFromTable( "maven2", tableElement, 1, 9 );
+        assertCellValueFromTable( "false", tableElement, 1, 10 );
+        assertImgWithAlt( "Edit" );
+        assertImgWithAlt( "Delete" );
+        assertImgWithAlt( "Build" );
+    }
+
+    @Test( dependsOnMethods = { "testAddProjectGroup2" } )
+    public void testAddInvalidGroupBuildDefinition()
+        throws Exception
+    {
+        String TEST2_PROJ_GRP_NAME = p.getProperty( "TEST2_PROJ_GRP_NAME" );
+        String TEST2_PROJ_GRP_ID = p.getProperty( "TEST2_PROJ_GRP_ID" );
+        String TEST2_PROJ_GRP_DESCRIPTION = p.getProperty( "TEST2_PROJ_GRP_DESCRIPTION" );
+        goToGroupBuildDefinitionPage( TEST2_PROJ_GRP_NAME, TEST2_PROJ_GRP_ID, TEST2_PROJ_GRP_DESCRIPTION );
+        clickButtonWithValue( "Add" );
+        setFieldValue( "buildFile", "" );
+        clickButtonWithValue( "Save" );
+        assertTextPresent( "Build file is required and cannot contain spaces only" );
+    }
+
+    @Test( dependsOnMethods = { "testAddProjectGroup2" } )
+    public void testBuildFromGroupBuildDefinition()
+        throws Exception
+    {
+        String TEST2_PROJ_GRP_NAME = p.getProperty( "TEST2_PROJ_GRP_NAME" );
+        String TEST2_PROJ_GRP_ID = p.getProperty( "TEST2_PROJ_GRP_ID" );
+        String TEST2_PROJ_GRP_DESCRIPTION = p.getProperty( "TEST2_PROJ_GRP_DESCRIPTION" );
+        goToGroupBuildDefinitionPage( TEST2_PROJ_GRP_NAME, TEST2_PROJ_GRP_ID, TEST2_PROJ_GRP_DESCRIPTION );
+        clickImgWithAlt( "Build" );
+        assertProjectGroupsSummaryPage();
+    }
+
+    @Test( dependsOnMethods = { "testAddProjectGroup2" } )
+    public void testAddDefautltGroupBuildDefinition()
+        throws Exception
+    {
+        String TEST2_PROJ_GRP_NAME = p.getProperty( "TEST2_PROJ_GRP_NAME" );
+        String TEST2_PROJ_GRP_ID = p.getProperty( "TEST2_PROJ_GRP_ID" );
+        String TEST2_PROJ_GRP_DESCRIPTION = p.getProperty( "TEST2_PROJ_GRP_DESCRIPTION" );
+        String BUILD_POM_NAME = p.getProperty( "BUILD_POM_NAME" );
+        String BUILD_GOALS = p.getProperty( "BUILD_GOALS" );
+        String BUILD_ARGUMENTS = p.getProperty( "BUILD_ARGUMENTS" );
+        String BUILD_DESCRIPTION = p.getProperty( "BUILD_DESCRIPTION" );
+        goToGroupBuildDefinitionPage( TEST2_PROJ_GRP_NAME, TEST2_PROJ_GRP_ID, TEST2_PROJ_GRP_DESCRIPTION );
+        clickButtonWithValue( "Add" );
+        addEditGroupBuildDefinition( TEST2_PROJ_GRP_NAME, BUILD_POM_NAME, BUILD_GOALS, BUILD_ARGUMENTS,
+                                     BUILD_DESCRIPTION, true, true, true );
+    }
+
+    @Test( dependsOnMethods = { "testAddProjectGroup2" } )
+    public void testAddNotDefautltGroupBuildDefinition()
+        throws Exception
+    {
+        String TEST2_PROJ_GRP_NAME = p.getProperty( "TEST2_PROJ_GRP_NAME" );
+        String TEST2_PROJ_GRP_ID = p.getProperty( "TEST2_PROJ_GRP_ID" );
+        String TEST2_PROJ_GRP_DESCRIPTION = p.getProperty( "TEST2_PROJ_GRP_DESCRIPTION" );
+        String BUILD_POM_NAME = p.getProperty( "BUILD_POM_NAME" );
+        String BUILD_GOALS = p.getProperty( "BUILD_GOALS" );
+        String BUILD_ARGUMENTS = p.getProperty( "BUILD_ARGUMENTS" );
+        String BUILD_DESCRIPTION = p.getProperty( "BUILD_DESCRIPTION" );
+        goToGroupBuildDefinitionPage( TEST2_PROJ_GRP_NAME, TEST2_PROJ_GRP_ID, TEST2_PROJ_GRP_DESCRIPTION );
+        clickButtonWithValue( "Add" );
+        addEditGroupBuildDefinition( TEST2_PROJ_GRP_NAME, BUILD_POM_NAME, BUILD_GOALS, BUILD_ARGUMENTS,
+                                     BUILD_DESCRIPTION, false, false, false );
+    }
+
+    @Test( dependsOnMethods = { "testAddNotDefautltGroupBuildDefinition" } )
+    public void testEditGroupBuildDefinition()
+        throws Exception
+    {
+        String TEST2_PROJ_GRP_NAME = p.getProperty( "TEST2_PROJ_GRP_NAME" );
+        String TEST2_PROJ_GRP_ID = p.getProperty( "TEST2_PROJ_GRP_ID" );
+        String TEST2_PROJ_GRP_DESCRIPTION = p.getProperty( "TEST2_PROJ_GRP_DESCRIPTION" );
+        String BUILD_POM_NAME = p.getProperty( "BUILD_POM_NAME" );
+        String BUILD_GOALS = p.getProperty( "BUILD_GOALS" );
+        String BUILD_ARGUMENTS = p.getProperty( "BUILD_ARGUMENTS" );
+        String BUILD_DESCRIPTION = p.getProperty( "BUILD_DESCRIPTION" );
+        String newPom = "newpom.xml";
+        String newGoals = "new goals";
+        String newArguments = "new arguments";
+        String newDescription = "new description";
+        goToGroupBuildDefinitionPage( TEST2_PROJ_GRP_NAME, TEST2_PROJ_GRP_ID, TEST2_PROJ_GRP_DESCRIPTION );
+        clickImgWithAlt( "Edit" );
+        addEditGroupBuildDefinition( TEST2_PROJ_GRP_NAME, newPom, newGoals, newArguments, newDescription, false, false,
+                                     false );
+        clickImgWithAlt( "Edit" );
+        addEditGroupBuildDefinition( TEST2_PROJ_GRP_NAME, BUILD_POM_NAME, BUILD_GOALS, BUILD_ARGUMENTS,
+                                     BUILD_DESCRIPTION, true, true, false );
+    }
+
+    @Test( dependsOnMethods = { "testEditGroupBuildDefinition" } )
+    public void testDeleteGroupBuildDefinition()
+        throws Exception
+    {
+        String TEST2_PROJ_GRP_NAME = p.getProperty( "TEST2_PROJ_GRP_NAME" );
+        String TEST2_PROJ_GRP_ID = p.getProperty( "TEST2_PROJ_GRP_ID" );
+        String TEST2_PROJ_GRP_DESCRIPTION = p.getProperty( "TEST2_PROJ_GRP_DESCRIPTION" );
+        String BUILD_GOALS = p.getProperty( "BUILD_GOALS" );
+        String BUILD_DESCRIPTION = p.getProperty( "BUILD_DESCRIPTION" );
+        goToGroupBuildDefinitionPage( TEST2_PROJ_GRP_NAME, TEST2_PROJ_GRP_ID, TEST2_PROJ_GRP_DESCRIPTION );
+        // Click in Delete Image
+        clickLinkWithXPath( "(//a[contains(@href,'removeGroupBuildDefinition')])//img" );
+        assertDeleteBuildDefinitionPage( BUILD_DESCRIPTION, BUILD_GOALS );
+        clickButtonWithValue( "Delete" );
+        assertGroupBuildDefinitionPage( TEST2_PROJ_GRP_NAME );
+    }
+
+    @Test( dependsOnMethods = { "testAddMavenTwoProjectFromRemoteSourceToNonDefaultProjectGroup" } )
+    public void testAddNotDefautltProjectBuildDefinition()
+        throws Exception
+    {
+        String TEST_PROJ_GRP_NAME = p.getProperty( "TEST_PROJ_GRP_NAME" );
+        String M2_PROJ_GRP_NAME = p.getProperty( "M2_PROJ_GRP_NAME" );
+        String BUILD_POM_NAME = p.getProperty( "BUILD_POM_NAME" );
+        String BUILD_GOALS = p.getProperty( "BUILD_GOALS" );
+        String BUILD_ARGUMENTS = p.getProperty( "BUILD_ARGUMENTS" );
+        String BUILD_DESCRIPTION = p.getProperty( "BUILD_DESCRIPTION" );
+        goToProjectInformationPage( TEST_PROJ_GRP_NAME, M2_PROJ_GRP_NAME );
+        clickLinkWithXPath( "//input[contains(@id,'buildDefinition')]" );
+        addEditGroupBuildDefinition( null, BUILD_POM_NAME, BUILD_GOALS, BUILD_ARGUMENTS, BUILD_DESCRIPTION, false,
+                                     false, false );
+    }
+
+    @Test( dependsOnMethods = { "testAddNotDefautltProjectBuildDefinition" } )
+    public void testDeleteProjectBuildDefinition()
+        throws Exception
+    {
+        String TEST_PROJ_GRP_NAME = p.getProperty( "TEST_PROJ_GRP_NAME" );
+        String M2_PROJ_GRP_NAME = p.getProperty( "M2_PROJ_GRP_NAME" );
+        String BUILD_GOALS = p.getProperty( "BUILD_GOALS" );
+        String BUILD_DESCRIPTION = p.getProperty( "BUILD_DESCRIPTION" );
+        goToProjectInformationPage( TEST_PROJ_GRP_NAME, M2_PROJ_GRP_NAME );
+        // Click in Delete Image
+        clickLinkWithXPath( "(//a[contains(@href,'removeProjectBuildDefinition')])//img" );
+        assertDeleteBuildDefinitionPage( BUILD_DESCRIPTION, BUILD_GOALS );
+        clickButtonWithValue( "Delete" );
+        assertProjectInformationPage();
+    }
+}

Added: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LoginTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LoginTest.java?rev=752530&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LoginTest.java (added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/LoginTest.java Wed Mar 11 17:12:06 2009
@@ -0,0 +1,116 @@
+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.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+/*
+ * Bug in TestNG. TESTNG-285: @Test(sequential=true) works incorrectly for classes with inheritance
+ * http://code.google.com/p/testng/source/browse/trunk/CHANGES.txt
+ * Waiting 5.9 release. It's comming soon.
+ */
+/**
+ * Based on LoginTest of Emmanuel Venisse test.
+ *
+ * @author José Morales Martínez
+ * @version $Id$
+ */
+@Test( groups = { "login" } )
+public class LoginTest
+    extends AbstractSeleniumTest
+{
+    public void testWithBadUsername()
+    {
+        diplayLoginPage();
+        geSelenium().type( "loginForm_username", "badUsername" );
+        geSelenium().type( "loginForm_username", p.getProperty( "ADMIN_PASSWORD" ) );
+        geSelenium().click( "loginForm__login" );
+        geSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertTextPresent( "You have entered an incorrect username and/or password" );
+    }
+
+    @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
+    public void testWithBadPassword()
+    {
+        diplayLoginPage();
+        geSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
+        geSelenium().type( "loginForm_password", "badPassword" );
+        geSelenium().click( "loginForm__login" );
+        geSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertTextPresent( "You have entered an incorrect username and/or password" );
+    }
+
+    @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
+    public void testWithEmptyUsername()
+    {
+        diplayLoginPage();
+        geSelenium().type( "loginForm_password", "password" );
+        geSelenium().click( "loginForm__login" );
+        geSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertTextPresent( "User Name is required" );
+    }
+
+    @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
+    public void testWithEmptyPassword()
+    {
+        diplayLoginPage();
+        geSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
+        geSelenium().click( "loginForm__login" );
+        geSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertTextPresent( "You have entered an incorrect username and/or password" );
+    }
+
+    @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
+    public void testWithCorrectUsernamePassword()
+    {
+        diplayLoginPage();
+        geSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
+        geSelenium().type( "loginForm_password", p.getProperty( "ADMIN_PASSWORD" ) );
+        geSelenium().click( "loginForm__login" );
+        geSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertTextPresent( "Edit Details" );
+        assertTextPresent( "Logout" );
+        assertTextPresent( p.getProperty( "ADMIN_USERNAME" ) );
+    }
+
+
+    @BeforeTest
+    public void open()
+        throws Exception
+    {
+        super.open(2);
+    }
+
+    @Override
+    @AfterTest
+    public void close()
+        throws Exception
+    {
+        super.close();
+    }
+
+    private void diplayLoginPage()
+    {
+        geSelenium().open( baseUrl + "/security/login.action" );
+        waitPage();
+    }
+}

Added: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenTwoProjectTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenTwoProjectTest.java?rev=752530&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenTwoProjectTest.java (added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MavenTwoProjectTest.java Wed Mar 11 17:12:06 2009
@@ -0,0 +1,163 @@
+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.testng.annotations.Test;
+
+/**
+ * Based on AddMavenTwoProjectTest of Emmanuel Venisse test.
+ *
+ * @author José Morales Martínez
+ * @version $Id$
+ */
+@Test( groups = { "mavenTwoProject" }, dependsOnMethods = { "testWithCorrectUsernamePassword" })
+public class MavenTwoProjectTest
+    extends AbstractContinuumTest
+{
+
+    public void testAddMavenTwoProject()
+        throws Exception
+    {
+        String M2_POM_URL = p.getProperty( "M2_POM_URL" );
+        String M2_POM_USERNAME = p.getProperty( "M2_POM_USERNAME" );
+        String M2_POM_PASSWORD = p.getProperty( "M2_POM_PASSWORD" );
+        String M2_PROJ_GRP_NAME = p.getProperty( "M2_PROJ_GRP_NAME" );
+        String M2_PROJ_GRP_ID = p.getProperty( "M2_PROJ_GRP_ID" );
+        String M2_PROJ_GRP_DESCRIPTION = p.getProperty( "M2_PROJ_GRP_DESCRIPTION" );
+        // Enter values into Add Maven Two Project fields, and submit
+        addMavenTwoProject( M2_POM_URL, M2_POM_USERNAME, M2_POM_PASSWORD, null, true );
+        // Wait Struct Listener
+        assertProjectGroupSummaryPage( M2_PROJ_GRP_NAME, M2_PROJ_GRP_ID, M2_PROJ_GRP_DESCRIPTION );
+    }
+
+    @Test( dependsOnMethods = { "testAddProjectGroup" })
+    public void testAddMavenTwoProjectFromRemoteSourceToNonDefaultProjectGroup()
+        throws Exception
+    {
+        String TEST_PROJ_GRP_NAME = p.getProperty( "TEST_PROJ_GRP_NAME" );
+        String TEST_PROJ_GRP_ID = p.getProperty( "TEST_PROJ_GRP_ID" );
+        String TEST_PROJ_GRP_DESCRIPTION = p.getProperty( "TEST_PROJ_GRP_DESCRIPTION" );
+
+        String M2_POM_URL = p.getProperty( "M2_POM_URL" );
+        String M2_POM_USERNAME = p.getProperty( "M2_POM_USERNAME" );
+        String M2_POM_PASSWORD = p.getProperty( "M2_POM_PASSWORD" );
+        addMavenTwoProject( M2_POM_URL, M2_POM_USERNAME, M2_POM_PASSWORD, TEST_PROJ_GRP_NAME, true );
+
+        assertProjectGroupSummaryPage( TEST_PROJ_GRP_NAME, TEST_PROJ_GRP_ID, TEST_PROJ_GRP_DESCRIPTION );
+    }
+
+    /**
+     * Test invalid pom url
+     */
+    public void testNoPomSpecified()
+        throws Exception
+    {
+        submitAddMavenTwoProjectPage( "", false );
+        assertTextPresent( "Either POM URL or Upload POM is required." );
+    }
+
+    /**
+     * Test when scm element is missing from pom
+     */
+    public void testMissingScmElementPom()
+        throws Exception
+    {
+        String pomUrl = p.getProperty( "NOT_SCM_POM_URL" );
+        submitAddMavenTwoProjectPage( pomUrl, false );
+        assertTextPresent( "Missing ''scm'' element in the POM, project Maven Two Project" );
+    }
+
+    /**
+     * test with a malformed pom url
+     */
+    public void testMalformedPomUrl()
+        throws Exception
+    {
+        String pomUrl = "aaa";
+        submitAddMavenTwoProjectPage( pomUrl, false);
+        assertTextPresent( "The specified resource cannot be accessed. Please try again later or contact your administrator." );
+    }
+
+    /**
+     * Test when the connection element is missing from the scm tag
+     */
+    public void testMissingConnectionElement()
+        throws Exception
+    {
+        String pomUrl = p.getProperty( "MISS_CONECT_POM_URL" );
+        submitAddMavenTwoProjectPage( pomUrl, false );
+        assertTextPresent( "Missing 'connection' sub-element in the 'scm' element in the POM." );
+    }
+
+    /**
+     * test unallowed file protocol
+     */
+    public void testNotAllowedProtocol()
+        throws Exception
+    {
+        String pomUrl = "file:///pom.xml";
+        submitAddMavenTwoProjectPage( pomUrl, false );
+        assertTextPresent( "The specified resource isn't a file or the protocol used isn't allowed." );
+    }
+
+    /**
+     * Test when the parent pom is missing or not yet added in continuum
+     */
+    public void testMissingParentPom()
+        throws Exception
+    {
+        String pomUrl = p.getProperty( "MISS_PARENT_POM_URL" );
+        submitAddMavenTwoProjectPage( pomUrl, false );
+        assertTextPresent( "Missing artifact trying to build the POM. Check that its parent POM is available or add it first in Continuum." );
+    }
+
+    /**
+     * Test when the modules/subprojects specified in the pom are not found
+     */
+    public void testMissingModules()
+        throws Exception
+    {
+        String pomUrl = p.getProperty( "MISS_SUBPRO_POM_URL" );
+        submitAddMavenTwoProjectPage( pomUrl, false );
+        assertTextPresent( "Unknown error trying to build POM." );
+    }
+
+    /**
+     * test with an inaccessible pom url
+     */
+    public void testInaccessiblePomUrl()
+        throws Exception
+    {
+        String pomUrl = "http://www.google.com";
+        submitAddMavenTwoProjectPage( pomUrl, false );
+        assertTextPresent( "POM file does not exist. Either the POM you specified or one of its modules does not exist." );
+    }
+
+    /**
+     * test cancel button
+     */
+    public void testCancelButton()
+    {
+        goToAboutPage();
+        goToAddMavenTwoProjectPage();
+        clickButtonWithValue( "Cancel" );
+        assertAboutPage();
+    }
+}

Added: continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MyAccountTest.java
URL: http://svn.apache.org/viewvc/continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MyAccountTest.java?rev=752530&view=auto
==============================================================================
--- continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MyAccountTest.java (added)
+++ continuum/trunk/continuum-webapp-test/src/test/testng/org/apache/continuum/web/test/MyAccountTest.java Wed Mar 11 17:12:06 2009
@@ -0,0 +1,66 @@
+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.testng.Assert;
+import org.testng.annotations.Test;
+
+/**
+ * Based on MyAccountTest of Emmanuel Venisse test.
+ *
+ * @author José Morales Martínez
+ * @version $Id$
+ */
+@Test( groups = { "myAccount" }, dependsOnMethods = {"testWithCorrectUsernamePassword"} )
+public class MyAccountTest
+    extends AbstractSeleniumTest
+{
+
+    public String newFullName = "Admin_FullName";
+
+    public String newEmail = "new_admin@mail.com";
+
+    public void testMyAccountEdit()
+        throws Exception
+    {
+        displayEditDetail();
+        String email = getFieldValue( "user.email" );
+        setFieldValue( "user.fullName", newFullName );
+        setFieldValue( "user.email", newEmail );
+        submit();
+        geSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        Assert.assertEquals( "Continuum - Group Summary", getTitle() );
+        displayEditDetail();
+        assertFieldValue( newFullName, "user.fullName" );
+        assertFieldValue( newEmail, "user.email" );
+        setFieldValue( "user.fullName", p.getProperty( "ADMIN_USERNAME" ) );
+        setFieldValue( "user.email", email );
+        submit();
+        displayEditDetail();
+        assertFieldValue( p.getProperty( "ADMIN_USERNAME" ), "user.fullName" );
+        assertFieldValue( email, "user.email" );
+    }
+
+    private void displayEditDetail()
+    {
+        clickLinkWithText( "Edit Details", true );
+    }
+    // TODO: Validate required values
+}