]> source.dussan.org Git - archiva.git/commitdiff
more cleanup of direct use of archiva-configuration
authorOlivier Lamy <olamy@apache.org>
Wed, 14 Sep 2011 10:22:19 +0000 (10:22 +0000)
committerOlivier Lamy <olamy@apache.org>
Wed, 14 Sep 2011 10:22:19 +0000 (10:22 +0000)
git-svn-id: https://svn.apache.org/repos/asf/archiva/trunk@1170512 13f79535-47bb-0310-9956-ffa450edef68

archiva-modules/archiva-web/archiva-webapp/src/main/java/org/apache/maven/archiva/web/action/UploadAction.java
archiva-modules/archiva-web/archiva-webapp/src/test/java/org/apache/maven/archiva/web/action/UploadActionTest.java

index ef7a42a755eb8a6bfa42258fc41d5c7cd485d647..2af4318f1f873c9781f876929626718d5ca9b5b8 100644 (file)
@@ -21,20 +21,25 @@ package org.apache.maven.archiva.web.action;
 
 import com.opensymphony.xwork2.Preparable;
 import com.opensymphony.xwork2.Validateable;
+import org.apache.archiva.admin.model.RepositoryAdminException;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
+import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
 import org.apache.archiva.audit.AuditEvent;
 import org.apache.archiva.audit.Auditable;
 import org.apache.archiva.checksum.ChecksumAlgorithm;
 import org.apache.archiva.checksum.ChecksummedFile;
 import org.apache.archiva.scheduler.ArchivaTaskScheduler;
 import org.apache.archiva.scheduler.repository.RepositoryTask;
+import org.apache.archiva.security.AccessDeniedException;
+import org.apache.archiva.security.ArchivaSecurityException;
+import org.apache.archiva.security.PrincipalNotFoundException;
+import org.apache.archiva.security.UserRepositories;
 import org.apache.commons.io.FilenameUtils;
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.common.utils.VersionComparator;
 import org.apache.maven.archiva.common.utils.VersionUtil;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
 import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
 import org.apache.maven.archiva.model.ArtifactReference;
 import org.apache.maven.archiva.model.SnapshotVersion;
@@ -46,10 +51,6 @@ import org.apache.maven.archiva.repository.metadata.MetadataTools;
 import org.apache.maven.archiva.repository.metadata.RepositoryMetadataException;
 import org.apache.maven.archiva.repository.metadata.RepositoryMetadataReader;
 import org.apache.maven.archiva.repository.metadata.RepositoryMetadataWriter;
-import org.apache.archiva.security.AccessDeniedException;
-import org.apache.archiva.security.ArchivaSecurityException;
-import org.apache.archiva.security.PrincipalNotFoundException;
-import org.apache.archiva.security.UserRepositories;
 import org.apache.maven.model.Model;
 import org.apache.maven.model.io.xpp3.MavenXpp3Writer;
 import org.codehaus.plexus.taskqueue.TaskQueueException;
@@ -134,11 +135,14 @@ public class UploadAction
      */
     private List<String> managedRepoIdList;
 
+    @Inject
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
     @Inject
     private UserRepositories userRepositories;
 
     @Inject
-    private ArchivaConfiguration configuration;
+    private ArchivaAdministration archivaAdministration;
 
     @Inject
     private RepositoryContentFactory repositoryFactory;
