aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrett Porter <brett@apache.org>2011-10-03 03:34:40 +0000
committerBrett Porter <brett@apache.org>2011-10-03 03:34:40 +0000
commit6b69ca6416cfc7b457090b81bb258765a3bbfadf (patch)
treee37ca825ba009a5b082b3ca0e193bc3e6fc05427
parent6907587afb8f9bb587faa56621c6abd1d669bf99 (diff)
downloadarchiva-6b69ca6416cfc7b457090b81bb258765a3bbfadf.tar.gz
archiva-6b69ca6416cfc7b457090b81bb258765a3bbfadf.zip
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
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/AbstractRepositoryAdmin.java5
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/main/java/org/apache/archiva/admin/repository/admin/DefaultArchivaAdministration.java5
-rw-r--r--archiva-modules/archiva-base/archiva-repository-admin/archiva-repository-admin-default/src/test/java/org/apache/archiva/admin/repository/admin/ArchivaAdministrationTest.java16
-rw-r--r--archiva-modules/archiva-web/archiva-webapp-test/src/test/testng/org/apache/archiva/web/test/RepositoryScanningTest.java23
-rw-r--r--archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/archiva/web/action/admin/scanning/RepositoryScanningAction.java2
5 files changed, 33 insertions, 18 deletions
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;