diff options
author | Martin Stockhammer <martin_s@apache.org> | 2021-08-09 23:40:20 +0200 |
---|---|---|
committer | Martin Stockhammer <martin_s@apache.org> | 2021-08-09 23:40:20 +0200 |
commit | 3e959d5b07d1cbd0f6111b59d8928e9502aa258f (patch) | |
tree | b25af05b7c2e2f5ee2877209d9c5264998689aeb /archiva-modules/archiva-web/archiva-webdav | |
parent | 32cf20409208f30c458ec9fc992e2bec1d64fd87 (diff) | |
download | archiva-3e959d5b07d1cbd0f6111b59d8928e9502aa258f.tar.gz archiva-3e959d5b07d1cbd0f6111b59d8928e9502aa258f.zip |
Refactoring repository registry
Diffstat (limited to 'archiva-modules/archiva-web/archiva-webdav')
2 files changed, 44 insertions, 21 deletions
diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java index 49974fd24..006df7fcf 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/AbstractRepositoryServletTestCase.java @@ -27,10 +27,12 @@ import org.apache.archiva.configuration.Configuration; import org.apache.archiva.configuration.ManagedRepositoryConfiguration; import org.apache.archiva.configuration.RemoteRepositoryConfiguration; import org.apache.archiva.indexer.ArchivaIndexingContext; +import org.apache.archiva.repository.RepositoryException; import org.apache.archiva.repository.base.ArchivaRepositoryRegistry; import org.apache.archiva.repository.ManagedRepository; import org.apache.archiva.repository.RepositoryType; import org.apache.archiva.repository.base.group.RepositoryGroupHandler; +import org.apache.archiva.repository.base.managed.ManagedRepositoryHandler; import org.apache.archiva.test.utils.ArchivaSpringJUnit4ClassRunner; import org.apache.archiva.webdav.httpunit.MkColMethodWebRequest; import org.apache.commons.io.FileUtils; @@ -104,6 +106,10 @@ public abstract class AbstractRepositoryServletTestCase @Inject RepositoryGroupHandler repositoryGroupHandler; + @SuppressWarnings( "unused" ) + @Inject + ManagedRepositoryHandler managedRepositoryHandler; + @Inject ArchivaRepositoryRegistry repositoryRegistry; @@ -166,8 +172,16 @@ public abstract class AbstractRepositoryServletTestCase System.setProperty( "appserver.base", getAppserverBase().toAbsolutePath().toString()); log.info("setUp appserverBase={}, projectBase={}, workingDir={}", getAppserverBase(), getProjectBase(), Paths.get("").toString()); - repositoryRegistry.getRepositories().stream().forEach(r -> r.close()); - + repositoryRegistry.getRepositories().stream().forEach(r -> { + try + { + repositoryRegistry.removeRepository( r ); + } + catch ( RepositoryException e ) + { + e.printStackTrace( ); + } + } ); org.apache.archiva.common.utils.FileUtils.deleteDirectory( getAppserverBase() ); Path testConf = getProjectBase().resolve( "src/test/resources/repository-archiva.xml" ); @@ -191,20 +205,21 @@ public abstract class AbstractRepositoryServletTestCase config.getRemoteRepositories().clear(); saveConfiguration( archivaConfiguration ); + // repositoryRegistry.reload(); - ArchivaIndexingContext ctx = repositoryRegistry.getManagedRepository( REPOID_INTERNAL ).getIndexingContext( ); - try - { - if (repositoryRegistry.getIndexManager(RepositoryType.MAVEN)!=null) { - repositoryRegistry.getIndexManager(RepositoryType.MAVEN).pack(ctx); - } - } finally - { - if (ctx!=null) - { - ctx.close( ); - } - } + // ArchivaIndexingContext ctx = repositoryRegistry.getManagedRepository( REPOID_INTERNAL ).getIndexingContext( ); +// try +// { +// if (repositoryRegistry.getIndexManager(RepositoryType.MAVEN)!=null) { +// repositoryRegistry.getIndexManager(RepositoryType.MAVEN).pack(ctx); +// } +// } finally +// { +// if (ctx!=null) +// { +// ctx.close( ); +// } +// } CacheManager.getInstance().clearAll(); @@ -856,8 +871,8 @@ public abstract class AbstractRepositoryServletTestCase repo.setLocation( location.toAbsolutePath().toString() ); repo.setBlockRedeployments( blockRedeployments ); repo.setType( "MAVEN" ); - repo.setIndexDir(".indexer"); - repo.setPackedIndexDir(".index"); + repo.setIndexDir(location.resolve( ".indexer" ).toAbsolutePath().toString()); + repo.setPackedIndexDir( location.resolve( ".index" ).toAbsolutePath( ).toString( ) ); return repo; } @@ -892,10 +907,13 @@ public abstract class AbstractRepositoryServletTestCase protected void setupCleanRepo( Path repoRootDir ) throws IOException { - org.apache.archiva.common.utils.FileUtils.deleteDirectory( repoRootDir ); - if ( !Files.exists(repoRootDir) ) + if (repoRootDir!=null) { - Files.createDirectories( repoRootDir ); + org.apache.archiva.common.utils.FileUtils.deleteDirectory( repoRootDir ); + if ( !Files.exists( repoRootDir ) ) + { + Files.createDirectories( repoRootDir ); + } } } diff --git a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java index 8d1bde66d..9b2dd4809 100644 --- a/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java +++ b/archiva-modules/archiva-web/archiva-webdav/src/test/java/org/apache/archiva/webdav/ArchivaDavResourceFactoryTest.java @@ -35,6 +35,7 @@ import org.apache.archiva.configuration.RepositoryGroupConfiguration; import org.apache.archiva.metadata.repository.storage.RepositoryPathTranslator; import org.apache.archiva.repository.ManagedRepositoryContent; import org.apache.archiva.repository.base.group.RepositoryGroupHandler; +import org.apache.archiva.repository.base.managed.ManagedRepositoryHandler; import org.apache.archiva.repository.maven.content.MavenContentHelper; import org.apache.archiva.repository.maven.metadata.storage.ArtifactMappingProvider; import org.apache.archiva.proxy.ProxyRegistry; @@ -163,6 +164,10 @@ public class ArchivaDavResourceFactoryTest @Inject RepositoryGroupHandler repositoryGroupHandler; + @SuppressWarnings( "unused" ) + @Inject + ManagedRepositoryHandler managedRepositoryHandler; + public Path getProjectBase() { if (this.projectBase.get()==null) { String pathVal = System.getProperty("mvn.project.base.dir"); @@ -195,7 +200,7 @@ public class ArchivaDavResourceFactoryTest archivaConfiguration = archivaConfigurationControl.createMock( ArchivaConfiguration.class ); config = new Configuration(); - expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 2, 20 ); + expect( archivaConfiguration.getConfiguration() ).andReturn( config ).times( 2, 25 ); expect (archivaConfiguration.getDefaultLocale()).andReturn( Locale.getDefault() ).anyTimes(); archivaConfiguration.addListener( EasyMock.anyObject( ) ); expectLastCall().times(0, 4); |