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.apache.archiva.redback.role.RoleManager;
41 import org.apache.archiva.redback.integration.interceptor.SecureActionBundle;
42 import org.apache.archiva.redback.integration.interceptor.SecureActionException;
43 import org.easymock.MockControl;
44 import org.easymock.classextension.MockClassControl;
47 import java.io.IOException;
48 import java.util.ArrayList;
49 import java.util.HashMap;
50 import java.util.List;
53 import static org.mockito.Mockito.mock;
54 import static org.mockito.Mockito.when;
57 * EditManagedRepositoryActionTest
61 public class EditManagedRepositoryActionTest
62 extends AbstractManagedRepositoryActionTest
64 private EditManagedRepositoryAction action;
66 private RoleManager roleManager;
68 private MockControl roleManagerControl;
70 private MockControl archivaConfigurationControl;
72 private ArchivaConfiguration archivaConfiguration;
74 private org.apache.archiva.redback.components.registry.Registry registry;
76 private MockControl registryControl;
78 private MetadataRepository metadataRepository;
80 private MockControl repositoryTaskSchedulerControl;
82 private RepositoryArchivaTaskScheduler repositoryTaskScheduler;
85 protected void setUp()
90 action = new EditManagedRepositoryAction();
92 archivaConfigurationControl = MockControl.createControl( ArchivaConfiguration.class );
93 archivaConfiguration = (ArchivaConfiguration) archivaConfigurationControl.getMock();
95 roleManagerControl = MockControl.createControl( RoleManager.class );
96 roleManager = (RoleManager) roleManagerControl.getMock();
98 registryControl = MockControl.createControl( org.apache.archiva.redback.components.registry.Registry.class );
99 registry = (org.apache.archiva.redback.components.registry.Registry) registryControl.getMock();
101 repositoryTaskSchedulerControl = MockClassControl.createControl( RepositoryArchivaTaskScheduler.class );
102 repositoryTaskScheduler = (RepositoryArchivaTaskScheduler) repositoryTaskSchedulerControl.getMock();
104 location = new File( System.getProperty( "basedir", "target/test/location" ) );
106 metadataRepository = mock( MetadataRepository.class );
107 RepositorySession repositorySession = mock( RepositorySession.class );
108 when( repositorySession.getRepository() ).thenReturn( metadataRepository );
109 TestRepositorySessionFactory factory = applicationContext.getBean( TestRepositorySessionFactory.class );
110 factory.setRepositorySession( repositorySession );
112 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setArchivaConfiguration( archivaConfiguration );
113 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRoleManager( roleManager );
114 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryTaskScheduler(
115 repositoryTaskScheduler );
116 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositorySessionFactory( factory );
118 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRegistry( registry );
120 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setAuditListeners(
121 new ArrayList<AuditListener>( 0 ) );
123 DefaultRepositoryCommonValidator defaultRepositoryCommonValidator = new DefaultRepositoryCommonValidator();
124 defaultRepositoryCommonValidator.setArchivaConfiguration( archivaConfiguration );
125 defaultRepositoryCommonValidator.setRegistry( registry );
127 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryCommonValidator(
128 defaultRepositoryCommonValidator );
130 action.setRepositoryCommonValidator( defaultRepositoryCommonValidator );
132 action.setManagedRepositoryAdmin( getManagedRepositoryAdmin() );
136 public void testSecureActionBundle()
137 throws SecureActionException, RepositoryAdminException
139 archivaConfiguration.getConfiguration();
140 archivaConfigurationControl.setReturnValue( new Configuration() );
141 archivaConfigurationControl.replay();
144 SecureActionBundle bundle = action.getSecureActionBundle();
145 assertTrue( bundle.requiresAuthentication() );
146 assertEquals( 1, bundle.getAuthorizationTuples().size() );
149 public void testEditRepositoryInitialPage()
152 Configuration configuration = createConfigurationForEditing( createRepository() );
154 archivaConfiguration.getConfiguration();
155 archivaConfigurationControl.setReturnValue( configuration );
156 Configuration stageRepoConfiguration = new Configuration();
157 stageRepoConfiguration.addManagedRepository( createStagingRepository() );
158 archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
160 archivaConfigurationControl.replay();
162 action.setRepoid( REPO_ID );
165 assertEquals( REPO_ID, action.getRepoid() );
166 ManagedRepository repository = action.getRepository();
167 assertNotNull( repository );
169 ManagedRepository newRepository = createRepository();
170 assertRepositoryEquals( repository, newRepository );
171 assertEquals( repository.getLocation(), newRepository.getLocation() );
173 String status = action.input();
174 assertEquals( Action.INPUT, status );
175 repository = action.getRepository();
176 assertRepositoryEquals( repository, createRepository() );
179 public void testEditRepository()
182 String stageRepoId = REPO_ID + "-stage";
184 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
185 roleManagerControl.setReturnValue( false );
186 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
187 roleManagerControl.setVoidCallable();
189 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
190 roleManagerControl.setReturnValue( false );
191 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
192 roleManagerControl.setVoidCallable();
194 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, stageRepoId );
195 roleManagerControl.setReturnValue( false );
196 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, stageRepoId );
197 roleManagerControl.setVoidCallable();
199 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, stageRepoId );
200 roleManagerControl.setReturnValue( false );
201 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, stageRepoId );
202 roleManagerControl.setVoidCallable();
204 roleManagerControl.replay();
206 registry.getString( "appserver.base", "${appserver.base}" );
207 registryControl.setReturnValue( "target/test", 1, 3 );
208 registry.getString( "appserver.home", "${appserver.home}" );
209 registryControl.setReturnValue( "target/test", 1, 3 );
211 registryControl.replay();
213 RepositoryTask task = new RepositoryTask();
214 task.setRepositoryId( REPO_ID );
215 repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
216 repositoryTaskSchedulerControl.setReturnValue( false );
217 repositoryTaskScheduler.queueTask( task );
218 repositoryTaskSchedulerControl.setVoidCallable();
220 RepositoryTask stageTask = new RepositoryTask();
221 stageTask.setRepositoryId( stageRepoId );
222 repositoryTaskScheduler.isProcessingRepositoryTask( stageRepoId );
223 repositoryTaskSchedulerControl.setReturnValue( false );
224 repositoryTaskScheduler.queueTask( stageTask );
225 repositoryTaskSchedulerControl.setVoidCallable();
227 repositoryTaskSchedulerControl.replay();
229 Configuration configuration = createConfigurationForEditing( createRepository() );
230 archivaConfiguration.getConfiguration();
231 archivaConfigurationControl.setReturnValue( configuration );
232 archivaConfigurationControl.setReturnValue( configuration );
233 archivaConfigurationControl.setReturnValue( configuration );
235 archivaConfigurationControl.setReturnValue( configuration );
236 archivaConfigurationControl.setReturnValue( configuration );
238 Configuration stageRepoConfiguration = new Configuration();
239 stageRepoConfiguration.addManagedRepository( createStagingRepository() );
240 archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
241 archivaConfigurationControl.setReturnValue( configuration );
242 archivaConfigurationControl.setReturnValue( configuration );
244 archivaConfiguration.save( configuration );
245 archivaConfiguration.save( configuration );
247 archivaConfiguration.save( configuration );
249 archivaConfigurationControl.replay();
251 action.setRepoid( REPO_ID );
253 assertEquals( REPO_ID, action.getRepoid() );
254 ManagedRepository repository = action.getRepository();
255 populateRepository( repository );
256 repository.setName( "new repo name" );
258 MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
259 RepositoryStatisticsManager repositoryStatisticsManager =
260 (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
261 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
262 repositoryStatisticsManager );
264 repositoryStatisticsManagerControl.replay();
266 new File( "target/test/" + REPO_ID + "-stage" ).mkdirs();
268 action.setRepository( repository );
269 action.setStageNeeded( true );
270 String status = action.commit();
271 assertEquals( Action.SUCCESS, status );
273 ManagedRepository newRepository = createRepository();
274 newRepository.setName( "new repo name" );
275 assertRepositoryEquals( repository, newRepository );
276 //assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
277 //assertEquals( location.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
279 roleManagerControl.verify();
280 //archivaConfigurationControl.verify();
281 repositoryStatisticsManagerControl.verify();
282 registryControl.verify();
285 public void testEditRepositoryLocationChanged()
288 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
289 roleManagerControl.setReturnValue( false );
290 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID );
291 roleManagerControl.setVoidCallable();
293 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
294 roleManagerControl.setReturnValue( false );
295 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID );
296 roleManagerControl.setVoidCallable();
298 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
299 roleManagerControl.setReturnValue( false );
300 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_OBSERVER, REPO_ID + "-stage" );
301 roleManagerControl.setVoidCallable();
303 roleManager.templatedRoleExists( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID + "-stage" );
304 roleManagerControl.setReturnValue( false );
305 roleManager.createTemplatedRole( ArchivaRoleConstants.TEMPLATE_REPOSITORY_MANAGER, REPO_ID + "-stage" );
306 roleManagerControl.setVoidCallable();
308 roleManagerControl.replay();
310 registry.getString( "appserver.base" );
311 registryControl.setReturnValue( "target/test", 1, 3 );
313 registry.getString( "appserver.base", "${appserver.base}" );
314 registryControl.setReturnValue( "target/test", 1, 3 );
315 registry.getString( "appserver.home", "${appserver.home}" );
316 registryControl.setReturnValue( "target/test", 1, 3 );
318 registryControl.replay();
320 RepositoryTask task = new RepositoryTask();
321 task.setRepositoryId( REPO_ID );
322 repositoryTaskScheduler.isProcessingRepositoryTask( REPO_ID );
323 repositoryTaskSchedulerControl.setReturnValue( false );
324 repositoryTaskScheduler.queueTask( task );
325 repositoryTaskSchedulerControl.setVoidCallable();
327 repositoryTaskSchedulerControl.replay();
329 Configuration configuration = createConfigurationForEditing( createRepository() );
330 archivaConfiguration.getConfiguration();
332 archivaConfigurationControl.setReturnValue( configuration );
333 archivaConfigurationControl.setReturnValue( configuration );
334 archivaConfigurationControl.setReturnValue( configuration );
335 archivaConfigurationControl.setReturnValue( configuration );
337 archivaConfigurationControl.setReturnValue( configuration );
339 archivaConfigurationControl.setReturnValue( buildEasyConfiguration() );
341 Configuration stageRepoConfiguration = buildEasyConfiguration();
342 stageRepoConfiguration.addManagedRepository( createStagingRepository() );
343 archivaConfigurationControl.setReturnValue( stageRepoConfiguration );
345 archivaConfigurationControl.setReturnValue( configuration );
346 archivaConfigurationControl.setReturnValue( configuration );
348 archivaConfiguration.save( configuration );
349 configuration.addManagedRepository( stageRepoConfiguration.getManagedRepositories().get( 0 ) );
350 archivaConfiguration.save( configuration );
351 archivaConfiguration.save( configuration );
353 archivaConfigurationControl.replay();
355 MockControl repositoryStatisticsManagerControl = MockControl.createControl( RepositoryStatisticsManager.class );
356 RepositoryStatisticsManager repositoryStatisticsManager =
357 (RepositoryStatisticsManager) repositoryStatisticsManagerControl.getMock();
358 ( (DefaultManagedRepositoryAdmin) getManagedRepositoryAdmin() ).setRepositoryStatisticsManager(
359 repositoryStatisticsManager );
360 repositoryStatisticsManager.deleteStatistics( metadataRepository, REPO_ID );
361 repositoryStatisticsManagerControl.replay();
363 new File( "target/test/location/" + REPO_ID + "-stage" ).mkdirs();
365 action.setStageNeeded( true );
366 action.setRepoid( REPO_ID );
368 assertEquals( REPO_ID, action.getRepoid() );
370 ManagedRepository repository = new ManagedRepository();
371 populateRepository( repository );
372 File testFile = new File( "target/test/location/new" );
373 FileUtils.deleteDirectory( testFile );
374 repository.setLocation( "${appserver.base}/location/new" );
375 action.setRepository( repository );
376 String status = action.commit();
377 assertEquals( Action.SUCCESS, status );
378 //assertEquals( Collections.singletonList( repository ), configuration.getManagedRepositories() );
379 //assertEquals( testFile.getCanonicalPath(), new File( repository.getLocation() ).getCanonicalPath() );
381 roleManagerControl.verify();
382 //archivaConfigurationControl.verify();
383 repositoryStatisticsManagerControl.verify();
384 registryControl.verify();
387 public void testStruts2ValidationFrameworkWithNullInputs()
391 // 0 is the default value for primitive int; null for objects
392 ManagedRepository managedRepositoryConfiguration = createManagedRepository( null, null, null, null, 1, 1 );
393 action.setRepository( managedRepositoryConfiguration );
396 actionValidatorManager.validate( action, EMPTY_STRING );
399 assertTrue( action.hasFieldErrors() );
401 Map<String, List<String>> fieldErrors = action.getFieldErrors();
403 // make an expected field error object
404 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
407 List<String> expectedErrorMessages = new ArrayList<String>();
408 expectedErrorMessages.add( "You must enter a repository identifier." );
409 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
411 expectedErrorMessages = new ArrayList<String>();
412 expectedErrorMessages.add( "You must enter a directory." );
413 expectedFieldErrors.put( "repository.location", expectedErrorMessages );
415 expectedErrorMessages = new ArrayList<String>();
416 expectedErrorMessages.add( "You must enter a repository name." );
417 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
419 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
422 public void testStruts2ValidationFrameworkWithBlankInputs()
426 // 0 is the default value for primitive int
427 ManagedRepository managedRepositoryConfiguration =
428 createManagedRepository( EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, EMPTY_STRING, 1, 1 );
429 action.setRepository( managedRepositoryConfiguration );
432 actionValidatorManager.validate( action, EMPTY_STRING );
435 assertTrue( action.hasFieldErrors() );
437 Map<String, List<String>> fieldErrors = action.getFieldErrors();
439 // make an expected field error object
440 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
443 List<String> expectedErrorMessages = new ArrayList<String>();
444 expectedErrorMessages.add( "You must enter a repository identifier." );
445 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
447 expectedErrorMessages = new ArrayList<String>();
448 expectedErrorMessages.add( "You must enter a directory." );
449 expectedFieldErrors.put( "repository.location", expectedErrorMessages );
451 expectedErrorMessages = new ArrayList<String>();
452 expectedErrorMessages.add( "You must enter a repository name." );
453 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
455 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
458 public void testStruts2ValidationFrameworkWithInvalidInputs()
462 ManagedRepository managedRepositoryConfiguration =
463 createManagedRepository( REPOSITORY_ID_INVALID_INPUT, REPOSITORY_NAME_INVALID_INPUT,
464 REPOSITORY_LOCATION_INVALID_INPUT, REPOSITORY_INDEX_DIR_INVALID_INPUT,
465 REPOSITORY_DAYS_OLDER_INVALID_INPUT, REPOSITORY_RETENTION_COUNT_INVALID_INPUT );
466 action.setRepository( managedRepositoryConfiguration );
469 actionValidatorManager.validate( action, EMPTY_STRING );
472 assertTrue( action.hasFieldErrors() );
474 Map<String, List<String>> fieldErrors = action.getFieldErrors();
476 // make an expected field error object
477 Map<String, List<String>> expectedFieldErrors = new HashMap<String, List<String>>();
480 List<String> expectedErrorMessages = new ArrayList<String>();
481 expectedErrorMessages.add(
482 "Identifier must only contain alphanumeric characters, underscores(_), dots(.), and dashes(-)." );
483 expectedFieldErrors.put( "repository.id", expectedErrorMessages );
485 expectedErrorMessages = new ArrayList<String>();
486 expectedErrorMessages.add(
487 "Directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
488 expectedFieldErrors.put( "repository.location", expectedErrorMessages );
490 expectedErrorMessages = new ArrayList<String>();
491 expectedErrorMessages.add(
492 "Repository Name must only contain alphanumeric characters, white-spaces(' '), forward-slashes(/), open-parenthesis('('), close-parenthesis(')'), underscores(_), dots(.), and dashes(-)." );
493 expectedFieldErrors.put( "repository.name", expectedErrorMessages );
495 expectedErrorMessages = new ArrayList<String>();
496 expectedErrorMessages.add(
497 "Index directory must only contain alphanumeric characters, equals(=), question-marks(?), exclamation-points(!), ampersands(&), forward-slashes(/), back-slashes(\\), underscores(_), dots(.), colons(:), tildes(~), and dashes(-)." );
498 expectedFieldErrors.put( "repository.indexDirectory", expectedErrorMessages );
500 expectedErrorMessages = new ArrayList<String>();
501 expectedErrorMessages.add( "Repository Purge By Retention Count needs to be between 1 and 100." );
502 expectedFieldErrors.put( "repository.retentionCount", expectedErrorMessages );
504 expectedErrorMessages = new ArrayList<String>();
505 expectedErrorMessages.add( "Repository Purge By Days Older Than needs to be larger than 0." );
506 expectedFieldErrors.put( "repository.daysOlder", expectedErrorMessages );
508 ValidatorUtil.assertFieldErrors( expectedFieldErrors, fieldErrors );
511 public void testStruts2ValidationFrameworkWithValidInputs()
515 ManagedRepository managedRepositoryConfiguration =
516 createManagedRepository( REPOSITORY_ID_VALID_INPUT, REPOSITORY_NAME_VALID_INPUT,
517 REPOSITORY_LOCATION_VALID_INPUT, REPOSITORY_INDEX_DIR_VALID_INPUT,
518 REPOSITORY_DAYS_OLDER_VALID_INPUT, REPOSITORY_RETENTION_COUNT_VALID_INPUT );
519 action.setRepository( managedRepositoryConfiguration );
522 actionValidatorManager.validate( action, EMPTY_STRING );
525 assertFalse( action.hasFieldErrors() );
528 private void assertRepositoryEquals( ManagedRepository expectedRepository, ManagedRepository actualRepository )
530 assertEquals( expectedRepository.getDaysOlder(), actualRepository.getDaysOlder() );
531 assertEquals( expectedRepository.getId(), actualRepository.getId() );
532 assertEquals( expectedRepository.getIndexDirectory(), actualRepository.getIndexDirectory() );
533 assertEquals( expectedRepository.getLayout(), actualRepository.getLayout() );
534 assertEquals( expectedRepository.getName(), actualRepository.getName() );
535 assertEquals( expectedRepository.getCronExpression(), actualRepository.getCronExpression() );
536 assertEquals( expectedRepository.getRetentionCount(), actualRepository.getRetentionCount() );
537 assertEquals( expectedRepository.isDeleteReleasedSnapshots(), actualRepository.isDeleteReleasedSnapshots() );
538 assertEquals( expectedRepository.isScanned(), actualRepository.isScanned() );
539 assertEquals( expectedRepository.isReleases(), actualRepository.isReleases() );
540 assertEquals( expectedRepository.isSnapshots(), actualRepository.isSnapshots() );
543 private Configuration createConfigurationForEditing( ManagedRepository repositoryConfiguration )
546 Configuration configuration = buildEasyConfiguration();
548 ManagedRepositoryConfiguration managedRepositoryConfiguration = new ManagedRepositoryConfiguration();
550 managedRepositoryConfiguration.setDaysOlder( repositoryConfiguration.getDaysOlder() );
551 managedRepositoryConfiguration.setIndexDir( repositoryConfiguration.getIndexDirectory() );
552 managedRepositoryConfiguration.setRetentionCount( repositoryConfiguration.getRetentionCount() );
553 managedRepositoryConfiguration.setBlockRedeployments( repositoryConfiguration.isBlockRedeployments() );
554 managedRepositoryConfiguration.setDeleteReleasedSnapshots(
555 repositoryConfiguration.isDeleteReleasedSnapshots() );
556 managedRepositoryConfiguration.setLocation( repositoryConfiguration.getLocation() );
557 managedRepositoryConfiguration.setRefreshCronExpression( repositoryConfiguration.getCronExpression() );
558 managedRepositoryConfiguration.setReleases( repositoryConfiguration.isReleases() );
559 managedRepositoryConfiguration.setScanned( repositoryConfiguration.isScanned() );
560 managedRepositoryConfiguration.setId( repositoryConfiguration.getId() );
561 managedRepositoryConfiguration.setName( repositoryConfiguration.getName() );
562 managedRepositoryConfiguration.setLayout( repositoryConfiguration.getLayout() );
564 configuration.addManagedRepository( managedRepositoryConfiguration );
565 return configuration;
568 // easy configuration for hashCode/equals
569 private Configuration buildEasyConfiguration()
571 return new Configuration()
574 public int hashCode()
576 return getManagedRepositories().size();
580 public boolean equals( Object o )
587 private ManagedRepository createRepository()
590 ManagedRepository r = new ManagedRepository();
592 populateRepository( r );
596 private ManagedRepositoryConfiguration createStagingRepository()
599 ManagedRepositoryConfiguration r = new ManagedRepositoryConfiguration();
600 r.setId( REPO_ID + "-stage" );
601 populateStagingRepository( r );
605 private void populateStagingRepository( ManagedRepositoryConfiguration repository )
608 repository.setId( REPO_ID + "-stage" );
609 repository.setName( "repo name" );
610 repository.setLocation( "${appserver.base}/location" );
611 repository.setLayout( "default" );
612 repository.setRefreshCronExpression( "* 0/5 * * * ?" );
613 repository.setDaysOlder( 31 );
614 repository.setRetentionCount( 20 );
615 repository.setReleases( true );
616 repository.setSnapshots( true );
617 repository.setScanned( false );
618 repository.setDeleteReleasedSnapshots( true );