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.RepositoryCommonValidator;
26 import org.apache.archiva.admin.repository.managed.DefaultManagedRepositoryAdmin;
27 import org.apache.archiva.audit.AuditListener;
28 import org.apache.archiva.metadata.repository.MetadataRepository;
29 import org.apache.archiva.metadata.repository.RepositorySession;
30 import org.apache.archiva.metadata.repository.memory.TestRepositorySessionFactory;
31 import org.apache.archiva.metadata.repository.stats.RepositoryStatisticsManager;
32 import org.apache.archiva.scheduler.repository.RepositoryArchivaTaskScheduler;
33 import org.apache.archiva.scheduler.repository.RepositoryTask;
34 import org.apache.archiva.security.ArchivaRoleConstants;
35 import org.apache.archiva.web.validator.utils.ValidatorUtil;
36 import org.apache.commons.io.FileUtils;
37 import org.apache.archiva.configuration.ArchivaConfiguration;
38 import org.apache.archiva.configuration.Configuration;
39 import org.apache.archiva.configuration.ManagedRepositoryConfiguration;
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 RepositoryCommonValidator repositoryCommonValidator = new RepositoryCommonValidator();
125 repositoryCommonValidator.setArchivaConfiguration( archivaConfiguration );
126 repositoryCommonValidator.setRegistry( registry );
128 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryCommonValidator(
129 repositoryCommonValidator );
131 action.setRepositoryCommonValidator( repositoryCommonValidator );
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" );
209 registry.getString( "appserver.home", "${appserver.home}" );
210 registryControl.setReturnValue( "target/test" );
212 registry.getString( "appserver.base", "${appserver.base}" );
213 registryControl.setReturnValue( "target/test" );
214 registry.getString( "appserver.home", "${appserver.home}" );
215 registryControl.setReturnValue( "target/test" );
217 registryControl.replay();
219 RepositoryTask task = new RepositoryTask();
220 task.setRepositoryId( REPO_ID );
221 repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
222 repositoryTaskSchedulerControl.setReturnValue( false );
223 repositoryTaskScheduler.queueTask( task );
224 repositoryTaskSchedulerControl.setVoidCallable();
226 RepositoryTask stageTask = new RepositoryTask();
227 stageTask.setRepositoryId( stageRepoId );
228 repositoryTaskScheduler.isProcessingRepositoryTask( stageRepoId );
229 repositoryTaskSchedulerControl.setReturnValue( false );
230 repositoryTaskScheduler.queueTask( stageTask );
231 repositoryTaskSchedulerControl.setVoidCallable();
233 repositoryTaskSchedulerControl.replay();
235 Configuration configuration = createConfigurationForEditing( createRepository() );
236 archivaConfiguration.getConfiguration();
237 archivaConfigurationControl.setReturnValue( configuration );
238 archivaConfigurationControl.setReturnValue( configuration );
239 archivaConfigurationControl.setReturnValue( configuration );
241 archivaConfigurationControl.setReturnValue( configuration );
242 archivaConfigurationControl.setReturnValue( configuration );
244 Configuration stageRepoConfiguration = new Configuration();
245 stageRepoConfiguration.addManagedRepository( createStagingRepository() );
246 archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
247 archivaConfigurationControl.setReturnValue( configuration );
248 archivaConfigurationControl.setReturnValue( configuration );
250 archivaConfiguration.save( configuration );
251 archivaConfiguration.save( configuration );
253 archivaConfiguration.save( configuration );
255 archivaConfigurationControl.replay();
257 action.setRepoid( REPO_ID );
259 assertEquals( REPO_ID, action.getRepoid() );
260 ManagedRepository repository = action.getRepository();
261 populateRepository( repository );
262 repository.setName( "new repo name" );
264 MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
265 RepositoryStatisticsManager repositoryStatisticsManager =
266 (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
267 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
268 repositoryStatisticsManager );
270 repositoryStatisticsManagerControl.replay();
272 new File( "target/test/" + REPO_ID + "-stage" ).mkdirs();
274 action.setRepository( repository );
275 action.setStageNeeded( true );
276 String status = action.commit();
277 assertEquals( Action.SUCCESS, status );
279 ManagedRepository newRepository = createRepository();
280 newRepository.setName( "new repo name" );
281 assertRepositoryEquals( repository, newRepository );
282 //assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
283 //assertEquals( location.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
285 roleManagerControl.verify();
286 //archivaConfigurationControl.verify();
287 repositoryStatisticsManagerControl.verify();
288 registryControl.verify();
291 public void testEditRepositoryLocationChanged()
294 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
295 roleManagerControl.setReturnValue( false );
296 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
297 roleManagerControl.setVoidCallable();
299 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
300 roleManagerControl.setReturnValue( false );
301 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
302 roleManagerControl.setVoidCallable();
304 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
305 roleManagerControl.setReturnValue( false );
306 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
307 roleManagerControl.setVoidCallable();
309 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID + "-stage" );
310 roleManagerControl.setReturnValue( false );
311 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID + "-stage" );
312 roleManagerControl.setVoidCallable();
314 roleManagerControl.replay();
316 registry.getString( "appserver.base", "${appserver.base}" );
317 registryControl.setReturnValue( "target/test" );
318 registry.getString( "appserver.home", "${appserver.home}" );
319 registryControl.setReturnValue( "target/test" );
321 registry.getString( "appserver.base", "${appserver.base}" );
322 registryControl.setReturnValue( "target/test" );
323 registry.getString( "appserver.home", "${appserver.home}" );
324 registryControl.setReturnValue( "target/test" );
326 registryControl.replay();
328 RepositoryTask task = new RepositoryTask();
329 task.setRepositoryId( REPO_ID );
330 repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
331 repositoryTaskSchedulerControl.setReturnValue( false );
332 repositoryTaskScheduler.queueTask( task );
333 repositoryTaskSchedulerControl.setVoidCallable();
335 repositoryTaskSchedulerControl.replay();
337 Configuration configuration = createConfigurationForEditing( createRepository() );
338 archivaConfiguration.getConfiguration();
339 archivaConfigurationControl.setReturnValue( configuration );
340 archivaConfigurationControl.setReturnValue( configuration );
341 archivaConfigurationControl.setReturnValue( configuration );
342 archivaConfigurationControl.setReturnValue( configuration );
344 archivaConfigurationControl.setReturnValue( configuration );
346 archivaConfigurationControl.setReturnValue( buildEasyConfiguration() );
348 Configuration stageRepoConfiguration = buildEasyConfiguration();
349 stageRepoConfiguration.addManagedRepository( createStagingRepository() );
350 archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
352 archivaConfigurationControl.setReturnValue( configuration );
353 archivaConfigurationControl.setReturnValue( configuration );
355 archivaConfiguration.save( configuration );
356 configuration.addManagedRepository( stageRepoConfiguration.getManagedRepositories().get( 0 ) );
357 archivaConfiguration.save( configuration );
358 archivaConfiguration.save( configuration );
360 archivaConfigurationControl.replay();
362 MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
363 RepositoryStatisticsManager repositoryStatisticsManager =
364 (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
365 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
366 repositoryStatisticsManager );
367 repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
368 repositoryStatisticsManagerControl.replay();
370 new File( "target/test/location/" + REPO_ID + "-stage" ).mkdirs();
372 action.setStageNeeded( true );
373 action.setRepoid( REPO_ID );
375 assertEquals( REPO_ID, action.getRepoid() );
377 ManagedRepository repository = new ManagedRepository();
378 populateRepository( repository );
379 File testFile = new File( "target/test/location/new" );
380 FileUtils.deleteDirectory( testFile );
381 repository.setLocation( "${appserver.base}/location/new" );
382 action.setRepository( repository );
383 String status = action.commit();
384 assertEquals( Action.SUCCESS, status );
385 //assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
386 //assertEquals( testFile.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
388 roleManagerControl.verify();
389 //archivaConfigurationControl.verify();
390 repositoryStatisticsManagerControl.verify();
391 registryControl.verify();
394 public void testStruts2ValidationFrameworkWithNullInputs()
398 // 0 is the default value for primitive int; null for objects
399 ManagedRepository managedRepositoryConfiguration = createManagedRepository( null, null, null, null, 1, 1 );
400 action.setRepository( managedRepositoryConfiguration );
403 actionValidatorManager.validate( action, EMPTY_STRING );
406 assertTrue( action.hasFieldErrors() );
408 Map<String, List<String>> fieldErrors = action.getFieldErrors();
410 // make an expected field error object
411 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
414 List<String> expectedErrorMessages = new ArrayList<String>();
415 expectedErrorMessages.add( "You must enter a repository identifier." );
416 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
418 expectedErrorMessages = new ArrayList<String>();
419 expectedErrorMessages.add( "You must enter a directory." );
420 expectedFieldErrors.put( "repository.location", expectedErrorMessages );
422 expectedErrorMessages = new ArrayList<String>();
423 expectedErrorMessages.add( "You must enter a repository name." );
424 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
426 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
429 public void testStruts2ValidationFrameworkWithBlankInputs()
433 // 0 is the default value for primitive int
434 ManagedRepository managedRepositoryConfiguration =
435 createManagedRepository( EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, 1, 1 );
436 action.setRepository( managedRepositoryConfiguration );
439 actionValidatorManager.validate( action, EMPTY_STRING );
442 assertTrue( action.hasFieldErrors() );
444 Map<String, List<String>> fieldErrors = action.getFieldErrors();
446 // make an expected field error object
447 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
450 List<String> expectedErrorMessages = new ArrayList<String>();
451 expectedErrorMessages.add( "You must enter a repository identifier." );
452 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
454 expectedErrorMessages = new ArrayList<String>();
455 expectedErrorMessages.add( "You must enter a directory." );
456 expectedFieldErrors.put( "repository.location", expectedErrorMessages );
458 expectedErrorMessages = new ArrayList<String>();
459 expectedErrorMessages.add( "You must enter a repository name." );
460 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
462 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
465 public void testStruts2ValidationFrameworkWithInvalidInputs()
469 ManagedRepository managedRepositoryConfiguration =
470 createManagedRepository( REPOSITORY_ID_INVALID_INPUT, REPOSITORY_NAME_INVALID_INPUT,
471 REPOSITORY_LOCATION_INVALID_INPUT, REPOSITORY_INDEX_DIR_INVALID_INPUT,
472 REPOSITORY_DAYS_OLDER_INVALID_INPUT, REPOSITORY_RETENTION_COUNT_INVALID_INPUT );
473 action.setRepository( managedRepositoryConfiguration );
476 actionValidatorManager.validate( action, EMPTY_STRING );
479 assertTrue( action.hasFieldErrors() );
481 Map<String, List<String>> fieldErrors = action.getFieldErrors();
483 // make an expected field error object
484 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
487 List<String> expectedErrorMessages = new ArrayList<String>();
488 expectedErrorMessages.add(
489 "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
490 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
492 expectedErrorMessages = new ArrayList<String>();
493 expectedErrorMessages.add(
494 "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.location", expectedErrorMessages );
497 expectedErrorMessages = new ArrayList<String>();
498 expectedErrorMessages.add(
499 "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
500 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
502 expectedErrorMessages = new ArrayList<String>();
503 expectedErrorMessages.add(
504 "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
505 expectedFieldErrors.put( "repository.indexDirectory", expectedErrorMessages );
507 expectedErrorMessages = new ArrayList<String>();
508 expectedErrorMessages.add( "Repository Purge By Retention Count needs to be between 1 and 100." );
509 expectedFieldErrors.put( "repository.retentionCount", expectedErrorMessages );
511 expectedErrorMessages = new ArrayList<String>();
512 expectedErrorMessages.add( "Repository Purge By Days Older Than needs to be larger than 0." );
513 expectedFieldErrors.put( "repository.daysOlder", expectedErrorMessages );
515 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
518 public void testStruts2ValidationFrameworkWithValidInputs()
522 ManagedRepository managedRepositoryConfiguration =
523 createManagedRepository( REPOSITORY_ID_VALID_INPUT, REPOSITORY_NAME_VALID_INPUT,
524 REPOSITORY_LOCATION_VALID_INPUT, REPOSITORY_INDEX_DIR_VALID_INPUT,
525 REPOSITORY_DAYS_OLDER_VALID_INPUT, REPOSITORY_RETENTION_COUNT_VALID_INPUT );
526 action.setRepository( managedRepositoryConfiguration );
529 actionValidatorManager.validate( action, EMPTY_STRING );
532 assertFalse( action.hasFieldErrors() );
535 private void assertRepositoryEquals( ManagedRepository expectedRepository, ManagedRepository actualRepository )
537 assertEquals( expectedRepository.getDaysOlder(), actualRepository.getDaysOlder() );
538 assertEquals( expectedRepository.getId(), actualRepository.getId() );
539 assertEquals( expectedRepository.getIndexDirectory(), actualRepository.getIndexDirectory() );
540 assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
541 assertEquals( expectedRepository.getName(), actualRepository.getName() );
542 assertEquals( expectedRepository.getCronExpression(), actualRepository.getCronExpression() );
543 assertEquals( expectedRepository.getRetentionCount(), actualRepository.getRetentionCount() );
544 assertEquals( expectedRepository.isDeleteReleasedSnapshots(), actualRepository.isDeleteReleasedSnapshots() );
545 assertEquals( expectedRepository.isScanned(), actualRepository.isScanned() );
546 assertEquals( expectedRepository.isReleases(), actualRepository.isReleases() );
547 assertEquals( expectedRepository.isSnapshots(), actualRepository.isSnapshots() );
550 private Configuration createConfigurationForEditing( ManagedRepository repositoryConfiguration )
553 Configuration configuration = buildEasyConfiguration();
555 ManagedRepositoryConfiguration managedRepositoryConfiguration = new ManagedRepositoryConfiguration();
557 managedRepositoryConfiguration.setDaysOlder( repositoryConfiguration.getDaysOlder() );
558 managedRepositoryConfiguration.setIndexDir( repositoryConfiguration.getIndexDirectory() );
559 managedRepositoryConfiguration.setRetentionCount( repositoryConfiguration.getRetentionCount() );
560 managedRepositoryConfiguration.setBlockRedeployments( repositoryConfiguration.isBlockRedeployments() );
561 managedRepositoryConfiguration.setDeleteReleasedSnapshots(
562 repositoryConfiguration.isDeleteReleasedSnapshots() );
563 managedRepositoryConfiguration.setLocation( repositoryConfiguration.getLocation() );
564 managedRepositoryConfiguration.setRefreshCronExpression( repositoryConfiguration.getCronExpression() );
565 managedRepositoryConfiguration.setReleases( repositoryConfiguration.isReleases() );
566 managedRepositoryConfiguration.setScanned( repositoryConfiguration.isScanned() );
567 managedRepositoryConfiguration.setId( repositoryConfiguration.getId() );
568 managedRepositoryConfiguration.setName( repositoryConfiguration.getName() );
569 managedRepositoryConfiguration.setLayout( repositoryConfiguration.getLayout() );
571 configuration.addManagedRepository( managedRepositoryConfiguration );
572 return configuration;
575 // easy configuration for hashCode/equals
576 private Configuration buildEasyConfiguration()
578 return new Configuration()
581 public int hashCode()
583 return getManagedRepositories().size();
587 public boolean equals( Object o )
594 private ManagedRepository createRepository()
597 ManagedRepository r = new ManagedRepository();
599 populateRepository( r );
603 private ManagedRepositoryConfiguration createStagingRepository()
606 ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
607 r.setId( REPO_ID + "-stage" );
608 populateStagingRepository( r );
612 private void populateStagingRepository( ManagedRepositoryConfiguration repository )
615 repository.setId( REPO_ID + "-stage" );
616 repository.setName( "repo name" );
617 repository.setLocation( "${appserver.base}/location" );
618 repository.setLayout( "default" );
619 repository.setRefreshCronExpression( "* 0/5 * * * ?" );
620 repository.setDaysOlder( 31 );
621 repository.setRetentionCount( 20 );
622 repository.setReleases( true );
623 repository.setSnapshots( true );
624 repository.setScanned( false );
625 repository.setDeleteReleasedSnapshots( true );