]> source.dussan.org Git - archiva.git/commitdiff
fix tests that check duplicate artifacts are not added to the lists
authorBrett Porter <brett@apache.org>
Mon, 3 Oct 2011 03:34:40 +0000 (03:34 +0000)
committerBrett Porter <brett@apache.org>
Mon, 3 Oct 2011 03:34:40 +0000 (03:34 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1178289 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java
archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java
archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java
archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningAction.java

index f359fdc8012425b60da7d4721ff9619c2d01fcc6..f8ed87627e1df65f60e90cdd69f7e8dd5fe1e9b1 100644 (file)
@@ -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 );
         }
     }
 
index 33727efedee1e9d8df9bb62c13237d1d4eb1e1b0..9d84fa708cd39016188c37d76d9f373db1748645 100644 (file)
@@ -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 );
index 93c8daacd9a62e74e97710460620173fdd2c1ea6..b54b85232344f3782e151d83af4ea988034861e8 100644 (file)
@@ -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
index 8a6295267eff76c4ee7f8f011502e0c49f3db4ff..f37a158be1ac5393d90d555453f93be5da3f89cd 100644 (file)
@@ -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
index fffcf60b4b836c7fe19236efc769dbd7c8e1ba39..34bfaf3fda119130418e10d983bd350fbb55fb0b 100644 (file)
@@ -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;