]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1164] TestNG/Selenium tests for login, browse, search, admin
authorWendy Smoak <wsmoak@apache.org>
Wed, 29 Apr 2009 21:21:40 +0000 (21:21 +0000)
committerWendy Smoak <wsmoak@apache.org>
Wed, 29 Apr 2009 21:21:40 +0000 (21:21 +0000)
Submitted by: Marecor Baclay

git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@769940 13f79535-47bb-0310-9956-ffa450edef68

14 files changed:
archiva-modules/archiva-web/archiva-webapp-test/ReadMe.txt [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/LoginTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractBrowseTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/testng-pom.xml [new file with mode: 0644]

diff --git a/archiva-modules/archiva-web/archiva-webapp-test/ReadMe.txt b/archiva-modules/archiva-web/archiva-webapp-test/ReadMe.txt
new file mode 100644 (file)
index 0000000..aa634ef
--- /dev/null
@@ -0,0 +1,9 @@
+ReadMe
+----------
+Run selenium tests in src/test/testng with Maven and TestNG
+  - Start Archiva
+  - Configure admin user for archiva (match values in src/test/resources/testng.properties )
+  - modify src/test/resources/testng.properties as needed
+  - mvn clean install -f testng-pom.xml
+
+For the default values in the scripts, to pass all the tests, you need to add an artifact in internal repository.
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties b/archiva-modules/archiva-web/archiva-webapp-test/src/test/resources/testng.properties
new file mode 100644 (file)
index 0000000..6a2bf3b
--- /dev/null
@@ -0,0 +1,26 @@
+# properties for integration tests
+
+BASE_URL=http://localhost:9091/
+MAX_WAIT_TIME_IN_MS=60000
+
+ADMIN_USERNAME=admin
+ADMIN_FULLNAME=Administrator
+ADMIN_EMAIL=admin@localhost
+ADMIN_PASSWORD=admin123
+
+SELENIUM_HOST=localhost
+SELENIUM_PORT=4444
+SELENIUM_BROWSER=*firefox
+
+# Search
+SEARCH_BAD_ARTIFACT=asdf
+# Existing Artifact
+ARTIFACT_GROUPID=test
+ARTIFACT_ARTIFACTID=test
+ARTIFACT_VERSION=1.0
+ARTIFACT_PACKAGING=jar
+
+# Reports
+REPOSITORY_NAME=internal
+START_DATE=04/01/2009
+END_DATE=04/30/2009
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml
new file mode 100644 (file)
index 0000000..7d56abb
--- /dev/null
@@ -0,0 +1,46 @@
+<?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="ArchivaTest" verbose="1">
+       <test name="BasicTest" enabled="true">
+               <groups>
+                       <run>
+                               <include name="about" />
+                       </run>
+               </groups>
+               <packages>
+                       <package name="org.apache.archiva.web.test" />
+               </packages>
+       </test>
+       <test name="AdminTest" enabled="true">
+               <groups>
+                       <run>
+                               <include name= "login" />
+                               <include name= "search" />
+                               <include name= "browse" />
+                               <include name= "reports" />
+                       </run>
+               </groups>
+               <packages>
+                       <package name="org.apache.archiva.web.test" />
+               </packages>
+       </test>
+</suite>
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ArchivaAdminTest.java
new file mode 100644 (file)
index 0000000..dca7c03
--- /dev/null
@@ -0,0 +1,79 @@
+package org.apache.archiva.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.archiva.web.test.parent.AbstractArchivaTest;
+import org.testng.Assert;
+import org.testng.annotations.AfterTest;
+import org.testng.annotations.BeforeSuite;
+import org.testng.annotations.BeforeTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "about" }, alwaysRun = true )
+public class ArchivaAdminTest 
+       extends AbstractArchivaTest
+{
+       @BeforeSuite
+    public void initializeContinuum()
+        throws Exception
+    {
+        super.open();
+        System.out.println( "open" );
+        getSelenium().open( baseUrl );
+        System.out.println( "URL" );
+        String title = getSelenium().getTitle();
+        if ( title.equals( "Create Admin User" ) )
+        {
+            assertCreateAdmin();
+            String fullname = p.getProperty( "ADMIN_FULLNAME" );
+            String username = p.getProperty( "ADMIN_USERNAME" );
+            String mail = p.getProperty( "ADMIN_EMAIL" );
+            String password = p.getProperty( "ADMIN_PASSWORD" );
+            submitAdminData( fullname, mail, password );            
+            assertLoginPage();
+            submitUserData( username, password, false, true );
+            assertAuthenticatedPage( username );
+            submit();
+            clickLinkWithText( "Logout" );
+       }
+        super.close();
+    }
+
+    @BeforeTest( groups = { "about" } )
+    public void open()
+        throws Exception
+    {
+        super.open();
+    }
+    public void displayLandingPage()
+    {
+        getSelenium().open( baseUrl + "index.action" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        Assert.assertEquals( "Apache Archiva \\ Quick Search", getSelenium().getTitle() );
+    }
+
+    @Override
+    @AfterTest( groups = { "about" } )
+    public void close()
+       throws Exception
+    {
+        super.close();
+    }
+}
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/BrowseTest.java
new file mode 100644 (file)
index 0000000..72fa33d
--- /dev/null
@@ -0,0 +1,45 @@
+package org.apache.archiva.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.archiva.web.test.parent.AbstractBrowseTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "browse" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+public class BrowseTest 
+       extends AbstractBrowseTest
+{
+       
+       public void testBrowseArtifact()
+       {
+               goToBrowsePage();
+               assertBrowsePage();
+       }
+       
+       public void testClickArtifactFromBrowse()
+       {
+               goToBrowsePage();
+               assertBrowsePage();
+               clickLinkWithText( p.getProperty( "ARTIFACT_ARTIFACTID" ) + "/" );
+               assertPage( "Apache Archiva \\ Browse Repository" );
+               assertTextPresent( "Artifacts" );
+       }
+
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/LoginTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/LoginTest.java
new file mode 100644 (file)
index 0000000..66398c4
--- /dev/null
@@ -0,0 +1,110 @@
+package org.apache.archiva.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.archiva.web.test.parent.AbstractArchivaTest;
+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 AbstractArchivaTest
+{
+       public void testWithBadUsername()
+    {
+        goToLoginPage();
+        getSelenium().type( "loginForm_username", "badUsername" );
+        getSelenium().click( "loginForm__login" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertTextPresent( "You have entered an incorrect username and/or password" );
+    }
+
+    @Test( dependsOnMethods = { "testWithBadUsername" }, alwaysRun = true )
+    public void testWithBadPassword()
+    {
+        goToLoginPage();
+        getSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
+        getSelenium().type( "loginForm_password", "badPassword" );
+        getSelenium().click( "loginForm__login" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertTextPresent( "You have entered an incorrect username and/or password" );
+    }
+
+    @Test( dependsOnMethods = { "testWithBadPassword" }, alwaysRun = true )
+    public void testWithEmptyUsername()
+    {
+        goToLoginPage();
+        getSelenium().type( "loginForm_password", "password" );
+        getSelenium().click( "loginForm__login" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertTextPresent( "User Name is required" );
+    }
+
+    @Test( dependsOnMethods = { "testWithEmptyUsername" }, alwaysRun = true )
+    public void testWithEmptyPassword()
+    {
+        goToLoginPage();
+        getSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
+        getSelenium().click( "loginForm__login" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertTextPresent( "You have entered an incorrect username and/or password" );
+    }
+
+    @Test( groups = { "loginSuccess" }, dependsOnMethods = { "testWithEmptyPassword" }, alwaysRun = true )
+    public void testWithCorrectUsernamePassword()
+    {
+        goToLoginPage();
+        getSelenium().type( "loginForm_username", p.getProperty( "ADMIN_USERNAME" ) );
+        getSelenium().type( "loginForm_password", p.getProperty( "ADMIN_PASSWORD" ) );
+        getSelenium().click( "loginForm__login" );
+        getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+        assertTextPresent( "Edit Details" );
+        assertTextPresent( "Logout" );
+        assertTextPresent( p.getProperty( "ADMIN_USERNAME" ) );
+    }
+       
+       @BeforeTest
+    public void open()
+        throws Exception
+    {
+        super.open();
+    }
+
+    @Override
+    @AfterTest
+    public void close()
+        throws Exception
+    {
+        super.close();
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/ReportsTest.java
new file mode 100644 (file)
index 0000000..334e2b9
--- /dev/null
@@ -0,0 +1,103 @@
+package org.apache.archiva.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.archiva.web.test.parent.AbstractArtifactReportsTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "reports" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+public class ReportsTest 
+       extends AbstractArtifactReportsTest
+{
+       //TODO Tests for repository with defects
+       
+       @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+       public void testRepoStatisticsWithoutRepoCompared()
+       {
+               goToReportsPage();
+               clickButtonWithValue( "View Statistics" );
+               assertTextPresent( "Please select a repository (or repositories) from the list." );
+       }
+       
+       @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+       public void testRepositoryStatisticsWithoutDate()
+       {
+               String repositoryName = p.getProperty( "REPOSITORY_NAME" ) ;
+               compareRepositories( "label=" + repositoryName, "", "" );
+               //TODO
+               assertTextPresent( "Statistics Report" );
+       }
+       
+       @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+       public void testRepositoryStatisticsEndEarlierThanStart()
+       {
+               String repositoryName = p.getProperty( "REPOSITORY_NAME" ) ;
+               String startDate = p.getProperty( "END_DATE" );
+               String endDate = p.getProperty( "START_DATE" );
+               compareRepositories( "label=" + repositoryName, startDate, endDate );
+               //assertTextPresent( "Statistics for Repository '" + repositoryName + "'" );
+               assertPage( "Apache Archiva \\ Reports" );
+               assertTextPresent( "Start Date must be earlier than the End Date" );
+       }
+               
+       @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )        
+       public void testRepositoryStatistics()
+       {
+               String repositoryName = p.getProperty( "REPOSITORY_NAME" ) ;
+               String startDate = p.getProperty( "START_DATE" );
+               String endDate = p.getProperty( "END_DATE" );
+               compareRepositories( "label=" + repositoryName, startDate, endDate );
+               //assertTextPresent( "Statistics for Repository '" + repositoryName + "'" );
+               assertPage( "Apache Archiva \\ Reports" );
+               assertTextPresent( "Statistics Report" );
+       }
+       
+       @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+       public void testRepositoriesStatisticComparisonReport()
+       {
+               goToReportsPage();
+               clickButtonWithValue( "-->>" , false );
+               clickButtonWithValue( "View Statistics" );
+               assertTextPresent( "Statistics Report" );
+       }
+       
+       @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+       public void testRepositoryHealthWithoutDefect()
+       {
+               goToReportsPage();
+               String groupId = p.getProperty( "ARTIFACT_GROUPID" );
+               getSelenium().type( "generateReport_groupId" , groupId );
+               clickButtonWithValue( "Show Report" );
+               assertPage( "Apache Archiva \\ Reports" );
+               assertTextPresent( "The operation generated an empty report." );
+       }
+       
+       @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+       public void testRepositoryHealthWithoutGroupId()
+       {
+               goToReportsPage();
+               clickButtonWithValue( "Show Report" );
+               assertPage( "Apache Archiva \\ Reports" );
+               assertTextPresent( "The operation generated an empty report." );
+               
+               //TODO As of the creation of the tests, GroupId is not a required field in showing the reports of repository health. GroupId should be required I think.
+       }
+       
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/SearchTest.java
new file mode 100644 (file)
index 0000000..fc0973b
--- /dev/null
@@ -0,0 +1,57 @@
+package org.apache.archiva.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.archiva.web.test.parent.AbstractSearchTest;
+import org.testng.annotations.Test;
+
+@Test( groups = { "search" }, dependsOnMethods = { "testWithCorrectUsernamePassword" } )
+public class SearchTest 
+       extends AbstractSearchTest
+{
+       
+       public void testSearchNonExistingArtifact()
+               throws Exception
+       {
+               searchForArtifact( p.getProperty( "SEARCH_BAD_ARTIFACT" ) );
+               assertTextPresent( "No results found" );
+       }
+    
+       public void testSearchExistingArtifact()
+       {
+               searchForArtifact( p.getProperty( "ARTIFACT_ARTIFACTID" ) );
+               assertTextPresent( "Results" );
+               assertTextPresent( "Hits: 1 to 1 of 1" );
+               assertLinkPresent( "test" );
+       }
+       
+       public void testViewSearchedArtifact()
+    {
+               searchForArtifact( p.getProperty( "ARTIFACT_ARTIFACTID" ) );
+               clickLinkWithText( p.getProperty( "ARTIFACT_ARTIFACTID" ) );
+               assertPage( "Apache Archiva \\ Browse Repository" );
+               assertTextPresent( p.getProperty( "ARTIFACT_ARTIFACTID" ) );
+               clickLinkWithText( p.getProperty( "ARTIFACT_VERSION" ) + "/"  );
+               assertPage( "Apache Archiva \\ Browse Repository" );
+    }
+       
+       
+
+}
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArchivaTest.java
new file mode 100644 (file)
index 0000000..0ac08e9
--- /dev/null
@@ -0,0 +1,222 @@
+package org.apache.archiva.web.test.parent;
+
+/*
+ * 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 AbstractArchivaTest 
+       extends AbstractSeleniumTest
+{
+
+       public void assertCreateAdmin()
+       {
+                       assertPage( "Create Admin User" );
+                       assertTextPresent( "Username" );
+               assertFieldValue( "admin", "user.username" );
+                       assertTextPresent( "Full Name*" );
+                       assertElementPresent( "user.fullName" );
+               assertTextPresent( "Email Address*" );
+               assertElementPresent( "user.email");
+               assertTextPresent( "Password*" );
+               assertElementPresent( "user.password" );
+               assertTextPresent( "Confirm Password*"   );
+               assertElementPresent( "user.confirmPassword" );
+               assertButtonWithValuePresent( "Create Admin" );
+       }
+       
+       public void submitAdminData( String fullname, String email, String password )
+       {
+               setFieldValue( "user.fullName", fullname );
+               setFieldValue( "user.emaim", email );
+               setFieldValue( "user.password", password );
+                       setFieldValue( "user.confirmPassword", password );
+               submit();
+       }
+       
+       //Go to Login Page
+       public void goToLoginPage()
+       {
+               getSelenium().open( baseUrl );
+               clickLinkWithText( "Login");
+               assertLoginPage();
+       }
+       
+       public void submitUserData( String username, String password, boolean rememberme, boolean success )
+       {
+
+               setFieldValue( "username", username );
+               setFieldValue( "password", password );
+               if ( rememberme )
+               {
+                       checkField( "rememberMe" );
+               }
+               
+               submit();
+               if ( success )
+               {
+                       assertAuthenticatedPage( username );
+               }
+               else
+               {
+                   assertLoginPage();
+               }
+       }
+       
+       public void assertLoginPage()
+       {
+                       assertPage( "Apache Archiva \\ Login Page" );
+               assertTextPresent( "Login" );
+               assertTextPresent( "Register" );
+               assertTextPresent( "Username" );
+               assertElementPresent( "username" );
+               assertTextPresent( "Password" );
+               assertElementPresent( "password" );
+               assertTextPresent( "Remember Me" );
+               assertElementPresent( "rememberMe" );
+               assertButtonWithValuePresent( "Login" );
+               assertButtonWithValuePresent( "Cancel" );
+               assertTextPresent( "Need an Account? Register!" );
+               assertTextPresent( "Forgot your Password? Request a password reset." );
+       }
+       
+       public void assertAuthenticatedPage( String username )
+       {
+               assertTextPresent( "Current User" );
+               assertTextPresent( "Edit Details" );
+               assertTextPresent( "Logout" );
+               assertTextNotPresent( "Login" );
+               assertTextPresent( username );
+       }
+       
+       
+/*     //Find Artifact
+       public void goToFindArtifactPage()
+       {
+               clickLinkWithText( "Find Artifact" );
+               assertFindArtifactPage();
+       }
+       
+       public void assertFindArtifactPage()
+       {
+               //assertPage( "Apache Archiva \\ Find Artifact" );
+               assertTextPresent( "Find Artifact" );
+               assertTextPresent( "Search For" );
+               assertElementPresent( "f" );
+               assertTextPresent( "Checksum" );
+               assertElementPresent( "q" );
+               assertButtonWithValuePresent( "Search" );
+               assertTextPresent( "This allows you to search the repository using the checksum of an artifact that you are trying to identify. You can either specify the checksum to look for directly, or scan a local artifact file. " );
+               assertTextPresent( "Tï scan a local file, select the file you would like to locate in the remote repository. Ôhe entire file will not  be uploaded$to the server. See the progress bar below for progress of locally creating a checksum that is uploaded to the server ifter you hit ");
+       }
+       
+
+       //User Management
+       public void goToUserManagementPage()
+       {
+               clickLinkWithText( "User Management" );
+               assertUserManagementPage();
+       }
+       
+       public void assertUserManagementPage()
+       {
+               //assertPage( "Apache Archiva \\ [Admin] User List" );
+               assertTextPresent( "[Admin] List of Users in Role: Any" );
+               assertTextPresent( "Navigation" );
+               assertImgWithAlt( "First" );
+               assertImgWithAlt( "Prev" );
+               assertImgWithAlt( "Next" );
+               assertImgWithAlt( "Last" );
+               assertTextPresent( "Display Rows" );
+               assertTextPresent( "Username" );
+               assertTextPresent( "Full Name" );
+               assertTextPresent( "Email" );
+               assertTextPresent( "Permanent" );
+               assertTextPresent( "Validated" );
+               assertTextPresent( "Locked" );
+               assertTextPresent( "Tasks" );
+               assertTextPresent( "Tools" );
+               assertTextPresent( "Tasks" );
+               assertTextPresent( "The following tools are available for administrators to manipulate the user list." );
+               assertButtonWithValuePresent( "Create New User" );
+               assertButtonWithValuePresent( "Show Users In Role" );
+               assertElementPresent( "roleName" );
+               assertTextPresent( "Reports" );
+               assertTextPresent( "Name" );
+               assertTextPresent( "Types" );
+               assertTextPresent( "User List" );
+               assertTextPresent( "Roles Matrix" );
+       }
+       
+       //User Role
+       public void goToUserRolesPage()
+       {
+               clickLinkWithText( "User Roles" );
+               assertUserRolesPage();
+       }
+       
+       public void assertUserRolesPage()
+       {
+               //assertPage( "Apache Archiva \\ [Admin] Role List" );
+               assertTextPresent( "[Admin] Role List" );
+               assertTextPresent( "Role Name" );
+               assertTextPresent( "Role Description" );
+               String userRoles = "Guest,Registered User,System Administrator,User Administrator,Global Repository Observer,Archiva Guest,Archiva System Administrator,Global Repository Manager,Archiva User Administrator,Repository Observer - internal,Repository Manager - internal,Repository Observer - snapshots,Repository Manager - snapshots";
+               String[] arrayRole = userRoles.split( "," );
+               for ( String userroles : arrayRole )
+                       assertLinkPresent( userroles );
+       }
+       
+       //Appearance
+       public void goToAppearancePage()
+       {
+               clickLinkWithText( "Appearance" );
+               assertAppearancePage();
+       }
+       
+       public void assertAppearancePage()
+       {
+               //assertPage( "Apache Archiva \\ Configure Appearance" );
+               String appearance = "Appearance,Organization Details,The logo in the top right of the screen is controlled by the following settings.,Organizations Information,Name,URL,Logo URL";
+               String[] arrayAppearance = appearance.split( "," );
+               for ( String appear : arrayAppearance )
+                       assertTextPresent( appear );
+               assertLinkPresent( "Edit" );
+               assertLinkPresent( "Change your appearance" );
+       }
+       
+       //Upload Artifact
+       public void goToUploadArtifactPage()
+       {
+               clickLinkWithText( "Upload Artifact" );
+               assertUploadArtifactPage();
+       }
+       
+       public void assertUploadArtifactPage()
+       {
+               //assertPage( "Apache Archiva \\ Upload Artifact" );
+               String uploadArtifact = "Upload Artifact,Group Id*,Artifact Id*,Version*,Packaging*,Classifier,Generate Maven 2 POM,Artifact File*,POM File,Repository Id";
+               String[] arrayUploadArtifact = uploadArtifact.split( "," );
+               for ( String uploadartifact : arrayUploadArtifact )
+                       assertTextPresent( uploadartifact );
+               String uploadElements = "groupId,artifactId,version,packaging,classifier,generatePom,artifact,pom,repositoryId";
+               String[] arrayUploadElements = uploadElements.split( "," );
+               for ( String uploadelements : arrayUploadElements )
+                       assertElementPresent( uploadelements );
+               assertButtonWithValuePresent( "Submit" );
+       } */
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractArtifactReportsTest.java
new file mode 100644 (file)
index 0000000..06d4a8b
--- /dev/null
@@ -0,0 +1,80 @@
+package org.apache.archiva.web.test.parent;
+
+/*
+ * 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 AbstractArtifactReportsTest 
+       extends AbstractArchivaTest
+{
+       
+       //Reports
+       public void goToReportsPage()
+       {
+               clickLinkWithText( "Reports" );
+               assertReportsPage();
+       }
+       
+       public void assertReportsPage()
+       {
+               assertPage( "Apache Archiva \\ Reports" );
+               assertTextPresent( "Reports" );
+               assertTextPresent( "Repository Statistics" );
+               assertTextPresent( "Repositories To Be Compared" );
+               assertElementPresent( "availableRepositories" );
+               assertButtonWithValuePresent( "v" );
+               assertButtonWithValuePresent( "^" );
+               assertButtonWithValuePresent( "<-" );
+               assertButtonWithValuePresent( "->" );
+               assertButtonWithValuePresent( "<<--" );
+               assertButtonWithValuePresent( "-->>" );
+               assertButtonWithValuePresent( "<*>" );
+               assertElementPresent( "selectedRepositories" );
+               assertButtonWithValuePresent( "v" );
+               assertButtonWithValuePresent( "^" );
+               assertTextPresent( "Row Count" );
+               assertElementPresent( "rowCount" );
+               assertTextPresent( "Start Date" );
+               assertElementPresent( "startDate" );
+               assertTextPresent( "End Date" );
+               assertElementPresent( "endDate" );
+               assertButtonWithValuePresent( "View Statistics" );
+               assertTextPresent( "Repository Health" );
+               assertTextPresent( "Row Count" );
+               assertElementPresent( "rowCount" );
+               assertTextPresent( "Group ID" );
+               assertElementPresent( "groupId" );
+               assertTextPresent( "Repository ID" );
+               assertElementPresent( "repositoryId" );
+               assertButtonWithValuePresent( "Show Report" );
+       }
+       
+       public void compareRepositories( String labelSelected, String startDate, String endDate )
+       {
+               goToReportsPage();
+               getSelenium().removeSelection( "generateStatisticsReport_availableRepositories" , labelSelected );
+               clickButtonWithValue( "->" , false );
+               getSelenium().type( "startDate", startDate );
+               //clickLinkWithLocator( "1" , false );
+               //getSelenium().click( "endDate" );
+               getSelenium().type( "endDate", endDate );
+               //clickLinkWithLocator( "30" , false );
+               clickButtonWithValue( "View Statistics" );
+       }
+
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractBrowseTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractBrowseTest.java
new file mode 100644 (file)
index 0000000..c9f5981
--- /dev/null
@@ -0,0 +1,40 @@
+package org.apache.archiva.web.test.parent;
+
+/*
+ * 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 AbstractBrowseTest 
+       extends AbstractArchivaTest
+{
+       
+       //Browse
+       public void goToBrowsePage()
+       {
+               clickLinkWithText( "Browse" );
+               assertBrowsePage();
+       }
+
+       public void assertBrowsePage()
+       {
+               assertPage( "Apache Archiva \\ Browse Repository" );
+               assertTextPresent( "Browse Repository" );
+               assertTextPresent( "Groups" );
+       }
+
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSearchTest.java
new file mode 100644 (file)
index 0000000..279f073
--- /dev/null
@@ -0,0 +1,57 @@
+package org.apache.archiva.web.test.parent;
+
+/*
+ * 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 AbstractSearchTest 
+       extends AbstractArchivaTest
+{      
+       //Search
+       public void goToSearchPage()
+       {
+               clickLinkWithText( "Search" );
+               assertSearchPage();
+       }
+       
+       public void assertSearchPage()
+       {
+               assertPage( "Apache Archiva \\ Quick Search" );
+               assertTextPresent( "Search for" );
+               assertElementPresent( "quickSearch_q" );
+               assertButtonWithValuePresent( "Search" );
+               //assertLinkPresent( "Advanced Search" );
+               assertTextPresent( "Enter your search terms. A variety of data will be searched for your keywords." );
+               //assertButtonWithDivIdPresent( "searchHint" );
+       }
+       
+       public void searchForArtifact( String artifactId )
+    {
+        if ( !"Apache Archiva \\ Quick Search".equals( getSelenium().getTitle() ) )
+        {
+            clickLinkWithText( "Search" );
+            
+            getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+            
+            assertPage( "Apache Archiva \\ Quick Search" );
+        }
+
+        getSelenium().type( "dom=document.forms[1].elements[0]", artifactId );
+        clickButtonWithValue( "Search" );
+    }
+}
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractSeleniumTest.java
new file mode 100644 (file)
index 0000000..82531a1
--- /dev/null
@@ -0,0 +1,349 @@
+package org.apache.archiva.web.test.parent;
+
+/*
+ * 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.Arrays;
+import java.util.Iterator;
+import java.util.List;
+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;
+
+/**
+ * @author <a href="mailto:evenisse@apache.org">Emmanuel Venisse</a>
+ * @version $Id: AbstractSeleniumTestCase.java 761154 2009-04-02 03:31:19Z wsmoak $
+ */
+
+public abstract class AbstractSeleniumTest {
+
+       public static String baseUrl;
+
+    public static String maxWaitTimeInMs;
+
+    private static ThreadLocal<Selenium> selenium;
+
+    public static Properties p;
+    
+    public void open()
+           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;
+               }
+           };
+           getSelenium().start();
+       }
+       
+       protected static Selenium getSelenium()
+       {
+           return selenium.get();
+       }
+    
+           public void close()
+           throws Exception
+       {
+           getSelenium().stop();
+       }
+       
+       // *******************************************************
+       // Auxiliar methods. This method help us and simplify test.
+       // *******************************************************
+       
+       public void assertFieldValue( String fieldValue, String fieldName )
+       {
+           assertElementPresent( fieldName );
+           Assert.assertEquals( fieldValue, getSelenium().getValue( fieldName ) );
+       }
+       
+       public void assertPage( String title )
+       {
+           Assert.assertEquals( getSelenium().getTitle(), title );
+       }
+       
+       public String getTitle()
+       {
+           return getSelenium().getTitle();
+       }
+       
+       public String getHtmlContent()
+       {
+           return getSelenium().getHtmlSource();
+       }
+       
+       public void assertTextPresent( String text )
+       {
+           Assert.assertTrue( getSelenium().isTextPresent( text ), "'" + text + "' isn't present." );
+       }
+       
+       public void assertTextNotPresent( String text )
+       {
+           Assert.assertFalse( getSelenium().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 + "' isî't present." );
+       }
+       
+       public void assertLinkNotPresenu( 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 getSelenium().isTextPresent( text );
+       }
+       
+       public boolean isLinkPresent( String text )
+       {
+           return isElementPresent( "link=" + text );
+       }
+       
+       public boolean isElementPresent( String locator )
+       {
+           return getSelenium().isElementPresent( locator );
+       }
+       
+       public void waitPage()
+       {
+           getSelenium().waitForPageToLoad( maxWaitTimeInMs );
+       }
+       
+       public String getFieldValue( String fieldName )
+       {
+           return getSelenium().getValue( fieldName );
+       }
+       
+       public String getCellValueFromTable( String tableElement, int row, int column )
+       {
+           return getSelenium().getTable( tableElement + "." + row + "." + column );
+       }
+       
+       public void selectValue( String locator, String value )
+       {
+           getSelenium().select( locator, "label=" + value );
+       }
+       
+       public void assertOptionPresent( String selectField, String[] options )
+       {
+           assertElementPresent( selectField );
+           String[] optionsPresent = getSelenium().getSelectOptions( selectField );
+           List<String> expected = Arrays.asList( options );
+        List<String> present = Arrays.asList( optionsPresent );
+           Assert.assertTrue( present.containsAll( expected ), "Options expected are not included in present options" );
+       }
+       
+       public void assertSelectedValue( String value, String fieldName )
+       {
+           assertElementPresent( fieldName );
+           String optionsPresent = getSelenium().getSelectedLabel( value );
+           Assert.assertEquals( optionsPresent, value );
+       }
+       
+       public void submit()
+       {
+           clickLinkWithXPath( "//input[@type='submit']" );
+       }
+       
+       public void assertButtonWithValuePresent( String text )
+       {
+           Assert.assertTrue( isButtonWithValuePresent( text ), "'" + text + "' button isn't present" );
+       }
+       
+       public void assertButtonWithIdPresent( String id )
+       {
+           Assert.assertTrue( isButtonWithIdPresent( id ), "'Button with id =" + id + "' 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 boolean isButtonWithIdPresent( String text )
+       {
+           return isElementPresent( "//button[@id='" + text + "']" ) || isElementPresent( "//input[@id='" + 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 );
+           getSelenium().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();
+       
+               getSelenium().type( entry.getKey(), entry.getValue() );
+           }
+       }
+       
+       public void setFieldValue( String fieldName, String value )
+       {
+           getSelenium().type( fieldName, value );
+       }
+       
+       public void checkField( String locator )
+       {
+           getSelenium().check( locator );
+       }
+       
+       public void uncheckField( String locator )
+       {
+           getSelenium().uncheck( locator );
+       }
+       
+       public boolean isChecked( String locator )
+       {
+           return getSelenium().isChecked( locator );
+       }
+       
+       public void assertIsChecked( String locator )
+       {
+           Assert.assertTrue( getSelenium().isChecked( locator ) );
+       }
+       
+       public void assertIsNotChecked( String locator )
+       {
+           Assert.assertFalse( getSelenium().isChecked( locator ) );
+       }
+           
+}
\ No newline at end of file
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/testng-pom.xml b/archiva-modules/archiva-web/archiva-webapp-test/testng-pom.xml
new file mode 100644 (file)
index 0000000..b1797c5
--- /dev/null
@@ -0,0 +1,223 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  ~ 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.
+  -->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+  <modelVersion>4.0.0</modelVersion>
+  <parent>
+    <groupId>org.apache.archiva</groupId>
+    <artifactId>archiva-web</artifactId>
+    <version>1.2.1-SNAPSHOT</version>
+  </parent>
+  <artifactId>archiva-webapp-test</artifactId>
+  <packaging>pom</packaging>
+  <name>Archiva Web :: Application Tests</name>
+
+  <repositories>
+    <repository>
+      <id>openqa-snapshots</id>
+      <url>http://nexus.openqa.org/content/repositories/snapshots</url>
+      <releases><enabled>false</enabled></releases>
+    </repository>
+  </repositories>
+
+  <dependencies>
+       <dependency>
+               <groupId>org.testng</groupId>
+               <artifactId>testng</artifactId>
+               <version>5.8</version>
+               <type>jar</type>
+               <classifier>jdk15</classifier>
+               <scope>test</scope>
+               <optional>false</optional>
+       </dependency>
+       <dependency>
+               <groupId>org.apache.archiva</groupId>
+               <artifactId>archiva-webapp</artifactId>
+               <version>${project.version}</version>
+               <type>war</type>
+               <optional>false</optional>
+       </dependency>
+       <dependency>
+               <groupId>org.apache.derby</groupId>
+               <artifactId>derby</artifactId>
+               <version>10.1.3.1</version>
+               <type>jar</type>
+               <optional>false</optional>
+       </dependency>
+       <dependency>
+               <groupId>javax.mail</groupId>
+               <artifactId>mail</artifactId>
+               <version>1.4</version>
+               <type>jar</type>
+               <optional>false</optional>
+       </dependency>
+       <dependency>
+               <groupId>javax.activation</groupId>
+               <artifactId>activation</artifactId>
+               <version>1.1</version>
+               <type>jar</type>
+               <optional>false</optional>
+       </dependency>
+       <dependency>
+               <groupId>org.codehaus.plexus</groupId>
+               <artifactId>plexus-utils</artifactId>
+               <version>1.4</version>
+               <type>jar</type>
+               <optional>false</optional>
+       </dependency>
+       <dependency>
+               <groupId>org.openqa.selenium.server</groupId>
+               <artifactId>selenium-server</artifactId>
+               <version>0.9.2</version>
+               <type>jar</type>
+               <optional>false</optional>
+               <exclusions>
+                       <exclusion>
+                               <groupId>commons-logging</groupId>
+                               <artifactId>commons-logging</artifactId>
+                       </exclusion>
+               </exclusions>
+       </dependency>
+       <dependency>
+               <groupId>org.openqa.selenium.client-drivers</groupId>
+               <artifactId>selenium-java-client-driver</artifactId>
+               <version>0.9.2</version>
+               <type>jar</type>
+               <scope>test</scope>
+               <optional>false</optional>
+               <exclusions>
+                       <exclusion>
+                               <groupId>commons-logging</groupId>
+                               <artifactId>commons-logging</artifactId>
+                       </exclusion>
+               </exclusions>
+       </dependency>
+  </dependencies>
+
+  <build>
+    <testSourceDirectory>src/test/testng</testSourceDirectory>
+    <testResources>
+      <testResource>
+        <directory>src/test/resources</directory>
+        <filtering>true</filtering>
+        <includes>
+          <include>**/*</include>
+        </includes>
+      </testResource>
+    </testResources>
+    <plugins>
+      <plugin>
+        <artifactId>maven-resources-plugin</artifactId>
+        <executions>
+          <execution>
+            <goals>
+              <goal>testResources</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-compiler-plugin</artifactId>
+        <configuration>
+          <source>1.5</source>
+          <target>1.5</target>
+          <verbose>true</verbose>
+        </configuration>
+        <executions>
+          <execution>
+            <goals>
+              <goal>testCompile</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+      <plugin>
+        <groupId>org.codehaus.mojo</groupId>
+        <artifactId>selenium-maven-plugin</artifactId>
+        <executions>
+          <execution>
+            <phase>pre-integration-test</phase>
+            <goals>
+              <goal>start-server</goal>
+            </goals>
+            <configuration>
+              <background>true</background>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+      
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-surefire-plugin</artifactId>
+        <configuration>
+          <suiteXmlFiles>
+            <suiteXmlFile>src/test/testng/config/testng.xml</suiteXmlFile>
+          </suiteXmlFiles>
+        </configuration>
+        <executions>
+          <execution>
+            <id>integration-tests</id>
+            <phase>integration-test</phase>
+            <goals>
+              <goal>test</goal>
+            </goals>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+  <profiles>
+    <profile>
+      <id>tomcat5x</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <properties>
+        <container.name>tomcat5x</container.name>
+        <container.url>http://apache.mirrors.redwire.net/tomcat/tomcat-5/v5.5.27/bin/apache-tomcat-5.5.27.zip
+        </container.url>
+      </properties>
+    </profile>
+    <profile>
+      <id>firefox</id>
+      <activation>
+        <activeByDefault>true</activeByDefault>
+      </activation>
+      <properties>
+        <browser>*firefox</browser>
+      </properties>
+    </profile>
+    <profile>
+      <id>iexplore</id>
+      <properties>
+        <browser>*iexplore</browser>
+      </properties>
+    </profile>
+    <profile>
+      <id>otherbrowser</id>
+      <properties>
+        <browser>*custom ${browserPath}</browser>
+      </properties>
+    </profile>
+  </profiles>
+</project>