@@ -288,8 +292,7 @@ public class UploadAction
     {
         try
         {
-            Configuration config = configuration.getConfiguration();
-            ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( repositoryId );
+            ManagedRepository repoConfig = managedRepositoryAdmin.getManagedRepository( repositoryId );
 
             ArtifactReference artifactReference = new ArtifactReference();
             artifactReference.setArtifactId( artifactId );
@@ -342,7 +345,7 @@ public class UploadAction
             }
 
             boolean fixChecksums =
-                !( config.getRepositoryScanning().getKnownContentConsumers().contains( "create-missing-checksums" ) );
+                !( archivaAdministration.getKnownContentConsumers().contains( "create-missing-checksums" ) );
 
             try
             {
@@ -409,7 +412,7 @@ public class UploadAction
             }
 
             // explicitly update only if metadata-updater consumer is not enabled!
-            if ( !config.getRepositoryScanning().getKnownContentConsumers().contains( "metadata-updater" ) )
+            if ( !archivaAdministration.getKnownContentConsumers().contains( "metadata-updater" ) )
             {
                 updateProjectMetadata( targetPath.getAbsolutePath(), lastUpdatedTimestamp, timestamp, newBuildNumber,
                                        fixChecksums );
@@ -439,6 +442,11 @@ public class UploadAction
             addActionError( "Repository exception: " + rep.getMessage() );
             return ERROR;
         }
+        catch ( RepositoryAdminException e )
+        {
+            addActionError( "RepositoryAdmin exception: " + e.getMessage() );
+            return ERROR;
+        }
     }
 
     private void fixChecksums( File file )
@@ -683,8 +691,23 @@ public class UploadAction
         this.repositoryFactory = repositoryFactory;
     }
 
-    public void setConfiguration( ArchivaConfiguration configuration )
+    public ManagedRepositoryAdmin getManagedRepositoryAdmin()
+    {
+        return managedRepositoryAdmin;
+    }
+
+    public void setManagedRepositoryAdmin( ManagedRepositoryAdmin managedRepositoryAdmin )
+    {
+        this.managedRepositoryAdmin = managedRepositoryAdmin;
+    }
+
+    public ArchivaAdministration getArchivaAdministration()
+    {
+        return archivaAdministration;
+    }
+
+    public void setArchivaAdministration( ArchivaAdministration archivaAdministration )
     {
-        this.configuration = configuration;
+        this.archivaAdministration = archivaAdministration;
     }
 }
index e3c81ed7b636dc38d24195de376ef0f03c089bc9..bfafc4fa76ff0aba3276a734f266fdfb6585b56d 100644 (file)
@@ -21,7 +21,9 @@ package org.apache.maven.archiva.web.action;
 
 import com.opensymphony.xwork2.Action;
 import net.sf.beanlib.provider.replicator.BeanReplicator;
+import org.apache.archiva.admin.model.admin.ArchivaAdministration;
 import org.apache.archiva.admin.model.managed.ManagedRepository;
+import org.apache.archiva.admin.model.managed.ManagedRepositoryAdmin;
 import org.apache.archiva.audit.AuditEvent;
 import org.apache.archiva.audit.AuditListener;
 import org.apache.archiva.checksum.ChecksumAlgorithm;
@@ -30,10 +32,6 @@ import org.apache.archiva.scheduler.ArchivaTaskScheduler;
 import org.apache.commons.io.FileUtils;
 import org.apache.commons.lang.StringUtils;
 import org.apache.maven.archiva.common.utils.FileUtil;
-import org.apache.maven.archiva.configuration.ArchivaConfiguration;
-import org.apache.maven.archiva.configuration.Configuration;
-import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
-import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
 import org.apache.maven.archiva.model.ArchivaRepositoryMetadata;
 import org.apache.maven.archiva.model.SnapshotVersion;
 import org.apache.maven.archiva.repository.ManagedRepositoryContent;
