1 package org.apache.archiva.web.action.admin.repositories;
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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
22 import com.opensymphony.xwork2.Action;
23 import org.apache.archiva.admin.model.RepositoryAdminException;
24 import org.apache.archiva.admin.model.beans.ManagedRepository;
25 import org.apache.archiva.admin.repository.DefaultRepositoryCommonValidator;
26 import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
27 import org.apache.archiva.audit.AuditListener;
28 import org.apache.archiva.configuration.ArchivaConfiguration;
29 import org.apache.archiva.configuration.Configuration;
30 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
31 import org.apache.archiva.metadata.repository.MetadataRepository;
32 import org.apache.archiva.metadata.repository.RepositorySession;
33 import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
34 import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
35 import org.apache.archiva.scheduler.repository.RepositoryTask;
36 import org.apache.archiva.security.common.ArchivaRoleConstants;
37 import org.apache.archiva.web.validator.utils.ValidatorUtil;
38 import org.apache.archiva.webtest.memory.TestRepositorySessionFactory;
39 import org.apache.commons.io.FileUtils;
40 import org.codehaus.plexus.redback.role.RoleManager;
41 import org.codehaus.plexus.registry.Registry;
42 import org.codehaus.redback.integration.interceptor.SecureActionBundle;
43 import org.codehaus.redback.integration.interceptor.SecureActionException;
44 import org.easymock.MockControl;
45 import org.easymock.classextension.MockClassControl;
48 import java.io.IOException;
49 import java.util.ArrayList;
50 import java.util.HashMap;
51 import java.util.List;
54 import static org.mockito.Mockito.mock;
55 import static org.mockito.Mockito.when;
58 * EditManagedRepositoryActionTest
62 public class EditManagedRepositoryActionTest
63 extends AbstractManagedRepositoryActionTest
65 private EditManagedRepositoryAction action;
67 private RoleManager roleManager;
69 private MockControl roleManagerControl;
71 private MockControl archivaConfigurationControl;
73 private ArchivaConfiguration archivaConfiguration;
75 private Registry registry;
77 private MockControl registryControl;
79 private MetadataRepository metadataRepository;
81 private MockControl repositoryTaskSchedulerControl;
83 private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
86 protected void setUp()
91 action = new EditManagedRepositoryAction();
93 archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
94 archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
96 roleManagerControl = MockControl.createControl( RoleManager.class );
97 roleManager = (RoleManager) roleManagerControl.getMock();
99 registryControl = MockControl.createControl( Registry.class );
100 registry = (Registry) registryControl.getMock();
102 repositoryTaskSchedulerControl = MockClassControl.createControl( RepositoryArchivaTaskScheduler.class );
103 repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) repositoryTaskSchedulerControl.getMock();
105 location = new File( "target/test/location" );
107 metadataRepository = mock( MetadataRepository.class );
108 RepositorySession repositorySession = mock( RepositorySession.class );
109 when( repositorySession.getRepository() ).thenReturn( metadataRepository );
110 TestRepositorySessionFactory factory = applicationContext.getBean( TestRepositorySessionFactory.class );
111 factory.setRepositorySession( repositorySession );
113 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfiguration );
114 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRoleManager( roleManager );
115 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryTaskScheduler(
116 repositoryTaskScheduler );
117 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositorySessionFactory( factory );
119 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRegistry( registry );
121 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setAuditListeners(
122 new ArrayList<AuditListener>( 0 ) );
124 DefaultRepositoryCommonValidator defaultRepositoryCommonValidator = new DefaultRepositoryCommonValidator();
125 defaultRepositoryCommonValidator.setArchivaConfiguration( archivaConfiguration );
126 defaultRepositoryCommonValidator.setRegistry( registry );
128 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryCommonValidator(
129 defaultRepositoryCommonValidator );
131 action.setRepositoryCommonValidator( defaultRepositoryCommonValidator );
133 action.setManagedRepositoryAdmin( getManagedRepositoryAdmin() );
137 public void testSecureActionBundle()
138 throws SecureActionException, RepositoryAdminException
140 archivaConfiguration.getConfiguration();
141 archivaConfigurationControl.setReturnValue( new Configuration() );
142 archivaConfigurationControl.replay();
145 SecureActionBundle bundle = action.getSecureActionBundle();
146 assertTrue( bundle.requiresAuthentication() );
147 assertEquals( 1, bundle.getAuthorizationTuples().size() );
150 public void testEditRepositoryInitialPage()
153 Configuration configuration = createConfigurationForEditing( createRepository() );
155 archivaConfiguration.getConfiguration();
156 archivaConfigurationControl.setReturnValue( configuration );
157 Configuration stageRepoConfiguration = new Configuration();
158 stageRepoConfiguration.addManagedRepository( createStagingRepository() );
159 archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
161 archivaConfigurationControl.replay();
163 action.setRepoid( REPO_ID );
166 assertEquals( REPO_ID, action.getRepoid() );
167 ManagedRepository repository = action.getRepository();
168 assertNotNull( repository );
170 ManagedRepository newRepository = createRepository();
171 assertRepositoryEquals( repository, newRepository );
172 assertEquals( repository.getLocation(), newRepository.getLocation() );
174 String status = action.input();
175 assertEquals( Action.INPUT, status );
176 repository = action.getRepository();
177 assertRepositoryEquals( repository, createRepository() );
180 public void testEditRepository()
183 String stageRepoId = REPO_ID + "-stage";
185 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
186 roleManagerControl.setReturnValue( false );
187 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
188 roleManagerControl.setVoidCallable();
190 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
191 roleManagerControl.setReturnValue( false );
192 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
193 roleManagerControl.setVoidCallable();
195 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, stageRepoId );
196 roleManagerControl.setReturnValue( false );
197 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, stageRepoId );
198 roleManagerControl.setVoidCallable();
200 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, stageRepoId );
201 roleManagerControl.setReturnValue( false );
202 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, stageRepoId );
203 roleManagerControl.setVoidCallable();
205 roleManagerControl.replay();
207 registry.getString( "appserver.base", "${appserver.base}" );
208 registryControl.setReturnValue( "target/test", 1, 3 );
209 registry.getString( "appserver.home", "${appserver.home}" );
210 registryControl.setReturnValue( "target/test", 1, 3 );
212 registryControl.replay();
214 RepositoryTask task = new RepositoryTask();
215 task.setRepositoryId( REPO_ID );
216 repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
217 repositoryTaskSchedulerControl.setReturnValue( false );
218 repositoryTaskScheduler.queueTask( task );
219 repositoryTaskSchedulerControl.setVoidCallable();
221 RepositoryTask stageTask = new RepositoryTask();
222 stageTask.setRepositoryId( stageRepoId );
223 repositoryTaskScheduler.isProcessingRepositoryTask( stageRepoId );
224 repositoryTaskSchedulerControl.setReturnValue( false );
225 repositoryTaskScheduler.queueTask( stageTask );
226 repositoryTaskSchedulerControl.setVoidCallable();
228 repositoryTaskSchedulerControl.replay();
230 Configuration configuration = createConfigurationForEditing( createRepository() );
231 archivaConfiguration.getConfiguration();
232 archivaConfigurationControl.setReturnValue( configuration );
233 archivaConfigurationControl.setReturnValue( configuration );
234 archivaConfigurationControl.setReturnValue( configuration );
236 archivaConfigurationControl.setReturnValue( configuration );
237 archivaConfigurationControl.setReturnValue( configuration );
239 Configuration stageRepoConfiguration = new Configuration();
240 stageRepoConfiguration.addManagedRepository( createStagingRepository() );
241 archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
242 archivaConfigurationControl.setReturnValue( configuration );
243 archivaConfigurationControl.setReturnValue( configuration );
245 archivaConfiguration.save( configuration );
246 archivaConfiguration.save( configuration );
248 archivaConfiguration.save( configuration );
250 archivaConfigurationControl.replay();
252 action.setRepoid( REPO_ID );
254 assertEquals( REPO_ID, action.getRepoid() );
255 ManagedRepository repository = action.getRepository();
256 populateRepository( repository );
257 repository.setName( "new repo name" );
259 MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
260 RepositoryStatisticsManager repositoryStatisticsManager =
261 (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
262 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
263 repositoryStatisticsManager );
265 repositoryStatisticsManagerControl.replay();
267 new File( "target/test/" + REPO_ID + "-stage" ).mkdirs();
269 action.setRepository( repository );
270 action.setStageNeeded( true );
271 String status = action.commit();
272 assertEquals( Action.SUCCESS, status );
274 ManagedRepository newRepository = createRepository();
275 newRepository.setName( "new repo name" );
276 assertRepositoryEquals( repository, newRepository );
277 //assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
278 //assertEquals( location.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
280 roleManagerControl.verify();
281 //archivaConfigurationControl.verify();
282 repositoryStatisticsManagerControl.verify();
283 registryControl.verify();
286 public void testEditRepositoryLocationChanged()
289 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
290 roleManagerControl.setReturnValue( false );
291 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
292 roleManagerControl.setVoidCallable();
294 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
295 roleManagerControl.setReturnValue( false );
296 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
297 roleManagerControl.setVoidCallable();
299 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
300 roleManagerControl.setReturnValue( false );
301 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
302 roleManagerControl.setVoidCallable();
304 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID + "-stage" );
305 roleManagerControl.setReturnValue( false );
306 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID + "-stage" );
307 roleManagerControl.setVoidCallable();
309 roleManagerControl.replay();
311 registry.getString( "appserver.base", "${appserver.base}" );
312 registryControl.setReturnValue( "target/test", 1, 3 );
313 registry.getString( "appserver.home", "${appserver.home}" );
314 registryControl.setReturnValue( "target/test", 1, 3 );
316 registryControl.replay();
318 RepositoryTask task = new RepositoryTask();
319 task.setRepositoryId( REPO_ID );
320 repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
321 repositoryTaskSchedulerControl.setReturnValue( false );
322 repositoryTaskScheduler.queueTask( task );
323 repositoryTaskSchedulerControl.setVoidCallable();
325 repositoryTaskSchedulerControl.replay();
327 Configuration configuration = createConfigurationForEditing( createRepository() );
328 archivaConfiguration.getConfiguration();
329 archivaConfigurationControl.setReturnValue( configuration );
330 archivaConfigurationControl.setReturnValue( configuration );
331 archivaConfigurationControl.setReturnValue( configuration );
332 archivaConfigurationControl.setReturnValue( configuration );
334 archivaConfigurationControl.setReturnValue( configuration );
336 archivaConfigurationControl.setReturnValue( buildEasyConfiguration() );
338 Configuration stageRepoConfiguration = buildEasyConfiguration();
339 stageRepoConfiguration.addManagedRepository( createStagingRepository() );
340 archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
342 archivaConfigurationControl.setReturnValue( configuration );
343 archivaConfigurationControl.setReturnValue( configuration );
345 archivaConfiguration.save( configuration );
346 configuration.addManagedRepository( stageRepoConfiguration.getManagedRepositories().get( 0 ) );
347 archivaConfiguration.save( configuration );
348 archivaConfiguration.save( configuration );
350 archivaConfigurationControl.replay();
352 MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
353 RepositoryStatisticsManager repositoryStatisticsManager =
354 (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
355 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
356 repositoryStatisticsManager );
357 repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
358 repositoryStatisticsManagerControl.replay();
360 new File( "target/test/location/" + REPO_ID + "-stage" ).mkdirs();
362 action.setStageNeeded( true );
363 action.setRepoid( REPO_ID );
365 assertEquals( REPO_ID, action.getRepoid() );
367 ManagedRepository repository = new ManagedRepository();
368 populateRepository( repository );
369 File testFile = new File( "target/test/location/new" );
370 FileUtils.deleteDirectory( testFile );
371 repository.setLocation( "${appserver.base}/location/new" );
372 action.setRepository( repository );
373 String status = action.commit();
374 assertEquals( Action.SUCCESS, status );
375 //assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
376 //assertEquals( testFile.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
378 roleManagerControl.verify();
379 //archivaConfigurationControl.verify();
380 repositoryStatisticsManagerControl.verify();
381 registryControl.verify();
384 public void testStruts2ValidationFrameworkWithNullInputs()
388 // 0 is the default value for primitive int; null for objects
389 ManagedRepository managedRepositoryConfiguration = createManagedRepository( null, null, null, null, 1, 1 );
390 action.setRepository( managedRepositoryConfiguration );
393 actionValidatorManager.validate( action, EMPTY_STRING );
396 assertTrue( action.hasFieldErrors() );
398 Map<String, List<String>> fieldErrors = action.getFieldErrors();
400 // make an expected field error object
401 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
404 List<String> expectedErrorMessages = new ArrayList<String>();
405 expectedErrorMessages.add( "You must enter a repository identifier." );
406 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
408 expectedErrorMessages = new ArrayList<String>();
409 expectedErrorMessages.add( "You must enter a directory." );
410 expectedFieldErrors.put( "repository.location", expectedErrorMessages );
412 expectedErrorMessages = new ArrayList<String>();
413 expectedErrorMessages.add( "You must enter a repository name." );
414 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
416 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
419 public void testStruts2ValidationFrameworkWithBlankInputs()
423 // 0 is the default value for primitive int
424 ManagedRepository managedRepositoryConfiguration =
425 createManagedRepository( EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, 1, 1 );
426 action.setRepository( managedRepositoryConfiguration );
429 actionValidatorManager.validate( action, EMPTY_STRING );
432 assertTrue( action.hasFieldErrors() );
434 Map<String, List<String>> fieldErrors = action.getFieldErrors();
436 // make an expected field error object
437 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
440 List<String> expectedErrorMessages = new ArrayList<String>();
441 expectedErrorMessages.add( "You must enter a repository identifier." );
442 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
444 expectedErrorMessages = new ArrayList<String>();
445 expectedErrorMessages.add( "You must enter a directory." );
446 expectedFieldErrors.put( "repository.location", expectedErrorMessages );
448 expectedErrorMessages = new ArrayList<String>();
449 expectedErrorMessages.add( "You must enter a repository name." );
450 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
452 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
455 public void testStruts2ValidationFrameworkWithInvalidInputs()
459 ManagedRepository managedRepositoryConfiguration =
460 createManagedRepository( REPOSITORY_ID_INVALID_INPUT, REPOSITORY_NAME_INVALID_INPUT,
461 REPOSITORY_LOCATION_INVALID_INPUT, REPOSITORY_INDEX_DIR_INVALID_INPUT,
462 REPOSITORY_DAYS_OLDER_INVALID_INPUT, REPOSITORY_RETENTION_COUNT_INVALID_INPUT );
463 action.setRepository( managedRepositoryConfiguration );
466 actionValidatorManager.validate( action, EMPTY_STRING );
469 assertTrue( action.hasFieldErrors() );
471 Map<String, List<String>> fieldErrors = action.getFieldErrors();
473 // make an expected field error object
474 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
477 List<String> expectedErrorMessages = new ArrayList<String>();
478 expectedErrorMessages.add(
479 "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
480 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
482 expectedErrorMessages = new ArrayList<String>();
483 expectedErrorMessages.add(
484 "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
485 expectedFieldErrors.put( "repository.location", expectedErrorMessages );
487 expectedErrorMessages = new ArrayList<String>();
488 expectedErrorMessages.add(
489 "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
490 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
492 expectedErrorMessages = new ArrayList<String>();
493 expectedErrorMessages.add(
494 "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
495 expectedFieldErrors.put( "repository.indexDirectory", expectedErrorMessages );
497 expectedErrorMessages = new ArrayList<String>();
498 expectedErrorMessages.add( "Repository Purge By Retention Count needs to be between 1 and 100." );
499 expectedFieldErrors.put( "repository.retentionCount", expectedErrorMessages );
501 expectedErrorMessages = new ArrayList<String>();
502 expectedErrorMessages.add( "Repository Purge By Days Older Than needs to be larger than 0." );
503 expectedFieldErrors.put( "repository.daysOlder", expectedErrorMessages );
505 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
508 public void testStruts2ValidationFrameworkWithValidInputs()
512 ManagedRepository managedRepositoryConfiguration =
513 createManagedRepository( REPOSITORY_ID_VALID_INPUT, REPOSITORY_NAME_VALID_INPUT,
514 REPOSITORY_LOCATION_VALID_INPUT, REPOSITORY_INDEX_DIR_VALID_INPUT,
515 REPOSITORY_DAYS_OLDER_VALID_INPUT, REPOSITORY_RETENTION_COUNT_VALID_INPUT );
516 action.setRepository( managedRepositoryConfiguration );
519 actionValidatorManager.validate( action, EMPTY_STRING );
522 assertFalse( action.hasFieldErrors() );
525 private void assertRepositoryEquals( ManagedRepository expectedRepository, ManagedRepository actualRepository )
527 assertEquals( expectedRepository.getDaysOlder(), actualRepository.getDaysOlder() );
528 assertEquals( expectedRepository.getId(), actualRepository.getId() );
529 assertEquals( expectedRepository.getIndexDirectory(), actualRepository.getIndexDirectory() );
530 assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
531 assertEquals( expectedRepository.getName(), actualRepository.getName() );
532 assertEquals( expectedRepository.getCronExpression(), actualRepository.getCronExpression() );
533 assertEquals( expectedRepository.getRetentionCount(), actualRepository.getRetentionCount() );
534 assertEquals( expectedRepository.isDeleteReleasedSnapshots(), actualRepository.isDeleteReleasedSnapshots() );
535 assertEquals( expectedRepository.isScanned(), actualRepository.isScanned() );
536 assertEquals( expectedRepository.isReleases(), actualRepository.isReleases() );
537 assertEquals( expectedRepository.isSnapshots(), actualRepository.isSnapshots() );
540 private Configuration createConfigurationForEditing( ManagedRepository repositoryConfiguration )
543 Configuration configuration = buildEasyConfiguration();
545 ManagedRepositoryConfiguration managedRepositoryConfiguration = new ManagedRepositoryConfiguration();
547 managedRepositoryConfiguration.setDaysOlder( repositoryConfiguration.getDaysOlder() );
548 managedRepositoryConfiguration.setIndexDir( repositoryConfiguration.getIndexDirectory() );
549 managedRepositoryConfiguration.setRetentionCount( repositoryConfiguration.getRetentionCount() );
550 managedRepositoryConfiguration.setBlockRedeployments( repositoryConfiguration.isBlockRedeployments() );
551 managedRepositoryConfiguration.setDeleteReleasedSnapshots(
552 repositoryConfiguration.isDeleteReleasedSnapshots() );
553 managedRepositoryConfiguration.setLocation( repositoryConfiguration.getLocation() );
554 managedRepositoryConfiguration.setRefreshCronExpression( repositoryConfiguration.getCronExpression() );
555 managedRepositoryConfiguration.setReleases( repositoryConfiguration.isReleases() );
556 managedRepositoryConfiguration.setScanned( repositoryConfiguration.isScanned() );
557 managedRepositoryConfiguration.setId( repositoryConfiguration.getId() );
558 managedRepositoryConfiguration.setName( repositoryConfiguration.getName() );
559 managedRepositoryConfiguration.setLayout( repositoryConfiguration.getLayout() );
561 configuration.addManagedRepository( managedRepositoryConfiguration );
562 return configuration;
565 // easy configuration for hashCode/equals
566 private Configuration buildEasyConfiguration()
568 return new Configuration()
571 public int hashCode()
573 return getManagedRepositories().size();
577 public boolean equals( Object o )
584 private ManagedRepository createRepository()
587 ManagedRepository r = new ManagedRepository();
589 populateRepository( r );
593 private ManagedRepositoryConfiguration createStagingRepository()
596 ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
597 r.setId( REPO_ID + "-stage" );
598 populateStagingRepository( r );
602 private void populateStagingRepository( ManagedRepositoryConfiguration repository )
605 repository.setId( REPO_ID + "-stage" );
606 repository.setName( "repo name" );
607 repository.setLocation( "${appserver.base}/location" );
608 repository.setLayout( "default" );
609 repository.setRefreshCronExpression( "* 0/5 * * * ?" );
610 repository.setDaysOlder( 31 );
611 repository.setRetentionCount( 20 );
612 repository.setReleases( true );
613 repository.setSnapshots( true );
614 repository.setScanned( false );
615 repository.setDeleteReleasedSnapshots( true );