]> source.dussan.org Git - archiva.git/commitdiff
[MRM-1241] Selenium Tests for Repository Scanning and Database
authorMarecor M. Baclay <mbaclay@apache.org>
Thu, 27 Aug 2009 01:55:46 +0000 (01:55 +0000)
committerMarecor M. Baclay <mbaclay@apache.org>
Thu, 27 Aug 2009 01:55:46 +0000 (01:55 +0000)
- added tests for repository scanning.

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

archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/config/testng.xml
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java [new file with mode: 0644]
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java

index 2786f891300b36521d0c19338128f9c5104e42ee..9eac33934507eca15e4cd25587c2994870477c20 100644 (file)
@@ -29,7 +29,8 @@ under the License.
                        <run>
                                <include name="about" />
                                <include name= "login" />
-                               <include name= "userroles" />   
+                               <include name= "userroles" />
+                               <include name= "reposcan" />
                                <include name= "artifactmanagement" />
                                <include name= "search" />
                                <include name= "browse" />
@@ -46,4 +47,4 @@ under the License.
                        <package name="org.apache.archiva.web.test" />
                </packages>
        </test>
-</suite>
\ No newline at end of file
+</suite>
diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java
new file mode 100644 (file)
index 0000000..c4d5bca
--- /dev/null
@@ -0,0 +1,182 @@
+package org.apache.archiva.web.test;
+
+import org.apache.archiva.web.test.parent.AbstractRepositoryTest;
+import org.testng.annotations.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.
+ */
+
+@Test( groups = { "reposcan" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true )
+public class RepositoryScanningTest 
+       extends AbstractRepositoryTest
+{
+       public void testAddArtifactFileType_NullValue()
+       {
+               goToRepositoryScanningPage();
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" );
+               assertTextPresent( "Unable to process blank pattern." );
+       }
+       
+       @Test (dependsOnMethods = { "testAddArtifactFileType_NullValue" } )
+       public void testAddArtifactFileType()
+       {
+               setFieldValue( "newpattern_0" , "**/*.dll" );
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" );
+               assertTextPresent( "**/*.dll" );
+       }
+       
+       @Test (dependsOnMethods = { "testAddArtifactFileType" } )
+       public void testAddArtifactFileType_ExistingValue()
+       {
+               setFieldValue( "newpattern_0" , "**/*.zip" );
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[15]/td[2]/a/img" );
+               assertTextPresent( "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." );
+       }
+       
+       @Test (dependsOnMethods = { "testAddArtifactFileType_ExistingValue" } )
+       public void testDeleteArtifactFileType()
+       {
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" );
+               assertTextNotPresent( "dll" ); 
+       }
+       
+       @Test (dependsOnMethods = { "testDeleteArtifactFileType" } )
+       public void testAddAutoRemove_NullValue()
+       {
+               setFieldValue( "newpattern_1" , "" );
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
+               assertTextPresent( "Unable to process blank pattern." );
+       }
+       
+       @Test (dependsOnMethods = { "testAddAutoRemove_NullValue" } )
+       public void testAddAutoRemove_ExistingValue()
+       {
+               setFieldValue( "newpattern_1" , "**/*-" );
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
+               assertTextPresent( "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." );
+       }
+       
+       @Test (dependsOnMethods = { "testAddAutoRemove_ExistingValue" } )
+       public void testAddAutoRemove()
+       {
+               setFieldValue( "newpattern_1" , "**/*.test" );
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
+               assertTextPresent( "**/*.test" );
+       }
+       
+       @Test (dependsOnMethods = { "testAddAutoRemove" } )
+       public void testDeleteAutoRemove()
+       {
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" );
+               assertTextNotPresent( "test" );
+       }
+       
+       @Test (dependsOnMethods = { "testDeleteAutoRemove" } )
+       public void testAddIgnoredArtifacts_NullValue()
+       {
+               setFieldValue( "newpattern_2" , "" );
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
+               assertTextPresent( "Unable to process blank pattern." );
+       }
+       
+       @Test (dependsOnMethods = { "testAddIgnoredArtifacts_NullValue" } )
+       public void testAddIgnoredArtifacts_ExistingValue()
+       {
+               setFieldValue( "newpattern_2" , "**/*.sh" );
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
+               assertTextPresent( "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." );
+       }
+       
+       @Test (dependsOnMethods = { "testAddIgnoredArtifacts_ExistingValue" } )
+       public void testAddIgnoredArtifacts()
+       {
+               setFieldValue( "newpattern_2" , "**/*.log" );
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
+               assertTextPresent( "**/*.log" );
+       }
+       
+       @Test (dependsOnMethods = { "testAddIgnoredArtifacts" } )
+       public void testDeleteIgnoredArtifacts()
+       {
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" );
+               assertTextNotPresent( "log" );
+        }
+       
+       //
+       @Test (dependsOnMethods = { "testDeleteIgnoredArtifacts" } )
+       public void testAddIndexableContent_NullValue()
+       {
+               setFieldValue( "newpattern_3" , "" );
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
+               assertTextPresent( "Unable to process blank pattern." );
+       }
+       
+       @Test (dependsOnMethods = { "testAddIndexableContent_NullValue" } )
+       public void testAddIndexableContent_ExistingValue()
+       {
+               setFieldValue( "newpattern_3" , "**/*.xml" );
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
+               assertTextPresent( "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." );
+       }
+       
+       @Test (dependsOnMethods = { "testAddIndexableContent_ExistingValue" } )
+       public void testAddIndexableContent()
+       {
+               setFieldValue( "newpattern_3" , "**/*.html" );
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
+               assertTextPresent( "**/*.html" );
+       }
+       
+       @Test (dependsOnMethods = { "testAddIndexableContent" } )
+       public void testDeleteIndexableContent()
+       {
+               clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" );
+               assertTextNotPresent( "html" );
+       }
+       
+       @Test (dependsOnMethods = { "testDeleteIndexableContent" } )
+       public void testUpdateConsumers()
+       {
+               checkField( "enabledKnownContentConsumers" );
+               checkField( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
+               clickButtonWithValue( "Update Consumers" );
+               assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
+       }
+       
+       @Test (dependsOnMethods = { "testUpdateConsumers" } )
+       public void testUpdateConsumers_UnsetAll()
+       {
+               getSelenium().uncheck( "enabledKnownContentConsumers" );
+               getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='auto-rename']" );
+               getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='create-missing-checksums']" );
+               getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='index-content']" );
+               getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='metadata-updater']" );
+               getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='repository-purge']" );
+               getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='update-db-artifact']" );
+               getSelenium().uncheck( "//input[@name='enabledKnownContentConsumers' and @value='validate-checksums']" );
+               clickButtonWithValue( "Update Consumers" );
+               
+               // remove the ff. 2 lines if MRM-1238 will be fixed. 
+               getSelenium().goBack();
+               waitPage();
+               
+               assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
+       }
+       
+}
index a18722d7b5c45e2868be663f2ce1ad7a0a863d75..a0ed9b0a6fae96bf55aa922175f011a90e7c3575 100644 (file)
@@ -26,6 +26,7 @@ import org.testng.annotations.Test;
 public class RepositoryTest
        extends AbstractRepositoryTest
 {
+       @Test(dependsOnMethods = { "testWithCorrectUsernamePassword" } )
        public void testAddManagedRepoValidValues()
        {
                goToRepositoriesPage();
index 029dc7b22f0c516ec49ddc1dfaca17d5d466ffc6..6b0cf721c41be3ce109b5e9a89aac2dbc462a11c 100644 (file)
@@ -323,4 +323,61 @@ public abstract class AbstractRepositoryTest
                String artifactFilePath = f.getAbsolutePath();
                return artifactFilePath + "/target/";
        }
+       
+       /////////////////////////////////////////////
+       // Repository Scanning
+       /////////////////////////////////////////////
+       public void goToRepositoryScanningPage()
+       {
+               clickLinkWithText( "Repository Scanning" );
+               assertRepositoryScanningPage();
+       }
+       
+       public void assertRepositoryScanningPage()
+       {
+               assertPage( "Apache Archiva \\ Administration - Repository Scanning" );
+               assertTextPresent( "Administration - Repository Scanning" );
+               assertTextPresent( "Repository Scanning - File Types" );
+               String artifactsTypes = "**/*.pom,**/*.jar,**/*.ear,**/*.war,**/*.car,**/*.sar,**/*.mar,**/*.rar,**/*.dtd,**/*.tld,**/*.tar.gz,**/*.tar.bz2,**/*.zip";
+               String [] arrayArtifactTypes = artifactsTypes.split( "," );
+               for (String artifacttypes : arrayArtifactTypes )
+                       assertTextPresent( artifacttypes );
+               
+               String autoremove = "**/*.bak,**/*~,**/*-";
+               String [] arrayAutoremove = autoremove.split( "," );
+               for ( String arrayautoremove : arrayAutoremove )
+                       assertTextPresent( arrayautoremove );
+               
+               String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**";
+               String [] arrayIgnored = ignored.split( "," );
+               for ( String arrayignored : arrayIgnored )
+                       assertTextPresent( arrayignored );
+               
+               String indexableContent = "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld";
+               String [] arrayIndexableContent = indexableContent.split( "," );
+               for ( String indexablecontent : arrayIndexableContent )
+                       assertTextPresent( indexablecontent );
+       }
+       
+       /////////////////////////////////////////////
+       // Database
+       /////////////////////////////////////////////
+       public void goToDatabasePage()
+       {
+               clickLinkWithText( "Database" );
+               assertDatabasePage();
+       }
+       
+       public void assertDatabasePage()
+       {
+               assertPage( "Apache Archiva \\ Administration - Database" );
+               assertTextPresent( "Administration - Database" );
+               assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
+               assertTextPresent( "Cron:" );
+               assertElementPresent( "cron" );
+               assertButtonWithValuePresent( "Update Cron" );
+               assertButtonWithValuePresent( "Update Database Now" );
+               assertTextPresent( "Database - Unprocessed Artifacts Scanning" );
+               assertTextPresent( "Database - Artifact Cleanup Scanning" );
+       }
 }