@@ -63,17 +61,22 @@ public class UploadActionTest
 {
     private UploadAction uploadAction;
 
-    private ArchivaConfiguration archivaConfig;
-
-    private MockControl archivaConfigControl;
-
     private RepositoryContentFactory repoFactory;
 
     private MockControl repoFactoryControl;
 
+    private MockControl managedRepoAdminControl;
+
+    private ManagedRepositoryAdmin managedRepositoryAdmin;
+
+    private MockControl archivaAdminControl;
+
+    private ArchivaAdministration archivaAdministration;
+
     private static final String REPOSITORY_ID = "test-repo";
 
-    private Configuration config;
+
+    private ManagedRepository managedRepository;
 
     public void setUp()
         throws Exception
@@ -83,15 +86,20 @@ public class UploadActionTest
         MockControl schedulerControl = MockControl.createControl( ArchivaTaskScheduler.class );
         ArchivaTaskScheduler scheduler = (ArchivaTaskScheduler) schedulerControl.getMock();
 
-        archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
-        archivaConfig = (ArchivaConfiguration) archivaConfigControl.getMock();
-
         repoFactoryControl = MockClassControl.createControl( RepositoryContentFactory.class );
         repoFactory = (RepositoryContentFactory) repoFactoryControl.getMock();
 
+        managedRepoAdminControl = MockControl.createControl( ManagedRepositoryAdmin.class );
+        managedRepositoryAdmin = (ManagedRepositoryAdmin) managedRepoAdminControl.getMock();
+
+        archivaAdminControl = MockControl.createControl( ArchivaAdministration.class );
+        archivaAdministration = (ArchivaAdministration) archivaAdminControl.getMock();
+
         uploadAction = new UploadAction();
         uploadAction.setScheduler( scheduler );
-        uploadAction.setConfiguration( archivaConfig );
+        uploadAction.setManagedRepositoryAdmin( managedRepositoryAdmin );
+        uploadAction.setArchivaAdministration( archivaAdministration );
+
         uploadAction.setRepositoryFactory( repoFactory );
 
         File testRepo = new File( FileUtil.getBasedir(), "target/test-classes/test-repo" );
@@ -99,24 +107,19 @@ public class UploadActionTest
 
         assertTrue( testRepo.exists() );
 
-        config = new Configuration();
-        ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
-        repoConfig.setId( REPOSITORY_ID );
-        repoConfig.setLayout( "default" );
-        repoConfig.setLocation( testRepo.getPath() );
-        repoConfig.setName( REPOSITORY_ID );
-        repoConfig.setBlockRedeployments( true );
-        config.addManagedRepository( repoConfig );
-
-        RepositoryScanningConfiguration repoScanning = new RepositoryScanningConfiguration();
-        repoScanning.setKnownContentConsumers( new ArrayList<String>() );
-        config.setRepositoryScanning( repoScanning );
+        managedRepository = new ManagedRepository();
+        managedRepository.setId( REPOSITORY_ID );
+        managedRepository.setLayout( "default" );
+        managedRepository.setLocation( testRepo.getPath() );
+        managedRepository.setName( REPOSITORY_ID );
+        managedRepository.setBlockRedeployments( true );
+
     }
 
     public void tearDown()
         throws Exception
     {
-        File testRepo = new File( config.findManagedRepositoryById( REPOSITORY_ID ).getLocation() );
+        File testRepo = new File( this.managedRepository.getLocation() );
         FileUtils.deleteDirectory( testRepo );
 
         assertFalse( testRepo.exists() );
@@ -292,12 +295,18 @@ public class UploadActionTest
                              false );
 
         ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
+        content.setRepository( getManagedRepository() );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
 
-        archivaConfigControl.replay();
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
         repoFactoryControl.replay();
 
         MockControl control = mockAuditLogs(
@@ -307,11 +316,10 @@ public class UploadActionTest
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
-        archivaConfigControl.verify();
         repoFactoryControl.verify();
         control.verify();
 
-        String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
+        String repoLocation = getManagedRepository().getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
 
         verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
@@ -328,12 +336,19 @@ public class UploadActionTest
                              false );
 
         ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
+        content.setRepository( getManagedRepository() );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
 
