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( System.getProperty( "basedir", "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" );
312 registryControl.setReturnValue( "target/test", 1, 3 );
314 registry.getString( "appserver.base", "${appserver.base}" );
315 registryControl.setReturnValue( "target/test", 1, 3 );
316 registry.getString( "appserver.home", "${appserver.home}" );
317 registryControl.setReturnValue( "target/test", 1, 3 );
319 registryControl.replay();
321 RepositoryTask task = new RepositoryTask();
322 task.setRepositoryId( REPO_ID );
323 repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
324 repositoryTaskSchedulerControl.setReturnValue( false );
325 repositoryTaskScheduler.queueTask( task );
326 repositoryTaskSchedulerControl.setVoidCallable();
328 repositoryTaskSchedulerControl.replay();
330 Configuration configuration = createConfigurationForEditing( createRepository() );
331 archivaConfiguration.getConfiguration();
333 archivaConfigurationControl.setReturnValue( configuration );
334 archivaConfigurationControl.setReturnValue( configuration );
335 archivaConfigurationControl.setReturnValue( configuration );
336 archivaConfigurationControl.setReturnValue( configuration );
338 archivaConfigurationControl.setReturnValue( configuration );
340 archivaConfigurationControl.setReturnValue( buildEasyConfiguration() );
342 Configuration stageRepoConfiguration = buildEasyConfiguration();
343 stageRepoConfiguration.addManagedRepository( createStagingRepository() );
344 archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
346 archivaConfigurationControl.setReturnValue( configuration );
347 archivaConfigurationControl.setReturnValue( configuration );
349 archivaConfiguration.save( configuration );
350 configuration.addManagedRepository( stageRepoConfiguration.getManagedRepositories().get( 0 ) );
351 archivaConfiguration.save( configuration );
352 archivaConfiguration.save( configuration );
354 archivaConfigurationControl.replay();
356 MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
357 RepositoryStatisticsManager repositoryStatisticsManager =
358 (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
359 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
360 repositoryStatisticsManager );
361 repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
362 repositoryStatisticsManagerControl.replay();
364 new File( "target/test/location/" + REPO_ID + "-stage" ).mkdirs();
366 action.setStageNeeded( true );
367 action.setRepoid( REPO_ID );
369 assertEquals( REPO_ID, action.getRepoid() );
371 ManagedRepository repository = new ManagedRepository();
372 populateRepository( repository );
373 File testFile = new File( "target/test/location/new" );
374 FileUtils.deleteDirectory( testFile );
375 repository.setLocation( "${appserver.base}/location/new" );
376 action.setRepository( repository );
377 String status = action.commit();
378 assertEquals( Action.SUCCESS, status );
379 //assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
380 //assertEquals( testFile.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
382 roleManagerControl.verify();
383 //archivaConfigurationControl.verify();
384 repositoryStatisticsManagerControl.verify();
385 registryControl.verify();
388 public void testStruts2ValidationFrameworkWithNullInputs()
392 // 0 is the default value for primitive int; null for objects
393 ManagedRepository managedRepositoryConfiguration = createManagedRepository( null, null, null, null, 1, 1 );
394 action.setRepository( managedRepositoryConfiguration );
397 actionValidatorManager.validate( action, EMPTY_STRING );
400 assertTrue( action.hasFieldErrors() );
402 Map<String, List<String>> fieldErrors = action.getFieldErrors();
404 // make an expected field error object
405 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
408 List<String> expectedErrorMessages = new ArrayList<String>();
409 expectedErrorMessages.add( "You must enter a repository identifier." );
410 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
412 expectedErrorMessages = new ArrayList<String>();
413 expectedErrorMessages.add( "You must enter a directory." );
414 expectedFieldErrors.put( "repository.location", expectedErrorMessages );
416 expectedErrorMessages = new ArrayList<String>();
417 expectedErrorMessages.add( "You must enter a repository name." );
418 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
420 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
423 public void testStruts2ValidationFrameworkWithBlankInputs()
427 // 0 is the default value for primitive int
428 ManagedRepository managedRepositoryConfiguration =
429 createManagedRepository( EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, 1, 1 );
430 action.setRepository( managedRepositoryConfiguration );
433 actionValidatorManager.validate( action, EMPTY_STRING );
436 assertTrue( action.hasFieldErrors() );
438 Map<String, List<String>> fieldErrors = action.getFieldErrors();
440 // make an expected field error object
441 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
444 List<String> expectedErrorMessages = new ArrayList<String>();
445 expectedErrorMessages.add( "You must enter a repository identifier." );
446 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
448 expectedErrorMessages = new ArrayList<String>();
449 expectedErrorMessages.add( "You must enter a directory." );
450 expectedFieldErrors.put( "repository.location", expectedErrorMessages );
452 expectedErrorMessages = new ArrayList<String>();
453 expectedErrorMessages.add( "You must enter a repository name." );
454 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
456 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
459 public void testStruts2ValidationFrameworkWithInvalidInputs()
463 ManagedRepository managedRepositoryConfiguration =
464 createManagedRepository( REPOSITORY_ID_INVALID_INPUT, REPOSITORY_NAME_INVALID_INPUT,
465 REPOSITORY_LOCATION_INVALID_INPUT, REPOSITORY_INDEX_DIR_INVALID_INPUT,
466 REPOSITORY_DAYS_OLDER_INVALID_INPUT, REPOSITORY_RETENTION_COUNT_INVALID_INPUT );
467 action.setRepository( managedRepositoryConfiguration );
470 actionValidatorManager.validate( action, EMPTY_STRING );
473 assertTrue( action.hasFieldErrors() );
475 Map<String, List<String>> fieldErrors = action.getFieldErrors();
477 // make an expected field error object
478 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
481 List<String> expectedErrorMessages = new ArrayList<String>();
482 expectedErrorMessages.add(
483 "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
484 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
486 expectedErrorMessages = new ArrayList<String>();
487 expectedErrorMessages.add(
488 "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
489 expectedFieldErrors.put( "repository.location", expectedErrorMessages );
491 expectedErrorMessages = new ArrayList<String>();
492 expectedErrorMessages.add(
493 "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
494 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
496 expectedErrorMessages = new ArrayList<String>();
497 expectedErrorMessages.add(
498 "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
499 expectedFieldErrors.put( "repository.indexDirectory", expectedErrorMessages );
501 expectedErrorMessages = new ArrayList<String>();
502 expectedErrorMessages.add( "Repository Purge By Retention Count needs to be between 1 and 100." );
503 expectedFieldErrors.put( "repository.retentionCount", expectedErrorMessages );
505 expectedErrorMessages = new ArrayList<String>();
506 expectedErrorMessages.add( "Repository Purge By Days Older Than needs to be larger than 0." );
507 expectedFieldErrors.put( "repository.daysOlder", expectedErrorMessages );
509 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
512 public void testStruts2ValidationFrameworkWithValidInputs()
516 ManagedRepository managedRepositoryConfiguration =
517 createManagedRepository( REPOSITORY_ID_VALID_INPUT, REPOSITORY_NAME_VALID_INPUT,
518 REPOSITORY_LOCATION_VALID_INPUT, REPOSITORY_INDEX_DIR_VALID_INPUT,
519 REPOSITORY_DAYS_OLDER_VALID_INPUT, REPOSITORY_RETENTION_COUNT_VALID_INPUT );
520 action.setRepository( managedRepositoryConfiguration );
523 actionValidatorManager.validate( action, EMPTY_STRING );
526 assertFalse( action.hasFieldErrors() );
529 private void assertRepositoryEquals( ManagedRepository expectedRepository, ManagedRepository actualRepository )
531 assertEquals( expectedRepository.getDaysOlder(), actualRepository.getDaysOlder() );
532 assertEquals( expectedRepository.getId(), actualRepository.getId() );
533 assertEquals( expectedRepository.getIndexDirectory(), actualRepository.getIndexDirectory() );
534 assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
535 assertEquals( expectedRepository.getName(), actualRepository.getName() );
536 assertEquals( expectedRepository.getCronExpression(), actualRepository.getCronExpression() );
537 assertEquals( expectedRepository.getRetentionCount(), actualRepository.getRetentionCount() );
538 assertEquals( expectedRepository.isDeleteReleasedSnapshots(), actualRepository.isDeleteReleasedSnapshots() );
539 assertEquals( expectedRepository.isScanned(), actualRepository.isScanned() );
540 assertEquals( expectedRepository.isReleases(), actualRepository.isReleases() );
541 assertEquals( expectedRepository.isSnapshots(), actualRepository.isSnapshots() );
544 private Configuration createConfigurationForEditing( ManagedRepository repositoryConfiguration )
547 Configuration configuration = buildEasyConfiguration();
549 ManagedRepositoryConfiguration managedRepositoryConfiguration = new ManagedRepositoryConfiguration();
551 managedRepositoryConfiguration.setDaysOlder( repositoryConfiguration.getDaysOlder() );
552 managedRepositoryConfiguration.setIndexDir( repositoryConfiguration.getIndexDirectory() );
553 managedRepositoryConfiguration.setRetentionCount( repositoryConfiguration.getRetentionCount() );
554 managedRepositoryConfiguration.setBlockRedeployments( repositoryConfiguration.isBlockRedeployments() );
555 managedRepositoryConfiguration.setDeleteReleasedSnapshots(
556 repositoryConfiguration.isDeleteReleasedSnapshots() );
557 managedRepositoryConfiguration.setLocation( repositoryConfiguration.getLocation() );
558 managedRepositoryConfiguration.setRefreshCronExpression( repositoryConfiguration.getCronExpression() );
559 managedRepositoryConfiguration.setReleases( repositoryConfiguration.isReleases() );
560 managedRepositoryConfiguration.setScanned( repositoryConfiguration.isScanned() );
561 managedRepositoryConfiguration.setId( repositoryConfiguration.getId() );
562 managedRepositoryConfiguration.setName( repositoryConfiguration.getName() );
563 managedRepositoryConfiguration.setLayout( repositoryConfiguration.getLayout() );
565 configuration.addManagedRepository( managedRepositoryConfiguration );
566 return configuration;
569 // easy configuration for hashCode/equals
570 private Configuration buildEasyConfiguration()
572 return new Configuration()
575 public int hashCode()
577 return getManagedRepositories().size();
581 public boolean equals( Object o )
588 private ManagedRepository createRepository()
591 ManagedRepository r = new ManagedRepository();
593 populateRepository( r );
597 private ManagedRepositoryConfiguration createStagingRepository()
600 ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
601 r.setId( REPO_ID + "-stage" );
602 populateStagingRepository( r );
606 private void populateStagingRepository( ManagedRepositoryConfiguration repository )
609 repository.setId( REPO_ID + "-stage" );
610 repository.setName( "repo name" );
611 repository.setLocation( "${appserver.base}/location" );
612 repository.setLayout( "default" );
613 repository.setRefreshCronExpression( "* 0/5 * * * ?" );
614 repository.setDaysOlder( 31 );
615 repository.setRetentionCount( 20 );
616 repository.setReleases( true );
617 repository.setSnapshots( true );
618 repository.setScanned( false );
619 repository.setDeleteReleasedSnapshots( true );