From: Brett Porter Date: Mon, 3 Oct 2011 03:34:40 +0000 (+0000) Subject: fix tests that check duplicate artifacts are not added to the lists X-Git-Tag: archiva-1.4-M1~107 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=6b69ca6416cfc7b457090b81bb258765a3bbfadf;p=archiva.git fix tests that check duplicate artifacts are not added to the lists git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1178289 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java index f359fdc80..f8ed87627 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java @@ -82,11 +82,12 @@ public abstract class AbstractRepositoryAdmin } catch ( RegistryException e ) { - throw new RepositoryAdminException( "Error occurred in the registry.", e ); + throw new RepositoryAdminException( "Error occurred in the registry: " + e.getLocalizedMessage(), e ); } catch ( IndeterminateConfigurationException e ) { - throw new RepositoryAdminException( "Error occurred while saving the configuration.", e ); + throw new RepositoryAdminException( + "Error occurred while saving the configuration: " + e.getLocalizedMessage(), e ); } } diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java index 33727efed..9d84fa708 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java @@ -110,6 +110,11 @@ public class DefaultArchivaAdministration { return; } + + if ( fileType.getPatterns().contains( pattern ) ) + { + throw new RepositoryAdminException( "File type [" + fileTypeId + "] already contains pattern [" + pattern + "]" ); + } fileType.addPattern( pattern ); saveConfiguration( configuration ); diff --git a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java index 93c8daacd..b54b85232 100644 --- a/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java +++ b/archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java @@ -114,6 +114,22 @@ public class ArchivaAdministrationTest mockAuditListener.clearEvents(); } + @Test(expected = RepositoryAdminException.class) + public void addFileTypePatternAgain() + throws RepositoryAdminException + { + try + { + archivaAdministration.addFileTypePattern( "artifacts", "**/*.jar", getFakeAuditInformation() ); + } + catch ( RepositoryAdminException e ) + { + // check the message + assertEquals( "File type [artifacts] already contains pattern [**/*.jar]", e.getMessage() ); + throw e; + } + } + @Test public void knownContentConsumersTest() throws Exception 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 8a6295267..f37a158be 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 @@ -43,15 +43,13 @@ public class RepositoryScanningTest Assert.assertEquals( getSelenium().getTable( "//div[@id='contentArea']/div/div[1]/table.13.0" ), "**/*.dll" ); } - @Test( dependsOnMethods = { "testAddArtifactFileType" }, enabled = false ) + @Test( dependsOnMethods = { "testAddArtifactFileType" } ) public void testAddArtifactFileType_ExistingValue() { goToRepositoryScanningPage(); - // FIXME: broken setFieldValue( "newpattern_0", "**/*.zip" ); clickAddIcon( "newpattern_0" ); - Assert.assertEquals( getErrorMessageText(), - "Not adding pattern \"**/*.zip\" to filetype artifacts as it already exists." ); + Assert.assertEquals( getErrorMessageText(), "File type [artifacts] already contains pattern [**/*.zip]" ); } @Test( dependsOnMethods = { "testAddArtifactFileType" } ) @@ -74,15 +72,13 @@ public class RepositoryScanningTest assertTextPresent( "Unable to process blank pattern." ); } - @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" }, enabled = false ) + @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" } ) public void testAddAutoRemove_ExistingValue() { goToRepositoryScanningPage(); setFieldValue( "newpattern_1", "**/*-" ); clickAddIcon( "newpattern_1" ); - // FIXME: broken - Assert.assertEquals( getErrorMessageText(), - "Not adding pattern \"**/*-\" to filetype auto-remove as it already exists." ); + Assert.assertEquals( getErrorMessageText(), "File type [auto-remove] already contains pattern [**/*-]" ); } @Test( dependsOnMethods = { "testAddAutoRemove_NullValue" } ) @@ -115,15 +111,13 @@ public class RepositoryScanningTest "Unable to process blank pattern." ); } - @Test(enabled = false) + @Test public void testAddIgnoredArtifacts_ExistingValue() { goToRepositoryScanningPage(); setFieldValue( "newpattern_2", "**/*.sh" ); clickAddIcon( "newpattern_2" ); - // FIXME: broken - Assert.assertEquals( getErrorMessageText(), - "Not adding pattern \"**/*.sh\" to filetype ignored as it already exists." ); + Assert.assertEquals( getErrorMessageText(), "File type [ignored] already contains pattern [**/*.sh]" ); } @Test @@ -158,15 +152,14 @@ public class RepositoryScanningTest "Unable to process blank pattern." ); } - @Test( enabled = false ) + @Test public void testAddIndexableContent_ExistingValue() { goToRepositoryScanningPage(); setFieldValue( "newpattern_3", "**/*.xml" ); clickAddIcon( "newpattern_3" ); - // FIXME: broken Assert.assertEquals( getErrorMessageText(), - "Not adding pattern \"**/*.xml\" to filetype indexable-content as it already exists." ); + "File type [indexable-content] already contains pattern [**/*.xml]" ); } @Test diff --git a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningAction.java b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningAction.java index fffcf60b4..34bfaf3fd 100644 --- a/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningAction.java +++ b/archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningAction.java @@ -117,7 +117,7 @@ public class RepositoryScanningAction } catch ( RepositoryAdminException e ) { - addActionError( "error adding file type pattern " + e.getMessage() ); + addActionError( e.getMessage() ); return INPUT; } return SUCCESS;