-        archivaConfigControl.replay();
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
         repoFactoryControl.replay();
 
         MockControl control = mockAuditLogs(
@@ -343,11 +358,10 @@ public class UploadActionTest
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
-        archivaConfigControl.verify();
         repoFactoryControl.verify();
         control.verify();
 
-        String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
+        String repoLocation = getManagedRepository().getLocation();
         assertTrue( new File( repoLocation,
                               "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0-tests.jar" ).exists() );
         assertTrue( new File( repoLocation,
@@ -381,12 +395,19 @@ public class UploadActionTest
                              null, true );
 
         ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
+        content.setRepository( getManagedRepository() );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
 
-        archivaConfigControl.replay();
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
         repoFactoryControl.replay();
 
         MockControl control = mockAuditLogs(
@@ -396,11 +417,10 @@ public class UploadActionTest
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
-        archivaConfigControl.verify();
         repoFactoryControl.verify();
         control.verify();
 
-        String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
+        String repoLocation = getManagedRepository().getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
 
         verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
@@ -416,12 +436,19 @@ public class UploadActionTest
                              null, false );
 
         ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
+        content.setRepository( getManagedRepository() );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
 
-        archivaConfigControl.replay();
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
         repoFactoryControl.replay();
 
         MockControl control =
@@ -430,11 +457,10 @@ public class UploadActionTest
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
-        archivaConfigControl.verify();
         repoFactoryControl.verify();
         control.verify();
 
-        String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
+        String repoLocation = getManagedRepository().getLocation();
         assertTrue(
             new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ).exists() );
         assertTrue(
@@ -492,20 +518,26 @@ public class UploadActionTest
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
                              null, false );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndThrow( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ),
                                            new RepositoryNotFoundException() );
 
-        archivaConfigControl.replay();
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
         repoFactoryControl.replay();
 
         String returnString = uploadAction.doUpload();
         assertEquals( Action.ERROR, returnString );
 
-        archivaConfigControl.verify();
         repoFactoryControl.verify();
 
-        String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
+        String repoLocation = getManagedRepository().getLocation();
         assertFalse(
             new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0/artifact-upload-1.0.jar" ).exists() );
 
@@ -524,12 +556,19 @@ public class UploadActionTest
                              null, true );
 
         ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
+        content.setRepository( getManagedRepository() );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
 
-        archivaConfigControl.replay();
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2, 5 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
         repoFactoryControl.replay();
 
         SimpleDateFormat fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
@@ -542,11 +581,10 @@ public class UploadActionTest
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
-        archivaConfigControl.verify();
         repoFactoryControl.verify();
         control.verify();
 
-        String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
+        String repoLocation = getManagedRepository().getLocation();
         String[] artifactsList = new File( repoLocation, "/org/apache/archiva/artifact-upload/1.0-SNAPSHOT/" ).list();
         Arrays.sort( artifactsList );
 
@@ -584,7 +622,6 @@ public class UploadActionTest
         String buildnumber = StringUtils.substringAfterLast( timestampPath, "-" );
         assertEquals( "Incorrect build number in filename.", "1", buildnumber );
 
-        archivaConfigControl.reset();
         repoFactoryControl.reset();
         control.reset();
 
@@ -596,10 +633,8 @@ public class UploadActionTest
                                                              "target/test-classes/upload-artifact-test/artifact-to-be-uploaded.jar" ),
                              null, true );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
 
-        archivaConfigControl.replay();
         repoFactoryControl.replay();
 
         fmt = new SimpleDateFormat( "yyyyMMdd.HHmmss" );
@@ -613,7 +648,6 @@ public class UploadActionTest
         returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
-        archivaConfigControl.verify();
         repoFactoryControl.verify();
         control.verify();
 
@@ -654,26 +688,31 @@ public class UploadActionTest
                              null, true );
 
         ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( REPOSITORY_ID );
+        ManagedRepository repoConfig = getManagedRepository();
         repoConfig.setBlockRedeployments( false );
-        content.setRepository( getManagedRepository( repoConfig ) );
+        content.setRepository( repoConfig );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
 
-        archivaConfigControl.replay();
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 repoConfig, 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2, 5 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
+
         repoFactoryControl.replay();
 
         String returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
-        archivaConfigControl.verify();
         repoFactoryControl.verify();
 
