From 9ef096945d1fa20d29cc7791e2ba77b3928de40e Mon Sep 17 00:00:00 2001 From: Brett Porter Date: Thu, 14 Jan 2010 05:28:31 +0000 Subject: [PATCH] fix repository scanning tests git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@899066 13f79535-47bb-0310-9956-ffa450edef68 --- .../web/test/RepositoryScanningTest.java | 43 ++++++++++--------- .../test/parent/AbstractRepositoryTest.java | 36 ++++++++++++---- 2 files changed, 50 insertions(+), 29 deletions(-) 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 index c4d5bcad9..6d00d1a32 100644 --- 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 @@ -1,8 +1,5 @@ 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 @@ -22,6 +19,10 @@ import org.testng.annotations.Test; * under the License. */ +import org.apache.archiva.web.test.parent.AbstractRepositoryTest; +import org.testng.annotations.Test; +import org.testng.Assert; + @Test( groups = { "reposcan" }, dependsOnMethods = { "testWithCorrectUsernamePassword" }, sequential = true ) public class RepositoryScanningTest extends AbstractRepositoryTest @@ -38,7 +39,7 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_0" , "**/*.dll" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" ); - assertTextPresent( "**/*.dll" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" ); } @Test (dependsOnMethods = { "testAddArtifactFileType" } ) @@ -46,14 +47,15 @@ public class RepositoryScanningTest { 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." ); + Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." ); } @Test (dependsOnMethods = { "testAddArtifactFileType_ExistingValue" } ) public void testDeleteArtifactFileType() { + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "**/*.dll" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[1]/table/tbody/tr[14]/td[2]/a/img" ); - assertTextNotPresent( "dll" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table.13.0"), "" ); } @Test (dependsOnMethods = { "testDeleteArtifactFileType" } ) @@ -69,7 +71,7 @@ public class RepositoryScanningTest { 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." ); + Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." ); } @Test (dependsOnMethods = { "testAddAutoRemove_ExistingValue" } ) @@ -77,14 +79,15 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_1" , "**/*.test" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" ); - assertTextPresent( "**/*.test" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" ); } @Test (dependsOnMethods = { "testAddAutoRemove" } ) public void testDeleteAutoRemove() { + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "**/*.test" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[2]/table/tbody/tr[4]/td[2]/a/img" ); - assertTextNotPresent( "test" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table.3.0"), "" ); } @Test (dependsOnMethods = { "testDeleteAutoRemove" } ) @@ -92,7 +95,7 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_2" , "" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" ); - assertTextPresent( "Unable to process blank pattern." ); + Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." ); } @Test (dependsOnMethods = { "testAddIgnoredArtifacts_NullValue" } ) @@ -100,7 +103,7 @@ public class RepositoryScanningTest { 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." ); + Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." ); } @Test (dependsOnMethods = { "testAddIgnoredArtifacts_ExistingValue" } ) @@ -108,14 +111,15 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_2" , "**/*.log" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" ); - assertTextPresent( "**/*.log" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" ); } @Test (dependsOnMethods = { "testAddIgnoredArtifacts" } ) public void testDeleteIgnoredArtifacts() { + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "**/*.log" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[3]/table/tbody/tr[7]/td[2]/a/img" ); - assertTextNotPresent( "log" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table.6.0"), "" ); } // @@ -124,7 +128,7 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_3" , "" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" ); - assertTextPresent( "Unable to process blank pattern." ); + Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Unable to process blank pattern." ); } @Test (dependsOnMethods = { "testAddIndexableContent_NullValue" } ) @@ -132,7 +136,7 @@ public class RepositoryScanningTest { 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." ); + Assert.assertEquals(getSelenium().getText("//span[@class='errorMessage']"), "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." ); } @Test (dependsOnMethods = { "testAddIndexableContent_ExistingValue" } ) @@ -140,14 +144,15 @@ public class RepositoryScanningTest { setFieldValue( "newpattern_3" , "**/*.html" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" ); - assertTextPresent( "**/*.html" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" ); } @Test (dependsOnMethods = { "testAddIndexableContent" } ) public void testDeleteIndexableContent() { + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "**/*.html" ); clickLinkWithXPath( "//div[@id='contentArea']/div/div[4]/table/tbody/tr[10]/td[2]/a/img" ); - assertTextNotPresent( "html" ); + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table.9.0"), "" ); } @Test (dependsOnMethods = { "testDeleteIndexableContent" } ) @@ -172,10 +177,6 @@ public class RepositoryScanningTest 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" ); } diff --git a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java index 137c9ccad..52f02ef8a 100644 --- a/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java +++ b/archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/parent/AbstractRepositoryTest.java @@ -1,6 +1,26 @@ 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.io.File; +import org.testng.Assert; public abstract class AbstractRepositoryTest extends AbstractArchivaTest @@ -307,23 +327,23 @@ public abstract class AbstractRepositoryTest 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 ); + for (int i = 0; i < arrayArtifactTypes.length; i++) + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[1]/table."+i+".0"), arrayArtifactTypes[i]); String autoremove = "**/*.bak,**/*~,**/*-"; String [] arrayAutoremove = autoremove.split( "," ); - for ( String arrayautoremove : arrayAutoremove ) - assertTextPresent( arrayautoremove ); + for (int i = 0; i < arrayAutoremove.length; i++) + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[2]/table."+i+".0"), arrayAutoremove[i]); String ignored = "**/.htaccess,**/KEYS,**/*.rb,**/*.sh,**/.svn/**,**/.DAV/**"; String [] arrayIgnored = ignored.split( "," ); - for ( String arrayignored : arrayIgnored ) - assertTextPresent( arrayignored ); + for (int i = 0; i < arrayIgnored.length; i++) + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[3]/table."+i+".0"), arrayIgnored[i]); String indexableContent = "**/*.txt,**/*.TXT,**/*.block,**/*.config,**/*.pom,**/*.xml,**/*.xsd,**/*.dtd,**/*.tld"; String [] arrayIndexableContent = indexableContent.split( "," ); - for ( String indexablecontent : arrayIndexableContent ) - assertTextPresent( indexablecontent ); + for (int i = 0; i < arrayIndexableContent.length; i++) + Assert.assertEquals(getSelenium().getTable("//div[@id='contentArea']/div/div[4]/table."+i+".0"), arrayIndexableContent[i]); } ///////////////////////////////////////////// -- 2.39.5