]> source.dussan.org Git - archiva.git/blob
aa4acc2de7235050593364392d666f6006ab9190
[archiva.git] /
1 package org.apache.archiva.web.xmlrpc.services;
2
3 /*
4  * Licensed to the Apache Software Foundation (ASF) under one
5  * or more contributor license agreements.  See the NOTICE file
6  * distributed with this work for additional information
7  * regarding copyright ownership.  The ASF licenses this file
8  * to you under the Apache License, Version 2.0 (the
9  * "License"); you may not use this file except in compliance
10  * with the License.  You may obtain a copy of the License at
11  *
12  *   http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing,
15  * software distributed under the License is distributed on an
16  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17  * KIND, either express or implied.  See the License for the
18  * specific language governing permissions and limitations
19  * under the License.
20  */
21
22 import java.util.ArrayList;
23 import java.util.List;
24
25 import org.apache.archiva.web.xmlrpc.api.AdministrationService;
26 import org.apache.archiva.web.xmlrpc.api.beans.ManagedRepository;
27 import org.apache.archiva.web.xmlrpc.api.beans.RemoteRepository;
28 import org.apache.maven.archiva.configuration.ArchivaConfiguration;
29 import org.apache.maven.archiva.configuration.Configuration;
30 import org.apache.maven.archiva.configuration.DatabaseScanningConfiguration;
31 import org.apache.maven.archiva.configuration.ManagedRepositoryConfiguration;
32 import org.apache.maven.archiva.configuration.RemoteRepositoryConfiguration;
33 import org.apache.maven.archiva.configuration.RepositoryScanningConfiguration;
34 import org.apache.maven.archiva.consumers.DatabaseCleanupConsumer;
35 import org.apache.maven.archiva.consumers.DatabaseUnprocessedArtifactConsumer;
36 import org.apache.maven.archiva.consumers.InvalidRepositoryContentConsumer;
37 import org.apache.maven.archiva.consumers.KnownRepositoryContentConsumer;
38 import org.apache.maven.archiva.database.updater.DatabaseConsumers;
39 import org.apache.maven.archiva.repository.scanner.RepositoryContentConsumers;
40 import org.apache.maven.archiva.scheduled.ArchivaTaskScheduler;
41 import org.apache.maven.archiva.scheduled.tasks.DatabaseTask;
42 import org.apache.maven.archiva.scheduled.tasks.RepositoryTask;
43 import org.codehaus.plexus.spring.PlexusInSpringTestCase;
44 import org.easymock.MockControl;
45 import org.easymock.classextension.MockClassControl;
46
47 /**
48  * AdministrationServiceImplTest
49  * 
50  * @version $Id: AdministrationServiceImplTest.java
51  */
52 public class AdministrationServiceImplTest
53     extends PlexusInSpringTestCase
54 {    
55     private MockControl archivaConfigControl;
56     
57     private ArchivaConfiguration archivaConfig;
58     
59     private MockControl configControl;
60     
61     private Configuration config;
62     
63     private AdministrationServiceImpl service;
64     
65     private MockControl taskSchedulerControl;
66     
67     private ArchivaTaskScheduler taskScheduler;
68     
69     // repository consumers
70     private MockControl repoConsumerUtilsControl;
71     
72     private RepositoryContentConsumers repoConsumersUtil;
73     
74     private MockControl knownContentConsumerControl;
75
76     private MockControl invalidContentConsumerControl;
77
78     private KnownRepositoryContentConsumer indexArtifactConsumer;
79
80     private KnownRepositoryContentConsumer indexPomConsumer;
81
82     private InvalidRepositoryContentConsumer checkPomConsumer;
83
84     private InvalidRepositoryContentConsumer checkMetadataConsumer;
85     
86     // database consumers
87     private MockControl dbConsumersUtilControl;
88     
89     private DatabaseConsumers dbConsumersUtil;
90     
91     private MockControl unprocessedConsumersControl;
92     
93     private MockControl cleanupConsumersControl;
94     
95     private DatabaseUnprocessedArtifactConsumer processArtifactConsumer;
96     
97     private DatabaseUnprocessedArtifactConsumer processPomConsumer;
98     
99     private DatabaseCleanupConsumer cleanupIndexConsumer;
100     
101     private DatabaseCleanupConsumer cleanupDbConsumer;
102         
103     protected void setUp()
104         throws Exception
105     {
106         super.setUp();
107         
108         archivaConfigControl = MockControl.createControl( ArchivaConfiguration.class );
109         archivaConfig = ( ArchivaConfiguration ) archivaConfigControl.getMock();
110         
111         configControl = MockClassControl.createControl( Configuration.class );
112         config = ( Configuration ) configControl.getMock();      
113         
114         taskSchedulerControl = MockControl.createControl( ArchivaTaskScheduler.class );
115         taskScheduler = ( ArchivaTaskScheduler ) taskSchedulerControl.getMock();
116         
117         // repo consumers
118         repoConsumerUtilsControl = MockClassControl.createControl( RepositoryContentConsumers.class );
119         repoConsumersUtil = ( RepositoryContentConsumers ) repoConsumerUtilsControl.getMock();
120         
121         knownContentConsumerControl = MockControl.createControl( KnownRepositoryContentConsumer.class );
122         indexArtifactConsumer = ( KnownRepositoryContentConsumer ) knownContentConsumerControl.getMock();
123         indexPomConsumer = ( KnownRepositoryContentConsumer ) knownContentConsumerControl.getMock();
124         
125         invalidContentConsumerControl = MockControl.createControl( InvalidRepositoryContentConsumer.class );
126         checkPomConsumer = ( InvalidRepositoryContentConsumer ) invalidContentConsumerControl.getMock();
127         checkMetadataConsumer = ( InvalidRepositoryContentConsumer ) invalidContentConsumerControl.getMock();
128         
129         // db consumers
130         dbConsumersUtilControl = MockClassControl.createControl( DatabaseConsumers.class );
131         dbConsumersUtil = ( DatabaseConsumers ) dbConsumersUtilControl.getMock();
132                 
133         cleanupConsumersControl = MockControl.createControl( DatabaseCleanupConsumer.class );
134         cleanupIndexConsumer = ( DatabaseCleanupConsumer ) cleanupConsumersControl.getMock();
135         cleanupDbConsumer = ( DatabaseCleanupConsumer ) cleanupConsumersControl.getMock();
136         
137         unprocessedConsumersControl = MockControl.createControl( DatabaseUnprocessedArtifactConsumer.class );
138         processArtifactConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock();
139         processPomConsumer = ( DatabaseUnprocessedArtifactConsumer ) unprocessedConsumersControl.getMock();
140         
141         service = new AdministrationServiceImpl();
142         service.setArchivaConfiguration( archivaConfig );
143         service.setRepoConsumersUtil( repoConsumersUtil );     
144         service.setDbConsumersUtil( dbConsumersUtil );
145     }
146   
147 /* Tests for database consumers  */
148     
149     public void testGetAllDbConsumers()
150         throws Exception
151     {   
152         recordDbConsumers();
153         
154         dbConsumersUtilControl.replay();
155         cleanupConsumersControl.replay();
156         unprocessedConsumersControl.replay();
157         
158         List<String> dbConsumers = service.getAllDatabaseConsumers();
159         
160         dbConsumersUtilControl.verify();
161         cleanupConsumersControl.verify();
162         unprocessedConsumersControl.verify();
163         
164         assertNotNull( dbConsumers );
165         assertEquals( 4, dbConsumers.size() );
166         assertTrue( dbConsumers.contains( "cleanup-index" ) );
167         assertTrue( dbConsumers.contains( "cleanup-database" ) );
168         assertTrue( dbConsumers.contains( "process-artifact" ) );
169         assertTrue( dbConsumers.contains( "process-pom" ) );
170     }
171     
172     public void testConfigureValidDatabaseConsumer()
173         throws Exception
174     {
175         DatabaseScanningConfiguration dbScanning = new DatabaseScanningConfiguration();
176         dbScanning.addCleanupConsumer( "cleanup-index" );
177         dbScanning.addCleanupConsumer( "cleanup-database" );
178         dbScanning.addUnprocessedConsumer( "process-artifact" );
179         
180         recordDbConsumers();
181         
182      // test enable "process-pom" db consumer
183         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
184         configControl.expectAndReturn( config.getDatabaseScanning(), dbScanning );
185         
186         config.setDatabaseScanning( dbScanning );
187         configControl.setMatcher( MockControl.ALWAYS_MATCHER );
188         configControl.setVoidCallable();
189         
190         archivaConfig.save( config );
191         archivaConfigControl.setVoidCallable();
192         
193         dbConsumersUtilControl.replay();
194         cleanupConsumersControl.replay();
195         unprocessedConsumersControl.replay();
196         archivaConfigControl.replay();
197         configControl.replay();
198         
199         try
200         {
201             boolean success = service.configureDatabaseConsumer( "process-pom", true );
202             assertTrue( success );
203         }
204         catch ( Exception e )
205         {
206             fail( "An exception should not have been thrown." );
207         }
208         
209         dbConsumersUtilControl.verify();
210         cleanupConsumersControl.verify();
211         unprocessedConsumersControl.verify();
212         archivaConfigControl.verify();
213         configControl.verify();
214                 
215       // test disable "process-pom" db consumer        
216         dbConsumersUtilControl.reset();
217         cleanupConsumersControl.reset();
218         unprocessedConsumersControl.reset();
219         archivaConfigControl.reset();
220         configControl.reset();
221                 
222         dbScanning.addUnprocessedConsumer( "process-pom" );
223         
224         recordDbConsumers();
225         
226         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
227         configControl.expectAndReturn( config.getDatabaseScanning(), dbScanning );
228         
229         config.setDatabaseScanning( dbScanning );
230         configControl.setMatcher( MockControl.ALWAYS_MATCHER );
231         configControl.setVoidCallable();
232         
233         archivaConfig.save( config );
234         archivaConfigControl.setVoidCallable();
235         
236         dbConsumersUtilControl.replay();
237         cleanupConsumersControl.replay();
238         unprocessedConsumersControl.replay();
239         archivaConfigControl.replay();
240         configControl.replay();
241         
242         try
243         {
244             boolean success = service.configureDatabaseConsumer( "process-pom", false );
245             assertTrue( success );
246         }
247         catch ( Exception e )
248         {
249             fail( "An exception should not have been thrown." );
250         }
251         
252         dbConsumersUtilControl.verify();
253         cleanupConsumersControl.verify();
254         unprocessedConsumersControl.verify();
255         archivaConfigControl.verify();
256         configControl.verify();
257     }
258     
259     public void testConfigureInvalidDatabaseConsumer()
260         throws Exception
261     {
262         recordDbConsumers();
263         
264         dbConsumersUtilControl.replay();
265         cleanupConsumersControl.replay();
266         unprocessedConsumersControl.replay();
267         
268         try
269         {
270             service.configureDatabaseConsumer( "invalid-consumer", true );
271             fail( "An exception should have been thrown." );
272         }
273         catch ( Exception e )
274         {
275             assertEquals( "Invalid database consumer.", e.getMessage() );
276         }
277         
278         dbConsumersUtilControl.verify();
279         cleanupConsumersControl.verify();
280         unprocessedConsumersControl.verify();
281     }
282         
283 /* Tests for repository consumers  */
284     
285     public void testGetAllRepoConsumers()
286         throws Exception
287     {   
288         recordRepoConsumers();
289         
290         repoConsumerUtilsControl.replay();
291         knownContentConsumerControl.replay();
292         invalidContentConsumerControl.replay();
293                 
294         List<String> repoConsumers = service.getAllRepositoryConsumers(); 
295         
296         repoConsumerUtilsControl.verify();
297         knownContentConsumerControl.verify();
298         invalidContentConsumerControl.verify();
299                         
300         assertNotNull( repoConsumers );
301         assertEquals( 4, repoConsumers.size() );
302         assertTrue( repoConsumers.contains( "index-artifact" ) );
303         assertTrue( repoConsumers.contains( "index-pom" ) );
304         assertTrue( repoConsumers.contains( "check-pom" ) );
305         assertTrue( repoConsumers.contains( "check-metadata" ) );
306     }
307     
308     public void testConfigureValidRepositoryConsumer()
309         throws Exception
310     {   
311         RepositoryScanningConfiguration repoScanning = new RepositoryScanningConfiguration();
312         repoScanning.addKnownContentConsumer( "index-artifact" );
313         repoScanning.addKnownContentConsumer( "index-pom" );
314         repoScanning.addInvalidContentConsumer( "check-pom" );        
315         
316      // test enable "check-metadata" consumer
317         recordRepoConsumers();
318         
319         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
320         configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning );
321         
322         config.setRepositoryScanning( repoScanning );                
323         configControl.setMatcher( MockControl.ALWAYS_MATCHER );
324         configControl.setVoidCallable();
325         
326         archivaConfig.save( config );
327         archivaConfigControl.setVoidCallable();
328                 
329         repoConsumerUtilsControl.replay();
330         knownContentConsumerControl.replay();
331         invalidContentConsumerControl.replay();
332         archivaConfigControl.replay();
333         configControl.replay();        
334         
335         try
336         {
337             boolean success = service.configureRepositoryConsumer( null, "check-metadata", true );
338             assertTrue( success );
339         }
340         catch ( Exception e )
341         {
342             fail( "An exception should not have been thrown." );
343         }
344         
345         repoConsumerUtilsControl.verify();
346         knownContentConsumerControl.verify();
347         invalidContentConsumerControl.verify();        
348         archivaConfigControl.verify();
349         configControl.verify();
350                 
351      // test disable "check-metadata" consumer 
352         repoConsumerUtilsControl.reset();
353         knownContentConsumerControl.reset();
354         invalidContentConsumerControl.reset();        
355         archivaConfigControl.reset();
356         configControl.reset();
357         
358         repoScanning.addInvalidContentConsumer( "check-metadata" );
359
360         recordRepoConsumers();
361         
362         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
363         configControl.expectAndReturn( config.getRepositoryScanning(), repoScanning );
364         
365         config.setRepositoryScanning( repoScanning );
366         configControl.setMatcher( MockControl.ALWAYS_MATCHER );
367         configControl.setVoidCallable();
368         
369         archivaConfig.save( config );
370         archivaConfigControl.setVoidCallable();
371                 
372         repoConsumerUtilsControl.replay();
373         knownContentConsumerControl.replay();
374         invalidContentConsumerControl.replay();
375         archivaConfigControl.replay();
376         configControl.replay();
377         
378         try
379         {
380             boolean success = service.configureRepositoryConsumer( null, "check-metadata", false );
381             
382             repoConsumerUtilsControl.verify();
383             knownContentConsumerControl.verify();
384             invalidContentConsumerControl.verify();        
385             archivaConfigControl.verify();
386             configControl.verify();
387             
388             assertTrue( success );
389         }
390         catch ( Exception e )
391         {
392             fail( "An excecption should not have been thrown." );
393         }     
394     }
395  
396     
397     public void testConfigureInvalidRepositoryConsumer()
398         throws Exception
399     {
400         recordRepoConsumers();
401         
402         repoConsumerUtilsControl.replay();
403         knownContentConsumerControl.replay();
404         invalidContentConsumerControl.replay();
405         
406         try
407         {
408             service.configureRepositoryConsumer( null, "invalid-consumer", true );
409             fail( "An exception should have been thrown." );
410         }
411         catch ( Exception e )
412         {
413             assertEquals( "Invalid repository consumer.", e.getMessage() );
414         }
415         
416         repoConsumerUtilsControl.verify();
417         knownContentConsumerControl.verify();
418         invalidContentConsumerControl.verify(); 
419     }
420
421 /* Tests for delete artifact  */
422     
423     /*   public void testDeleteArtifactArtifactExists()
424         throws Exception
425     {
426         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
427         configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ),
428                                        createManagedRepo( "internal", "default", "Internal Repository", true, false ) );
429         
430         // TODO 
431         // - mock checking of artifact existence in the repo
432         // - mock artifact delete
433         
434         archivaConfigControl.replay();
435         configControl.replay();
436        
437         try
438         {
439             boolean success = service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" );
440             assertTrue( success ); 
441         }
442         catch ( Exception e )
443         {
444             fail( "An exception should not have been thrown." );
445         }
446         
447         archivaConfigControl.verify();
448         configControl.verify();
449     }
450     
451     public void testDeleteArtifactArtifactDoesNotExist()
452         throws Exception
453     {
454         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
455         configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ),
456                                        createManagedRepo( "internal", "default", "Internal Repository", true, false ) );
457         
458         // TODO mock checking of artifact existence in the repo
459         
460         archivaConfigControl.replay();
461         configControl.replay();
462        
463         try
464         {
465             service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" );
466             fail( "An exception should have been thrown." );
467         }
468         catch ( Exception e )
469         {
470             assertEquals( "Artifact does not exist.", e.getMessage() );
471         }
472         
473         archivaConfigControl.verify();
474         configControl.verify();
475     }
476     
477     public void testDeleteArtifacRepositoryDoesNotExist()
478         throws Exception
479     {
480         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
481         configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), null );
482         
483         archivaConfigControl.replay();
484         configControl.replay();
485        
486         try
487         {
488             service.deleteArtifact( "internal", "org.apache.archiva", "archiva-test", "1.0" );
489             fail( "An exception should have been thrown." );
490         }
491         catch ( Exception e )
492         {
493             assertEquals( "Repository does not exist.", e.getMessage() );
494         }
495         
496         archivaConfigControl.verify();
497         configControl.verify();
498     }
499     
500 // REPO SCANNING
501     
502     public void testExecuteRepoScannerRepoExists()
503         throws Exception
504     {        
505         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
506         configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ),
507                                        createManagedRepo( "internal", "default", "Internal Repository", true, false ) );
508         
509         RepositoryTask task = new RepositoryTask();
510         
511         taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingAnyRepositoryTask(), false );
512         taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingRepositoryTask( "internal" ), false );
513         
514         taskScheduler.queueRepositoryTask( task );
515         taskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER );
516         taskSchedulerControl.setVoidCallable();
517         
518         archivaConfigControl.replay();
519         configControl.replay();
520         taskSchedulerControl.replay();
521
522         try
523         {
524             boolean success = service.executeRepositoryScanner( "internal" );
525             assertTrue( success );
526         }
527         catch ( Exception e )
528         {
529             fail( "An exception should not have been thrown." );
530         }
531         
532         archivaConfigControl.verify();
533         configControl.verify();
534         taskSchedulerControl.verify();
535     }
536     
537     public void testExecuteRepoScannerRepoDoesNotExist()
538         throws Exception
539     {
540         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
541         configControl.expectAndReturn( config.findManagedRepositoryById( "internal" ), null );
542         
543         archivaConfigControl.replay();
544         configControl.replay();
545        
546         try
547         {
548             service.executeRepositoryScanner( "internal" );
549             fail( "An exception should have been thrown." );
550         }
551         catch ( Exception e )
552         {
553             assertEquals( "Repository does not exist.", e.getMessage() );
554         }
555         
556         archivaConfigControl.verify();
557         configControl.verify();
558     }
559     
560  // DATABASE SCANNING
561     
562     public void testExecuteDbScanner()
563         throws Exception
564     {
565         DatabaseTask task = new DatabaseTask();
566         
567         taskSchedulerControl.expectAndReturn( taskScheduler.isProcessingDatabaseTask(), false );
568                 
569         taskScheduler.queueDatabaseTask( task );
570         taskSchedulerControl.setMatcher( MockControl.ALWAYS_MATCHER );
571         taskSchedulerControl.setVoidCallable();
572         
573         taskSchedulerControl.replay();
574
575         boolean success = service.executeDatabaseScanner();
576         
577         taskSchedulerControl.verify();        
578         
579         assertTrue( success );
580     }
581      
582  // REPOSITORIES
583     
584     public void testGetAllManagedRepositories()
585         throws Exception
586     {
587         List<ManagedRepositoryConfiguration> managedRepos = new ArrayList<ManagedRepositoryConfiguration>();        
588         managedRepos.add( createManagedRepo( "internal", "default", "Internal Repository", true, false ) );
589         managedRepos.add( createManagedRepo( "snapshots", "default", "Snapshots Repository", false, true ) );
590         
591         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
592         configControl.expectAndReturn( config.getManagedRepositories(), managedRepos );
593         
594         archivaConfigControl.replay();
595         configControl.replay();
596         
597         List<ManagedRepository> repos = service.getAllManagedRepositories(); 
598         
599         archivaConfigControl.verify();
600         configControl.verify();
601         
602         assertNotNull( repos );
603         assertEquals( 2, repos.size() );
604                 
605         assertManagedRepo( ( ManagedRepository ) repos.get( 0 ), managedRepos.get( 0 ) );
606         assertManagedRepo( ( ManagedRepository ) repos.get( 1 ), managedRepos.get( 1 ) );
607     }
608
609     public void testGetAllRemoteRepositories()
610         throws Exception
611     {
612         List<RemoteRepositoryConfiguration> remoteRepos = new ArrayList<RemoteRepositoryConfiguration>(); 
613         remoteRepos.add( createRemoteRepository( "central", "Central Repository", "default", "http://repo1.maven.org/maven2") );
614         remoteRepos.add( createRemoteRepository( "dummy", "Dummy Remote Repository", "legacy", "http://dummy.com/dummy") );
615         
616         archivaConfigControl.expectAndReturn( archivaConfig.getConfiguration(), config );
617         configControl.expectAndReturn( config.getRemoteRepositories(), remoteRepos );
618         
619         archivaConfigControl.replay();
620         configControl.replay();
621         
622         List<RemoteRepository> repos = service.getAllRemoteRepositories(); 
623         
624         archivaConfigControl.verify();
625         configControl.verify();
626         
627         assertNotNull( repos );
628         assertEquals( 2, repos.size() );
629          
630         assertRemoteRepo( (RemoteRepository) repos.get( 0 ), remoteRepos.get( 0 ) );
631         assertRemoteRepo( (RemoteRepository) repos.get( 1 ), remoteRepos.get( 1 ) );        
632     }
633 */
634     private void assertRemoteRepo( RemoteRepository remoteRepo, RemoteRepositoryConfiguration expectedRepoConfig )
635     {
636         assertEquals( expectedRepoConfig.getId(), remoteRepo.getId() );
637         assertEquals( expectedRepoConfig.getLayout(), remoteRepo.getLayout() );
638         assertEquals( expectedRepoConfig.getName(), remoteRepo.getName() );
639         assertEquals( expectedRepoConfig.getUrl(), remoteRepo.getUrl() );       
640     }
641     
642     private RemoteRepositoryConfiguration createRemoteRepository(String id, String name, String layout, String url)
643     {
644         RemoteRepositoryConfiguration remoteConfig = new RemoteRepositoryConfiguration();
645         remoteConfig.setId( id );
646         remoteConfig.setName( name );
647         remoteConfig.setLayout( layout );
648         remoteConfig.setUrl( url );
649         
650         return remoteConfig;
651     }
652     
653     private void assertManagedRepo( ManagedRepository managedRepo, ManagedRepositoryConfiguration expectedRepoConfig )
654     {
655         assertEquals( expectedRepoConfig.getId(), managedRepo.getId() );
656         assertEquals( expectedRepoConfig.getLayout(), managedRepo.getLayout() );
657         assertEquals( expectedRepoConfig.getName(), managedRepo.getName() );
658         assertEquals( "http://localhost:8080/archiva/repository/" + expectedRepoConfig.getId(), managedRepo.getUrl() );
659         assertEquals( expectedRepoConfig.isReleases(), managedRepo.isReleases() );
660         assertEquals( expectedRepoConfig.isSnapshots(), managedRepo.isSnapshots() );
661     }
662
663     private ManagedRepositoryConfiguration createManagedRepo( String id, String layout, String name,
664                                                               boolean hasReleases, boolean hasSnapshots )
665     {
666         ManagedRepositoryConfiguration repoConfig = new ManagedRepositoryConfiguration();
667         repoConfig.setId( id );
668         repoConfig.setLayout( layout );
669         repoConfig.setName( name );
670         repoConfig.setReleases( hasReleases );
671         repoConfig.setSnapshots( hasSnapshots );
672         
673         return repoConfig;
674     }
675     
676     private void recordRepoConsumers()
677     {
678         List<KnownRepositoryContentConsumer> availableKnownConsumers = new ArrayList<KnownRepositoryContentConsumer>();
679         availableKnownConsumers.add( indexArtifactConsumer );
680         availableKnownConsumers.add( indexPomConsumer );
681         
682         List<InvalidRepositoryContentConsumer> availableInvalidConsumers = new ArrayList<InvalidRepositoryContentConsumer>();
683         availableInvalidConsumers.add( checkPomConsumer );
684         availableInvalidConsumers.add( checkMetadataConsumer );
685         
686         repoConsumerUtilsControl.expectAndReturn( repoConsumersUtil.getAvailableKnownConsumers(), availableKnownConsumers );
687         knownContentConsumerControl.expectAndReturn( indexArtifactConsumer.getId(), "index-artifact" );
688         knownContentConsumerControl.expectAndReturn( indexPomConsumer.getId(), "index-pom" );
689         
690         repoConsumerUtilsControl.expectAndReturn( repoConsumersUtil.getAvailableInvalidConsumers(), availableInvalidConsumers );
691         invalidContentConsumerControl.expectAndReturn( checkPomConsumer.getId(), "check-pom" );
692         invalidContentConsumerControl.expectAndReturn( checkMetadataConsumer.getId(), "check-metadata" );
693     }
694     
695     private void recordDbConsumers()
696     {
697         List<DatabaseCleanupConsumer> cleanupConsumers = new ArrayList<DatabaseCleanupConsumer>();
698         cleanupConsumers.add( cleanupIndexConsumer );
699         cleanupConsumers.add( cleanupDbConsumer );
700         
701         List<DatabaseUnprocessedArtifactConsumer> unprocessedConsumers =
702             new ArrayList<DatabaseUnprocessedArtifactConsumer>();
703         unprocessedConsumers.add( processArtifactConsumer );
704         unprocessedConsumers.add( processPomConsumer );
705         
706         dbConsumersUtilControl.expectAndReturn( dbConsumersUtil.getAvailableCleanupConsumers(), cleanupConsumers );
707         cleanupConsumersControl.expectAndReturn( cleanupIndexConsumer.getId(), "cleanup-index" );
708         cleanupConsumersControl.expectAndReturn( cleanupDbConsumer.getId(), "cleanup-database" );
709         
710         dbConsumersUtilControl.expectAndReturn( dbConsumersUtil.getAvailableUnprocessedConsumers(), unprocessedConsumers );
711         unprocessedConsumersControl.expectAndReturn( processArtifactConsumer.getId(), "process-artifact" );
712         unprocessedConsumersControl.expectAndReturn( processPomConsumer.getId(), "process-pom" );
713     }    
714 }