-        archivaConfigControl.reset();
         repoFactoryControl.reset();
 
-        String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
+        String repoLocation = getManagedRepository().getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
 
         verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
@@ -685,10 +724,8 @@ public class UploadActionTest
                                                     "target/test-classes/upload-artifact-test/artifact-to-be-reuploaded.jar" ),
                              null, true );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
         repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content );
 
-        archivaConfigControl.replay();
         repoFactoryControl.replay();
 
         // TODO: track modifications?
@@ -700,11 +737,10 @@ public class UploadActionTest
         returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
-        archivaConfigControl.verify();
         repoFactoryControl.verify();
         control.verify();
 
-        repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
+        repoLocation = getManagedRepository().getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
 
         verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
@@ -720,12 +756,19 @@ public class UploadActionTest
                              null, true );
 
         ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        content.setRepository( getManagedRepository( config.findManagedRepositoryById( REPOSITORY_ID ) ) );
+        content.setRepository( getManagedRepository() );
+
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 1, 8 );
+
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 getManagedRepository(), 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2, 5 );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 );
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 2 );
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
 
-        archivaConfigControl.replay();
         repoFactoryControl.replay();
 
         String returnString = uploadAction.doUpload();
@@ -740,11 +783,10 @@ public class UploadActionTest
         returnString = uploadAction.doUpload();
         assertEquals( Action.ERROR, returnString );
 
-        archivaConfigControl.verify();
         repoFactoryControl.verify();
         control.verify();
 
-        String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
+        String repoLocation = getManagedRepository().getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
 
         verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
@@ -760,14 +802,21 @@ public class UploadActionTest
                              null, true );
 
         ManagedRepositoryContent content = new ManagedDefaultRepositoryContent();
-        ManagedRepositoryConfiguration repoConfig = config.findManagedRepositoryById( REPOSITORY_ID );
+        ManagedRepository repoConfig = getManagedRepository();
         repoConfig.setBlockRedeployments( false );
-        content.setRepository( getManagedRepository( repoConfig ) );
+        content.setRepository( repoConfig );
 
-        archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config, 2 );
-        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 2 );
+        repoFactoryControl.expectAndReturn( repoFactory.getManagedRepositoryContent( REPOSITORY_ID ), content, 1, 8 );
+
+        managedRepoAdminControl.expectAndReturn( managedRepositoryAdmin.getManagedRepository( REPOSITORY_ID ),
+                                                 repoConfig, 1, 8 );
+
+        archivaAdminControl.expectAndReturn( archivaAdministration.getKnownContentConsumers(), new ArrayList<String>(),
+                                             2, 5 );
+
+        managedRepoAdminControl.replay();
+        archivaAdminControl.replay();
 
-        archivaConfigControl.replay();
         repoFactoryControl.replay();
 
         String returnString = uploadAction.doUpload();
@@ -786,11 +835,10 @@ public class UploadActionTest
         returnString = uploadAction.doUpload();
         assertEquals( Action.SUCCESS, returnString );
 
-        archivaConfigControl.verify();
         repoFactoryControl.verify();
         control.verify();
 
-        String repoLocation = config.findManagedRepositoryById( REPOSITORY_ID ).getLocation();
+        String repoLocation = getManagedRepository().getLocation();
         assertAllArtifactsIncludingSupportArtifactsArePresent( repoLocation, "artifact-upload-1.0", "1.0" );
 
         verifyArtifactChecksums( repoLocation, "artifact-upload-1.0", "1.0" );
@@ -798,8 +846,9 @@ public class UploadActionTest
         verifyProjectMetadataChecksums( repoLocation );
     }
 
-    ManagedRepository getManagedRepository( ManagedRepositoryConfiguration conf )
+    ManagedRepository getManagedRepository()
     {
-        return new BeanReplicator().replicateBean( conf, ManagedRepository.class );
+        return new BeanReplicator().replicateBean( this.managedRepository, ManagedRepository.class );
     }
+
 }